From: Lennart Poettering Date: Thu, 20 Feb 2025 22:18:27 +0000 (+0100) Subject: repart: port to new factory reset state apis X-Git-Tag: v258-rc1~1176^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e050b0458930b96dc9abebd822ab0b8fe2b14aa;p=thirdparty%2Fsystemd.git repart: port to new factory reset state apis --- diff --git a/NEWS b/NEWS index 1d5578e86bb..804c33e3394 100644 --- a/NEWS +++ b/NEWS @@ -76,6 +76,12 @@ CHANGES WITH 258 in spe: *now* to include a native systemd unit file instead of a legacy System V script to retain compatibility with future systemd releases. + * Support for systemd-repart's FactoryReset EFI variable has been + deprecated and support for it will be removed in v260. Use the newer, + more generic FactoryResetRequest variable instead, which can be + managed by "systemd-factory-reset request" and "systemd-factory-reset + complete". + * To work around limitations of X11's keyboard handling systemd's keyboard mapping hardware database (hwdb.d/60-keyboard.hwdb) so far mapped the microphone mute and touchpad on/off/toggle keys to the diff --git a/TODO b/TODO index b56f0a7da68..76c1d940bd1 100644 --- a/TODO +++ b/TODO @@ -125,6 +125,9 @@ Deprecations and removals: * Once baseline is 4.13, remove support for INTERFACE_OLD= checks in "udevadm trigger"'s waiting logic, since we can then rely on uuid-tagged uevents +* In v260: remove support for deprecated FactoryReset EFI variable in + systemd-repart, replaced by FactoryResetRequest. + Features: * Maybe rename pkcs7 and public verbs of systemd-keyutil to be more verb like. diff --git a/man/systemd-repart.xml b/man/systemd-repart.xml index f4823cd0e2e..40376bc7738 100644 --- a/man/systemd-repart.xml +++ b/man/systemd-repart.xml @@ -130,9 +130,9 @@ systemd-repart may be used to erase existing partitions to reset an installation back to vendor defaults. This mode of operation is used when either the switch is passed on the tool's command line, or the option is - specified on the kernel command line, or the FactoryReset EFI variable (vendor UUID - 8cf2644b-4b0b-428f-9387-6d876050dc67) is set to "yes". It alters the algorithm above - slightly: between the 3rd and the 4th step above any partition marked explicitly via the + specified on the kernel command line, or the FactoryResetRequest EFI variable (vendor + UUID 8cf2644b-4b0b-428f-9387-6d876050dc67) is set to "yes". It alters the algorithm + above slightly: between the 3rd and the 4th step above any partition marked explicitly via the FactoryReset= boolean is deleted, and the algorithm restarted, thus immediately re-creating these partitions anew empty. diff --git a/src/repart/repart.c b/src/repart/repart.c index c8ff37124cf..9827d032b5c 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -33,6 +33,7 @@ #include "dirent-util.h" #include "efivars.h" #include "errno-util.h" +#include "factory-reset.h" #include "fd-util.h" #include "fdisk-util.h" #include "fileio.h" @@ -8712,23 +8713,20 @@ static int parse_argv(int argc, char *argv[], X509 **ret_certificate, EVP_PKEY * } static int parse_proc_cmdline_factory_reset(void) { - bool b; - int r; - if (arg_factory_reset >= 0) /* Never override what is specified on the process command line */ return 0; if (!in_initrd()) /* Never honour kernel command line factory reset request outside of the initrd */ return 0; - r = proc_cmdline_get_bool("systemd.factory_reset", /* flags = */ 0, &b); - if (r < 0) - return log_error_errno(r, "Failed to parse systemd.factory_reset kernel command line argument: %m"); - if (r > 0) { - arg_factory_reset = b; + FactoryResetMode f = factory_reset_mode(); + if (f < 0) + return log_error_errno(f, "Failed to determine factory reset status: %m"); + if (f != FACTORY_RESET_UNSPECIFIED) { + arg_factory_reset = f == FACTORY_RESET_ON; - if (b) - log_notice("Honouring factory reset requested via kernel command line."); + if (arg_factory_reset) + log_notice("Honouring factory reset requested via kernel command line or EFI variable."); } return 0; @@ -8738,6 +8736,10 @@ static int parse_efi_variable_factory_reset(void) { _cleanup_free_ char *value = NULL; int r; + /* NB: This is legacy, people should move to the newer FactoryResetRequest variable! */ + + // FIXME: Remove this in v260 + if (arg_factory_reset >= 0) /* Never override what is specified on the process command line */ return 0; @@ -8751,6 +8753,8 @@ static int parse_efi_variable_factory_reset(void) { return log_error_errno(r, "Failed to read EFI variable FactoryReset: %m"); } + log_warning("Warning, EFI variable FactoryReset is in use, please migrate to use FactoryResetRequest instead, support will be removed in v260!"); + r = parse_boolean(value); if (r < 0) return log_error_errno(r, "Failed to parse EFI variable FactoryReset: %m"); @@ -8765,6 +8769,8 @@ static int parse_efi_variable_factory_reset(void) { static int remove_efi_variable_factory_reset(void) { int r; + // FIXME: Remove this in v260, see above + r = efi_set_variable(EFI_SYSTEMD_VARIABLE_STR("FactoryReset"), NULL, 0); if (r < 0) { if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))