mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
logind/systemctl: one follow-up for DesignatedMaintenanceWindow (#34966)
Fixes https://github.com/systemd/systemd/issues/33429
This commit is contained in:
commit
02bf14d924
@ -60,8 +60,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, EOPNOTSUPP),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_SESSION_BUSY, EBUSY),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_NOT_YOUR_DEVICE, EPERM),
|
||||
/* needs to be EOPNOTSUPP for proper handling in callers of logind_schedule_shutdown() */
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED, EOPNOTSUPP),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED, EBADSLT),
|
||||
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED, EALREADY),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_NO_NTP_SUPPORT, EOPNOTSUPP),
|
||||
|
@ -2663,11 +2663,11 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT)
|
||||
return sd_bus_error_set(error,
|
||||
BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED,
|
||||
"No upcoming maintenance window scheduled");
|
||||
return sd_bus_error_setf(error,
|
||||
BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED,
|
||||
"Failed to determine next maintenance window");
|
||||
BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED,
|
||||
"No upcoming maintenance window scheduled");
|
||||
|
||||
return sd_bus_error_set_errnof(error, r,
|
||||
"Failed to determine next maintenance window: %m");
|
||||
}
|
||||
|
||||
log_info("Scheduled %s at maintenance window %s", type, FORMAT_TIMESTAMP(elapse));
|
||||
|
@ -180,10 +180,9 @@ int halt_main(void) {
|
||||
return start_with_fallback();
|
||||
}
|
||||
|
||||
if (geteuid() != 0) {
|
||||
(void) must_be_root();
|
||||
return -EPERM;
|
||||
}
|
||||
r = must_be_root();
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!arg_no_wtmp) {
|
||||
if (sd_booted() > 0)
|
||||
|
@ -201,14 +201,17 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
|
||||
case ACTION_KEXEC:
|
||||
case ACTION_HALT:
|
||||
case ACTION_SOFT_REBOOT:
|
||||
if (arg_when == 0)
|
||||
if (arg_when == 0) {
|
||||
r = logind_reboot(a);
|
||||
else
|
||||
if (r >= 0 || IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
|
||||
/* The latter indicates that the requested operation requires auth,
|
||||
* is not supported or already in progress, in which cases we ignore the error. */
|
||||
return r;
|
||||
} else {
|
||||
r = logind_schedule_shutdown(a);
|
||||
if (r >= 0 || IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
|
||||
/* The latter indicates that the requested operation requires auth,
|
||||
* is not supported or already in progress, in which cases we ignore the error. */
|
||||
return r;
|
||||
if (r != -ENOSYS)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* On all other errors, try low-level operation. In order to minimize the difference
|
||||
* between operation with and without logind, we explicitly enable non-blocking mode
|
||||
|
Loading…
Reference in New Issue
Block a user