From: Luca Boccassi Date: Wed, 21 May 2025 23:56:18 +0000 (+0100) Subject: Revert "logind: always enclose list fields (that may contain spaces) in quotes" X-Git-Tag: v258-rc1~523 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3c79aeb524717921fafee4ea71b5a0607929532;p=thirdparty%2Fsystemd.git Revert "logind: always enclose list fields (that may contain spaces) in quotes" This breaks GNOME on Wayland, login no longer works: gnome-shell[2250]: Running GNOME Shell (using mutter 48.2) as a Wayland display server gnome-shell[2250]: Failed to setup: Failed to find any matching session systemd[2054]: org.gnome.Shell@wayland.service: Failed with result 'protocol'. systemd[2054]: Failed to start org.gnome.Shell@wayland.service - GNOME Shell on Wayland. This reverts commit b0555149de780f81ec6f741d36bdb41b4d1d8a94. --- diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 1b6b1aa475d..84a6264fe6d 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -131,19 +131,20 @@ int seat_save(Seat *s) { } if (s->sessions) { - fputs("SESSIONS=\"", f); - LIST_FOREACH(sessions_by_seat, i, s->sessions) + fputs("SESSIONS=", f); + LIST_FOREACH(sessions_by_seat, i, s->sessions) { fprintf(f, - "%s%s", + "%s%c", i->id, - i->sessions_by_seat_next ? " " : "\"\n"); + i->sessions_by_seat_next ? ' ' : '\n'); + } - fputs("UIDS=\"", f); + fputs("UIDS=", f); LIST_FOREACH(sessions_by_seat, i, s->sessions) fprintf(f, - UID_FMT"%s", + UID_FMT"%c", i->user->user_record->uid, - i->sessions_by_seat_next ? " " : "\"\n"); + i->sessions_by_seat_next ? ' ' : '\n'); } r = flink_tmpfile(f, temp_path, s->state_file, LINK_TMPFILE_REPLACE); diff --git a/src/login/logind-session.c b/src/login/logind-session.c index ad7391effb6..9311d918fae 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -270,19 +270,12 @@ int session_set_leader_consume(Session *s, PidRef _leader) { static void session_save_devices(Session *s, FILE *f) { SessionDevice *sd; - if (hashmap_isempty(s->devices)) - return; - - bool need_space = false; - fputs("DEVICES=\"", f); - HASHMAP_FOREACH(sd, s->devices) { - if (need_space) - fputc(' ', f); - - fprintf(f, DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(sd->dev)); - need_space = true; + if (!hashmap_isempty(s->devices)) { + fprintf(f, "DEVICES="); + HASHMAP_FOREACH(sd, s->devices) + fprintf(f, DEVNUM_FORMAT_STR " ", DEVNUM_FORMAT_VAL(sd->dev)); + fprintf(f, "\n"); } - fputs("\"\n", f); } int session_save(Session *s) { diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 19eda779338..2005a4da189 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -195,7 +195,7 @@ static int user_save_internal(User *u) { if (u->sessions) { bool first; - fputs("SESSIONS=\"", f); + fputs("SESSIONS=", f); first = true; LIST_FOREACH(sessions_by_user, i, u->sessions) { if (first) @@ -206,8 +206,7 @@ static int user_save_internal(User *u) { fputs(i->id, f); } - fputs("\"\n" - "SEATS=\"", f); + fputs("\nSEATS=", f); first = true; LIST_FOREACH(sessions_by_user, i, u->sessions) { if (!i->seat) @@ -221,8 +220,7 @@ static int user_save_internal(User *u) { fputs(i->seat->id, f); } - fputs("\"\n" - "ACTIVE_SESSIONS=\"", f); + fputs("\nACTIVE_SESSIONS=", f); first = true; LIST_FOREACH(sessions_by_user, i, u->sessions) { if (!session_is_active(i)) @@ -236,8 +234,7 @@ static int user_save_internal(User *u) { fputs(i->id, f); } - fputs("\"\n" - "ONLINE_SESSIONS=\"", f); + fputs("\nONLINE_SESSIONS=", f); first = true; LIST_FOREACH(sessions_by_user, i, u->sessions) { if (session_get_state(i) == SESSION_CLOSING) @@ -251,8 +248,7 @@ static int user_save_internal(User *u) { fputs(i->id, f); } - fputs("\"\n" - "ACTIVE_SEATS=\"", f); + fputs("\nACTIVE_SEATS=", f); first = true; LIST_FOREACH(sessions_by_user, i, u->sessions) { if (!session_is_active(i) || !i->seat) @@ -266,8 +262,7 @@ static int user_save_internal(User *u) { fputs(i->seat->id, f); } - fputs("\"\n" - "ONLINE_SEATS=\"", f); + fputs("\nONLINE_SEATS=", f); first = true; LIST_FOREACH(sessions_by_user, i, u->sessions) { if (session_get_state(i) == SESSION_CLOSING || !i->seat) @@ -280,7 +275,7 @@ static int user_save_internal(User *u) { fputs(i->seat->id, f); } - fputs("\"\n", f); + fputc('\n', f); } r = flink_tmpfile(f, temp_path, u->state_file, LINK_TMPFILE_REPLACE);