]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Fix ut_type for btmp records
authorArtem Savkov <artem.savkov@gmail.com>
Tue, 18 Nov 2025 15:26:11 +0000 (16:26 +0100)
committerDarren Tucker <dtucker@dtucker.net>
Sat, 7 Feb 2026 15:55:47 +0000 (02:55 +1100)
According to man utmp ut_type is supposed to be only switched from
LOGIN_PROCESS to USER_PROCESS after succesfull authentication and this
is how sshd behaved before 671c44078.

Fixes: 671c44078 ("use construct_utmp to construct btmp records")
Signed-off-by: Artem Savkov <artem.savkov@gmail.com>
loginrec.c
loginrec.h

index d57a9d14632ee0b42c39d02ea2fbf6f79b37a88b..7499aa97562596f263909f88b53908e0a1ef574a 100644 (file)
@@ -651,6 +651,9 @@ construct_utmp(struct logininfo *li,
 # ifdef HAVE_TYPE_IN_UTMP
        /* This is done here to keep utmp constants out of struct logininfo */
        switch (li->type) {
+       case LTYPE_FAILED:
+               ut->ut_type = LOGIN_PROCESS;
+               break;
        case LTYPE_LOGIN:
                ut->ut_type = USER_PROCESS;
                break;
@@ -1732,7 +1735,7 @@ record_failed_login(struct ssh *ssh, const char *username, const char *hostname,
 
        /* Construct a logininfo and turn it into a utmp */
        memset(&li, 0, sizeof(li));
-       li.type = LTYPE_LOGIN;
+       li.type = LTYPE_FAILED;
        li.pid = getpid();
        strlcpy(li.line, "ssh:notty", sizeof(li.line));
        strlcpy(li.username, username, sizeof(li.username));
index 62ddd01d515a652c00f190320f0e53475063aaab..42b45f040c04ff2a94467dcfed07d2f2aa265a32 100644 (file)
@@ -52,6 +52,7 @@ union login_netinfo {
  */
 /* types - different to utmp.h 'type' macros */
 /* (though set to the same value as linux, openbsd and others...) */
+#define LTYPE_FAILED   6
 #define LTYPE_LOGIN    7
 #define LTYPE_LOGOUT   8