]> granicus.if.org Git - sudo/commitdiff
Do not try to set the close on exec flag if we didn't actually open sudoers.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 9 Jan 2009 00:13:37 +0000 (00:13 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 9 Jan 2009 00:13:37 +0000 (00:13 +0000)
sudo.c

diff --git a/sudo.c b/sudo.c
index efee4831035c60b7d4b06e1000b83d68677f0485..2ff8927fa343534b044f5177dc4cacacf8572f99 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -1077,16 +1077,18 @@ open_sudoers(sudoers, keepopen)
            (unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID);
     else if ((fp = fopen(sudoers, "r")) == NULL)
        log_error(USE_ERRNO, "can't open %s", sudoers);
-    else if (statbuf.st_size != 0) {
+    else {
        /*
         * Make sure we can actually read sudoers so we can present the
-        * user with a reasonable error message.
+        * user with a reasonable error message (unlike the lexer).
         */
-       if (fgetc(fp) == EOF)
-           log_error(USE_ERRNO, "can't read %s", sudoers);
-       rewind(fp);
+       if (statbuf.st_size != 0) {
+           if (fgetc(fp) == EOF)
+               log_error(USE_ERRNO, "can't read %s", sudoers);
+           rewind(fp);
+       }
+       (void) fcntl(fileno(fp), F_SETFD, 1);
     }
-    (void) fcntl(fileno(fp), F_SETFD, 1);
 
     set_perms(PERM_ROOT);              /* change back to root */
     return(fp);