]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: don't follow symlinks when opening type1/type2 files
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Sep 2022 16:22:11 +0000 (18:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Sep 2022 11:14:05 +0000 (13:14 +0200)
let's not follow symlinks when going from enumeraiton dir to enumerated
file either.

src/shared/bootspec.c

index 7ca218f955a3413356421948c74b6e08ddc1fdc1..498a1e65508c26d98219ec8b145bfb1e174a34a7 100644 (file)
@@ -629,7 +629,7 @@ static int boot_entries_find_type1(
                 if (!endswith_no_case(de->d_name, ".conf"))
                         continue;
 
-                r = xfopenat(dir_fd, de->d_name, "re", 0, &f);
+                r = xfopenat(dir_fd, de->d_name, "re", O_NOFOLLOW|O_NOCTTY, &f);
                 if (r < 0) {
                         log_warning_errno(r, "Failed to open %s/%s, ignoring: %m", full, de->d_name);
                         continue;
@@ -888,7 +888,7 @@ static int boot_entries_find_unified(
                 if (!GREEDY_REALLOC0(config->entries, config->n_entries + 1))
                         return log_oom();
 
-                fd = openat(dirfd(d), de->d_name, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
+                fd = openat(dirfd(d), de->d_name, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOFOLLOW|O_NOCTTY);
                 if (fd < 0) {
                         log_warning_errno(errno, "Failed to open %s/%s, ignoring: %m", full, de->d_name);
                         continue;