summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--auth-pam.c92
2 files changed, 48 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 2fed3fb38..9a14a06ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
3 - (dtucker) [auth-pam.c auth-pam.h session.c] Bug #890: Send output from 3 - (dtucker) [auth-pam.c auth-pam.h session.c] Bug #890: Send output from
4 failing PAM session modules to user then exit, similar to the way 4 failing PAM session modules to user then exit, similar to the way
5 /etc/nologin is handled. ok djm@ 5 /etc/nologin is handled. ok djm@
6 - (dtucker) [auth-pam.c] Relocate sshpam_store_conv(), no code change.
6 7
720040830 820040830
8 - (dtucker) [session.c openbsd-compat/bsd-cygwin_util.{c,h}] Bug #915: only 9 - (dtucker) [session.c openbsd-compat/bsd-cygwin_util.{c,h}] Bug #915: only
@@ -1722,4 +1723,4 @@
1722 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 1723 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
1723 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 1724 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
1724 1725
1725$Id: ChangeLog,v 1.3541 2004/09/11 12:17:26 dtucker Exp $ 1726$Id: ChangeLog,v 1.3542 2004/09/11 12:28:01 dtucker Exp $
diff --git a/auth-pam.c b/auth-pam.c
index 27b9bab23..4ad86de9e 100644
--- a/auth-pam.c
+++ b/auth-pam.c
@@ -47,7 +47,7 @@
47 47
48/* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */ 48/* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */
49#include "includes.h" 49#include "includes.h"
50RCSID("$Id: auth-pam.c,v 1.115 2004/09/11 12:17:26 dtucker Exp $"); 50RCSID("$Id: auth-pam.c,v 1.116 2004/09/11 12:28:02 dtucker Exp $");
51 51
52#ifdef USE_PAM 52#ifdef USE_PAM
53#if defined(HAVE_SECURITY_PAM_APPL_H) 53#if defined(HAVE_SECURITY_PAM_APPL_H)
@@ -490,6 +490,51 @@ sshpam_null_conv(int n, struct pam_message **msg,
490 490
491static struct pam_conv null_conv = { sshpam_null_conv, NULL }; 491static struct pam_conv null_conv = { sshpam_null_conv, NULL };
492 492
493static int
494sshpam_store_conv(int n, struct pam_message **msg,
495 struct pam_response **resp, void *data)
496{
497 struct pam_response *reply;
498 int i;
499 size_t len;
500
501 debug3("PAM: %s called with %d messages", __func__, n);
502 *resp = NULL;
503
504 if (n <= 0 || n > PAM_MAX_NUM_MSG)
505 return (PAM_CONV_ERR);
506
507 if ((reply = malloc(n * sizeof(*reply))) == NULL)
508 return (PAM_CONV_ERR);
509 memset(reply, 0, n * sizeof(*reply));
510
511 for (i = 0; i < n; ++i) {
512 switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
513 case PAM_ERROR_MSG:
514 case PAM_TEXT_INFO:
515 len = strlen(PAM_MSG_MEMBER(msg, i, msg));
516 buffer_append(&loginmsg, PAM_MSG_MEMBER(msg, i, msg), len);
517 buffer_append(&loginmsg, "\n", 1 );
518 reply[i].resp_retcode = PAM_SUCCESS;
519 break;
520 default:
521 goto fail;
522 }
523 }
524 *resp = reply;
525 return (PAM_SUCCESS);
526
527 fail:
528 for(i = 0; i < n; i++) {
529 if (reply[i].resp != NULL)
530 xfree(reply[i].resp);
531 }
532 xfree(reply);
533 return (PAM_CONV_ERR);
534}
535
536static struct pam_conv store_conv = { sshpam_store_conv, NULL };
537
493void 538void
494sshpam_cleanup(void) 539sshpam_cleanup(void)
495{ 540{
@@ -894,51 +939,6 @@ do_pam_chauthtok(void)
894 pam_strerror(sshpam_handle, sshpam_err)); 939 pam_strerror(sshpam_handle, sshpam_err));
895} 940}
896 941
897static int
898sshpam_store_conv(int n, struct pam_message **msg,
899 struct pam_response **resp, void *data)
900{
901 struct pam_response *reply;
902 int i;
903 size_t len;
904
905 debug3("PAM: %s called with %d messages", __func__, n);
906 *resp = NULL;
907
908 if (n <= 0 || n > PAM_MAX_NUM_MSG)
909 return (PAM_CONV_ERR);
910
911 if ((reply = malloc(n * sizeof(*reply))) == NULL)
912 return (PAM_CONV_ERR);
913 memset(reply, 0, n * sizeof(*reply));
914
915 for (i = 0; i < n; ++i) {
916 switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
917 case PAM_ERROR_MSG:
918 case PAM_TEXT_INFO:
919 len = strlen(PAM_MSG_MEMBER(msg, i, msg));
920 buffer_append(&loginmsg, PAM_MSG_MEMBER(msg, i, msg), len);
921 buffer_append(&loginmsg, "\n", 1 );
922 reply[i].resp_retcode = PAM_SUCCESS;
923 break;
924 default:
925 goto fail;
926 }
927 }
928 *resp = reply;
929 return (PAM_SUCCESS);
930
931 fail:
932 for(i = 0; i < n; i++) {
933 if (reply[i].resp != NULL)
934 xfree(reply[i].resp);
935 }
936 xfree(reply);
937 return (PAM_CONV_ERR);
938}
939
940static struct pam_conv store_conv = { sshpam_store_conv, NULL };
941
942void 942void
943do_pam_session(void) 943do_pam_session(void)
944{ 944{