Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local ID,root
- if args[1] then
- ID = tonumber(args[1])
- root = ("/"..ID)
- else
- return -- exits program :P
- end
- oldID = os.getComputerID()
- oldPath = shell.path()
- OldGID = os.getComputerID
- if type(ID) ~= "number" then
- print("Please use proper arguments, EX: Simulate <ID>")
- return
- end
- function os.getComputerID()
- return ID
- end
- if not fs.exists("/"..ID) then
- fs.makeDir("/"..ID)
- end
- shell.setPath("/EmuRom/programs")
- shell.setDir(root)
- local oldSet = shell.setDir
- local resolve = shell.resolve
- local oldRun = shell.run
- function exit()
- shell.setDir = oldSet
- shell.run = oldRun
- end
- function shell.setDir(toDir)
- --shell.setDir = oldSet
- local absolute = resolve(toDir)
- local lastc = fs.getName(absolute)
- if absolute == "/" or absolute:match("(.+/)") ~= ID then
- printError("Attempt to leave sandbox")
- return
- end
- --[[if lastc=="root" or lastc=="EmuRom" then
- printError("Attempt to leave sandbox")
- return
- end]]--
- return oldSet(toDir)
- end
- function shell.run(prog,...)
- if shell.resolveProgram(prog) == shell.resolveProgram("shell") or shell.resolveProgram(prog) == shell.resolveProgram("/rom/programs/shell") then
- printError("Attempt to leave sandbox")
- return
- end
- return oldRun(prog,...)
- end
Add Comment
Please, Sign In to add comment