Added Michael Johnsons' PAM modifications <johnsonm@redhat.com>
authorJohn Terpstra <jht@samba.org>
Thu, 16 Oct 1997 05:33:24 +0000 (05:33 +0000)
committerJohn Terpstra <jht@samba.org>
Thu, 16 Oct 1997 05:33:24 +0000 (05:33 +0000)
This patch has been checked over. JHT
(This used to be commit c84a043f89ccba001597962cd03e2f2a634c4b08)

source3/smbd/password.c

index 1b1bd34bccada1d12b455e60c8241f4405e30667..9f4f0abcae80b4a283800438f5b90a909a9085de 100644 (file)
@@ -416,33 +416,33 @@ static int PAM_conv (int num_msg,
                      struct pam_message **msg,
                      struct pam_response **resp,
                      void *appdata_ptr) {
-  int count = 0, replies = 0;
+  int replies = 0;
   struct pam_response *reply = NULL;
-  int size = sizeof(struct pam_response);
 
-  #define GET_MEM if (reply) realloc(reply, size); else reply = malloc(size); \
-  if (!reply) return PAM_CONV_ERR; \
-  size += sizeof(struct pam_response)
   #define COPY_STRING(s) (s) ? strdup(s) : NULL
 
-  for (count = 0; count < num_msg; count++) {
-    switch (msg[count]->msg_style) {
+  reply = malloc(sizeof(struct pam_response) * num_msg);
+  if (!reply) return PAM_CONV_ERR;
+
+  for (replies = 0; replies < num_msg; replies++) {
+    switch (msg[replies]->msg_style) {
       case PAM_PROMPT_ECHO_ON:
-        GET_MEM;
         reply[replies].resp_retcode = PAM_SUCCESS;
-        reply[replies++].resp = COPY_STRING(PAM_username);
+        reply[replies].resp = COPY_STRING(PAM_username);
           /* PAM frees resp */
         break;
       case PAM_PROMPT_ECHO_OFF:
-        GET_MEM;
         reply[replies].resp_retcode = PAM_SUCCESS;
-        reply[replies++].resp = COPY_STRING(PAM_password);
+        reply[replies].resp = COPY_STRING(PAM_password);
           /* PAM frees resp */
         break;
       case PAM_TEXT_INFO:
+       /* fall through */
+      case PAM_ERROR_MSG:
         /* ignore it... */
+        reply[replies].resp_retcode = PAM_SUCCESS;
+        reply[replies].resp = NULL;
         break;
-      case PAM_ERROR_MSG:
       default:
         /* Must be an error of some sort... */
         free (reply);