]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: reuse DEAD_PROCESS utmp entries
authorKarel Zak <kzak@redhat.com>
Fri, 5 Oct 2012 10:07:10 +0000 (12:07 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 5 Oct 2012 10:07:10 +0000 (12:07 +0200)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=858009
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index c0cc00a667f3673eeb21a356d93f4030bf262c5b..8ae5266f1370aab8c5cb731672457cf302069604 100644 (file)
@@ -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