From: Jeremy Stanley Date: Fri, 9 Oct 2020 16:55:20 +0000 (+0000) Subject: Move debug warning from setup to load X-Git-Tag: 0.4.0~21 X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=d204f90b0f863b764d878bc230b3ebf03b14a4fc;p=mudpy.git Move debug warning from setup to load Relocate the warning logged about debug mode from the misc.setup() function to the Universe class load() method. This way, if debug mode is enabled in configuration during a live reload event, it will be logged. Also update the admin documentation to reflect that enabling or disabling debug can be done with a reload, not only a restart. Correct a minor spacing error in the configuration docs too. --- diff --git a/doc/source/admin.rst b/doc/source/admin.rst index 3ece3f7..b5cd800 100644 --- a/doc/source/admin.rst +++ b/doc/source/admin.rst @@ -95,7 +95,7 @@ a command handler with limited Python :code:`__builtins__`, the and also blocks evaluation of any statement containing double-underscores (:code:`__`) as well as :code:`lambda` functions. For admins to gain access to unsafe debugging commands, the ``.mudpy.limit.debug`` option must be -enabled in configuration first and the service completely restarted. It +enabled in configuration first and the service reloaded or restarted. It should still be considered unsafe, since the engine's file handling functions could easily alter accessible files or expressions like ``9**9**9`` could be used to hang the service for indeterminate periods. diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 2ced5c2..fbde003 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -176,7 +176,7 @@ Whether unsafe debugging functionality is enabled. If unspecified or set to false, unsafe debugging functions will be disabled. Be very careful enabling this feature, as debugging commands may allow service administrators to run arbitrary shell commands or modify files -accessible to the system user underwhich the service is running. +accessible to the system user under which the service is running. Example:: diff --git a/mudpy/misc.py b/mudpy/misc.py index 86e4b9d..df17211 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -405,6 +405,11 @@ class Universe: element.update_location() element.clean_contents() + # warn when debug mode has been engaged + if self.debug_mode(): + pending_loglines.append(( + "WARNING: Unsafe debugging mode is enabled!", 6)) + # done loading, so disallow updating elements from read-only files self.loading = False @@ -2118,8 +2123,6 @@ def setup(): log("Running version: %s" % universe.versions.version, 1) log("Initial directory: %s" % universe.startdir, 1) log("Command line: %s" % " ".join(sys.argv), 1) - if universe.debug_mode(): - log("WARNING: Unsafe debugging mode is enabled!", 6) # pass the initialized universe back return universe