files: do not make a failsafe backup when in restricted mode

When in restricted mode, nano should not write to any other file
than to the ones mentioned on the command line.
master
Benno Schulenberg 2020-07-14 15:19:50 +02:00
parent bde8858a3a
commit 65321f9234
2 changed files with 2 additions and 2 deletions

2
NEWS
View File

@ -1,4 +1,4 @@
2020.05.23 - GNU nano 4.9.3 "Almendras"
s2020.05.23 - GNU nano 4.9.3 "Almendras"
• One more bug introduced in version 4.9 is fixed: a crash when
the terminal screen is resized while at a lock-file prompt.

View File

@ -1797,7 +1797,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* When the user requested a backup, we do this only if the file exists and
* isn't temporary AND the file has not been modified by someone else since
* we opened it (or we are appending/prepending or writing a selection). */
if (is_existing_file && openfile->statinfo &&
if (is_existing_file && !ISSET(RESTRICTED) && openfile->statinfo &&
(openfile->statinfo->st_mtime == st.st_mtime ||
method != OVERWRITE || openfile->mark)) {
if (!backup_file(realname, &backupname))