]> granicus.if.org Git - shadow/commitdiff
* src/login.c: Copy the name of the user authenticated by PAM to
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 20 Sep 2008 19:54:35 +0000 (19:54 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 20 Sep 2008 19:54:35 +0000 (19:54 +0000)
username. This simplify later logging (avoid USE_PAM
conditional).

ChangeLog
src/login.c

index 9db2e1a8dae37124ad8978a26a34cdc006779d61..68be08003e7f35a5be0b85c18169ce4adc1a9e2c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2008-09-20  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/login.c: Use a dynamic buffer for usernames.
+       * src/login.c: Copy the name of the user authenticated by PAM to
+       username. This simplify later logging (avoid USE_PAM
+       conditional).
 
 2008-09-20  Nicolas François  <nicolas.francois@centraliens.net>
 
index 68ff646002cb0b9d4c1b07c36cbf2680b746d143..60964d3dc1d23e13b0319d450cbd21680b75d8b0 100644 (file)
@@ -787,11 +787,16 @@ int main (int argc, char **argv)
           First get the username that we are actually using, though.
         */
        retcode = pam_get_item (pamh, PAM_USER, (const void **)ptr_pam_user);
-       pwd = xgetpwnam (pam_user);
+       if (NULL != username) {
+               free (username);
+       }
+       username = xstrdup (pam_user);
+
+       pwd = xgetpwnam (username);
        if (NULL == pwd) {
                SYSLOG ((LOG_ERR, "xgetpwnam(%s) failed",
                         getdef_bool ("LOG_UNKFAIL_ENAB") ?
-                        pam_user : "UNKNOWN"));
+                        username : "UNKNOWN"));
                exit (1);
        }
 
@@ -1023,11 +1028,7 @@ int main (int argc, char **argv)
                addenv ("IFS= \t\n", NULL);     /* ... instead, set a safe IFS */
        }
 
-#ifdef USE_PAM
-       setutmp (pam_user, tty, hostname);      /* make entry in utmp & wtmp files */
-#else
        setutmp (username, tty, hostname);      /* make entry in utmp & wtmp files */
-#endif
        if (pwent.pw_shell[0] == '*') { /* subsystem root */
                pwent.pw_shell++;       /* skip the '*' */
                subsystem (&pwent);     /* figure out what to execute */
@@ -1216,11 +1217,7 @@ int main (int argc, char **argv)
        if (0 == pwent.pw_uid) {
                SYSLOG ((LOG_NOTICE, "ROOT LOGIN %s", fromhost));
        } else if (getdef_bool ("LOG_OK_LOGINS")) {
-#ifdef USE_PAM
-               SYSLOG ((LOG_INFO, "'%s' logged in %s", pam_user, fromhost));
-#else
                SYSLOG ((LOG_INFO, "'%s' logged in %s", username, fromhost));
-#endif
        }
        closelog ();
        tmp = getdef_str ("FAKE_SHELL");