summaryrefslogtreecommitdiff
path: root/auth-pam.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-02-17 23:20:07 +1100
committerDarren Tucker <dtucker@zip.com.au>2004-02-17 23:20:07 +1100
commit5cf8ef735c5d7d76c1c69e491419b1311ec1575b (patch)
tree38da666cf1d1a73aab4aa77699f55dffceb3c908 /auth-pam.c
parentba53b839d30de74c994b8c6a20360967cb844ade (diff)
- (dtucker) [auth-pam.c] Store output from pam_session and pam_setcred for
display after login. Should fix problems like pam_motd not displaying anything, noticed by cjwatson at debian.org. ok djm@
Diffstat (limited to 'auth-pam.c')
-rw-r--r--auth-pam.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/auth-pam.c b/auth-pam.c
index 0ab5554a3..397f7d3a8 100644
--- a/auth-pam.c
+++ b/auth-pam.c
@@ -31,7 +31,7 @@
31 31
32/* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */ 32/* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */
33#include "includes.h" 33#include "includes.h"
34RCSID("$Id: auth-pam.c,v 1.94 2004/02/17 09:46:59 dtucker Exp $"); 34RCSID("$Id: auth-pam.c,v 1.95 2004/02/17 12:20:08 dtucker Exp $");
35 35
36#ifdef USE_PAM 36#ifdef USE_PAM
37#if defined(HAVE_SECURITY_PAM_APPL_H) 37#if defined(HAVE_SECURITY_PAM_APPL_H)
@@ -823,12 +823,57 @@ do_pam_chauthtok(void)
823 pam_strerror(sshpam_handle, sshpam_err)); 823 pam_strerror(sshpam_handle, sshpam_err));
824} 824}
825 825
826static int
827pam_store_conv(int n, const struct pam_message **msg,
828 struct pam_response **resp, void *data)
829{
830 struct pam_response *reply;
831 int i;
832 size_t len;
833
834 debug3("PAM: %s called with %d messages", __func__, n);
835 *resp = NULL;
836
837 if (n <= 0 || n > PAM_MAX_NUM_MSG)
838 return (PAM_CONV_ERR);
839
840 if ((reply = malloc(n * sizeof(*reply))) == NULL)
841 return (PAM_CONV_ERR);
842 memset(reply, 0, n * sizeof(*reply));
843
844 for (i = 0; i < n; ++i) {
845 switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
846 case PAM_ERROR_MSG:
847 case PAM_TEXT_INFO:
848 len = strlen(PAM_MSG_MEMBER(msg, i, msg));
849 buffer_append(&loginmsg, PAM_MSG_MEMBER(msg, i, msg), len);
850 buffer_append(&loginmsg, "\n", 1 );
851 reply[i].resp_retcode = PAM_SUCCESS;
852 break;
853 default:
854 goto fail;
855 }
856 }
857 *resp = reply;
858 return (PAM_SUCCESS);
859
860 fail:
861 for(i = 0; i < n; i++) {
862 if (reply[i].resp != NULL)
863 xfree(reply[i].resp);
864 }
865 xfree(reply);
866 return (PAM_CONV_ERR);
867}
868
869static struct pam_conv store_conv = { pam_store_conv, NULL };
870
826void 871void
827do_pam_session(void) 872do_pam_session(void)
828{ 873{
829 debug3("PAM: opening session"); 874 debug3("PAM: opening session");
830 sshpam_err = pam_set_item(sshpam_handle, PAM_CONV, 875 sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
831 (const void *)&tty_conv); 876 (const void *)&store_conv);
832 if (sshpam_err != PAM_SUCCESS) 877 if (sshpam_err != PAM_SUCCESS)
833 fatal("PAM: failed to set PAM_CONV: %s", 878 fatal("PAM: failed to set PAM_CONV: %s",
834 pam_strerror(sshpam_handle, sshpam_err)); 879 pam_strerror(sshpam_handle, sshpam_err));