diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-05 22:10:38 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-05 22:10:38 +0200 |
commit | 3a41611bc5ddeda6044e1f1e2956174b25389ce0 (patch) | |
tree | adfc8a982cf321cc859900a28e9e92c82d43caea /init/halt.c | |
parent | 37f5bef63c0db4892d8ffa3c38a04c7998e10f83 (diff) |
telnetd: write LOGIN/DEAD_PROCESS utmp records. Closes bug 1363
function old new delta
write_new_utmp - 253 +253
skip_dev_pfx - 30 +30
handle_sigchld 42 72 +30
telnetd_main 1650 1673 +23
make_new_session 415 438 +23
...
login_main 1140 1148 +8
update_utmp 337 313 -24
write_wtmp 220 154 -66
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 11/6 up/down: 406/-115) Total: ~291 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init/halt.c')
-rw-r--r-- | init/halt.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/init/halt.c b/init/halt.c index a3459ee48..f1bb2c4a8 100644 --- a/init/halt.c +++ b/init/halt.c @@ -18,17 +18,18 @@ static void write_wtmp(void) { struct utmp utmp; struct utsname uts; - if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) { + /* "man utmp" says wtmp file should *not* be created automagically */ + /*if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) { close(creat(bb_path_wtmp_file, 0664)); - } + }*/ memset(&utmp, 0, sizeof(utmp)); utmp.ut_tv.tv_sec = time(NULL); - safe_strncpy(utmp.ut_user, "shutdown", UT_NAMESIZE); + strcpy(utmp.ut_user, "shutdown"); /* it is wide enough */ utmp.ut_type = RUN_LVL; - safe_strncpy(utmp.ut_id, "~~", sizeof(utmp.ut_id)); - safe_strncpy(utmp.ut_line, "~~", UT_LINESIZE); - if (uname(&uts) == 0) - safe_strncpy(utmp.ut_host, uts.release, sizeof(utmp.ut_host)); + utmp.ut_id[0] = '~'; utmp.ut_id[1] = '~'; /* = strcpy(utmp.ut_id, "~~"); */ + utmp.ut_line[0] = '~'; utmp.ut_line[1] = '~'; /* = strcpy(utmp.ut_line, "~~"); */ + uname(&uts); + safe_strncpy(utmp.ut_host, uts.release, sizeof(utmp.ut_host)); updwtmp(bb_path_wtmp_file, &utmp); } #else |