Patch by jonlar in Bug 312 to split the U_W_TMP feature into sep UTMP and WTMP options

This commit is contained in:
Mike Frysinger 2005-07-01 01:04:32 +00:00
parent a87bb60809
commit 8deb686d2e
6 changed files with 35 additions and 27 deletions

View File

@ -597,7 +597,7 @@ config CONFIG_WC
config CONFIG_WHO config CONFIG_WHO
bool "who" bool "who"
default n default n
select CONFIG_FEATURE_U_W_TMP select CONFIG_FEATURE_UTMP
help help
who is used to show who is logged on. who is used to show who is logged on.

View File

@ -57,14 +57,21 @@ config CONFIG_GETTY
help help
getty lets you log in on a tty, it is normally invoked by init. getty lets you log in on a tty, it is normally invoked by init.
config CONFIG_FEATURE_U_W_TMP config CONFIG_FEATURE_UTMP
bool " Support utmp and wtmp files" bool " Support utmp file"
depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO || CONFIG_LAST depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO
default n default n
help help
The files /var/run/utmp and /var/run/wtmp can be used to track when The file /var/run/utmp is used to track who is currently logged in.
user's have logged into and logged out of the system, allowing programs
such as 'who' and 'last' to list who is currently logged in. config CONFIG_FEATURE_WTMP
bool " Support wtmp file"
depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_LAST
default n
select CONFIG_FEATURE_UTMP
help
The file /var/run/wtmp is used to track when user's have logged into
and logged out of the system.
config CONFIG_LOGIN config CONFIG_LOGIN
bool "login" bool "login"

View File

@ -47,7 +47,7 @@
#ifdef LOGIN_PROCESS /* defined in System V utmp.h */ #ifdef LOGIN_PROCESS /* defined in System V utmp.h */
#define SYSV_STYLE /* select System V style getty */ #define SYSV_STYLE /* select System V style getty */
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_WTMP
extern void updwtmp(const char *filename, const struct utmp *ut); extern void updwtmp(const char *filename, const struct utmp *ut);
#endif #endif
#endif /* LOGIN_PROCESS */ #endif /* LOGIN_PROCESS */
@ -231,7 +231,7 @@ static int caps_lock(const char *s);
static int bcode(char *s); static int bcode(char *s);
static void error(const char *fmt, ...) __attribute__ ((noreturn)); static void error(const char *fmt, ...) __attribute__ ((noreturn));
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
static void update_utmp(char *line); static void update_utmp(char *line);
#endif #endif
@ -289,7 +289,7 @@ int getty_main(int argc, char **argv)
#ifdef SYSV_STYLE #ifdef SYSV_STYLE
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
update_utmp(options.tty); update_utmp(options.tty);
#endif #endif
#endif #endif
@ -482,7 +482,7 @@ static void parse_speeds(struct options *op, char *arg)
} }
#ifdef SYSV_STYLE #ifdef SYSV_STYLE
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
/* update_utmp - update our utmp entry */ /* update_utmp - update our utmp entry */
static void update_utmp(char *line) static void update_utmp(char *line)
@ -533,15 +533,14 @@ static void update_utmp(char *line)
pututline(&ut); pututline(&ut);
endutent(); endutent();
{ #ifdef CONFIG_FEATURE_WTMP
if (access(_PATH_WTMP, R_OK|W_OK) == -1) { if (access(_PATH_WTMP, R_OK|W_OK) == -1)
close(creat(_PATH_WTMP, 0664)); close(creat(_PATH_WTMP, 0664));
} updwtmp(_PATH_WTMP, &ut);
updwtmp(_PATH_WTMP, &ut); #endif
}
} }
#endif /* CONFIG_FEATURE_U_W_TMP */ #endif /* CONFIG_FEATURE_UTMP */
#endif /* SYSV_STYLE */ #endif /* SYSV_STYLE */
/* open_tty - set up tty as standard { input, output, error } */ /* open_tty - set up tty as standard { input, output, error } */

View File

@ -23,7 +23,7 @@
#include <errno.h> #include <errno.h>
#endif #endif
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
// import from utmp.c // import from utmp.c
static void checkutmp(int picky); static void checkutmp(int picky);
static void setutmp(const char *name, const char *line); static void setutmp(const char *name, const char *line);
@ -121,7 +121,7 @@ extern int login_main(int argc, char **argv)
if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 ))
return EXIT_FAILURE; /* Must be a terminal */ return EXIT_FAILURE; /* Must be a terminal */
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
checkutmp ( !amroot ); checkutmp ( !amroot );
#endif #endif
@ -133,13 +133,13 @@ extern int login_main(int argc, char **argv)
else else
safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); safe_strncpy ( tty, "UNKNOWN", sizeof( tty ));
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
if ( amroot ) if ( amroot )
memset ( utent.ut_host, 0, sizeof utent.ut_host ); memset ( utent.ut_host, 0, sizeof utent.ut_host );
#endif #endif
if ( opt_host ) { if ( opt_host ) {
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host ));
#endif #endif
snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host );
@ -221,7 +221,7 @@ auth_ok:
if ( check_nologin ( pw-> pw_uid == 0 )) if ( check_nologin ( pw-> pw_uid == 0 ))
return EXIT_FAILURE; return EXIT_FAILURE;
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
setutmp ( username, tty ); setutmp ( username, tty );
#endif #endif
@ -402,7 +402,7 @@ static void motd (void)
} }
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
// vv Taken from tinylogin utmp.c vv // vv Taken from tinylogin utmp.c vv
#define NO_UTENT \ #define NO_UTENT \
@ -480,9 +480,11 @@ static void setutmp(const char *name, const char *line)
setutent(); setutent();
pututline(&utent); pututline(&utent);
endutent(); endutent();
#ifdef CONFIG_FEATURE_WTMP
if (access(_PATH_WTMP, R_OK|W_OK) == -1) { if (access(_PATH_WTMP, R_OK|W_OK) == -1) {
close(creat(_PATH_WTMP, 0664)); close(creat(_PATH_WTMP, 0664));
} }
updwtmp(_PATH_WTMP, &utent); updwtmp(_PATH_WTMP, &utent);
#endif
} }
#endif /* CONFIG_FEATURE_U_W_TMP */ #endif /* CONFIG_FEATURE_UTMP */

View File

@ -91,7 +91,7 @@ int su_main ( int argc, char **argv )
opt_args = argv + optind; opt_args = argv + optind;
#if defined( SYSLOG_SUCCESS ) || defined( SYSLOG_FAILURE ) #if defined( SYSLOG_SUCCESS ) || defined( SYSLOG_FAILURE )
#ifdef CONFIG_FEATURE_U_W_TMP #ifdef CONFIG_FEATURE_UTMP
/* The utmp entry (via getlogin) is probably the best way to identify /* The utmp entry (via getlogin) is probably the best way to identify
the user, especially if someone su's from a su-shell. */ the user, especially if someone su's from a su-shell. */
old_user = getlogin ( ); old_user = getlogin ( );

View File

@ -93,7 +93,7 @@ config CONFIG_EJECT
config CONFIG_LAST config CONFIG_LAST
bool "last" bool "last"
default n default n
select CONFIG_FEATURE_U_W_TMP select CONFIG_FEATURE_WTMP
help help
'last' displays a list of the last users that logged into the system. 'last' displays a list of the last users that logged into the system.