summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-09-28 19:47:20 +0200
committerSven Eden <yamakuzure@gmx.net>2018-09-28 19:47:20 +0200
commit48ed2296c6f7e463d12ff0e0f90e494d27eae239 (patch)
tree03ede357cf487b9dfe6f43c5c3512c17f5424ae5
parenteee8275c6ac591d293085ee5a4c0242242413403 (diff)
Prep v239: Add execution of executables in systemshutdowndir
-rw-r--r--src/login/elogind-dbus.c18
-rw-r--r--src/login/logind-dbus.c2
2 files changed, 15 insertions, 5 deletions
diff --git a/src/login/elogind-dbus.c b/src/login/elogind-dbus.c
index bed528145..f359e1867 100644
--- a/src/login/elogind-dbus.c
+++ b/src/login/elogind-dbus.c
@@ -19,6 +19,7 @@
#include "elogind-dbus.h"
+#include "exec-util.h"
#include "process-util.h"
#include "sd-messages.h"
#include "sleep.h"
@@ -74,9 +75,16 @@ static int bus_manager_log_shutdown(
}
/* elogind specific helper to make HALT and REBOOT possible. */
-static int run_helper(const char *helper) {
+static int run_helper(const char *helper, const char *arg_verb) {
+ char *arguments[3];
+ static const char* const dirs[] = { SYSTEM_SHUTDOWN_PATH, NULL };
int r = 0;
+ arguments[0] = NULL;
+ arguments[1] = (char*)arg_verb;
+ arguments[2] = NULL;
+ execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL, NULL, arguments);
+
r = safe_fork_full(helper, NULL, 0, FORK_RESET_SIGNALS|FORK_REOPEN_LOG, NULL);
if (r < 0)
@@ -99,13 +107,13 @@ static int shutdown_or_sleep(Manager *m, HandleAction action) {
switch (action) {
case HANDLE_POWEROFF:
- return run_helper(POWEROFF);
+ return run_helper(POWEROFF, "poweroff");
case HANDLE_REBOOT:
- return run_helper(REBOOT);
+ return run_helper(REBOOT, "reboot");
case HANDLE_HALT:
- return run_helper(HALT);
+ return run_helper(HALT, "halt");
case HANDLE_KEXEC:
- return run_helper(KEXEC);
+ return run_helper(KEXEC, "kexec");
case HANDLE_SUSPEND:
return do_sleep(m, "suspend");
case HANDLE_HIBERNATE:
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 9d7092869..acf50e62e 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2440,7 +2440,9 @@ static int method_can_shutdown_or_sleep(
action, result);
}
+#if 0 /// UNNEEDED by elogind
finish:
+#endif // 0
return sd_bus_reply_method_return(message, "s", result);
}