From: Lennart Poettering Date: Wed, 7 Sep 2022 16:22:11 +0000 (+0200) Subject: bootspec: don't follow symlinks when opening type1/type2 files X-Git-Tag: v252-rc1~228^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2c513048ce18d5ed0f9260c9ab7354b81ff16b1;p=thirdparty%2Fsystemd.git bootspec: don't follow symlinks when opening type1/type2 files let's not follow symlinks when going from enumeraiton dir to enumerated file either. --- diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 7ca218f955a..498a1e65508 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -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;