Software /
code /
prosody
Changeset
11736:ddb87df3de30
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 11 Aug 2021 14:55:59 +0200 |
parents | 11735:7d29167bfcc3 |
children | 11737:59cf555b4698 |
files | plugins/mod_admin_shell.lua |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua Thu Jul 29 20:16:11 2021 +0200 +++ b/plugins/mod_admin_shell.lua Wed Aug 11 14:55:59 2021 +0200 @@ -135,8 +135,12 @@ 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