mirror of
https://github.com/systemd/systemd.git
synced 2025-03-06 00:58:29 +03:00
repart: port to new factory reset state apis
This commit is contained in:
parent
45623d4ad6
commit
9e050b0458
6
NEWS
6
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
|
||||
|
3
TODO
3
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.
|
||||
|
@ -130,9 +130,9 @@
|
||||
<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>
|
||||
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user