summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2009-01-09 00:14:52 +0000
committermillert <millert@openbsd.org>2009-01-09 00:14:52 +0000
commit2efc9a3c7aa6a1fdee100380ad6f7e1e1300a6fe (patch)
tree9ed4d4400589c16b81ad9c2a06bfd71e9144fe34
parentFile removed by miod seven month ago. -moj (diff)
downloadwireguard-openbsd-2efc9a3c7aa6a1fdee100380ad6f7e1e1300a6fe.tar.xz
wireguard-openbsd-2efc9a3c7aa6a1fdee100380ad6f7e1e1300a6fe.zip
Do not try to set the close on exec flag if we didn't actually open sudoers.
Fixes a crash when sudoers owenership is wrong found by thib@
-rw-r--r--usr.bin/sudo/sudo.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/sudo/sudo.c b/usr.bin/sudo/sudo.c
index 7191ee14a68..5fe8009993b 100644
--- a/usr.bin/sudo/sudo.c
+++ b/usr.bin/sudo/sudo.c
@@ -102,7 +102,7 @@
#include "version.h"
#ifndef lint
-__unused static const char rcsid[] = "$Sudo: sudo.c,v 1.500 2008/11/18 15:57:09 millert Exp $";
+__unused static const char rcsid[] = "$Sudo: sudo.c,v 1.501 2009/01/09 00:13:37 millert Exp $";
#endif /* lint */
/*
@@ -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);