]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs: 449203
authorAndrew G. Morgan <morgan@kernel.org>
Wed, 19 Sep 2001 06:18:46 +0000 (06:18 +0000)
committerAndrew G. Morgan <morgan@kernel.org>
Wed, 19 Sep 2001 06:18:46 +0000 (06:18 +0000)
Purpose of commit: new support

Commit summary:
---------------
Include some BSD changes (to the conversation function) and fix a few
gcc warnings.

CHANGELOG
libpam/pam_delay.c
libpam/pam_handlers.c
libpam/pam_second.c
libpam_misc/misc_conv.c
libpamc/include/security/pam_client.h

index 11ccbe20fc9c974069abc112e3f5363502afde3d..ae2fa0bcf4400c9ee744f1fbcc9d584cf669c05d 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -49,6 +49,9 @@ bug report - outstanding bugs are listed here:
 0.76: please submit patches for this section with actual code/doc
       patches!
 
+* some BSD updates and fixes from Mark Murray - including a slightly
+  more robust conversation function and some minimization of gcc
+  warnings. (Bug 449203 - agmorgan)
 * pam_unix/support.c: sample use of reentrant NSS function.  Not yet active,
   because modules do not include _pam_aconf_h! (Bug 440107 - vorlon)
 * doc/Makefile changes - use $(mandir) [courtesy Harald Welte] (Bug
index 1b8d34fb56fd82a714696e18a994bb9c6116e994..553bf72b98428130ab1c56ce0f9a624c3292d02d 100644 (file)
@@ -133,7 +133,7 @@ void _pam_await_timer(pam_handle_t *pamh, int status)
 
 int pam_fail_delay(pam_handle_t *pamh, unsigned int usec)
 {
-     int largest;
+     unsigned int largest;
 
      IF_NO_PAMH("pam_fail_delay", pamh, PAM_SYSTEM_ERR);
 
index b2065999979f07d43e63a468b08d5c9365e2c01a..8e32f8e80c7f5d070906216d9a44ac5454e01d94 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  * created by Marc Ewing.
- * Currently maintained by Andrew G. Morgan <morgan@linux.kernel.org>
+ * Currently maintained by Andrew G. Morgan <morgan@kernel.org>
  *
  * $Id$
  *
 
 #include "pam_private.h"
 
-/* FreeBSD doesn't define this */
-#ifndef RTLD_NOW
-# define RTLD_NOW      1
-#endif
-
-/* If not required, define as nothing - FreeBSD needs it to be "_"... */
+/* If not required, define as nothing */
 #ifndef SHLIB_SYM_PREFIX
 # define SHLIB_SYM_PREFIX ""
 #endif
index e764f987f366f71448df9b89c2ce7c90a85fc759..31bdc6cbdaa79f5fb317f19f58877dab999b38f0 100644 (file)
 
 /* p 42 */
 
+/* XXX - there are actually no plans to support this function. It does
+   not appear to be very well defined */
+
+int pam_authenticate_secondary(pam_handle_t *pamh,
+                              char *target_username,
+                              char *target_module_type,
+                              char *target_authn_domain,
+                              char *target_supp_data,
+                              unsigned char *target_module_authtok,
+                              int flags);
+
 int pam_authenticate_secondary(pam_handle_t *pamh,
                               char *target_username,
                               char *target_module_type,
index 7d4b1b99ba9f6519b1df015eb105792d9e86eebe..fbde373540c29b7e08a8b519f2eb82169fabff2e 100644 (file)
@@ -57,7 +57,7 @@ void (*pam_binary_handler_free)(void *appdata, pamc_bp_t *prompt_p)
 
 /* the following code is used to get text input */
 
-volatile static int expired=0;
+static volatile int expired=0;
 
 /* return to the previous signal handling */
 static void reset_alarm(struct sigaction *o_ptr)
@@ -130,10 +130,11 @@ static int get_delay(void)
 static char *read_string(int echo, const char *prompt)
 {
     struct termios term_before, term_tmp;
-    char line[INPUTSIZE];
+    char line[INPUTSIZE], *input;
     struct sigaction old_sig;
     int delay, nc, have_term=0;
-
+    sigset_t oset, nset;
     D(("called with echo='%s', prompt='%s'.", echo ? "ON":"OFF" , prompt));
 
     if (isatty(STDIN_FILENO)) {                      /* terminal state */
@@ -149,6 +150,16 @@ static char *read_string(int echo, const char *prompt)
        }
        have_term = 1;
 
+       /*
+        * We make a simple attempt to block TTY signals from terminating
+        * the conversation without giving PAM a chance to clean up.
+        */
+
+       sigemptyset(&nset); 
+       sigaddset(&nset, SIGINT); 
+       sigaddset(&nset, SIGTSTP); 
+       (void) sigprocmask(SIG_BLOCK, &nset, &oset);
+
     } else if (!echo) {
        D(("<warning: cannot turn echo off>"));
     }
@@ -180,7 +191,6 @@ static char *read_string(int echo, const char *prompt)
            if (expired) {
                delay = get_delay();
            } else if (nc > 0) {                 /* we got some user input */
-               char *input;
 
                if (nc > 0 && line[nc-1] == '\n') {     /* <NUL> terminate */
                    line[--nc] = '\0';
@@ -190,25 +200,46 @@ static char *read_string(int echo, const char *prompt)
                input = x_strdup(line);
                _pam_overwrite(line);
 
-               return input;                  /* return malloc()ed string */
+               goto cleanexit;                /* return malloc()ed string */
            } else if (nc == 0) {                                /* Ctrl-D */
                D(("user did not want to type anything"));
+
+               input = x_strdup("");
                fprintf(stderr, "\n");
-               break;
+               goto cleanexit;                /* return malloc()ed "" */
            }
        }
     }
 
     /* getting here implies that the timer expired */
-    if (have_term)
+    input = NULL;
+    _pam_overwrite(line);
+
+ cleanexit:
+
+    if (have_term) {
+       (void) sigprocmask(SIG_SETMASK, &oset, NULL);
        (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &term_before);
+    }
 
-    memset(line, 0, INPUTSIZE);                      /* clean up */
     return NULL;
 }
 
 /* end of read_string functions */
 
+/*
+ * This conversation function is supposed to be a generic PAM one.
+ * Unfortunately, it is _not_ completely compatible with the Solaris PAM
+ * codebase.
+ *
+ * Namely, for msgm's that contain multiple prompts, this function
+ * interprets "const struct pam_message **msgm" as equivalent to
+ * "const struct pam_message *msgm[]". The Solaris module
+ * implementation interprets the **msgm object as a pointer to a
+ * pointer to an array of "struct pam_message" objects (that is, a
+ * confusing amount of pointer indirection).
+ */
+
 int misc_conv(int num_msg, const struct pam_message **msgm,
              struct pam_response **response, void *appdata_ptr)
 {
index 16a2c1b1130a2279046ab5eb3c7206941ad647b4..2afddd77084be6384a35b9c17550559dd45fb8d2 100644 (file)
@@ -140,7 +140,7 @@ do {                                                                       \
 
 #define PAM_BP_FILL(prmpt, offset, length, data)                           \
 do {                                                                       \
-    int bp_length;                                                         \
+    size_t bp_length;                                                      \
     __u8 *prompt = (__u8 *) (prmpt);                                       \
     bp_length = PAM_BP_LENGTH(prompt);                                     \
     if (bp_length < ((length)+(offset))) {                                 \
@@ -151,7 +151,7 @@ do {                                                                       \
 
 #define PAM_BP_EXTRACT(prmpt, offset, length, data)                        \
 do {                                                                       \
-    int __bp_length;                                                       \
+    size_t __bp_length;                                                    \
     const __u8 *__prompt = (const __u8 *) (prmpt);                         \
     __bp_length = PAM_BP_LENGTH(__prompt);                                 \
     if (((offset) < 0) || (__bp_length < ((length)+(offset)))              \