[Pkg-shadow-commits] r2429 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sat Sep 20 19:54:36 UTC 2008


Author: nekral-guest
Date: 2008-09-20 19:54:35 +0000 (Sat, 20 Sep 2008)
New Revision: 2429

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/login.c
Log:
	* src/login.c: Copy the name of the user authenticated by PAM to
	username. This simplify later logging (avoid USE_PAM
	conditional).


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-09-20 19:44:12 UTC (rev 2428)
+++ upstream/trunk/ChangeLog	2008-09-20 19:54:35 UTC (rev 2429)
@@ -1,6 +1,9 @@
 2008-09-20  Nicolas François  <nicolas.francois at 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 at centraliens.net>
 

Modified: upstream/trunk/src/login.c
===================================================================
--- upstream/trunk/src/login.c	2008-09-20 19:44:12 UTC (rev 2428)
+++ upstream/trunk/src/login.c	2008-09-20 19:54:35 UTC (rev 2429)
@@ -787,11 +787,16 @@
 	   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 @@
 		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 @@
 	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");




More information about the Pkg-shadow-commits mailing list