aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-08-11 14:55:59 +0200
committerKim Alvefur <zash@zash.se>2021-08-11 14:55:59 +0200
commitd6122ce3a54ca33b519640746d64e1711ef4cebb (patch)
treef07042c1417169cf8530a63f1e1b73828487f02b
parent9dd9cb43927a6d29e4df1c857b80ff3475410b3d (diff)
downloadprosody-d6122ce3a54ca33b519640746d64e1711ef4cebb.tar.gz
prosody-d6122ce3a54ca33b519640746d64e1711ef4cebb.zip
mod_admin_shell: Keep unrestricted environment for session lifetime
Makes it so that global values set in the environment are kept longer than within one line, and thus can be used until the session ends. They still don't pollute the global environment, which is an error anyway. Thanks phryk for noticing.
-rw-r--r--plugins/mod_admin_shell.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index 3b1ce277..bab5c4b2 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -135,8 +135,12 @@ local function handle_line(event)
return;
end
+ if useglobalenv and not session.globalenv then
+ session.globalenv = redirect_output(_G, session);
+ end
+
local chunkname = "=console";
- local env = (useglobalenv and redirect_output(_G, session)) or session.env or nil
+ local env = (useglobalenv and session.globalenv) or session.env or nil
-- luacheck: ignore 311/err
local chunk, err = envload("return "..line, chunkname, env);
if not chunk then