visudo creates file even if editor is closed without saving
ReillyBrogan opened this issue · 1 comments
I noticed this when in the process of updating the Solus sudo package to 1.9.14p2.
If you run visudo /non-existant-file
and then exit without saving the file (for instance, in Nano using ctrl+x) the end result will be that visudo will create an empty /non-existant-file
.
This seems undesirable to me, perhaps the user simply misspelled a file name and exited to use a different file name. In that case they would not expect the misspelled file to be created.
Things can get a little complicated. For example, if you add a #include
line to sudoers, visudo must create the file, even if it is empty. Otherwise the file will not parse properly. The change I committed will prevent a new top-level sudoers file from being created via visudo if the editor is exited without writing any changes.