diff options
| author | Eric Andersen <andersen@codepoet.org> | 2002-10-10 03:55:09 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2002-10-10 03:55:09 +0000 |
| commit | fdfe298a966da0e6eecdc355efd640acf73c00e5 (patch) | |
| tree | bbba20b8aeb730194fe47b35bea6deea8d752a37 | |
| parent | d274b53c1d45aa829178c0aded9434f50a044a2f (diff) | |
| download | busybox-w32-fdfe298a966da0e6eecdc355efd640acf73c00e5.tar.gz busybox-w32-fdfe298a966da0e6eecdc355efd640acf73c00e5.tar.bz2 busybox-w32-fdfe298a966da0e6eecdc355efd640acf73c00e5.zip | |
last_patch60 from vodz:
login and getty applets writes utmp/wtmp but init do clearing not.
I think, in current time deny wtmp/utmp writes as undefault features.
| -rw-r--r-- | loginutils/getty.c | 17 | ||||
| -rw-r--r-- | loginutils/login.c | 8 |
2 files changed, 21 insertions, 4 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c index 468208a49..fec8ae8e5 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
| @@ -37,8 +37,6 @@ | |||
| 37 | #define USE_SYSLOG | 37 | #define USE_SYSLOG |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | extern void updwtmp(const char *filename, const struct utmp *ut); | ||
| 41 | |||
| 42 | /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ | 40 | /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ |
| 43 | #ifdef USE_SYSLOG | 41 | #ifdef USE_SYSLOG |
| 44 | #include <syslog.h> | 42 | #include <syslog.h> |
| @@ -52,7 +50,10 @@ extern void updwtmp(const char *filename, const struct utmp *ut); | |||
| 52 | 50 | ||
| 53 | #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ | 51 | #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ |
| 54 | #define SYSV_STYLE /* select System V style getty */ | 52 | #define SYSV_STYLE /* select System V style getty */ |
| 53 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 54 | extern void updwtmp(const char *filename, const struct utmp *ut); | ||
| 55 | #endif | 55 | #endif |
| 56 | #endif /* LOGIN_PROCESS */ | ||
| 56 | 57 | ||
| 57 | /* | 58 | /* |
| 58 | * Things you may want to modify. | 59 | * Things you may want to modify. |
| @@ -218,7 +219,6 @@ static struct Speedtab speedtab[] = { | |||
| 218 | 219 | ||
| 219 | static void parse_args(int argc, char **argv, struct options *op); | 220 | static void parse_args(int argc, char **argv, struct options *op); |
| 220 | static void parse_speeds(struct options *op, char *arg); | 221 | static void parse_speeds(struct options *op, char *arg); |
| 221 | static void update_utmp(char *line); | ||
| 222 | static void open_tty(char *tty, struct termio *tp, int local); | 222 | static void open_tty(char *tty, struct termio *tp, int local); |
| 223 | static void termio_init(struct termio *tp, int speed, struct options *op); | 223 | static void termio_init(struct termio *tp, int speed, struct options *op); |
| 224 | static void auto_baud(struct termio *tp); | 224 | static void auto_baud(struct termio *tp); |
| @@ -234,6 +234,10 @@ static int caps_lock(const char *s); | |||
| 234 | static int bcode(const char *s); | 234 | static int bcode(const char *s); |
| 235 | static void error(const char *fmt, ...) __attribute__ ((noreturn)); | 235 | static void error(const char *fmt, ...) __attribute__ ((noreturn)); |
| 236 | 236 | ||
| 237 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 238 | static void update_utmp(char *line); | ||
| 239 | #endif | ||
| 240 | |||
| 237 | /* The following is used for understandable diagnostics. */ | 241 | /* The following is used for understandable diagnostics. */ |
| 238 | 242 | ||
| 239 | /* Fake hostname for ut_host specified on command line. */ | 243 | /* Fake hostname for ut_host specified on command line. */ |
| @@ -286,9 +290,12 @@ int getty_main(int argc, char **argv) | |||
| 286 | 290 | ||
| 287 | /* Update the utmp file. */ | 291 | /* Update the utmp file. */ |
| 288 | 292 | ||
| 293 | |||
| 289 | #ifdef SYSV_STYLE | 294 | #ifdef SYSV_STYLE |
| 295 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 290 | update_utmp(options.tty); | 296 | update_utmp(options.tty); |
| 291 | #endif | 297 | #endif |
| 298 | #endif | ||
| 292 | 299 | ||
| 293 | debug("calling open_tty\n"); | 300 | debug("calling open_tty\n"); |
| 294 | /* Open the tty as standard { input, output, error }. */ | 301 | /* Open the tty as standard { input, output, error }. */ |
| @@ -492,6 +499,7 @@ static void parse_speeds(struct options *op, char *arg) | |||
| 492 | } | 499 | } |
| 493 | 500 | ||
| 494 | #ifdef SYSV_STYLE | 501 | #ifdef SYSV_STYLE |
| 502 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 495 | 503 | ||
| 496 | /* update_utmp - update our utmp entry */ | 504 | /* update_utmp - update our utmp entry */ |
| 497 | static void update_utmp(char *line) | 505 | static void update_utmp(char *line) |
| @@ -544,7 +552,8 @@ static void update_utmp(char *line) | |||
| 544 | } | 552 | } |
| 545 | } | 553 | } |
| 546 | 554 | ||
| 547 | #endif | 555 | #endif /* CONFIG_FEATURE_U_W_TMP */ |
| 556 | #endif /* SYSV_STYLE */ | ||
| 548 | 557 | ||
| 549 | /* open_tty - set up tty as standard { input, output, error } */ | 558 | /* open_tty - set up tty as standard { input, output, error } */ |
| 550 | static void open_tty(char *tty, struct termio *tp, int local) | 559 | static void open_tty(char *tty, struct termio *tp, int local) |
diff --git a/loginutils/login.c b/loginutils/login.c index 7687556ba..714829db1 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
| @@ -18,9 +18,11 @@ | |||
| 18 | #include "busybox.h" | 18 | #include "busybox.h" |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 21 | // import from utmp.c | 22 | // import from utmp.c |
| 22 | static void checkutmp(int picky); | 23 | static void checkutmp(int picky); |
| 23 | static void setutmp(const char *name, const char *line); | 24 | static void setutmp(const char *name, const char *line); |
| 25 | #endif | ||
| 24 | 26 | ||
| 25 | // import from encrypt.c | 27 | // import from encrypt.c |
| 26 | extern char *pw_encrypt(const char *clear, const char *salt); | 28 | extern char *pw_encrypt(const char *clear, const char *salt); |
| @@ -119,7 +121,9 @@ extern int login_main(int argc, char **argv) | |||
| 119 | if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) | 121 | if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) |
| 120 | return EXIT_FAILURE; /* Must be a terminal */ | 122 | return EXIT_FAILURE; /* Must be a terminal */ |
| 121 | 123 | ||
| 124 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 122 | checkutmp ( !amroot ); | 125 | checkutmp ( !amroot ); |
| 126 | #endif | ||
| 123 | 127 | ||
| 124 | tmp = ttyname ( 0 ); | 128 | tmp = ttyname ( 0 ); |
| 125 | if ( tmp && ( strncmp ( tmp, "/dev/", 5 ) == 0 )) | 129 | if ( tmp && ( strncmp ( tmp, "/dev/", 5 ) == 0 )) |
| @@ -212,7 +216,9 @@ auth_ok: | |||
| 212 | if ( check_nologin ( pw-> pw_uid == 0 )) | 216 | if ( check_nologin ( pw-> pw_uid == 0 )) |
| 213 | return EXIT_FAILURE; | 217 | return EXIT_FAILURE; |
| 214 | 218 | ||
| 219 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 215 | setutmp ( username, tty ); | 220 | setutmp ( username, tty ); |
| 221 | #endif | ||
| 216 | if ( *tty != '/' ) | 222 | if ( *tty != '/' ) |
| 217 | snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty); | 223 | snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty); |
| 218 | else | 224 | else |
| @@ -356,6 +362,7 @@ static void motd ( ) | |||
| 356 | } | 362 | } |
| 357 | 363 | ||
| 358 | 364 | ||
| 365 | #ifdef CONFIG_FEATURE_U_W_TMP | ||
| 359 | // vv Taken from tinylogin utmp.c vv | 366 | // vv Taken from tinylogin utmp.c vv |
| 360 | 367 | ||
| 361 | #define _WTMP_FILE "/var/log/wtmp" | 368 | #define _WTMP_FILE "/var/log/wtmp" |
| @@ -437,3 +444,4 @@ static void setutmp(const char *name, const char *line) | |||
| 437 | endutent(); | 444 | endutent(); |
| 438 | updwtmp(_WTMP_FILE, &utent); | 445 | updwtmp(_WTMP_FILE, &utent); |
| 439 | } | 446 | } |
| 447 | #endif /* CONFIG_FEATURE_U_W_TMP */ | ||
