]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/utmp.c: Refactoring for readability
authorEvgeny Grin (Karlson2k) <k2k@drgrin.dev>
Tue, 15 Jul 2025 14:34:21 +0000 (16:34 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Fri, 18 Jul 2025 19:55:10 +0000 (21:55 +0200)
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
lib/utmp.c

index fade895f288e1205f98ea934f3f772079dca6fe9..2b342a1bafc902c92c4ee24e51b087bb134e3d50 100644 (file)
@@ -158,11 +158,13 @@ get_current_utmp(void)
 
        /* First, try to find a valid utmp entry for this process.  */
        while ((ut = getutxent()) != NULL) {
+               if (   (LOGIN_PROCESS != ut->ut_type)
+                   && (USER_PROCESS  != ut->ut_type))
+                       continue;
+
                if (   (   (ut->ut_pid == getpid ())
                        || (ut->ut_pid == getppid ()))
                    && ('\0' != ut->ut_id[0])
-                   && (   (LOGIN_PROCESS == ut->ut_type)
-                       || (USER_PROCESS  == ut->ut_type))
                    /* A process may have failed to close an entry
                     * Check if this entry refers to the current tty */
                    && is_my_tty(ut->ut_line))