From 5af674214abbe16ee57352de24eaef5dc97afdd1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Apr 2025 16:46:25 +0200 Subject: [PATCH] logind: save logind session information to disk once we acquired it via utmp Fixes: #36930 --- src/login/logind-utmp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index d2a1331374c..9b6f4adcf03 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -6,15 +6,12 @@ int manager_read_utmp(Manager *m) { #if ENABLE_UTMP - int r; - _unused_ _cleanup_(utxent_cleanup) bool utmpx = false; - assert(m); if (utmpxname(UTMPX_FILE) < 0) return log_error_errno(errno, "Failed to set utmp path to " UTMPX_FILE ": %m"); - utmpx = utxent_start(); + _unused_ _cleanup_(utxent_cleanup) bool utmpx = utxent_start(); for (;;) { _cleanup_free_ char *t = NULL; @@ -44,8 +41,7 @@ int manager_read_utmp(Manager *m) { c = path_startswith(t, "/dev/"); if (c) { - r = free_and_strdup(&t, c); - if (r < 0) + if (free_and_strdup(&t, c) < 0) return log_oom(); } @@ -63,6 +59,7 @@ int manager_read_utmp(Manager *m) { s->tty = mfree(s->tty); s->tty_validity = TTY_UTMP_INCONSISTENT; log_debug("Session '%s' has inconsistent TTY information, dropping TTY information.", s->id); + session_save(s); continue; } @@ -73,6 +70,7 @@ int manager_read_utmp(Manager *m) { s->tty = TAKE_PTR(t); s->tty_validity = TTY_FROM_UTMP; log_debug("Acquired TTY information '%s' from utmp for session '%s'.", s->tty, s->id); + session_save(s); } #else -- 2.47.3