diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-08-01 15:33:35 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-09-16 18:08:54 +0200 |
commit | 53aa0d02add93d8c0afa2772609372a2040c162a (patch) | |
tree | ce98eaa014d4a7ef706f561b10023b7295aa3c21 /src/basic/efivars.c | |
parent | test-proc-cmdline: use test_setup_logging() (diff) | |
download | systemd-53aa0d02add93d8c0afa2772609372a2040c162a.tar.xz systemd-53aa0d02add93d8c0afa2772609372a2040c162a.zip |
Add support for SystemdOptions EFI var to augment /proc/cmdline
In various circumstances, overriding the kernel commandline can be inconvenient.
People have different bootloaders, and e.g. the grub config can be pretty scary.
grubby helps, but it isn't always available.
This option adds an alternative mechanism that can quite convenient on EFI
systems. cmdline settings have higher priority, because they can be (usually)
changed on the bootloader prompt.
$SYSTEMD_EFI_OPTIONS can be used to override, same as $SYSTEMD_PROC_CMDLINE.
Diffstat (limited to 'src/basic/efivars.c')
-rw-r--r-- | src/basic/efivars.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/basic/efivars.c b/src/basic/efivars.c index 5264ab1b50..53875de5a0 100644 --- a/src/basic/efivars.c +++ b/src/basic/efivars.c @@ -222,4 +222,29 @@ int efi_set_variable_string(sd_id128_t vendor, const char *name, const char *v) return efi_set_variable(vendor, name, u16, (char16_strlen(u16) + 1) * sizeof(char16_t)); } +int efi_systemd_options_variable(char **line) { + const char *e; + int r; + + assert(line); + + /* For testing purposes it is sometimes useful to be able to override this */ + e = secure_getenv("SYSTEMD_EFI_OPTIONS"); + if (e) { + char *m; + + m = strdup(e); + if (!m) + return -ENOMEM; + + *line = m; + return 0; + } + + r = efi_get_variable_string(EFI_VENDOR_SYSTEMD, "SystemdOptions", line); + if (r == -ENOENT) + return -ENODATA; + + return r; +} #endif |