From 7f204857e140a4da9f0c536544eebd1ffc23b21a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 10 Feb 2026 11:48:25 +0100 Subject: [PATCH 1/3] bootctl: fix varlink IDL for rootDirectory field --- src/shared/varlink-io.systemd.BootControl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/varlink-io.systemd.BootControl.c b/src/shared/varlink-io.systemd.BootControl.c index a24b4b076e..c369b134ef 100644 --- a/src/shared/varlink-io.systemd.BootControl.c +++ b/src/shared/varlink-io.systemd.BootControl.c @@ -128,7 +128,7 @@ static SD_VARLINK_DEFINE_METHOD( SD_VARLINK_FIELD_COMMENT("Index into array of file descriptors passed along with this message, pointing to file descriptor to root file system to operate on"), SD_VARLINK_DEFINE_INPUT(rootFileDescriptor, SD_VARLINK_INT, SD_VARLINK_NULLABLE), SD_VARLINK_FIELD_COMMENT("Root directory to operate relative to. If both this and rootFileDescriptor is specified, this is purely informational. If only this is specified, it is what will be used."), - SD_VARLINK_DEFINE_INPUT(rootDirectory, SD_VARLINK_INT, SD_VARLINK_NULLABLE), + SD_VARLINK_DEFINE_INPUT(rootDirectory, SD_VARLINK_STRING, SD_VARLINK_NULLABLE), SD_VARLINK_FIELD_COMMENT("Selects how to identify boot entries"), SD_VARLINK_DEFINE_INPUT_BY_TYPE(bootEntryTokenType, BootEntryTokenType, SD_VARLINK_NULLABLE), SD_VARLINK_FIELD_COMMENT("If true the boot loader will be registered in an EFI boot entry via EFI variables, otherwise this is omitted"), From 10268261a8d530450d4193575c3329af12902c7a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 10 Feb 2026 11:46:58 +0100 Subject: [PATCH 2/3] bootctl: toughen fd validation in Install() handler Let's also check the fd flags. Just in case. --- src/bootctl/bootctl-install.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index 8399a2da72..a25557895b 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -2035,6 +2035,10 @@ int vl_method_install( if (p.context.root_fd < 0) return log_debug_errno(p.context.root_fd, "Failed to acquire root fd from Varlink: %m"); + r = fd_verify_safe_flags_full(p.context.root_fd, O_DIRECTORY); + if (r < 0) + return sd_varlink_error_invalid_parameter_name(link, "rootFileDescriptor"); + r = fd_verify_directory(p.context.root_fd); if (r < 0) return log_debug_errno(r, "Specified file descriptor does not refer to a directory: %m"); From 51480b56c802ead2cd81844df79580df9c719d8f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 10 Feb 2026 11:47:33 +0100 Subject: [PATCH 3/3] bootctl: rearrange if branches in vl_method_install() --- src/bootctl/bootctl-install.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index a25557895b..50ab7b602c 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -2051,15 +2051,11 @@ int vl_method_install( if (empty_or_root(p.context.root)) p.context.root = mfree(p.context.root); } - } - - if (p.context.root_fd < 0 && p.context.root) { + } else if (p.context.root) { p.context.root_fd = open(p.context.root, O_RDONLY|O_CLOEXEC|O_DIRECTORY); if (p.context.root_fd < 0) return log_debug_errno(errno, "Failed to open '%s': %m", p.context.root); - } - - if (p.context.root_fd < 0) + } else p.context.root_fd = XAT_FDROOT; if (p.context.entry_token_type < 0)