From: Yu Watanabe Date: Sat, 31 May 2025 01:24:17 +0000 (+0900) Subject: bootctl: do not print slash more than once X-Git-Tag: v258-rc1~434 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91c60ff52801512eaf41e9da7016cb98580fe852;p=thirdparty%2Fsystemd.git bootctl: do not print slash more than once When bootctl is called by an unprivileged user, then previously we got ``` Failed to read "/boot/EFI/systemd": Permission denied Failed to open '/boot//loader/loader.conf': Permission denied ``` Now, with this patch, we get ``` Failed to read "/boot/EFI/systemd": Permission denied Failed to open '/boot/loader/loader.conf': Permission denied ``` --- diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index c1a08b60490..816a4c8ac0f 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -880,7 +880,7 @@ static int install_variables( if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Cannot access \"%s/%s\": %m", esp_path, path); + return log_error_errno(r, "Cannot access \"%s/%s\": %m", esp_path, skip_leading_slash(path)); r = find_slot(uuid, path, &slot); if (r < 0) { diff --git a/src/bootctl/bootctl-status.c b/src/bootctl/bootctl-status.c index 352ab48ce70..9715c91d269 100644 --- a/src/bootctl/bootctl-status.c +++ b/src/bootctl/bootctl-status.c @@ -215,7 +215,7 @@ static int enumerate_binaries( if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Failed to read \"%s/%s\": %m", esp_path, path); + return log_error_errno(r, "Failed to read \"%s/%s\": %m", esp_path, skip_leading_slash(path)); FOREACH_DIRENT(de, d, break) { _cleanup_free_ char *v = NULL, *filename = NULL; @@ -855,7 +855,7 @@ static int cleanup_orphaned_files( if (dir_fd == -ENOENT) return 0; if (dir_fd < 0) - return log_error_errno(dir_fd, "Failed to open '%s/%s': %m", root, arg_entry_token); + return log_error_errno(dir_fd, "Failed to open '%s/%s': %m", root, skip_leading_slash(arg_entry_token)); p = path_join("/", arg_entry_token); if (!p) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index f57a3d57407..980c8c53ad5 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -536,7 +536,7 @@ static int boot_loader_read_conf_path(BootConfig *config, const char *root, cons if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Failed to open '%s/%s': %m", root, path); + return log_error_errno(r, "Failed to open '%s/%s': %m", root, skip_leading_slash(path)); return boot_loader_read_conf(config, f, full); } @@ -648,7 +648,7 @@ static int boot_entries_find_type1( if (dir_fd == -ENOENT) return 0; if (dir_fd < 0) - return log_error_errno(dir_fd, "Failed to open '%s/%s': %m", root, dir); + return log_error_errno(dir_fd, "Failed to open '%s/%s': %m", root, skip_leading_slash(dir)); r = readdir_all(dir_fd, RECURSE_DIR_IGNORE_DOT, &dentries); if (r < 0) @@ -1111,7 +1111,7 @@ static int boot_entries_find_unified_addons( if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Failed to open '%s/%s': %m", root, addon_dir); + return log_error_errno(r, "Failed to open '%s/%s': %m", root, skip_leading_slash(addon_dir)); FOREACH_DIRENT(de, d, return log_error_errno(errno, "Failed to read %s: %m", full)) { _cleanup_free_ char *j = NULL, *cmdline = NULL, *location = NULL; @@ -1173,7 +1173,7 @@ static int boot_entries_find_unified_global_addons( if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Failed to open '%s/%s': %m", root, d_name); + return log_error_errno(r, "Failed to open '%s/%s': %m", root, skip_leading_slash(d_name)); return boot_entries_find_unified_addons(config, dirfd(d), d_name, root, ret_addons); } @@ -1213,7 +1213,7 @@ static int boot_entries_find_unified( if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Failed to open '%s/%s': %m", root, dir); + return log_error_errno(r, "Failed to open '%s/%s': %m", root, skip_leading_slash(dir)); FOREACH_DIRENT(de, d, return log_error_errno(errno, "Failed to read %s: %m", full)) { if (!dirent_is_file(de))