1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00

sleep: don't init /sys/power/resume if 'resume=' option is missing and EFI is disabled

Otherwise in such case a first `systemctl hibernate` would fail but would still
initialize /sys/power/resume fooling a second `systemctl hibernate` into
believing that 'resume=' is correctly set and can be used by the resume process
to find the swap device to resume from.

Follow-up for #27330.
This commit is contained in:
Franck Bui 2023-07-26 17:04:10 +02:00 committed by Luca Boccassi
parent 8f766afe98
commit f1f331a252

View File

@ -262,16 +262,18 @@ static int execute(
return log_error_errno(r, "Failed to find location to hibernate to: %m");
resume_set = r > 0;
r = write_efi_hibernate_location(hibernate_location, !resume_set);
if (!resume_set) {
if (r == -EOPNOTSUPP)
return log_error_errno(r, "No valid 'resume=' option found, refusing to hibernate.");
if (r < 0)
return r;
r = write_kernel_hibernate_location(hibernate_location);
if (r < 0)
return log_error_errno(r, "Failed to prepare for hibernation: %m");
}
r = write_efi_hibernate_location(hibernate_location, !resume_set);
if (r < 0 && !resume_set)
return r;
r = write_mode(modes);
if (r < 0)
return log_error_errno(r, "Failed to write mode to /sys/power/disk: %m");