summaryrefslogtreecommitdiffstats
path: root/src/sulogin-shell/sulogin-shell.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-07-05 17:54:01 +0200
committerLennart Poettering <lennart@poettering.net>2023-07-10 16:39:16 +0200
commita93993584df69c84bd92c6a13453cab861061a51 (patch)
tree643fa40fd9ccc1e02fefa2edc8a3a57d270fc964 /src/sulogin-shell/sulogin-shell.c
parenttest-fstab-generator: use test_env (diff)
downloadsystemd-a93993584df69c84bd92c6a13453cab861061a51.tar.xz
systemd-a93993584df69c84bd92c6a13453cab861061a51.zip
bus-unit-util: add common code for reloading PID 1
We have this very similar code in various places, and it#s not entirely obvious (since we want a prolonged timeout for the reload), hence unify this at one place.
Diffstat (limited to '')
-rw-r--r--src/sulogin-shell/sulogin-shell.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c
index e81bb527ff..068ab3f4a0 100644
--- a/src/sulogin-shell/sulogin-shell.c
+++ b/src/sulogin-shell/sulogin-shell.c
@@ -8,43 +8,21 @@
#include "sd-bus.h"
+#include "bus-error.h"
#include "bus-locator.h"
+#include "bus-unit-util.h"
#include "bus-util.h"
-#include "bus-error.h"
#include "constants.h"
#include "env-util.h"
#include "initrd-util.h"
#include "log.h"
#include "main-func.h"
-#include "process-util.h"
#include "proc-cmdline.h"
+#include "process-util.h"
#include "signal-util.h"
#include "special.h"
#include "unit-def.h"
-static int reload_manager(sd_bus *bus) {
- _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
- int r;
-
- log_info("Reloading system manager configuration");
-
- r = bus_message_new_method_call(
- bus,
- &m,
- bus_systemd_mgr,
- "Reload");
- if (r < 0)
- return bus_log_create_error(r);
-
- /* Reloading the daemon may take long, hence set a longer timeout here */
- r = sd_bus_call(bus, m, DAEMON_RELOAD_TIMEOUT_SEC, &error, NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to reload daemon: %s", bus_error_message(&error, r));
-
- return 0;
-}
-
static int target_is_inactive(sd_bus *bus, const char *target) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *path = NULL, *state = NULL;
@@ -151,7 +129,9 @@ static int run(int argc, char *argv[]) {
goto fallback;
}
- if (reload_manager(bus) < 0)
+ log_info("Reloading system manager configuration.");
+ r = bus_service_manager_reload(bus);
+ if (r < 0)
goto fallback;
const char *target = in_initrd() ? SPECIAL_INITRD_TARGET : SPECIAL_DEFAULT_TARGET;