return r;
}
-static int set_wall_message(sd_bus *bus) {
+static int logind_set_wall_message(sd_bus *bus) {
#ifdef HAVE_LOGIND
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *m = NULL;
/* Ask systemd-logind, which might grant access to unprivileged users
* through PolicyKit */
-static int reboot_with_logind(sd_bus *bus, enum action a) {
+static int logind_reboot(sd_bus *bus, enum action a) {
#ifdef HAVE_LOGIND
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
const char *method, *description;
polkit_agent_open_if_enabled();
- (void) set_wall_message(bus);
+ (void) logind_set_wall_message(bus);
switch (a) {
#endif
}
-static int check_inhibitors(sd_bus *bus, enum action a) {
+static int logind_check_inhibitors(sd_bus *bus, enum action a) {
#ifdef HAVE_LOGIND
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_strv_free_ char **sessions = NULL;
a = verb_to_action(args[0]);
- r = check_inhibitors(bus, a);
+ r = logind_check_inhibitors(bus, a);
if (r < 0)
return r;
ACTION_SUSPEND,
ACTION_HIBERNATE,
ACTION_HYBRID_SLEEP)) {
- r = reboot_with_logind(bus, a);
+ r = logind_reboot(bus, a);
if (r >= 0)
return r;
if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
static int halt_main(sd_bus *bus) {
int r;
- r = check_inhibitors(bus, arg_action);
+ r = logind_check_inhibitors(bus, arg_action);
if (r < 0)
return r;
if (IN_SET(arg_action,
ACTION_POWEROFF,
ACTION_REBOOT)) {
- r = reboot_with_logind(bus, arg_action);
+ r = logind_reboot(bus, arg_action);
if (r >= 0)
return r;
if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
return 0;
}
-static int cancel_shutdown(void) {
+static int logind_cancel_shutdown(void) {
+#ifdef HAVE_LOGIND
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
int r;
if (r < 0)
return log_error_errno(r, "Unable to open system bus: %m");
- (void) set_wall_message(b);
+ (void) logind_set_wall_message(b);
r = sd_bus_call_method(
b,
return log_warning_errno(r, "Failed to talk to logind, shutdown hasn't been cancelled: %s", bus_error_message(&error, r));
return 0;
+#else
+ log_error("Not compiled with logind support, cannot cancel scheduled shutdowns.");
+ return -ENOSYS;
+#endif
}
int main(int argc, char*argv[]) {
break;
case ACTION_CANCEL_SHUTDOWN:
- r = cancel_shutdown();
+ r = logind_cancel_shutdown();
break;
case ACTION_RUNLEVEL: