Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 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 |
parent | 10044:4fd27023224a |
child | 10068:73a8192058f9 |
comparison
equal
deleted
inserted
replaced
10066:216ae100c04a | 10067:598befab492e |
---|---|
112 end | 112 end |
113 end | 113 end |
114 | 114 |
115 session.env._ = line; | 115 session.env._ = line; |
116 | 116 |
117 if not useglobalenv and commands[line:lower()] then | |
118 commands[line:lower()](session, line); | |
119 return; | |
120 end | |
121 | |
117 local chunkname = "=console"; | 122 local chunkname = "=console"; |
118 local env = (useglobalenv and redirect_output(_G, session)) or session.env or nil | 123 local env = (useglobalenv and redirect_output(_G, session)) or session.env or nil |
119 local chunk, err = envload("return "..line, chunkname, env); | 124 local chunk, err = envload("return "..line, chunkname, env); |
120 if not chunk then | 125 if not chunk then |
121 chunk, err = envload(line, chunkname, env); | 126 chunk, err = envload(line, chunkname, env); |
127 return; | 132 return; |
128 end | 133 end |
129 end | 134 end |
130 | 135 |
131 local ranok, taskok, message = pcall(chunk); | 136 local ranok, taskok, message = pcall(chunk); |
132 | |
133 if not (ranok or message or useglobalenv) and commands[line:lower()] then | |
134 commands[line:lower()](session, line); | |
135 return; | |
136 end | |
137 | 137 |
138 if not ranok then | 138 if not ranok then |
139 session.print("Fatal error while running command, it did not complete"); | 139 session.print("Fatal error while running command, it did not complete"); |
140 session.print("Error: "..taskok); | 140 session.print("Error: "..taskok); |
141 return; | 141 return; |