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.
This commit is contained in:
Eric Andersen 2002-10-10 03:55:09 +00:00
parent d274b53c1d
commit fdfe298a96
2 changed files with 21 additions and 4 deletions

View File

@ -37,8 +37,6 @@
#define USE_SYSLOG #define USE_SYSLOG
#endif #endif
extern void updwtmp(const char *filename, const struct utmp *ut);
/* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
#include <syslog.h> #include <syslog.h>
@ -52,7 +50,10 @@ extern void updwtmp(const char *filename, const struct utmp *ut);
#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
extern void updwtmp(const char *filename, const struct utmp *ut);
#endif #endif
#endif /* LOGIN_PROCESS */
/* /*
* Things you may want to modify. * 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_args(int argc, char **argv, struct options *op);
static void parse_speeds(struct options *op, char *arg); 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 open_tty(char *tty, struct termio *tp, int local);
static void termio_init(struct termio *tp, int speed, struct options *op); static void termio_init(struct termio *tp, int speed, struct options *op);
static void auto_baud(struct termio *tp); 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 int bcode(const char *s);
static void error(const char *fmt, ...) __attribute__ ((noreturn)); 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. */ /* The following is used for understandable diagnostics. */
/* Fake hostname for ut_host specified on command line. */ /* Fake hostname for ut_host specified on command line. */
@ -286,8 +290,11 @@ int getty_main(int argc, char **argv)
/* Update the utmp file. */ /* Update the utmp file. */
#ifdef SYSV_STYLE #ifdef SYSV_STYLE
#ifdef CONFIG_FEATURE_U_W_TMP
update_utmp(options.tty); update_utmp(options.tty);
#endif
#endif #endif
debug("calling open_tty\n"); debug("calling open_tty\n");
@ -492,6 +499,7 @@ static void parse_speeds(struct options *op, char *arg)
} }
#ifdef SYSV_STYLE #ifdef SYSV_STYLE
#ifdef CONFIG_FEATURE_U_W_TMP
/* update_utmp - update our utmp entry */ /* update_utmp - update our utmp entry */
static void update_utmp(char *line) 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 } */ /* open_tty - set up tty as standard { input, output, error } */
static void open_tty(char *tty, struct termio *tp, int local) static void open_tty(char *tty, struct termio *tp, int local)

View File

@ -18,9 +18,11 @@
#include "busybox.h" #include "busybox.h"
#ifdef CONFIG_FEATURE_U_W_TMP
// 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);
#endif
// import from encrypt.c // import from encrypt.c
extern char *pw_encrypt(const char *clear, const char *salt); 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 )) 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
checkutmp ( !amroot ); checkutmp ( !amroot );
#endif
tmp = ttyname ( 0 ); tmp = ttyname ( 0 );
if ( tmp && ( strncmp ( tmp, "/dev/", 5 ) == 0 )) if ( tmp && ( strncmp ( tmp, "/dev/", 5 ) == 0 ))
@ -212,7 +216,9 @@ 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
setutmp ( username, tty ); setutmp ( username, tty );
#endif
if ( *tty != '/' ) if ( *tty != '/' )
snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty); snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty);
else else
@ -356,6 +362,7 @@ static void motd ( )
} }
#ifdef CONFIG_FEATURE_U_W_TMP
// vv Taken from tinylogin utmp.c vv // vv Taken from tinylogin utmp.c vv
#define _WTMP_FILE "/var/log/wtmp" #define _WTMP_FILE "/var/log/wtmp"
@ -437,3 +444,4 @@ static void setutmp(const char *name, const char *line)
endutent(); endutent();
updwtmp(_WTMP_FILE, &utent); updwtmp(_WTMP_FILE, &utent);
} }
#endif /* CONFIG_FEATURE_U_W_TMP */