aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/factoid/sandbox.lua
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2019-07-06 03:39:02 +0200
committerJokler <jokler.contact@gmail.com>2019-07-06 03:39:02 +0200
commit4b95d4541b9e16c5e351eddaf1b0e883ed06c59d (patch)
treed1dcd1317218f0242af5f1c2de8808e5fa5fff00 /src/plugins/factoid/sandbox.lua
parent9e427d9063a5d0180b8acc8705c3c2d7b0c01bcc (diff)
downloadfrippy-4b95d4541b9e16c5e351eddaf1b0e883ed06c59d.tar.gz
frippy-4b95d4541b9e16c5e351eddaf1b0e883ed06c59d.zip
Factoid: Move sandbox hooks to rust & drop unsafe
Diffstat (limited to 'src/plugins/factoid/sandbox.lua')
-rw-r--r--src/plugins/factoid/sandbox.lua27
1 files changed, 0 insertions, 27 deletions
diff --git a/src/plugins/factoid/sandbox.lua b/src/plugins/factoid/sandbox.lua
index a927535..108a30d 100644
--- a/src/plugins/factoid/sandbox.lua
+++ b/src/plugins/factoid/sandbox.lua
@@ -90,35 +90,8 @@ end
sandbox_env.eval = eval
sandbox_env.sleep = safesleep
--- Check if the factoid timed out
-function checktime()
- if os.time() - time >= timeout then
- error("Timed out after " .. timeout .. " seconds", 0)
- else
- -- Limit the cpu usage of factoids
- sleep(1)
- end
-end
-
--- Check if the factoid uses too much memory
-function checkmem()
- if collectgarbage("count") > maxmem then
- error("Factoid used over " .. maxmem .. " kbyte of ram")
- end
-end
-
local f, e = load(factoid, nil, nil, sandbox_env)
--- Add timeout hook
-time = os.time()
--- The timeout is defined in seconds
-timeout = 30
-debug.sethook(checktime, "l")
--- Add memory check hook
--- The max memory is defined in kilobytes
-maxmem = 1000
-debug.sethook(checkmem, "l")
-
if f then
f()
else