]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: save position only if we have a seat
authorLennart Poettering <lennart@poettering.net>
Thu, 22 May 2025 16:04:25 +0000 (18:04 +0200)
committerMike Yuan <me@yhndnzj.com>
Tue, 24 Jun 2025 20:16:41 +0000 (22:16 +0200)
src/login/logind-session.c

index ef79214b5dd09135d3cfd08b696b834ba2599903..db835d56d7dd72c2dffa27fd63223c97d4c90715 100644 (file)
@@ -341,11 +341,12 @@ int session_save(Session *s) {
         env_file_fputs_assignment(f, "SERVICE=", s->service);
         env_file_fputs_assignment(f, "DESKTOP=", s->desktop);
 
-        if (s->seat && seat_has_vts(s->seat))
-                fprintf(f, "VTNR=%u\n", s->vtnr);
-
-        if (!s->vtnr)
-                fprintf(f, "POSITION=%u\n", s->position);
+        if (s->seat) {
+                if (!seat_has_vts(s->seat))
+                        fprintf(f, "POSITION=%u\n", s->position);
+                else if (s->vtnr > 0)
+                        fprintf(f, "VTNR=%u\n", s->vtnr);
+        }
 
         if (pidref_is_set(&s->leader)) {
                 fprintf(f, "LEADER="PID_FMT"\n", s->leader.pid);
@@ -495,7 +496,7 @@ int session_load(Session *s) {
         }
 
         if (vtnr)
-                safe_atou(vtnr, &s->vtnr);
+                (void) safe_atou(vtnr, &s->vtnr);
 
         if (seat && !s->seat) {
                 Seat *o;
@@ -513,7 +514,7 @@ int session_load(Session *s) {
         if (position && s->seat) {
                 unsigned npos;
 
-                safe_atou(position, &npos);
+                (void) safe_atou(position, &npos);
                 seat_claim_position(s->seat, s, npos);
         }