diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-07-30 17:24:47 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-07-30 17:24:47 +0000 |
commit | a9268c988bbddb5cf73690f152d04713983f2dee (patch) | |
tree | 5dc7bdc6d5ffd211abc3e76e8b43f2e53fba3e10 | |
parent | 592fad0d8930ed2d4cfb9cb6323432caacaafe69 (diff) | |
download | busybox-w32-a9268c988bbddb5cf73690f152d04713983f2dee.tar.gz busybox-w32-a9268c988bbddb5cf73690f152d04713983f2dee.tar.bz2 busybox-w32-a9268c988bbddb5cf73690f152d04713983f2dee.zip |
Fixup getty, login, etc so the utmp and wtmp are updated, allowing
the 'who' and 'last' applets among other things to work as expected.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@9047 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/Config.in | 1 | ||||
-rw-r--r-- | loginutils/Config.in | 9 | ||||
-rw-r--r-- | loginutils/getty.c | 10 | ||||
-rw-r--r-- | loginutils/login.c | 7 | ||||
-rw-r--r-- | miscutils/Config.in | 1 |
5 files changed, 23 insertions, 5 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in index 5c0180a5e..c995e55ff 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in | |||
@@ -538,6 +538,7 @@ config CONFIG_WC | |||
538 | config CONFIG_WHO | 538 | config CONFIG_WHO |
539 | bool "who" | 539 | bool "who" |
540 | default n | 540 | default n |
541 | select CONFIG_FEATURE_U_W_TMP | ||
541 | help | 542 | help |
542 | who is used to show who is logged on. | 543 | who is used to show who is logged on. |
543 | 544 | ||
diff --git a/loginutils/Config.in b/loginutils/Config.in index db038abb0..d9938b066 100644 --- a/loginutils/Config.in +++ b/loginutils/Config.in | |||
@@ -57,6 +57,15 @@ 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 | ||
60 | config CONFIG_FEATURE_U_W_TMP | ||
61 | bool " Support utmp and wtmp files" | ||
62 | depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO || CONFIG_LAST | ||
63 | default n | ||
64 | help | ||
65 | The files /var/run/utmp and /var/run/wtmp can be used to track when | ||
66 | user's have logged into and logged out of the system, allowing programs | ||
67 | such as 'who' and 'last' to list who is currently logged in. | ||
68 | |||
60 | config CONFIG_LOGIN | 69 | config CONFIG_LOGIN |
61 | bool "login" | 70 | bool "login" |
62 | default n | 71 | default n |
diff --git a/loginutils/getty.c b/loginutils/getty.c index b211733ee..2b37136fe 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -228,7 +228,7 @@ static void termio_final(struct options *op, struct termio *tp, | |||
228 | 228 | ||
229 | struct chardata *cp); | 229 | struct chardata *cp); |
230 | static int caps_lock(const char *s); | 230 | static int caps_lock(const char *s); |
231 | static int bcode(const char *s); | 231 | static int bcode(char *s); |
232 | static void error(const char *fmt, ...) __attribute__ ((noreturn)); | 232 | static void error(const char *fmt, ...) __attribute__ ((noreturn)); |
233 | 233 | ||
234 | #ifdef CONFIG_FEATURE_U_W_TMP | 234 | #ifdef CONFIG_FEATURE_U_W_TMP |
@@ -503,6 +503,9 @@ static void update_utmp(char *line) | |||
503 | * utmp file can be opened for update, and if we are able to find our | 503 | * utmp file can be opened for update, and if we are able to find our |
504 | * entry in the utmp file. | 504 | * entry in the utmp file. |
505 | */ | 505 | */ |
506 | if (access(_PATH_UTMP, R_OK|W_OK) == -1) { | ||
507 | creat(_PATH_UTMP, O_RDWR); | ||
508 | } | ||
506 | utmpname(_PATH_UTMP); | 509 | utmpname(_PATH_UTMP); |
507 | setutent(); | 510 | setutent(); |
508 | while ((utp = getutent()) | 511 | while ((utp = getutent()) |
@@ -531,6 +534,9 @@ static void update_utmp(char *line) | |||
531 | endutent(); | 534 | endutent(); |
532 | 535 | ||
533 | { | 536 | { |
537 | if (access(_PATH_WTMP, R_OK|W_OK) == -1) { | ||
538 | creat(_PATH_WTMP, O_RDWR); | ||
539 | } | ||
534 | updwtmp(_PATH_WTMP, &ut); | 540 | updwtmp(_PATH_WTMP, &ut); |
535 | } | 541 | } |
536 | } | 542 | } |
@@ -953,7 +959,7 @@ static int caps_lock(const char *s) | |||
953 | } | 959 | } |
954 | 960 | ||
955 | /* bcode - convert speed string to speed code; return 0 on failure */ | 961 | /* bcode - convert speed string to speed code; return 0 on failure */ |
956 | static int bcode(const char *s) | 962 | static int bcode(char *s) |
957 | { | 963 | { |
958 | int r; | 964 | int r; |
959 | unsigned long value; | 965 | unsigned long value; |
diff --git a/loginutils/login.c b/loginutils/login.c index 20fab0753..93d81d314 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -403,8 +403,6 @@ static void motd ( ) | |||
403 | #ifdef CONFIG_FEATURE_U_W_TMP | 403 | #ifdef CONFIG_FEATURE_U_W_TMP |
404 | // vv Taken from tinylogin utmp.c vv | 404 | // vv Taken from tinylogin utmp.c vv |
405 | 405 | ||
406 | #define _WTMP_FILE "/var/log/wtmp" | ||
407 | |||
408 | #define NO_UTENT \ | 406 | #define NO_UTENT \ |
409 | "No utmp entry. You must exec \"login\" from the lowest level \"sh\"" | 407 | "No utmp entry. You must exec \"login\" from the lowest level \"sh\"" |
410 | #define NO_TTY \ | 408 | #define NO_TTY \ |
@@ -480,6 +478,9 @@ static void setutmp(const char *name, const char *line) | |||
480 | setutent(); | 478 | setutent(); |
481 | pututline(&utent); | 479 | pututline(&utent); |
482 | endutent(); | 480 | endutent(); |
483 | updwtmp(_WTMP_FILE, &utent); | 481 | if (access(_PATH_WTMP, R_OK|W_OK) == -1) { |
482 | creat(_PATH_WTMP, O_RDWR); | ||
483 | } | ||
484 | updwtmp(_PATH_WTMP, &utent); | ||
484 | } | 485 | } |
485 | #endif /* CONFIG_FEATURE_U_W_TMP */ | 486 | #endif /* CONFIG_FEATURE_U_W_TMP */ |
diff --git a/miscutils/Config.in b/miscutils/Config.in index ded26b3a8..3c92c4674 100644 --- a/miscutils/Config.in +++ b/miscutils/Config.in | |||
@@ -83,6 +83,7 @@ config CONFIG_DEVFSD_VERBOSE | |||
83 | config CONFIG_LAST | 83 | config CONFIG_LAST |
84 | bool "last" | 84 | bool "last" |
85 | default n | 85 | default n |
86 | select CONFIG_FEATURE_U_W_TMP | ||
86 | help | 87 | help |
87 | 'last' displays a list of the last users that logged into the system. | 88 | 'last' displays a list of the last users that logged into the system. |
88 | 89 | ||