]> granicus.if.org Git - sudo/commitdiff
Restore old behavior where visudo prevents you from making the main
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 27 May 2015 19:34:28 +0000 (13:34 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 27 May 2015 19:34:28 +0000 (13:34 -0600)
sudoers file zero length.

plugins/sudoers/visudo.c

index 2f65f2c31f396be74c45f18d556173443ddee647..b2e2839963d0b4b7f7b13b420e772b83d3c20f19 100644 (file)
@@ -451,10 +451,12 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
            goto done;
        }
        if (sb.st_size == 0 && orig_size != 0) {
-           sudo_warnx(U_("zero length temporary file (%s), %s unchanged"),
-               sp->tpath, sp->path);
-           sp->modified = true;
-           goto done;
+           /* Avoid accidental zeroing of main sudoers file. */
+           if (sp == TAILQ_FIRST(&sudoerslist)) {
+               sudo_warnx(U_("zero length temporary file (%s), %s unchanged"),
+                   sp->tpath, sp->path);
+               goto done;
+           }
        }
     } else {
        sudo_warnx(U_("editor (%s) failed, %s unchanged"), editor, sp->path);