From: Todd C. Miller Date: Mon, 11 Jan 2016 18:15:42 +0000 (-0700) Subject: No need to check whether the fd we opened is really a directory in X-Git-Tag: SUDO_1_8_16^2~81 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7c80913ef5258bcc632bce370b88aa967b19e52;p=sudo No need to check whether the fd we opened is really a directory in sudo_edit_open_nonwritable() since if not, the openat() will fail with ENOTDIR anyway. --- diff --git a/src/sudo_edit.c b/src/sudo_edit.c index ce060d972..c09d79354 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -364,13 +364,7 @@ restart: #endif debug_return_int(-1); } -#ifndef O_DIRECTORY - if (!S_ISDIR(sb.st_mode)) { - close(dfd); - errno = ENOTDIR; - debug_return_int(-1); - } -#endif + is_writable = dir_is_writable(&sb, user_details.uid, user_details.gid, user_details.ngroups, user_details.groups);