summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-03-05 23:11:48 +0800
committerMike Yuan <me@yhndnzj.com>2023-03-14 19:21:11 +0800
commit92b00e867844948bdf559758739343c4308570c0 (patch)
treeb6a35085680c6814584d0ac789ee41006dabc255 /src/systemctl
parent9071eea01bd26d838bfd793db497efd849ad44da (diff)
downloadsystemd-92b00e867844948bdf559758739343c4308570c0.tar.gz
systemctl: logind: make logind_schedule_shutdown accept action as param
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-compat-halt.c2
-rw-r--r--src/systemctl/systemctl-logind.c8
-rw-r--r--src/systemctl/systemctl-logind.h2
3 files changed, 7 insertions, 5 deletions
diff --git a/src/systemctl/systemctl-compat-halt.c b/src/systemctl/systemctl-compat-halt.c
index 8a0e4e6294..b9164c27ab 100644
--- a/src/systemctl/systemctl-compat-halt.c
+++ b/src/systemctl/systemctl-compat-halt.c
@@ -149,7 +149,7 @@ int halt_main(void) {
if (arg_force == 0) {
/* always try logind first */
if (arg_when > 0)
- r = logind_schedule_shutdown();
+ r = logind_schedule_shutdown(arg_action);
else {
r = logind_check_inhibitors(arg_action);
if (r < 0)
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c
index f910fe6675..068f54e18b 100644
--- a/src/systemctl/systemctl-logind.c
+++ b/src/systemctl/systemctl-logind.c
@@ -291,19 +291,21 @@ int prepare_boot_loader_entry(void) {
#endif
}
-int logind_schedule_shutdown(void) {
-
+int logind_schedule_shutdown(enum action a) {
#if ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *action;
sd_bus *bus;
int r;
+ assert(a >= 0);
+ assert(a < _ACTION_MAX);
+
r = acquire_bus(BUS_FULL, &bus);
if (r < 0)
return r;
- action = action_table[arg_action].verb;
+ action = action_table[a].verb;
if (!action)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Scheduling not supported for this action.");
diff --git a/src/systemctl/systemctl-logind.h b/src/systemctl/systemctl-logind.h
index 925f4559c1..516f74952f 100644
--- a/src/systemctl/systemctl-logind.h
+++ b/src/systemctl/systemctl-logind.h
@@ -10,7 +10,7 @@ int prepare_firmware_setup(void);
int prepare_boot_loader_menu(void);
int prepare_boot_loader_entry(void);
-int logind_schedule_shutdown(void);
+int logind_schedule_shutdown(enum action a);
int logind_cancel_shutdown(void);
int logind_show_shutdown(void);