]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs: 486361
authorAndrew G. Morgan <morgan@kernel.org>
Sun, 9 Dec 2001 22:39:03 +0000 (22:39 +0000)
committerAndrew G. Morgan <morgan@kernel.org>
Sun, 9 Dec 2001 22:39:03 +0000 (22:39 +0000)
Purpose of commit: bugfix

Commit summary:
---------------
pam_unix is too generic a module to override the PAM_USER_PROMPT item.
(More modifications to xsh to help me test this change.)

CHANGELOG
examples/xsh.c
modules/pam_unix/pam_unix_auth.c

index 5b9af1e615722443e2e23ca858be814945b82b1b..f8ad1ea9d7824880ee80de6dde204859fd620ab6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -55,6 +55,9 @@ bug report - outstanding bugs are listed here:
 0.76: please submit patches for this section with actual code/doc
       patches!
 
+* somehow pam_unix has started forcing the user prompt to be "login: ".
+  This is entirely inapropriate as it overrides PAM_USER_PROMPT. (Bug
+  486361 - agmorgan).
 * added a static module helper library object includes a few changes
   to examples/xsh.c for testing purposes, and also modified the
   pam_rhosts_auth module to use this new library. (Bug 490938 - agmorgan)
index dbb2416cf7ccb5bd8afd41ad1cd9f904f0fb24a3..fdbbbfd0561c5609cb5f6beaa64ce646f6ec70b3 100644 (file)
@@ -49,7 +49,7 @@ int main(int argc, char **argv)
      if (argc > 3) {
          fprintf(stderr,"usage: %s [username [service-name]]\n",argv[0]);
      }
-     if (argc >= 2) {
+     if ((argc >= 2) && (argv[1][0] != '-')) {
          username = argv[1];
      }
      if (argc == 3) {
@@ -60,16 +60,18 @@ int main(int argc, char **argv)
      retcode = pam_start(service, username, &conv, &pamh);
      bail_out(pamh,1,retcode,"pam_start");
 
-     /* fill in the RUSER and RHOST fields */
+     /* fill in the RUSER and RHOST etc. fields */
      {
         char buffer[100];
         struct passwd *pw;
+        const char *tty;
 
         pw = getpwuid(getuid());
         if (pw != NULL) {
             retcode = pam_set_item(pamh, PAM_RUSER, pw->pw_name);
             bail_out(pamh,1,retcode,"pam_set_item(PAM_RUSER)");
         }
+
         retcode = gethostname(buffer, sizeof(buffer)-1);
         if (retcode) {
             perror("failed to look up hostname");
@@ -78,6 +80,12 @@ int main(int argc, char **argv)
         }
         retcode = pam_set_item(pamh, PAM_RHOST, buffer);
         bail_out(pamh,1,retcode,"pam_set_item(PAM_RHOST)");
+
+        tty = ttyname(fileno(stdin));
+        if (tty) {
+            retcode = pam_set_item(pamh, PAM_TTY, tty);
+            bail_out(pamh,1,retcode,"pam_set_item(PAM_RHOST)");
+        }
      }
 
      /* to avoid using goto we abuse a loop here */
index 319f4f05d19a0cc5c3e4944f46e54ada1f2b2461..67497e067a67c44e8a5d7b5540fc8a53b59355ff 100644 (file)
@@ -119,7 +119,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags
 
        /* get the user'name' */
 
-       retval = pam_get_user(pamh, &name, "login: ");
+       retval = pam_get_user(pamh, &name, NULL);
        if (retval == PAM_SUCCESS) {
                /*
                 * Various libraries at various times have had bugs related to