From: Karel Zak Date: Fri, 5 Oct 2012 10:07:10 +0000 (+0200) Subject: login: reuse DEAD_PROCESS utmp entries X-Git-Tag: v2.23-rc1~654 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98193daa8c3cd285c347a91579e1cb11944b7fc0;p=thirdparty%2Futil-linux.git login: reuse DEAD_PROCESS utmp entries Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=858009 Signed-off-by: Karel Zak --- diff --git a/login-utils/login.c b/login-utils/login.c index c0cc00a667..8ae5266f13 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -584,14 +584,22 @@ static void log_utmp(struct login_context *cxt) /* If we can't find a pre-existing entry by pid, try by line. * BSD network daemons may rely on this. */ - if (utp == NULL) { + if (utp == NULL && cxt->tty_name) { setutent(); ut.ut_type = LOGIN_PROCESS; - if (cxt->tty_name) - strncpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line)); + strncpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line)); utp = getutline(&ut); } + /* If we can't find a pre-existing entry by pid and line, try it by id. + * Very stupid telnetd deamons don't set up utmp at all (kzak) */ + if (utp == NULL && cxt->tty_number) { + setutent(); + ut.ut_type = DEAD_PROCESS; + strncpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id)); + utp = getutid(&ut); + } + if (utp) memcpy(&ut, utp, sizeof(ut)); else