X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmanager.c;h=ef58bdd16182c7fc83a5bb93c8b525a6c0f32aa4;hb=c95f97a20f3b854109dc564da64950067b388aeb;hp=7af502aba606b5d1048ca7cd5fe27fd0a50d288c;hpb=79008bddf679a5e0900369950eb346c9fa687107;p=elogind.git diff --git a/src/core/manager.c b/src/core/manager.c index 7af502aba..ef58bdd16 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -303,7 +303,7 @@ static int manager_watch_idle_pipe(Manager *m) { r = sd_event_add_io(m->event, &m->idle_pipe_event_source, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m); if (r < 0) { - log_error("Failed to watch idle pipe: %s", strerror(-r)); + log_error_errno(r, "Failed to watch idle pipe: %m"); return r; } @@ -349,7 +349,7 @@ static int manager_setup_time_change(Manager *m) { r = sd_event_add_io(m->event, &m->time_change_event_source, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m); if (r < 0) { - log_error("Failed to create time change event source: %s", strerror(-r)); + log_error_errno(r, "Failed to create time change event source: %m"); return r; } @@ -697,7 +697,7 @@ static int manager_setup_notify(Manager *m) { if (!m->notify_event_source) { r = sd_event_add_io(m->event, &m->notify_event_source, m->notify_fd, EPOLLIN, manager_dispatch_notify_fd, m); if (r < 0) { - log_error("Failed to allocate notify event source: %s", strerror(-r)); + log_error_errno(r, "Failed to allocate notify event source: %m"); return -errno; } @@ -705,7 +705,7 @@ static int manager_setup_notify(Manager *m) { * still identify to which service an exit message belongs */ r = sd_event_source_set_priority(m->notify_event_source, -7); if (r < 0) { - log_error("Failed to set priority of notify event source: %s", strerror(-r)); + log_error_errno(r, "Failed to set priority of notify event source: %m"); return r; } } @@ -722,7 +722,13 @@ static int manager_setup_kdbus(Manager *m) { if (m->test_run || m->kdbus_fd >= 0) return 0; - m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p); + if (getpid() == 1) + bus_kernel_fix_attach_mask(); + + m->kdbus_fd = bus_kernel_create_bus( + m->running_as == SYSTEMD_SYSTEM ? "system" : "user", + m->running_as == SYSTEMD_SYSTEM, &p); + if (m->kdbus_fd < 0) { log_debug("Failed to set up kdbus: %s", strerror(-m->kdbus_fd)); return m->kdbus_fd; @@ -1054,7 +1060,7 @@ static void manager_build_unit_path_cache(Manager *m) { return; fail: - log_error("Failed to build unit path cache: %s", strerror(-r)); + log_error_errno(r, "Failed to build unit path cache: %m"); set_free_free(m->unit_path_cache); m->unit_path_cache = NULL; @@ -1876,8 +1882,8 @@ static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint assert(m->time_change_fd == fd); log_struct(LOG_INFO, - MESSAGE_ID(SD_MESSAGE_TIME_CHANGE), - "MESSAGE=Time has been changed", + LOG_MESSAGE_ID(SD_MESSAGE_TIME_CHANGE), + LOG_MESSAGE("Time has been changed"), NULL); /* Restart the watch */ @@ -1983,7 +1989,7 @@ int manager_loop(Manager *m) { r = sd_event_run(m->event, wait_usec); if (r < 0) { - log_error("Failed to run event loop: %s", strerror(-r)); + log_error_errno(r, "Failed to run event loop: %m"); return r; } } @@ -2585,28 +2591,28 @@ static void manager_notify_finished(Manager *m) { initrd_usec = m->userspace_timestamp.monotonic - m->initrd_timestamp.monotonic; log_struct(LOG_INFO, - MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), + LOG_MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), "KERNEL_USEC="USEC_FMT, kernel_usec, "INITRD_USEC="USEC_FMT, initrd_usec, "USERSPACE_USEC="USEC_FMT, userspace_usec, - "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.", - format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC), - format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC), - format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC), - format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC), + LOG_MESSAGE("Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.", + format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC), + format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC), + format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC), + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)), NULL); } else { kernel_usec = m->userspace_timestamp.monotonic - m->kernel_timestamp.monotonic; initrd_usec = 0; log_struct(LOG_INFO, - MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), + LOG_MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), "KERNEL_USEC="USEC_FMT, kernel_usec, "USERSPACE_USEC="USEC_FMT, userspace_usec, - "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.", - format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC), - format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC), - format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC), + LOG_MESSAGE("Startup finished in %s (kernel) + %s (userspace) = %s.", + format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC), + format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC), + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)), NULL); } } else { @@ -2614,10 +2620,10 @@ static void manager_notify_finished(Manager *m) { total_usec = userspace_usec = m->finish_timestamp.monotonic - m->userspace_timestamp.monotonic; log_struct(LOG_INFO, - MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), + LOG_MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), "USERSPACE_USEC="USEC_FMT, userspace_usec, - "MESSAGE=Startup finished in %s.", - format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC), + LOG_MESSAGE("Startup finished in %s.", + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)), NULL); }