From: Lennart Poettering Date: Fri, 23 Feb 2024 21:46:04 +0000 (+0100) Subject: fd-util: O_DIRECTORY is fine in fd_verify_safe_flags() too X-Git-Tag: v256-rc1~671^2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a5aa6842d12a406651cdfa6e5278b0cb2df1872;p=thirdparty%2Fsystemd.git fd-util: O_DIRECTORY is fine in fd_verify_safe_flags() too --- diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 371547facb9..c16a2ab658e 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -926,6 +926,8 @@ int fd_verify_safe_flags(int fd) { * * RAW_O_LARGEFILE: glibc secretly sets this and neglects to hide it from us if we call fcntl. * See comment in missing_fcntl.h for more details about this. + * + * O_DIRECTORY: this is set for directories, which are totally fine */ assert(fd >= 0); @@ -934,7 +936,7 @@ int fd_verify_safe_flags(int fd) { if (flags < 0) return -errno; - unexpected_flags = flags & ~(O_ACCMODE|O_NOFOLLOW|RAW_O_LARGEFILE); + unexpected_flags = flags & ~(O_ACCMODE|O_NOFOLLOW|RAW_O_LARGEFILE|O_DIRECTORY); if (unexpected_flags != 0) return log_debug_errno(SYNTHETIC_ERRNO(EREMOTEIO), "Unexpected flags set for extrinsic fd: 0%o",