From 36d7cd10ee9c62c5b152a2e39baf67da0fb64bae Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 31 Jul 2017 05:04:23 -0400 Subject: [PATCH] telnetd-diag: add 'send' to 'exec' interp. scope --- telnetd/telnetd-diag.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telnetd/telnetd-diag.lua b/telnetd/telnetd-diag.lua index ec51612..e3b238f 100644 --- a/telnetd/telnetd-diag.lua +++ b/telnetd/telnetd-diag.lua @@ -6,6 +6,10 @@ return { ["fifo"] = function(_,s) if rtcfifo and rtcfifo.ready() ~= 0 then s(string.format("fifo=%d",rtcfifo.count())) else s("no rtcfifo") end end, ["exec"] = function(l,s) local f, err = loadstring(l) - if f then local ok, res = pcall(f); if ok == true then s("ok: "..tostring(res)) else s("pcall err: "..res) end - else s("err: "..err) end end + if f + then getfenv(f).send = function(x) s(tostring(x)) end + local ok, res = pcall(f); if ok then s("ok: "..tostring(res)) else s("pcall err: "..res) end + else s("err: "..err) + end + end } -- 2.50.1