mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 11:27:32 +03:00
systemctl: when a shutdown is scheduled, always go via logind
This commit is contained in:
parent
19578bb26b
commit
7f96539d45
@ -7524,10 +7524,11 @@ static int halt_main(void) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
if (arg_when > 0)
|
||||||
|
return logind_schedule_shutdown();
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
if (geteuid() != 0) {
|
||||||
if (arg_when > 0 ||
|
if (arg_dry || arg_force > 0) {
|
||||||
arg_dry ||
|
|
||||||
arg_force > 0) {
|
|
||||||
log_error("Must be root.");
|
log_error("Must be root.");
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
@ -7535,25 +7536,19 @@ static int halt_main(void) {
|
|||||||
/* Try logind if we are a normal user and no special
|
/* Try logind if we are a normal user and no special
|
||||||
* mode applies. Maybe PolicyKit allows us to shutdown
|
* mode applies. Maybe PolicyKit allows us to shutdown
|
||||||
* the machine. */
|
* the machine. */
|
||||||
if (IN_SET(arg_action,
|
if (IN_SET(arg_action, ACTION_POWEROFF, ACTION_REBOOT)) {
|
||||||
ACTION_POWEROFF,
|
|
||||||
ACTION_REBOOT)) {
|
|
||||||
r = logind_reboot(arg_action);
|
r = logind_reboot(arg_action);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
return r;
|
return r;
|
||||||
if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
|
if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
|
||||||
/* requested operation is not supported or already in progress */
|
/* requested operation is not
|
||||||
|
* supported on the local system or
|
||||||
|
* already in progress */
|
||||||
return r;
|
return r;
|
||||||
/* on all other errors, try low-level operation */
|
/* on all other errors, try low-level operation */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_when > 0) {
|
|
||||||
r = logind_schedule_shutdown();
|
|
||||||
if (r >= 0)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arg_dry && !arg_force)
|
if (!arg_dry && !arg_force)
|
||||||
return start_with_fallback();
|
return start_with_fallback();
|
||||||
|
|
||||||
@ -7573,7 +7568,6 @@ static int halt_main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = halt_now(arg_action);
|
r = halt_now(arg_action);
|
||||||
|
|
||||||
return log_error_errno(r, "Failed to reboot: %m");
|
return log_error_errno(r, "Failed to reboot: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user