nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] startup: allow reading nanorc in restricted mode, t


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] startup: allow reading nanorc in restricted mode, to permit customization
Date: Thu, 27 Sep 2018 20:04:24 +0200

Move the unsetting of some options further down, to prevent the user's
nanorc enabling things that are not permitted in restricted mode.

Also, in restricted mode, suppress error messages about functions not
being present in the requested menus, so that a nanorc that is valid in
normal mode does not cause unnecessary messages when using --restricted.

This fulfills https://savannah.gnu.org/bugs/?54732.
---
 src/nano.c   | 24 +++++++++++-------------
 src/rcfile.c |  4 +++-
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index d5f195e1..3b8493bf 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2312,19 +2312,6 @@ int main(int argc, char **argv)
                }
        }
 
-       /* If we're using restricted mode, disable suspending, backups,
-        * rcfiles, and history files, since they all would allow reading
-        * from or writing to files not specified on the command line. */
-       if (ISSET(RESTRICTED)) {
-               UNSET(SUSPEND);
-               UNSET(BACKUP_FILE);
-#ifdef ENABLE_NANORC
-               no_rcfiles = TRUE;
-               UNSET(HISTORYLOG);
-               UNSET(POS_HISTORY);
-#endif
-       }
-
        /* Set up the function and shortcut lists.  This needs to be done
         * before reading the rcfile, to be able to rebind/unbind keys. */
        shortcut_init();
@@ -2434,6 +2421,17 @@ int main(int argc, char **argv)
        if (ISSET(BOLD_TEXT))
                hilite_attribute = A_BOLD;
 
+       /* When in restricted mode, disable backups, suspending, and history 
files,
+        * since they allow writing to files not specified on the command line. 
*/
+       if (ISSET(RESTRICTED)) {
+               UNSET(BACKUP_FILE);
+               UNSET(SUSPEND);
+#ifdef ENABLE_NANORC
+               UNSET(HISTORYLOG);
+               UNSET(POS_HISTORY);
+#endif
+       }
+
 #ifdef ENABLE_HISTORIES
        /* Initialize the pointers for the Search/Replace/Execute histories. */
        history_init();
diff --git a/src/rcfile.c b/src/rcfile.c
index 6a226d16..75f085f0 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -451,7 +451,9 @@ void parse_binding(char *ptr, bool dobind)
                menu = menu & (is_universal(newsc->func) ? MMOST : mask);
 
                if (!menu) {
-                       rcfile_error(N_("Function '%s' does not exist in menu 
'%s'"), funcptr, menuptr);
+                       if (!ISSET(RESTRICTED))
+                               rcfile_error(N_("Function '%s' does not exist 
in menu '%s'"),
+                                                                       
funcptr, menuptr);
                        goto free_things;
                }
 
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]