diff options
Diffstat (limited to 'auth-pam.c')
-rw-r--r-- | auth-pam.c | 92 |
1 files changed, 46 insertions, 46 deletions
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" |
50 | RCSID("$Id: auth-pam.c,v 1.115 2004/09/11 12:17:26 dtucker Exp $"); | 50 | RCSID("$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 | ||
491 | static struct pam_conv null_conv = { sshpam_null_conv, NULL }; | 491 | static struct pam_conv null_conv = { sshpam_null_conv, NULL }; |
492 | 492 | ||
493 | static int | ||
494 | sshpam_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 | |||
536 | static struct pam_conv store_conv = { sshpam_store_conv, NULL }; | ||
537 | |||
493 | void | 538 | void |
494 | sshpam_cleanup(void) | 539 | sshpam_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 | ||
897 | static int | ||
898 | sshpam_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 | |||
940 | static struct pam_conv store_conv = { sshpam_store_conv, NULL }; | ||
941 | |||
942 | void | 942 | void |
943 | do_pam_session(void) | 943 | do_pam_session(void) |
944 | { | 944 | { |