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>
This commit is contained in:
Denys Vlasenko
2010-04-05 22:10:38 +02:00
parent 37f5bef63c
commit 3a41611bc5
7 changed files with 134 additions and 56 deletions

View File

@@ -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