summaryrefslogtreecommitdiffstats
path: root/src/boot/bootctl-systemd-efi-options.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /src/boot/bootctl-systemd-efi-options.c
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boot/bootctl-systemd-efi-options.c')
-rw-r--r--src/boot/bootctl-systemd-efi-options.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/boot/bootctl-systemd-efi-options.c b/src/boot/bootctl-systemd-efi-options.c
new file mode 100644
index 0000000..7f8308f
--- /dev/null
+++ b/src/boot/bootctl-systemd-efi-options.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "alloc-util.h"
+#include "bootctl.h"
+#include "bootctl-systemd-efi-options.h"
+#include "efi-loader.h"
+
+int verb_systemd_efi_options(int argc, char *argv[], void *userdata) {
+ int r;
+
+ /* This is obsolete and subject to removal */
+
+ if (!arg_quiet)
+ log_notice("Use of the SystemdOptions EFI variable is deprecated.");
+
+ if (argc == 1) {
+ _cleanup_free_ char *line = NULL, *new = NULL;
+
+ r = systemd_efi_options_variable(&line);
+ if (r == -ENODATA)
+ log_debug("No SystemdOptions EFI variable present in cache.");
+ else if (r < 0)
+ return log_error_errno(r, "Failed to read SystemdOptions EFI variable from cache: %m");
+ else
+ puts(line);
+
+ r = systemd_efi_options_efivarfs_if_newer(&new);
+ if (r == -ENODATA) {
+ if (line)
+ log_notice("Note: SystemdOptions EFI variable has been removed since boot.");
+ } else if (r < 0)
+ log_warning_errno(r, "Failed to check SystemdOptions EFI variable in efivarfs, ignoring: %m");
+ else if (new && !streq_ptr(line, new))
+ log_notice("Note: SystemdOptions EFI variable has been modified since boot. New value: %s",
+ new);
+ } else {
+ r = efi_set_variable_string(EFI_SYSTEMD_VARIABLE(SystemdOptions), argv[1]);
+ if (r < 0)
+ return log_error_errno(r, "Failed to set SystemdOptions EFI variable: %m");
+ }
+
+ return 0;
+}