From: Todd C. Miller Date: Sun, 22 Nov 2009 16:12:38 +0000 (+0000) Subject: Don't exit() from open_sudoers, just return NULL for all errors. X-Git-Tag: SUDO_1_7_3~188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a86896a1c7b8bb881591c027175491a18885de1b;p=sudo Don't exit() from open_sudoers, just return NULL for all errors. --- diff --git a/sudo.c b/sudo.c index a92a25a16..d03a5635f 100644 --- a/sudo.c +++ b/sudo.c @@ -1161,17 +1161,21 @@ open_sudoers(sudoers, doedit, keepopen) log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers, (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); + log_error(USE_ERRNO|NO_EXIT, "can't open %s", sudoers); else { /* * Make sure we can actually read sudoers so we can present the * user with a reasonable error message (unlike the lexer). */ - if (statbuf.st_size != 0) { - if (fgetc(fp) == EOF) - log_error(USE_ERRNO, "can't read %s", sudoers); - rewind(fp); + if (statbuf.st_size != 0 && fgetc(fp) == EOF) { + log_error(USE_ERRNO|NO_EXIT, "can't read %s", sudoers); + fclose(fp); + fp = NULL; } + } + + if (fp != NULL) { + rewind(fp); (void) fcntl(fileno(fp), F_SETFD, 1); }