]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: port to new factory reset state apis
authorLennart Poettering <lennart@poettering.net>
Thu, 20 Feb 2025 22:18:27 +0000 (23:18 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 5 Mar 2025 11:37:24 +0000 (12:37 +0100)
NEWS
TODO
man/systemd-repart.xml
src/repart/repart.c

diff --git a/NEWS b/NEWS
index 1d5578e86bb0f99feacf8eac66da36d0fca690ff..804c33e3394dba9ae8b7a715209dfdb915130d41 100644 (file)
--- 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 b56f0a7da68d39028fe992480a035e7a5afd5921..76c1d940bd13ea417830f4919cb976a4319b0ad8 100644 (file)
--- 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.
index f4823cd0e2e34ead1a634ea681a217259821ced8..40376bc77387804eeba0c5c1a9488930d0b0d6a5 100644 (file)
     <command>systemd-repart</command> may be used to erase existing partitions to reset an installation back
     to vendor defaults. This mode of operation is used when either the <option>--factory-reset=yes</option>
     switch is passed on the tool's command line, or the <option>systemd.factory_reset=yes</option> option is
-    specified on the kernel command line, or the <varname>FactoryReset</varname> EFI variable (vendor UUID
-    <constant>8cf2644b-4b0b-428f-9387-6d876050dc67</constant>) 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 <varname>FactoryResetRequest</varname> EFI variable (vendor
+    UUID <constant>8cf2644b-4b0b-428f-9387-6d876050dc67</constant>) is set to "yes". It alters the algorithm
+    above slightly: between the 3rd and the 4th step above any partition marked explicitly via the
     <varname>FactoryReset=</varname> boolean is deleted, and the algorithm restarted, thus immediately
     re-creating these partitions anew empty.</para>
 
index c8ff37124cf4303569fd7c1f6cf14e9f5f4aa1be..9827d032b5c71f28b0b2d36c0e199e617894e274 100644 (file)
@@ -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))