From: Todd C. Miller Date: Wed, 30 Oct 1996 23:04:02 +0000 (+0000) Subject: deal with case where there is no sudoers file X-Git-Tag: SUDO_1_5_3~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b6e45e63979c8235ea9535280389a37d687a799;p=sudo deal with case where there is no sudoers file --- diff --git a/visudo.c b/visudo.c index 1425e945f..a1618dea7 100644 --- a/visudo.c +++ b/visudo.c @@ -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); /*