local function wrapProgram( path )
if runningProgram and coroutine.status( runningProgram ) == "suspended" then
error("Thread already running on Stage.", 2)
end
if not path or type( path ) ~= "string" then
error("new.runProgram: Expected: path String")
end
local func = false
if getfenv and setfenv and type( getfenv ) == "function" and type( setfenv ) == "function" then
local result, err = loadfile( path )
if not result then
if err then
error("new.runProgram: "..tostring( err ))
else
error("new.runProgram: Error while loading file.")
end
elseif result then
func = result
setfenv( func, sandbox )
end
if func then
runningProgram = coroutine.create(func)
pgPath = path
else
error("new.runProgram: Could not load file")
end
end
end
The coroutine created is run by a loop elsewhere, which isn't super important. My problem is this:
Say that the "path" is to a file that loads an API, and this API prints and effects the terminal, my sandbox prevents the path file from doing this, although the API simply bypasses it. This is both a huge security problem and means people running their program using my sandbox cannot use APIs, which is crazy.
Example:
--# file loaded
print("hey") --# blocked
os.loadAPI("myPrintingAPI")
myPrintingAPI.prnit("hey") --# is NOT blocked.
--# I need ANY and ALL attempts to draw to the screen to be captured so my framework can process them.
Some help with this would be great, it appears I would need to set the functions in the global space which raises heaps of other problems, because this is object oriented and each stage needs the functions object set, setting the functions in the global space gets messy pretty quick and can probably be overridden (maybe? I dont really know)… setfenv doesn't seem to affect loaded APIs at all.
Thanks in advance!