]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: log a more accurate error when we failed at session creation
authorFranck Bui <fbui@suse.com>
Tue, 17 Mar 2020 17:30:58 +0000 (18:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 26 Mar 2020 13:34:10 +0000 (14:34 +0100)
We used to log the following error:

  "Start job for unit user-1000.slice failed with 'canceled'"

which can be really misleading if the actual job failed at *stopping* a unit.

Indeed "Start" was hard coded but it was wrong since we can also fail with stop
jobs which are enqueued when a session is stopped.

(cherry picked from commit b39648ed47065202b343d1d4bde3232d81fdfecc)
(cherry picked from commit 8f0feac20f7d4c29a42839343308fcd602ec5b63)
(cherry picked from commit 6aae7f596afd62a72b18c92f464abc8bebbc8cba)

src/login/logind-dbus.c

index 00eaf9a97c6273f3a71dab8edb25173774b51095..7d53136d4e9ef54c4b0d1a7937e251e9a0e540f8 100644 (file)
@@ -3409,7 +3409,7 @@ const sd_bus_vtable manager_vtable[] = {
         SD_BUS_VTABLE_END
 };
 
-static int session_jobs_reply(Session *s, const char *unit, const char *result) {
+static int session_jobs_reply(Session *s, uint32_t jid, const char *unit, const char *result) {
         assert(s);
         assert(unit);
 
@@ -3420,7 +3420,7 @@ static int session_jobs_reply(Session *s, const char *unit, const char *result)
                 _cleanup_(sd_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);
+                                  "Job %u for unit '%s' failed with '%s'", jid, unit, result);
                 return session_send_create_reply(s, &e);
         }
 
@@ -3460,7 +3460,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
         if (session) {
                 if (streq_ptr(path, session->scope_job)) {
                         session->scope_job = mfree(session->scope_job);
-                        (void) session_jobs_reply(session, unit, result);
+                        (void) session_jobs_reply(session, id, unit, result);
 
                         session_save(session);
                         user_save(session->user);
@@ -3475,7 +3475,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
                         user->service_job = mfree(user->service_job);
 
                         LIST_FOREACH(sessions_by_user, session, user->sessions)
-                                (void) session_jobs_reply(session, unit, NULL /* don't propagate user service failures to the client */);
+                                (void) session_jobs_reply(session, id, unit, NULL /* don't propagate user service failures to the client */);
 
                         user_save(user);
                 }