]> granicus.if.org Git - sudo/commitdiff
deal with case where there is no sudoers file
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 30 Oct 1996 23:04:02 +0000 (23:04 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 30 Oct 1996 23:04:02 +0000 (23:04 +0000)
visudo.c

index 1425e945ff4b95be9ba73924692cad748bbbfee4..a1618dea78cbb2cd356bce0d1ed19dca1447403a 100644 (file)
--- 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);
 
     /*