* src/login.c: Added update_utmp() to group the prepare_utmp and
setutmp (and the utmpx versions).
This commit is contained in:
parent
f59a69f4b6
commit
790dbb07fc
@ -1,3 +1,8 @@
|
||||
2009-04-22 Nicolas François <nicolas.francois@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@centraliens.net>
|
||||
|
||||
* src/login.c: Do not include netdb.h. gethostbyname() is no more
|
||||
|
39
src/login.c
39
src/login.c
@ -118,6 +118,10 @@ static void usage (void);
|
||||
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;
|
||||
@ -438,6 +442,32 @@ static const char *get_failent_user (const char *user)
|
||||
return failent_user;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
@ -1051,14 +1081,7 @@ int main (int argc, char **argv)
|
||||
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 '*' */
|
||||
|
Loading…
Reference in New Issue
Block a user