summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-30 23:10:26 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-30 23:10:26 +0000
commit5cfff08875198e5dd842dd3e21bcdd704e8399eb (patch)
tree0873034da2cac4ff7f34965820ce757cb4dec4fd /gnu
parent072b56c97e17e8e69ddab5a735b5297387a88a70 (diff)
deal with case where there is no sudoers file--pointed out by downsj
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/sudo/visudo/visudo.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gnu/usr.bin/sudo/visudo/visudo.c b/gnu/usr.bin/sudo/visudo/visudo.c
index 85099e75715..55202a64925 100644
--- a/gnu/usr.bin/sudo/visudo/visudo.c
+++ b/gnu/usr.bin/sudo/visudo/visudo.c
@@ -26,7 +26,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: visudo.c,v 1.1 1996/10/14 05:14:58 millert Exp $";
+static char rcsid[] = "$Id: visudo.c,v 1.2 1996/10/30 23:10:25 millert Exp $";
#endif /* lint */
#include "config.h"
@@ -187,7 +187,7 @@ int main(argc, argv)
setup_signals();
sudoers_fd = open(sudoers, O_RDONLY);
- if (sudoers_fd < 0) {
+ if (sudoers_fd < 0 && errno != ENOENT) {
(void) fprintf(stderr, "%s: ", Argv[0]);
perror(sudoers);
Exit(1);
@@ -196,14 +196,16 @@ int main(argc, argv)
/*
* Copy the data
*/
- while ((n = read(sudoers_fd, buf, sizeof(buf))) > 0)
- if (write(stmp_fd, buf, n) != n) {
- (void) fprintf(stderr, "%s: Write failed: ", Argv[0]);
- perror("");
- Exit(1);
- }
+ if (sudoers_fd >= 0) {
+ while ((n = read(sudoers_fd, buf, sizeof(buf))) > 0)
+ if (write(stmp_fd, buf, n) != n) {
+ (void) fprintf(stderr, "%s: Write failed: ", Argv[0]);
+ perror("");
+ Exit(1);
+ }
- (void) close(sudoers_fd);
+ (void) close(sudoers_fd);
+ }
(void) close(stmp_fd);
/*