nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 689748843cef6bd39175c95a836f0d626ccb18ff
parent ea07eb6aa3320001665faf9913728ddb66a43196
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat,  1 Jun 2024 11:08:48 +0200

files: with --rectrict, prevent invoking the browser and toggling backups

Prevent also the toggling of Append and Prepend.  All four functions
should not be available in restricted mode, and are absent from the
WriteOut menu in that mode, but using {browser}, {backup}, {append}
or {prepend} in a string bind allowed to bypass the menu checks.

This fixes https://savannah.gnu.org/bugs/?65819.

Problem existed since version 7.0, since braced function names
were introduced.

Diffstat:
Msrc/files.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -2196,7 +2196,7 @@ int write_it_out(bool exiting, bool withprompt) given = mallocstrcpy(given, answer); #ifdef ENABLE_BROWSER - if (function == to_files) { + if (function == to_files && !ISSET(RESTRICTED)) { char *chosen = browse_in(answer); if (chosen == NULL) @@ -2213,10 +2213,10 @@ int write_it_out(bool exiting, bool withprompt) } else if (function == mac_format) { openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE : MAC_FILE; continue; - } else if (function == back_it_up) { + } else if (function == back_it_up && !ISSET(RESTRICTED)) { TOGGLE(MAKE_BACKUP); continue; - } else if (function == prepend_it || function == append_it) { + } else if ((function == prepend_it || function == append_it) && !ISSET(RESTRICTED)) { if (function == prepend_it) method = (method == PREPEND) ? OVERWRITE : PREPEND; else