ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
698723
From a05c1077911652954c8b9e82cfdc0fc643eca782 Mon Sep 17 00:00:00 2001
698723
From: Lennart Poettering <lennart@poettering.net>
698723
Date: Mon, 6 Aug 2018 21:44:45 +0200
698723
Subject: [PATCH] logind: rework how we manage the slice and
698723
 user-runtime-dir@.service unit for each user
698723
698723
Instead of managing it explicitly, let's simplify things and rely on
698723
regular Wants=/Requires= dependencies to pull in these units from
698723
user@.service and the session scope, and StopWhenUneeded= to stop these
698723
auxiliary units again. This way, they can be pulled in easily by
698723
unrelated units too.
698723
698723
This simplifies things quite a bit: for each session we now only need to
698723
manage the session scope, and for each user the user@.service, the other
698723
units are not something we need to manage anymore.
698723
698723
This patch also makes sure that if user@.service of a user is masked we
698723
will continue to work, and user-runtime-dir@.service will still be
698723
correctly pulled in, as it is now a dependency of the scope unit.
698723
698723
Fixes: #9461
698723
Replaces: #5546
698723
(cherry picked from commit 25a1ab4ed48b72e974f77a68dcbe3521014787bb)
698723
698723
Related: #1642460
698723
---
698723
 src/login/logind-dbus.c    |  58 ++++++++--------
698723
 src/login/logind-session.c |  64 ++++++++++--------
698723
 src/login/logind-session.h |   2 +-
698723
 src/login/logind-user.c    | 134 ++++++++++++++-----------------------
698723
 src/login/logind-user.h    |   7 +-
698723
 src/login/logind.c         |   2 +-
698723
 src/login/logind.h         |   2 +-
698723
 7 files changed, 123 insertions(+), 146 deletions(-)
698723
698723
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
698723
index 4b2c418453..7eba617fff 100644
698723
--- a/src/login/logind-dbus.c
698723
+++ b/src/login/logind-dbus.c
698723
@@ -847,7 +847,7 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
698723
         if (r < 0)
698723
                 goto fail;
698723
 
698723
-        r = session_start(session, message);
698723
+        r = session_start(session, message, error);
698723
         if (r < 0)
698723
                 goto fail;
698723
 
698723
@@ -3110,24 +3110,20 @@ const sd_bus_vtable manager_vtable[] = {
698723
 };
698723
 
698723
 static int session_jobs_reply(Session *s, const char *unit, const char *result) {
698723
-        int r = 0;
698723
-
698723
         assert(s);
698723
         assert(unit);
698723
 
698723
         if (!s->started)
698723
-                return r;
698723
+                return 0;
698723
 
698723
-        if (streq(result, "done"))
698723
-                r = session_send_create_reply(s, NULL);
698723
-        else {
698723
+        if (result && !streq(result, "done")) {
698723
                 _cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
698723
 
698723
-                sd_bus_error_setf(&e, BUS_ERROR_JOB_FAILED, "Start job for unit %s failed with '%s'", unit, result);
698723
-                r = session_send_create_reply(s, &e);
698723
+                sd_bus_error_setf(&e, BUS_ERROR_JOB_FAILED, "Start job for unit '%s' failed with '%s'", unit, result);
698723
+                return session_send_create_reply(s, &e);
698723
         }
698723
 
698723
-        return r;
698723
+        return session_send_create_reply(s, NULL);
698723
 }
698723
 
698723
 int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
698723
@@ -3160,30 +3156,29 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
698723
         }
698723
 
698723
         session = hashmap_get(m->session_units, unit);
698723
-        if (session && streq_ptr(path, session->scope_job)) {
698723
-                session->scope_job = mfree(session->scope_job);
698723
-                session_jobs_reply(session, unit, result);
698723
+        if (session) {
698723
+                if (streq_ptr(path, session->scope_job)) {
698723
+                        session->scope_job = mfree(session->scope_job);
698723
+                        (void) session_jobs_reply(session, unit, result);
698723
+
698723
+                        session_save(session);
698723
+                        user_save(session->user);
698723
+                }
698723
 
698723
-                session_save(session);
698723
-                user_save(session->user);
698723
                 session_add_to_gc_queue(session);
698723
         }
698723
 
698723
         user = hashmap_get(m->user_units, unit);
698723
-        if (user &&
698723
-            (streq_ptr(path, user->service_job) ||
698723
-             streq_ptr(path, user->slice_job))) {
698723
-
698723
-                if (streq_ptr(path, user->service_job))
698723
+        if (user) {
698723
+                if (streq_ptr(path, user->service_job)) {
698723
                         user->service_job = mfree(user->service_job);
698723
 
698723
-                if (streq_ptr(path, user->slice_job))
698723
-                        user->slice_job = mfree(user->slice_job);
698723
+                        LIST_FOREACH(sessions_by_user, session, user->sessions)
698723
+                                (void) session_jobs_reply(session, unit, NULL /* don't propagate user service failures to the client */);
698723
 
698723
-                LIST_FOREACH(sessions_by_user, session, user->sessions)
698723
-                        session_jobs_reply(session, unit, result);
698723
+                        user_save(user);
698723
+                }
698723
 
698723
-                user_save(user);
698723
                 user_add_to_gc_queue(user);
698723
         }
698723
 
698723
@@ -3315,13 +3310,14 @@ int manager_start_scope(
698723
                 pid_t pid,
698723
                 const char *slice,
698723
                 const char *description,
698723
-                const char *after,
698723
-                const char *after2,
698723
+                char **wants,
698723
+                char **after,
698723
                 sd_bus_message *more_properties,
698723
                 sd_bus_error *error,
698723
                 char **job) {
698723
 
698723
         _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
698723
+        char **i;
698723
         int r;
698723
 
698723
         assert(manager);
698723
@@ -3359,14 +3355,14 @@ int manager_start_scope(
698723
                         return r;
698723
         }
698723
 
698723
-        if (!isempty(after)) {
698723
-                r = sd_bus_message_append(m, "(sv)", "After", "as", 1, after);
698723
+        STRV_FOREACH(i, wants) {
698723
+                r = sd_bus_message_append(m, "(sv)", "Wants", "as", 1, *i);
698723
                 if (r < 0)
698723
                         return r;
698723
         }
698723
 
698723
-        if (!isempty(after2)) {
698723
-                r = sd_bus_message_append(m, "(sv)", "After", "as", 1, after2);
698723
+        STRV_FOREACH(i, after) {
698723
+                r = sd_bus_message_append(m, "(sv)", "After", "as", 1, *i);
698723
                 if (r < 0)
698723
                         return r;
698723
         }
698723
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
698723
index 960a24d1a7..d56b48a732 100644
698723
--- a/src/login/logind-session.c
698723
+++ b/src/login/logind-session.c
698723
@@ -27,6 +27,7 @@
698723
 #include "path-util.h"
698723
 #include "process-util.h"
698723
 #include "string-table.h"
698723
+#include "strv.h"
698723
 #include "terminal-util.h"
698723
 #include "user-util.h"
698723
 #include "util.h"
698723
@@ -560,17 +561,18 @@ int session_activate(Session *s) {
698723
         return 0;
698723
 }
698723
 
698723
-static int session_start_scope(Session *s, sd_bus_message *properties) {
698723
+static int session_start_scope(Session *s, sd_bus_message *properties, sd_bus_error *error) {
698723
         int r;
698723
 
698723
         assert(s);
698723
         assert(s->user);
698723
 
698723
         if (!s->scope) {
698723
-                _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
698723
-                char *scope, *job = NULL;
698723
+                _cleanup_free_ char *scope = NULL;
698723
                 const char *description;
698723
 
698723
+                s->scope_job = mfree(s->scope_job);
698723
+
698723
                 scope = strjoin("session-", s->id, ".scope");
698723
                 if (!scope)
698723
                         return log_oom();
698723
@@ -583,21 +585,15 @@ static int session_start_scope(Session *s, sd_bus_message *properties) {
698723
                                 s->leader,
698723
                                 s->user->slice,
698723
                                 description,
698723
-                                "systemd-logind.service",
698723
-                                "systemd-user-sessions.service",
698723
+                                STRV_MAKE(s->user->runtime_dir_service, s->user->service), /* These two have StopWhenUnneeded= set, hence add a dep towards them */
698723
+                                STRV_MAKE("systemd-logind.service", "systemd-user-sessions.service", s->user->runtime_dir_service, s->user->service), /* And order us after some more */
698723
                                 properties,
698723
-                                &error,
698723
-                                &job;;
698723
-                if (r < 0) {
698723
-                        log_error_errno(r, "Failed to start session scope %s: %s", scope, bus_error_message(&error, r));
698723
-                        free(scope);
698723
-                        return r;
698723
-                } else {
698723
-                        s->scope = scope;
698723
+                                error,
698723
+                                &s->scope_job);
698723
+                if (r < 0)
698723
+                        return log_error_errno(r, "Failed to start session scope %s: %s", scope, bus_error_message(error, r));
698723
 
698723
-                        free(s->scope_job);
698723
-                        s->scope_job = job;
698723
-                }
698723
+                s->scope = TAKE_PTR(scope);
698723
         }
698723
 
698723
         if (s->scope)
698723
@@ -606,7 +602,7 @@ static int session_start_scope(Session *s, sd_bus_message *properties) {
698723
         return 0;
698723
 }
698723
 
698723
-int session_start(Session *s, sd_bus_message *properties) {
698723
+int session_start(Session *s, sd_bus_message *properties, sd_bus_error *error) {
698723
         int r;
698723
 
698723
         assert(s);
698723
@@ -614,6 +610,9 @@ int session_start(Session *s, sd_bus_message *properties) {
698723
         if (!s->user)
698723
                 return -ESTALE;
698723
 
698723
+        if (s->stopping)
698723
+                return -EINVAL;
698723
+
698723
         if (s->started)
698723
                 return 0;
698723
 
698723
@@ -621,8 +620,7 @@ int session_start(Session *s, sd_bus_message *properties) {
698723
         if (r < 0)
698723
                 return r;
698723
 
698723
-        /* Create cgroup */
698723
-        r = session_start_scope(s, properties);
698723
+        r = session_start_scope(s, properties, error);
698723
         if (r < 0)
698723
                 return r;
698723
 
698723
@@ -673,21 +671,24 @@ static int session_stop_scope(Session *s, bool force) {
698723
          * that is left in the scope is "left-over". Informing systemd about this has the benefit that it will log
698723
          * when killing any processes left after this point. */
698723
         r = manager_abandon_scope(s->manager, s->scope, &error);
698723
-        if (r < 0)
698723
+        if (r < 0) {
698723
                 log_warning_errno(r, "Failed to abandon session scope, ignoring: %s", bus_error_message(&error, r));
698723
+                sd_bus_error_free(&error);
698723
+        }
698723
+
698723
+        s->scope_job = mfree(s->scope_job);
698723
 
698723
         /* Optionally, let's kill everything that's left now. */
698723
         if (force || manager_shall_kill(s->manager, s->user->name)) {
698723
-                char *job = NULL;
698723
 
698723
-                r = manager_stop_unit(s->manager, s->scope, &error, &job;;
698723
-                if (r < 0)
698723
-                        return log_error_errno(r, "Failed to stop session scope: %s", bus_error_message(&error, r));
698723
+                r = manager_stop_unit(s->manager, s->scope, &error, &s->scope_job);
698723
+                if (r < 0) {
698723
+                        if (force)
698723
+                                return log_error_errno(r, "Failed to stop session scope: %s", bus_error_message(&error, r));
698723
 
698723
-                free(s->scope_job);
698723
-                s->scope_job = job;
698723
+                        log_warning_errno(r, "Failed to stop session scope, ignoring: %s", bus_error_message(&error, r));
698723
+                }
698723
         } else {
698723
-                s->scope_job = mfree(s->scope_job);
698723
 
698723
                 /* With no killing, this session is allowed to persist in "closing" state indefinitely.
698723
                  * Therefore session stop and session removal may be two distinct events.
698723
@@ -707,8 +708,17 @@ int session_stop(Session *s, bool force) {
698723
 
698723
         assert(s);
698723
 
698723
+        /* This is called whenever we begin with tearing down a session record. It's called in four cases: explicit API
698723
+         * request via the bus (either directly for the session object or for the seat or user object this session
698723
+         * belongs to; 'force' is true), or due to automatic GC (i.e. scope vanished; 'force' is false), or because the
698723
+         * session FIFO saw an EOF ('force' is false), or because the release timer hit ('force' is false). */
698723
+
698723
         if (!s->user)
698723
                 return -ESTALE;
698723
+        if (!s->started)
698723
+                return 0;
698723
+        if (s->stopping)
698723
+                return 0;
698723
 
698723
         s->timer_event_source = sd_event_source_unref(s->timer_event_source);
698723
 
698723
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
698723
index 572f2545c1..7d17d9a25f 100644
698723
--- a/src/login/logind-session.h
698723
+++ b/src/login/logind-session.h
698723
@@ -124,7 +124,7 @@ void session_set_idle_hint(Session *s, bool b);
698723
 int session_get_locked_hint(Session *s);
698723
 void session_set_locked_hint(Session *s, bool b);
698723
 int session_create_fifo(Session *s);
698723
-int session_start(Session *s, sd_bus_message *properties);
698723
+int session_start(Session *s, sd_bus_message *properties, sd_bus_error *error);
698723
 int session_stop(Session *s, bool force);
698723
 int session_finalize(Session *s);
698723
 int session_release(Session *s);
698723
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
698723
index 3e4c99bdbd..39fc76f4dc 100644
698723
--- a/src/login/logind-user.c
698723
+++ b/src/login/logind-user.c
698723
@@ -68,6 +68,10 @@ int user_new(User **ret, Manager *m, uid_t uid, gid_t gid, const char *name) {
698723
         if (r < 0)
698723
                 return r;
698723
 
698723
+        r = unit_name_build("user-runtime-dir", lu, ".service", &u->runtime_dir_service);
698723
+        if (r < 0)
698723
+                return r;
698723
+
698723
         r = hashmap_put(m->users, UID_TO_PTR(uid), u);
698723
         if (r < 0)
698723
                 return r;
698723
@@ -80,6 +84,10 @@ int user_new(User **ret, Manager *m, uid_t uid, gid_t gid, const char *name) {
698723
         if (r < 0)
698723
                 return r;
698723
 
698723
+        r = hashmap_put(m->user_units, u->runtime_dir_service, u);
698723
+        if (r < 0)
698723
+                return r;
698723
+
698723
         *ret = TAKE_PTR(u);
698723
         return 0;
698723
 }
698723
@@ -97,15 +105,18 @@ User *user_free(User *u) {
698723
         if (u->service)
698723
                 hashmap_remove_value(u->manager->user_units, u->service, u);
698723
 
698723
+        if (u->runtime_dir_service)
698723
+                hashmap_remove_value(u->manager->user_units, u->runtime_dir_service, u);
698723
+
698723
         if (u->slice)
698723
                 hashmap_remove_value(u->manager->user_units, u->slice, u);
698723
 
698723
         hashmap_remove_value(u->manager->users, UID_TO_PTR(u->uid), u);
698723
 
698723
-        u->slice_job = mfree(u->slice_job);
698723
         u->service_job = mfree(u->service_job);
698723
 
698723
         u->service = mfree(u->service);
698723
+        u->runtime_dir_service = mfree(u->runtime_dir_service);
698723
         u->slice = mfree(u->slice);
698723
         u->runtime_path = mfree(u->runtime_path);
698723
         u->state_file = mfree(u->state_file);
698723
@@ -149,9 +160,6 @@ static int user_save_internal(User *u) {
698723
         if (u->service_job)
698723
                 fprintf(f, "SERVICE_JOB=%s\n", u->service_job);
698723
 
698723
-        if (u->slice_job)
698723
-                fprintf(f, "SLICE_JOB=%s\n", u->slice_job);
698723
-
698723
         if (u->display)
698723
                 fprintf(f, "DISPLAY=%s\n", u->display->id);
698723
 
698723
@@ -311,66 +319,46 @@ int user_load(User *u) {
698723
         return 0;
698723
 }
698723
 
698723
-static int user_start_service(User *u) {
698723
+static void user_start_service(User *u) {
698723
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
698723
-        char *job;
698723
         int r;
698723
 
698723
         assert(u);
698723
 
698723
+        /* Start the service containing the "systemd --user" instance (user@.service). Note that we don't explicitly
698723
+         * start the per-user slice or the systemd-runtime-dir@.service instance, as those are pulled in both by
698723
+         * user@.service and the session scopes as dependencies. */
698723
+
698723
         u->service_job = mfree(u->service_job);
698723
 
698723
-        r = manager_start_unit(
698723
-                        u->manager,
698723
-                        u->service,
698723
-                        &error,
698723
-                        &job;;
698723
+        r = manager_start_unit(u->manager, u->service, &error, &u->service_job);
698723
         if (r < 0)
698723
                 /* we don't fail due to this, let's try to continue */
698723
                 log_full_errno(sd_bus_error_has_name(&error, BUS_ERROR_UNIT_MASKED) ? LOG_DEBUG : LOG_WARNING, r,
698723
                                "Failed to start user service '%s', ignoring: %s", u->service, bus_error_message(&error, r));
698723
-        else
698723
-                u->service_job = job;
698723
-
698723
-        return 0;
698723
 }
698723
 
698723
 int user_start(User *u) {
698723
-        int r;
698723
-
698723
         assert(u);
698723
 
698723
         if (u->started && !u->stopping)
698723
                 return 0;
698723
 
698723
-        /*
698723
-         * If u->stopping is set, the user is marked for removal and the slice
698723
-         * and service stop-jobs are queued. We have to clear that flag before
698723
-         * queing the start-jobs again. If they succeed, the user object can be
698723
-         * re-used just fine (pid1 takes care of job-ordering and proper
698723
-         * restart), but if they fail, we want to force another user_stop() so
698723
-         * possibly pending units are stopped.
698723
-         * Note that we don't clear u->started, as we have no clue what state
698723
-         * the user is in on failure here. Hence, we pretend the user is
698723
-         * running so it will be properly taken down by GC. However, we clearly
698723
-         * return an error from user_start() in that case, so no further
698723
-         * reference to the user is taken.
698723
-         */
698723
+        /* If u->stopping is set, the user is marked for removal and service stop-jobs are queued. We have to clear
698723
+         * that flag before queing the start-jobs again. If they succeed, the user object can be re-used just fine
698723
+         * (pid1 takes care of job-ordering and proper restart), but if they fail, we want to force another user_stop()
698723
+         * so possibly pending units are stopped. */
698723
         u->stopping = false;
698723
 
698723
         if (!u->started)
698723
                 log_debug("Starting services for new user %s.", u->name);
698723
 
698723
-        /* Save the user data so far, because pam_systemd will read the
698723
-         * XDG_RUNTIME_DIR out of it while starting up systemd --user.
698723
-         * We need to do user_save_internal() because we have not
698723
-         * "officially" started yet. */
698723
+        /* Save the user data so far, because pam_systemd will read the XDG_RUNTIME_DIR out of it while starting up
698723
+         * systemd --user.  We need to do user_save_internal() because we have not "officially" started yet. */
698723
         user_save_internal(u);
698723
 
698723
-        /* Spawn user systemd */
698723
-        r = user_start_service(u);
698723
-        if (r < 0)
698723
-                return r;
698723
+        /* Start user@UID.service */
698723
+        user_start_service(u);
698723
 
698723
         if (!u->started) {
698723
                 if (!dual_timestamp_is_set(&u->timestamp))
698723
@@ -385,68 +373,50 @@ int user_start(User *u) {
698723
         return 0;
698723
 }
698723
 
698723
-static int user_stop_slice(User *u) {
698723
+static void user_stop_service(User *u) {
698723
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
698723
-        char *job;
698723
         int r;
698723
 
698723
         assert(u);
698723
+        assert(u->service);
698723
 
698723
-        r = manager_stop_unit(u->manager, u->slice, &error, &job;;
698723
-        if (r < 0) {
698723
-                log_error("Failed to stop user slice: %s", bus_error_message(&error, r));
698723
-                return r;
698723
-        }
698723
+        /* The reverse of user_start_service(). Note that we only stop user@UID.service here, and let StopWhenUnneeded=
698723
+         * deal with the slice and the user-runtime-dir@.service instance. */
698723
 
698723
-        free(u->slice_job);
698723
-        u->slice_job = job;
698723
-
698723
-        return r;
698723
-}
698723
-
698723
-static int user_stop_service(User *u) {
698723
-        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
698723
-        char *job;
698723
-        int r;
698723
-
698723
-        assert(u);
698723
-
698723
-        r = manager_stop_unit(u->manager, u->service, &error, &job;;
698723
-        if (r < 0) {
698723
-                log_error("Failed to stop user service: %s", bus_error_message(&error, r));
698723
-                return r;
698723
-        }
698723
+        u->service_job = mfree(u->service_job);
698723
 
698723
-        free_and_replace(u->service_job, job);
698723
-        return r;
698723
+        r = manager_stop_unit(u->manager, u->service, &error, &u->service_job);
698723
+        if (r < 0)
698723
+                log_warning_errno(r, "Failed to stop user service '%s', ignoring: %s", u->service, bus_error_message(&error, r));
698723
 }
698723
 
698723
 int user_stop(User *u, bool force) {
698723
         Session *s;
698723
-        int r = 0, k;
698723
+        int r = 0;
698723
         assert(u);
698723
 
698723
-        /* Stop jobs have already been queued */
698723
-        if (u->stopping) {
698723
+        /* This is called whenever we begin with tearing down a user record. It's called in two cases: explicit API
698723
+         * request to do so via the bus (in which case 'force' is true) and automatically due to GC, if there's no
698723
+         * session left pinning it (in which case 'force' is false). Note that this just initiates tearing down of the
698723
+         * user, the User object will remain in memory until user_finalize() is called, see below. */
698723
+
698723
+        if (!u->started)
698723
+                return 0;
698723
+
698723
+        if (u->stopping) { /* Stop jobs have already been queued */
698723
                 user_save(u);
698723
-                return r;
698723
+                return 0;
698723
         }
698723
 
698723
         LIST_FOREACH(sessions_by_user, s, u->sessions) {
698723
+                int k;
698723
+
698723
                 k = session_stop(s, force);
698723
                 if (k < 0)
698723
                         r = k;
698723
         }
698723
 
698723
-        /* Kill systemd */
698723
-        k = user_stop_service(u);
698723
-        if (k < 0)
698723
-                r = k;
698723
-
698723
-        /* Kill cgroup */
698723
-        k = user_stop_slice(u);
698723
-        if (k < 0)
698723
-                r = k;
698723
+        user_stop_service(u);
698723
 
698723
         u->stopping = true;
698723
 
698723
@@ -461,6 +431,9 @@ int user_finalize(User *u) {
698723
 
698723
         assert(u);
698723
 
698723
+        /* Called when the user is really ready to be freed, i.e. when all unit stop jobs and suchlike for it are
698723
+         * done. This is called as a result of an earlier user_done() when all jobs are completed. */
698723
+
698723
         if (u->started)
698723
                 log_debug("User %s logged out.", u->name);
698723
 
698723
@@ -554,9 +527,6 @@ bool user_may_gc(User *u, bool drop_not_started) {
698723
         if (user_check_linger_file(u) > 0)
698723
                 return false;
698723
 
698723
-        if (u->slice_job && manager_job_is_active(u->manager, u->slice_job))
698723
-                return false;
698723
-
698723
         if (u->service_job && manager_job_is_active(u->manager, u->service_job))
698723
                 return false;
698723
 
698723
@@ -581,7 +551,7 @@ UserState user_get_state(User *u) {
698723
         if (u->stopping)
698723
                 return USER_CLOSING;
698723
 
698723
-        if (!u->started || u->slice_job || u->service_job)
698723
+        if (!u->started || u->service_job)
698723
                 return USER_OPENING;
698723
 
698723
         if (u->sessions) {
698723
diff --git a/src/login/logind-user.h b/src/login/logind-user.h
698723
index 03e020b870..5e1f7b813a 100644
698723
--- a/src/login/logind-user.h
698723
+++ b/src/login/logind-user.h
698723
@@ -25,11 +25,12 @@ struct User {
698723
         char *name;
698723
         char *state_file;
698723
         char *runtime_path;
698723
-        char *slice;
698723
-        char *service;
698723
+
698723
+        char *slice;                     /* user-UID.slice */
698723
+        char *service;                   /* user@UID.service */
698723
+        char *runtime_dir_service;       /* user-runtime-dir@UID.service */
698723
 
698723
         char *service_job;
698723
-        char *slice_job;
698723
 
698723
         Session *display;
698723
 
698723
diff --git a/src/login/logind.c b/src/login/logind.c
698723
index 1b366cd55f..6c208c8e89 100644
698723
--- a/src/login/logind.c
698723
+++ b/src/login/logind.c
698723
@@ -1158,7 +1158,7 @@ static int manager_startup(Manager *m) {
698723
                 user_start(user);
698723
 
698723
         HASHMAP_FOREACH(session, m->sessions, i)
698723
-                session_start(session, NULL);
698723
+                (void) session_start(session, NULL, NULL);
698723
 
698723
         HASHMAP_FOREACH(inhibitor, m->inhibitors, i)
698723
                 inhibitor_start(inhibitor);
698723
diff --git a/src/login/logind.h b/src/login/logind.h
698723
index a6ebc9e152..ae4d74076b 100644
698723
--- a/src/login/logind.h
698723
+++ b/src/login/logind.h
698723
@@ -161,7 +161,7 @@ int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name
698723
 
698723
 int manager_send_changed(Manager *manager, const char *property, ...) _sentinel_;
698723
 
698723
-int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, sd_bus_message *more_properties, sd_bus_error *error, char **job);
698723
+int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, char **wants, char **after, sd_bus_message *more_properties, sd_bus_error *error, char **job);
698723
 int manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
698723
 int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
698723
 int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error);