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);
}