aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-07-01 01:04:32 +0000
committervapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-07-01 01:04:32 +0000
commitce7992948b559cbc4ac9d815adbeb3b53c4f27a2 (patch)
tree132237fb52e98c8d72570d7ee2728f3e299383de
parentac6d18e54ca537f9a26e5ca65e1b1c0faf88d7ad (diff)
downloadbusybox-w32-ce7992948b559cbc4ac9d815adbeb3b53c4f27a2.tar.gz
busybox-w32-ce7992948b559cbc4ac9d815adbeb3b53c4f27a2.tar.bz2
busybox-w32-ce7992948b559cbc4ac9d815adbeb3b53c4f27a2.zip
Patch by jonlar in Bug 312 to split the U_W_TMP feature into sep UTMP and WTMP options
git-svn-id: svn://busybox.net/trunk/busybox@10679 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--coreutils/Config.in2
-rw-r--r--loginutils/Config.in19
-rw-r--r--loginutils/getty.c21
-rw-r--r--loginutils/login.c16
-rw-r--r--loginutils/su.c2
-rw-r--r--miscutils/Config.in2
6 files changed, 35 insertions, 27 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in
index 6d19909a8..79081e5f7 100644
--- a/coreutils/Config.in
+++ b/coreutils/Config.in
@@ -597,7 +597,7 @@ config CONFIG_WC
597config CONFIG_WHO 597config CONFIG_WHO
598 bool "who" 598 bool "who"
599 default n 599 default n
600 select CONFIG_FEATURE_U_W_TMP 600 select CONFIG_FEATURE_UTMP
601 help 601 help
602 who is used to show who is logged on. 602 who is used to show who is logged on.
603 603
diff --git a/loginutils/Config.in b/loginutils/Config.in
index 5619aa9af..12c208c64 100644
--- a/loginutils/Config.in
+++ b/loginutils/Config.in
@@ -57,14 +57,21 @@ config CONFIG_GETTY
57 help 57 help
58 getty lets you log in on a tty, it is normally invoked by init. 58 getty lets you log in on a tty, it is normally invoked by init.
59 59
60config CONFIG_FEATURE_U_W_TMP 60config CONFIG_FEATURE_UTMP
61 bool " Support utmp and wtmp files" 61 bool " Support utmp file"
62 depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO || CONFIG_LAST 62 depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO
63 default n 63 default n
64 help 64 help
65 The files /var/run/utmp and /var/run/wtmp can be used to track when 65 The file /var/run/utmp is used to track who is currently logged in.
66 user's have logged into and logged out of the system, allowing programs 66
67 such as 'who' and 'last' to list who is currently logged in. 67config CONFIG_FEATURE_WTMP
68 bool " Support wtmp file"
69 depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_LAST
70 default n
71 select CONFIG_FEATURE_UTMP
72 help
73 The file /var/run/wtmp is used to track when user's have logged into
74 and logged out of the system.
68 75
69config CONFIG_LOGIN 76config CONFIG_LOGIN
70 bool "login" 77 bool "login"
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 3dd6258c5..9950988f4 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -47,7 +47,7 @@
47 47
48#ifdef LOGIN_PROCESS /* defined in System V utmp.h */ 48#ifdef LOGIN_PROCESS /* defined in System V utmp.h */
49#define SYSV_STYLE /* select System V style getty */ 49#define SYSV_STYLE /* select System V style getty */
50#ifdef CONFIG_FEATURE_U_W_TMP 50#ifdef CONFIG_FEATURE_WTMP
51extern void updwtmp(const char *filename, const struct utmp *ut); 51extern void updwtmp(const char *filename, const struct utmp *ut);
52#endif 52#endif
53#endif /* LOGIN_PROCESS */ 53#endif /* LOGIN_PROCESS */
@@ -231,7 +231,7 @@ static int caps_lock(const char *s);
231static int bcode(char *s); 231static int bcode(char *s);
232static void error(const char *fmt, ...) __attribute__ ((noreturn)); 232static void error(const char *fmt, ...) __attribute__ ((noreturn));
233 233
234#ifdef CONFIG_FEATURE_U_W_TMP 234#ifdef CONFIG_FEATURE_UTMP
235static void update_utmp(char *line); 235static void update_utmp(char *line);
236#endif 236#endif
237 237
@@ -289,7 +289,7 @@ int getty_main(int argc, char **argv)
289 289
290 290
291#ifdef SYSV_STYLE 291#ifdef SYSV_STYLE
292#ifdef CONFIG_FEATURE_U_W_TMP 292#ifdef CONFIG_FEATURE_UTMP
293 update_utmp(options.tty); 293 update_utmp(options.tty);
294#endif 294#endif
295#endif 295#endif
@@ -482,7 +482,7 @@ static void parse_speeds(struct options *op, char *arg)
482} 482}
483 483
484#ifdef SYSV_STYLE 484#ifdef SYSV_STYLE
485#ifdef CONFIG_FEATURE_U_W_TMP 485#ifdef CONFIG_FEATURE_UTMP
486 486
487/* update_utmp - update our utmp entry */ 487/* update_utmp - update our utmp entry */
488static void update_utmp(char *line) 488static void update_utmp(char *line)
@@ -533,15 +533,14 @@ static void update_utmp(char *line)
533 pututline(&ut); 533 pututline(&ut);
534 endutent(); 534 endutent();
535 535
536 { 536#ifdef CONFIG_FEATURE_WTMP
537 if (access(_PATH_WTMP, R_OK|W_OK) == -1) { 537 if (access(_PATH_WTMP, R_OK|W_OK) == -1)
538 close(creat(_PATH_WTMP, 0664)); 538 close(creat(_PATH_WTMP, 0664));
539 } 539 updwtmp(_PATH_WTMP, &ut);
540 updwtmp(_PATH_WTMP, &ut); 540#endif
541 }
542} 541}
543 542
544#endif /* CONFIG_FEATURE_U_W_TMP */ 543#endif /* CONFIG_FEATURE_UTMP */
545#endif /* SYSV_STYLE */ 544#endif /* SYSV_STYLE */
546 545
547/* open_tty - set up tty as standard { input, output, error } */ 546/* open_tty - set up tty as standard { input, output, error } */
diff --git a/loginutils/login.c b/loginutils/login.c
index 5186e2369..6632a7665 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -23,7 +23,7 @@
23#include <errno.h> 23#include <errno.h>
24#endif 24#endif
25 25
26#ifdef CONFIG_FEATURE_U_W_TMP 26#ifdef CONFIG_FEATURE_UTMP
27// import from utmp.c 27// import from utmp.c
28static void checkutmp(int picky); 28static void checkutmp(int picky);
29static void setutmp(const char *name, const char *line); 29static void setutmp(const char *name, const char *line);
@@ -121,7 +121,7 @@ extern int login_main(int argc, char **argv)
121 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) 121 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 ))
122 return EXIT_FAILURE; /* Must be a terminal */ 122 return EXIT_FAILURE; /* Must be a terminal */
123 123
124#ifdef CONFIG_FEATURE_U_W_TMP 124#ifdef CONFIG_FEATURE_UTMP
125 checkutmp ( !amroot ); 125 checkutmp ( !amroot );
126#endif 126#endif
127 127
@@ -133,13 +133,13 @@ extern int login_main(int argc, char **argv)
133 else 133 else
134 safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); 134 safe_strncpy ( tty, "UNKNOWN", sizeof( tty ));
135 135
136#ifdef CONFIG_FEATURE_U_W_TMP 136#ifdef CONFIG_FEATURE_UTMP
137 if ( amroot ) 137 if ( amroot )
138 memset ( utent.ut_host, 0, sizeof utent.ut_host ); 138 memset ( utent.ut_host, 0, sizeof utent.ut_host );
139#endif 139#endif
140 140
141 if ( opt_host ) { 141 if ( opt_host ) {
142#ifdef CONFIG_FEATURE_U_W_TMP 142#ifdef CONFIG_FEATURE_UTMP
143 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); 143 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host ));
144#endif 144#endif
145 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); 145 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host );
@@ -221,7 +221,7 @@ auth_ok:
221 if ( check_nologin ( pw-> pw_uid == 0 )) 221 if ( check_nologin ( pw-> pw_uid == 0 ))
222 return EXIT_FAILURE; 222 return EXIT_FAILURE;
223 223
224#ifdef CONFIG_FEATURE_U_W_TMP 224#ifdef CONFIG_FEATURE_UTMP
225 setutmp ( username, tty ); 225 setutmp ( username, tty );
226#endif 226#endif
227 227
@@ -402,7 +402,7 @@ static void motd (void)
402} 402}
403 403
404 404
405#ifdef CONFIG_FEATURE_U_W_TMP 405#ifdef CONFIG_FEATURE_UTMP
406// vv Taken from tinylogin utmp.c vv 406// vv Taken from tinylogin utmp.c vv
407 407
408#define NO_UTENT \ 408#define NO_UTENT \
@@ -480,9 +480,11 @@ static void setutmp(const char *name, const char *line)
480 setutent(); 480 setutent();
481 pututline(&utent); 481 pututline(&utent);
482 endutent(); 482 endutent();
483#ifdef CONFIG_FEATURE_WTMP
483 if (access(_PATH_WTMP, R_OK|W_OK) == -1) { 484 if (access(_PATH_WTMP, R_OK|W_OK) == -1) {
484 close(creat(_PATH_WTMP, 0664)); 485 close(creat(_PATH_WTMP, 0664));
485 } 486 }
486 updwtmp(_PATH_WTMP, &utent); 487 updwtmp(_PATH_WTMP, &utent);
488#endif
487} 489}
488#endif /* CONFIG_FEATURE_U_W_TMP */ 490#endif /* CONFIG_FEATURE_UTMP */
diff --git a/loginutils/su.c b/loginutils/su.c
index 5f6140917..3e82d2428 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -91,7 +91,7 @@ int su_main ( int argc, char **argv )
91 opt_args = argv + optind; 91 opt_args = argv + optind;
92 92
93#if defined( SYSLOG_SUCCESS ) || defined( SYSLOG_FAILURE ) 93#if defined( SYSLOG_SUCCESS ) || defined( SYSLOG_FAILURE )
94#ifdef CONFIG_FEATURE_U_W_TMP 94#ifdef CONFIG_FEATURE_UTMP
95 /* The utmp entry (via getlogin) is probably the best way to identify 95 /* The utmp entry (via getlogin) is probably the best way to identify
96 the user, especially if someone su's from a su-shell. */ 96 the user, especially if someone su's from a su-shell. */
97 old_user = getlogin ( ); 97 old_user = getlogin ( );
diff --git a/miscutils/Config.in b/miscutils/Config.in
index b02def60c..79f44274f 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -93,7 +93,7 @@ config CONFIG_EJECT
93config CONFIG_LAST 93config CONFIG_LAST
94 bool "last" 94 bool "last"
95 default n 95 default n
96 select CONFIG_FEATURE_U_W_TMP 96 select CONFIG_FEATURE_WTMP
97 help 97 help
98 'last' displays a list of the last users that logged into the system. 98 'last' displays a list of the last users that logged into the system.
99 99