summaryrefslogtreecommitdiff
path: root/auth-pam.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-09-11 22:28:01 +1000
committerDarren Tucker <dtucker@zip.com.au>2004-09-11 22:28:01 +1000
commit0a7e3c6c899b7e25efd36cfb9ffb0a8fb36ca67a (patch)
tree281040883dd13568eea99758f5166069c900f8d2 /auth-pam.c
parent69687f4b65373e09269db8c18f18b4ac7225a382 (diff)
- (dtucker) [auth-pam.c] Relocate sshpam_store_conv(), no code change.
Diffstat (limited to 'auth-pam.c')
-rw-r--r--auth-pam.c92
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"
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{