[Pkg-shadow-commits] r2741 - in upstream/trunk: . src
Nicolas FRANÇOIS
nekral-guest at alioth.debian.org
Wed Apr 22 19:58:39 UTC 2009
Author: nekral-guest
Date: 2009-04-22 19:58:39 +0000 (Wed, 22 Apr 2009)
New Revision: 2741
Modified:
upstream/trunk/ChangeLog
upstream/trunk/src/login.c
Log:
* src/login.c: Added update_utmp() to group the prepare_utmp and
setutmp (and the utmpx versions).
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2009-04-22 19:54:28 UTC (rev 2740)
+++ upstream/trunk/ChangeLog 2009-04-22 19:58:39 UTC (rev 2741)
@@ -1,5 +1,10 @@
2009-04-22 Nicolas François <nicolas.francois at centraliens.net>
+ * src/login.c: Added update_utmp() to group the prepare_utmp and
+ setutmp (and the utmpx versions).
+
+2009-04-22 Nicolas François <nicolas.francois at centraliens.net>
+
* src/login.c: Do not include netdb.h. gethostbyname() is no more
called from within login.c. Also UT_ADDR does not exist anymore.
Modified: upstream/trunk/src/login.c
===================================================================
--- upstream/trunk/src/login.c 2009-04-22 19:54:28 UTC (rev 2740)
+++ upstream/trunk/src/login.c 2009-04-22 19:58:39 UTC (rev 2741)
@@ -118,6 +118,10 @@
static void setup_tty (void);
static void process_flags (int, char *const *);
static const char *get_failent_user (const char *user);
+static void update_utmp (const char *username,
+ const char *tty,
+ const char *hostname,
+ const struct utmp *utent);
#ifndef USE_PAM
static struct faillog faillog;
@@ -439,6 +443,32 @@
}
/*
+ * update_utmp - Update or create an utmp entry in utmp, wtmp, utmpw, and
+ * wtmpx
+ *
+ * utent should be the utmp entry returned by get_current_utmp (or
+ * NULL).
+ */
+static void update_utmp (const char *username,
+ const char *tty,
+ const char *hostname,
+ /*@null@*/const struct utmp *utent)
+{
+ struct utmp *ut = prepare_utmp (username, tty, hostname, utent);
+#ifdef HAVE_UTMPX_H
+ struct utmpx *utx = prepare_utmpx (username, tty, hostname, utent);
+#endif /* HAVE_UTMPX_H */
+
+ (void) setutmp (ut); /* make entry in the utmp & wtmp files */
+ free (ut);
+
+#ifdef HAVE_UTMPX_H
+ (void) setutmpx (utx); /* make entry in the utmpx & wtmpx files */
+ free (utx);
+#endif /* HAVE_UTMPX_H */
+}
+
+/*
* login - create a new login session for a user
*
* login is typically called by getty as the second step of a
@@ -1051,14 +1081,7 @@
addenv ("IFS= \t\n", NULL); /* ... instead, set a safe IFS */
}
- struct utmp *ut = prepare_utmp (username, tty, hostname, utent);
- (void) setutmp (ut); /* make entry in the utmp & wtmp files */
- free (ut);
-#ifdef HAVE_UTMPX_H
- struct utmpx *utx = prepare_utmpx (username, tty, hostname, utent);
- (void) setutmpx (utx); /* make entry in the utmpx & wtmpx files */
- free (utx);
-#endif /* HAVE_UTMPX_H */
+ update_utmp (username, tty, hostname, utent);
if (pwd->pw_shell[0] == '*') { /* subsystem root */
pwd->pw_shell++; /* skip the '*' */
More information about the Pkg-shadow-commits
mailing list