From 5e300f1e4c0d0ae407bac6393d1bbdcc9d640334 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 19 Jan 2016 19:50:27 -0700 Subject: [PATCH] There are no systems that support O_SEARCH/O_PATH that do not also support O_DIRECTORY so simplify the definition of DIR_OPEN_FLAGS a bit. --- src/sudo_edit.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/sudo_edit.c b/src/sudo_edit.c index c63d4b603..15abf1183 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -344,24 +344,16 @@ dir_is_writable(int dfd, struct user_details *ud, struct command_details *cd) /* * Directory open flags for use with openat(2). - * Use O_PATH/O_SEARCH and O_DIRECTORY where possible. + * Use O_SEARCH/O_PATH and/or O_DIRECTORY where possible. */ -#if defined(O_PATH) -# if defined(O_DIRECTORY) -# define DIR_OPEN_FLAGS (O_PATH|O_DIRECTORY) -# else -# define DIR_OPEN_FLAGS (O_PATH) -# endif -#elif defined(O_SEARCH) -# if defined(O_DIRECTORY) -# define DIR_OPEN_FLAGS (O_SEARCH|O_DIRECTORY) -# else -# define DIR_OPEN_FLAGS (O_SEARCH) -# endif +#if defined(O_SEARCH) +# define DIR_OPEN_FLAGS (O_SEARCH|O_DIRECTORY) +#elif defined(O_PATH) +# define DIR_OPEN_FLAGS (O_PATH|O_DIRECTORY) #elif defined(O_DIRECTORY) -# define DIR_OPEN_FLAGS (O_RDONLY|O_DIRECTORY) +# define DIR_OPEN_FLAGS (O_RDONLY|O_DIRECTORY) #else -# define DIR_OPEN_FLAGS (O_RDONLY|O_NONBLOCK) +# define DIR_OPEN_FLAGS (O_RDONLY|O_NONBLOCK) #endif static int -- 2.40.0