Changeset

10067:598befab492e

mod_admin_telnet: Check for simple commands before executing in sandbox This makes fixing yield over pcall boundry issue easier since it would have jumped to the thread error handler instead of proceeding to checking for simple commands.
author Kim Alvefur <zash@zash.se>
date Fri, 10 May 2019 01:28:09 +0200
parents 10066:216ae100c04a
children 10068:73a8192058f9
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Tue Jul 09 15:12:32 2019 +0200
+++ b/plugins/mod_admin_telnet.lua	Fri May 10 01:28:09 2019 +0200
@@ -114,6 +114,11 @@
 
 	session.env._ = line;
 
+	if not useglobalenv and commands[line:lower()] then
+		commands[line:lower()](session, line);
+		return;
+	end
+
 	local chunkname = "=console";
 	local env = (useglobalenv and redirect_output(_G, session)) or session.env or nil
 	local chunk, err = envload("return "..line, chunkname, env);
@@ -130,11 +135,6 @@
 
 	local ranok, taskok, message = pcall(chunk);
 
-	if not (ranok or message or useglobalenv) and commands[line:lower()] then
-		commands[line:lower()](session, line);
-		return;
-	end
-
 	if not ranok then
 		session.print("Fatal error while running command, it did not complete");
 		session.print("Error: "..taskok);