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.
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 468208a..fec8ae8 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 <syslog.h>
@@ -52,7 +50,10 @@
#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 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 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,9 +290,12 @@
/* Update the utmp file. */
+
#ifdef SYSV_STYLE
+#ifdef CONFIG_FEATURE_U_W_TMP
update_utmp(options.tty);
#endif
+#endif
debug("calling open_tty\n");
/* Open the tty as standard { input, output, error }. */
@@ -492,6 +499,7 @@
}
#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 @@
}
}
-#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 7687556..714829d 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 @@
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 @@
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 @@
}
+#ifdef CONFIG_FEATURE_U_W_TMP
// vv Taken from tinylogin utmp.c vv
#define _WTMP_FILE "/var/log/wtmp"
@@ -437,3 +444,4 @@
endutent();
updwtmp(_WTMP_FILE, &utent);
}
+#endif /* CONFIG_FEATURE_U_W_TMP */