From: Todd C. Miller Date: Wed, 27 May 2015 19:34:28 +0000 (-0600) Subject: Restore old behavior where visudo prevents you from making the main X-Git-Tag: SUDO_1_8_14^2~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21f5753b7daf348d8ef4b57c208fd8c6e7cf996c;p=sudo Restore old behavior where visudo prevents you from making the main sudoers file zero length. --- diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 2f65f2c31..b2e283996 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -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);