diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index 8399a2da72..50ab7b602c 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"); @@ -2047,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) 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"),