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 @@ #define USE_SYSLOG #endif -extern void updwtmp(const char *filename, const struct utmp *ut); - /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ #ifdef USE_SYSLOG #include @@ -52,7 +50,10 @@ extern void updwtmp(const char *filename, const struct utmp *ut); #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ #define SYSV_STYLE /* select System V style getty */ +#ifdef CONFIG_FEATURE_U_W_TMP +extern void updwtmp(const char *filename, const struct utmp *ut); #endif +#endif /* LOGIN_PROCESS */ /* * Things you may want to modify. @@ -218,7 +219,6 @@ static struct Speedtab speedtab[] = { static void parse_args(int argc, char **argv, struct options *op); static void parse_speeds(struct options *op, char *arg); -static void update_utmp(char *line); static void open_tty(char *tty, struct termio *tp, int local); static void termio_init(struct termio *tp, int speed, struct options *op); static void auto_baud(struct termio *tp); @@ -234,6 +234,10 @@ static int caps_lock(const char *s); static int bcode(const char *s); static void error(const char *fmt, ...) __attribute__ ((noreturn)); +#ifdef CONFIG_FEATURE_U_W_TMP +static void update_utmp(char *line); +#endif + /* The following is used for understandable diagnostics. */ /* Fake hostname for ut_host specified on command line. */ @@ -286,8 +290,11 @@ int getty_main(int argc, char **argv) /* Update the utmp file. */ + #ifdef SYSV_STYLE +#ifdef CONFIG_FEATURE_U_W_TMP update_utmp(options.tty); +#endif #endif debug("calling open_tty\n"); @@ -492,6 +499,7 @@ static void parse_speeds(struct options *op, char *arg) } #ifdef SYSV_STYLE +#ifdef CONFIG_FEATURE_U_W_TMP /* update_utmp - update our utmp entry */ static void update_utmp(char *line) @@ -544,7 +552,8 @@ static void update_utmp(char *line) } } -#endif +#endif /* CONFIG_FEATURE_U_W_TMP */ +#endif /* SYSV_STYLE */ /* open_tty - set up tty as standard { input, output, error } */ 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 @@ #include "busybox.h" +#ifdef CONFIG_FEATURE_U_W_TMP // import from utmp.c static void checkutmp(int picky); static void setutmp(const char *name, const char *line); +#endif // import from encrypt.c extern char *pw_encrypt(const char *clear, const char *salt); @@ -119,7 +121,9 @@ extern int login_main(int argc, char **argv) if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) return EXIT_FAILURE; /* Must be a terminal */ +#ifdef CONFIG_FEATURE_U_W_TMP checkutmp ( !amroot ); +#endif tmp = ttyname ( 0 ); if ( tmp && ( strncmp ( tmp, "/dev/", 5 ) == 0 )) @@ -212,7 +216,9 @@ auth_ok: if ( check_nologin ( pw-> pw_uid == 0 )) return EXIT_FAILURE; +#ifdef CONFIG_FEATURE_U_W_TMP setutmp ( username, tty ); +#endif if ( *tty != '/' ) snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty); else @@ -356,6 +362,7 @@ static void motd ( ) } +#ifdef CONFIG_FEATURE_U_W_TMP // vv Taken from tinylogin utmp.c vv #define _WTMP_FILE "/var/log/wtmp" @@ -437,3 +444,4 @@ static void setutmp(const char *name, const char *line) endutent(); updwtmp(_WTMP_FILE, &utent); } +#endif /* CONFIG_FEATURE_U_W_TMP */