From 305393135b90c3650faaa518cdc8a35d9fbf839d Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 16 Jul 2026 19:20:57 +0100 Subject: [PATCH 1/2] rm-rf: use faccessat instead of fstatat Follow-up for 9dd2dab37e91ab4b000802d98aa7c4713836d53a --- src/shared/rm-rf.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/shared/rm-rf.c b/src/shared/rm-rf.c index 56a56ed9ab..203e075b9a 100644 --- a/src/shared/rm-rf.c +++ b/src/shared/rm-rf.c @@ -444,14 +444,8 @@ int rm_rf_at(int dir_fd, const char *path, RemoveFlags flags) { /* We refuse to clean the root file system with this call. This is extra paranoia to never cause a * really seriously broken system. */ r = path_is_root_at(dir_fd, path); - if (r == -ENOENT) { - struct stat st; - - if (fstatat(dir_fd, path, &st, AT_SYMLINK_NOFOLLOW) < 0) - r = -errno; - else - r = 0; /* The entry exists, but is most likely a dangling symlink. */ - } + if (r == -ENOENT) + r = RET_NERRNO(faccessat(dir_fd, path, F_OK, AT_SYMLINK_NOFOLLOW)); if (FLAGS_SET(flags, REMOVE_MISSING_OK) && r == -ENOENT) return 0; if (r < 0) From 002d467ce4c19c902c9596d3f5d8dae6d2cf28ae Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 16 Jul 2026 19:21:48 +0100 Subject: [PATCH 2/2] shift-uid: use TAKE_FD on input fd Follow-up for c3eafb10a0b886876316bca6f9af06db67308ad0 --- src/shared/shift-uid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/shift-uid.c b/src/shared/shift-uid.c index e1c53dcb88..d01a4dad8d 100644 --- a/src/shared/shift-uid.c +++ b/src/shared/shift-uid.c @@ -297,7 +297,7 @@ static int is_fs_fully_userns_compatible(const struct statfs *sfs) { static int recurse_fd(int input_fd, const struct stat *st, uid_t shift, bool is_toplevel) { _cleanup_closedir_ DIR *d = NULL; - _cleanup_close_ int fd = input_fd; + _cleanup_close_ int fd = TAKE_FD(input_fd); bool changed = false; struct statfs sfs; int r;