Merge pull request #10061 from xnox/fix-logindless-scheduled-shutdown
Fix logindless scheduled shutdown
This commit is contained in:
commit
b0b3ba69c0
|
@ -8501,8 +8501,9 @@ static int halt_now(enum action a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_LOGIND
|
|
||||||
static int logind_schedule_shutdown(void) {
|
static int logind_schedule_shutdown(void) {
|
||||||
|
|
||||||
|
#if ENABLE_LOGIND
|
||||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
char date[FORMAT_TIMESTAMP_MAX];
|
char date[FORMAT_TIMESTAMP_MAX];
|
||||||
const char *action;
|
const char *action;
|
||||||
|
@ -8554,8 +8555,11 @@ static int logind_schedule_shutdown(void) {
|
||||||
if (!arg_quiet)
|
if (!arg_quiet)
|
||||||
log_info("Shutdown scheduled for %s, use 'shutdown -c' to cancel.", format_timestamp(date, sizeof(date), arg_when));
|
log_info("Shutdown scheduled for %s, use 'shutdown -c' to cancel.", format_timestamp(date, sizeof(date), arg_when));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
#else
|
||||||
|
log_error("Cannot schedule shutdown without logind support, proceeding with immediate shutdown.");
|
||||||
|
return -ENOSYS;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static int halt_main(void) {
|
static int halt_main(void) {
|
||||||
int r;
|
int r;
|
||||||
|
@ -8564,12 +8568,10 @@ static int halt_main(void) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (arg_when > 0)
|
/* Delayed shutdown requested, and was successful */
|
||||||
#if ENABLE_LOGIND
|
if (arg_when > 0 && logind_schedule_shutdown() == 0)
|
||||||
return logind_schedule_shutdown();
|
return 0;
|
||||||
#else
|
/* no delay, or logind failed or is not at all available */
|
||||||
log_error("Cannot schedule shutdown without logind support, proceeding with immediate shutdown.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
if (geteuid() != 0) {
|
||||||
if (arg_dry_run || arg_force > 0) {
|
if (arg_dry_run || arg_force > 0) {
|
||||||
|
|
Loading…
Reference in New Issue