mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #32136 from YHNdnzj/nextroot-auto-mountpoint
systemctl-logind: auto soft-reboot only if /run/nextroot/ is mountpoint
This commit is contained in:
@@ -2088,10 +2088,10 @@ static int method_do_shutdown_or_sleep(
|
||||
"Both reboot via kexec and soft reboot selected, which is not supported");
|
||||
|
||||
if (action != HANDLE_REBOOT) {
|
||||
if (flags & SD_LOGIND_REBOOT_VIA_KEXEC)
|
||||
if (FLAGS_SET(flags, SD_LOGIND_REBOOT_VIA_KEXEC))
|
||||
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Reboot via kexec option is only applicable with reboot operations");
|
||||
if ((flags & SD_LOGIND_SOFT_REBOOT) || (flags & SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP))
|
||||
if (flags & (SD_LOGIND_SOFT_REBOOT|SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP))
|
||||
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Soft reboot option is only applicable with reboot operations");
|
||||
}
|
||||
@@ -2110,10 +2110,10 @@ static int method_do_shutdown_or_sleep(
|
||||
|
||||
const HandleActionData *a = NULL;
|
||||
|
||||
if ((flags & SD_LOGIND_SOFT_REBOOT) ||
|
||||
((flags & SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP) && path_is_os_tree("/run/nextroot") > 0))
|
||||
if (FLAGS_SET(flags, SD_LOGIND_SOFT_REBOOT) ||
|
||||
(FLAGS_SET(flags, SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP) && path_is_os_tree("/run/nextroot") > 0))
|
||||
a = handle_action_lookup(HANDLE_SOFT_REBOOT);
|
||||
else if ((flags & SD_LOGIND_REBOOT_VIA_KEXEC) && kexec_loaded())
|
||||
else if (FLAGS_SET(flags, SD_LOGIND_REBOOT_VIA_KEXEC) && kexec_loaded())
|
||||
a = handle_action_lookup(HANDLE_KEXEC);
|
||||
|
||||
if (action == HANDLE_SLEEP) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "bus-error.h"
|
||||
#include "bus-locator.h"
|
||||
#include "login-util.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "process-util.h"
|
||||
#include "systemctl-logind.h"
|
||||
#include "systemctl-start-unit.h"
|
||||
@@ -84,9 +85,12 @@ int logind_reboot(enum action a) {
|
||||
SET_FLAG(flags,
|
||||
SD_LOGIND_REBOOT_VIA_KEXEC,
|
||||
a == ACTION_KEXEC || (a == ACTION_REBOOT && getenv_bool("SYSTEMCTL_SKIP_AUTO_KEXEC") <= 0));
|
||||
/* Try to soft-reboot if /run/nextroot/ is a valid OS tree, but only if it's also a mount point.
|
||||
* Otherwise, if people store new rootfs directly on /run/ tmpfs, 'systemctl reboot' would always
|
||||
* soft-reboot, as /run/nextroot/ can never go away. */
|
||||
SET_FLAG(flags,
|
||||
SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP,
|
||||
a == ACTION_REBOOT && getenv_bool("SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT") <= 0);
|
||||
a == ACTION_REBOOT && getenv_bool("SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT") <= 0 && path_is_mount_point("/run/nextroot") > 0);
|
||||
SET_FLAG(flags, SD_LOGIND_SOFT_REBOOT, a == ACTION_SOFT_REBOOT);
|
||||
|
||||
r = bus_call_method(bus, bus_login_mgr, method_with_flags, &error, NULL, "t", flags);
|
||||
|
||||
Reference in New Issue
Block a user