chiark / gitweb /
logind: wait for the user service to finish startup before completing login attempt
authorLennart Poettering <lennart@poettering.net>
Wed, 8 Jan 2014 22:45:38 +0000 (06:45 +0800)
committerLennart Poettering <lennart@poettering.net>
Wed, 8 Jan 2014 22:51:09 +0000 (06:51 +0800)
src/login/logind-dbus.c
src/login/logind-session-dbus.c

index 08510b5..2c86b9f 100644 (file)
@@ -1971,6 +1971,20 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b
                         user->slice_job = NULL;
                 }
 
+                LIST_FOREACH(sessions_by_user, session, user->sessions) {
+                        if (!session->started)
+                                continue;
+
+                        if (streq(result, "done"))
+                                session_send_create_reply(session, NULL);
+                        else {
+                                _cleanup_bus_error_free_ sd_bus_error e = SD_BUS_ERROR_NULL;
+
+                                sd_bus_error_setf(&e, BUS_ERROR_JOB_FAILED, "Start job for unit %s failed with '%s'", unit, result);
+                                session_send_create_reply(session, &e);
+                        }
+                }
+
                 user_save(user);
                 user_add_to_gc_queue(user);
         }
index f1905e9..54ad827 100644 (file)
@@ -647,13 +647,16 @@ int session_send_create_reply(Session *s, sd_bus_error *error) {
 
         assert(s);
 
-        /* This is called after the session scope was successfully
-         * created, and finishes where bus_manager_create_session()
-         * left off. */
+        /* This is called after the session scope and the user service
+         * were successfully created, and finishes where
+         * bus_manager_create_session() left off. */
 
         if (!s->create_message)
                 return 0;
 
+        if (!sd_bus_error_is_set(error) && (s->scope_job || s->user->service_job))
+                return 0;
+
         c = s->create_message;
         s->create_message = NULL;