summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/luat-exe.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/luat-exe.lua')
-rw-r--r--tex/context/base/mkiv/luat-exe.lua129
1 files changed, 89 insertions, 40 deletions
diff --git a/tex/context/base/mkiv/luat-exe.lua b/tex/context/base/mkiv/luat-exe.lua
index d8d954a30..db06c63cb 100644
--- a/tex/context/base/mkiv/luat-exe.lua
+++ b/tex/context/base/mkiv/luat-exe.lua
@@ -8,66 +8,115 @@ if not modules then modules = { } end modules ['luat-exe'] = {
if not sandbox then require("l-sandbox") require("util-sbx") end -- for testing
+-- Ok, as usual, after finishing some code, I rewarded myself with searching youtube for
+-- new music ... this time I ran into the swedisch group 'wintergatan' (search for: marble
+-- machine) ... mechanical computers are so much more fun than the ones needed for running
+-- the code below. Nice videos (and shows) too ...
+
local type = type
-local executers = resolvers.executers or { }
-resolvers.executers = executers
+local executers = resolvers.executers or { }
+resolvers.executers = executers
-local disablerunners = sandbox.disablerunners
-local registerbinary = sandbox.registerbinary
-local registerroot = sandbox.registerroot
+local disablerunners = sandbox.disablerunners
+local disablelibraries = sandbox.disablelibraries
+local registerbinary = sandbox.registerbinary
+local registerlibrary = sandbox.registerlibrary
+local registerroot = sandbox.registerroot
-local lpegmatch = lpeg.match
+local lpegmatch = lpeg.match
-local sc_splitter = lpeg.tsplitat(";")
-local cm_splitter = lpeg.tsplitat(",")
+local sc_splitter = lpeg.tsplitat(";")
+local cm_splitter = lpeg.tsplitat(",")
local execution_mode directives.register("system.executionmode", function(v) execution_mode = v end)
local execution_list directives.register("system.executionlist", function(v) execution_list = v end)
local root_list directives.register("system.rootlist", function(v) root_list = v end)
+local library_mode directives.register("system.librarymode", function(v) library_mode = v end)
+local library_list directives.register("system.librarylist", function(v) library_list = v end)
-sandbox.initializer(function()
- if execution_mode == "none" then
- -- will be done later
- elseif execution_mode == "list" then
- if type(execution_list) == "string" then
- execution_list = lpegmatch(cm_splitter,execution_list)
- end
- if type(execution_list) == "table" then
- for i=1,#execution_list do
- registerbinary(execution_list[i])
+sandbox.initializer {
+ category = "binaries",
+ action = function()
+ if execution_mode == "none" then
+ -- will be done later
+ elseif execution_mode == "list" then
+ if type(execution_list) == "string" then
+ execution_list = lpegmatch(cm_splitter,execution_list)
+ end
+ if type(execution_list) == "table" then
+ for i=1,#execution_list do
+ registerbinary(execution_list[i])
+ end
end
+ else
+ registerbinary(true) -- all
end
- else
- -- whatever else we have configured
end
-end)
+}
-sandbox.initializer(function()
- if type(root_list) == "string" then
- root_list = lpegmatch(sc_splitter,root_list)
+sandbox.finalizer {
+ category = "binaries",
+ action = function()
+ if execution_mode == "none" then
+ disablerunners()
+ end
end
- if type(root_list) == "table" then
- for i=1,#root_list do
- local entry = root_list[i]
- if entry ~= "" then
- registerroot(entry)
+}
+
+sandbox.initializer {
+ category = "libraries",
+ action = function()
+ if library_mode == "none" then
+ -- will be done later
+ elseif library_mode == "list" then
+ if type(library_list) == "string" then
+ library_list = lpegmatch(cm_splitter,library_list)
+ end
+ if type(library_list) == "table" then
+ for i=1,#library_list do
+ registerlibrary(library_list[i])
+ end
end
+ else
+ registerlibrary(true) -- all
+ end
+ end
+}
+
+sandbox.finalizer {
+ category = "libraries",
+ action = function()
+ if library_mode == "none" then
+ disablelibraries()
end
end
-end)
+}
-sandbox.finalizer(function()
- if execution_mode == "none" then
- disablerunners()
+-- A bit of file system protection.
+
+sandbox.initializer{
+ category = "files",
+ action = function ()
+ if type(root_list) == "string" then
+ root_list = lpegmatch(sc_splitter,root_list)
+ end
+ if type(root_list) == "table" then
+ for i=1,#root_list do
+ registerroot(root_list[i])
+ end
+ end
end
-end)
+}
-- Let's prevent abuse of these libraries (built-in support still works).
-sandbox.finalizer(function()
- mplib = nil
- epdf = nil
- zip = nil
- fontloader = nil
-end)
+sandbox.finalizer {
+ category = "functions",
+ action = function()
+ mplib = nil
+ epdf = nil
+ zip = nil
+ fontloader = nil
+ end
+}