mirror of
https://github.com/kepler155c/opus
synced 2025-10-23 19:57:39 +00:00
security update round 2
This commit is contained in:
@@ -1,68 +1,28 @@
|
||||
-- Loads the Opus environment regardless if the file system is local or not
|
||||
local fs = _G.fs
|
||||
local http = _G.http
|
||||
|
||||
_G.OPUS_BRANCH = 'develop-1.8'
|
||||
local GIT_REPO = 'kepler155c/opus/' .. _G.OPUS_BRANCH
|
||||
local BASE = 'https://raw.githubusercontent.com/' .. GIT_REPO
|
||||
local fs = _G.fs
|
||||
|
||||
local sandboxEnv = setmetatable({ }, { __index = _G })
|
||||
for k,v in pairs(_ENV) do
|
||||
sandboxEnv[k] = v
|
||||
end
|
||||
|
||||
_G._syslog = function() end
|
||||
|
||||
local function makeEnv()
|
||||
local function run(file, ...)
|
||||
local env = setmetatable({ }, { __index = _G })
|
||||
for k,v in pairs(sandboxEnv) do
|
||||
env[k] = v
|
||||
end
|
||||
return env
|
||||
end
|
||||
|
||||
local function run(file, ...)
|
||||
local s, m = loadfile(file, makeEnv())
|
||||
local s, m = loadfile(file, env)
|
||||
if s then
|
||||
return s(...)
|
||||
end
|
||||
error('Error loading ' .. file .. '\n' .. m)
|
||||
end
|
||||
|
||||
local function runUrl(file, ...)
|
||||
local url = BASE .. '/' .. file
|
||||
|
||||
local u = http.get(url)
|
||||
if u then
|
||||
local fn = load(u.readAll(), url, nil, makeEnv())
|
||||
u.close()
|
||||
if fn then
|
||||
return fn(...)
|
||||
end
|
||||
end
|
||||
error('Failed to download ' .. url)
|
||||
end
|
||||
_G._syslog = function() end
|
||||
_G.OPUS_BRANCH = 'develop-1.8'
|
||||
|
||||
-- Install require shim
|
||||
if fs.exists('sys/modules/opus/injector.lua') then
|
||||
_G.requireInjector = run('sys/modules/opus/injector.lua')
|
||||
else
|
||||
-- not local, run the file system directly from git
|
||||
if package and package.path then
|
||||
package.path = package.path .. ';' .. BASE .. '/sys/modules/opus'
|
||||
else
|
||||
sandboxEnv.package = {
|
||||
path = BASE .. '/sys/modules/opus'
|
||||
}
|
||||
end
|
||||
|
||||
_G.requireInjector = runUrl('sys/modules/opus/injector.lua')
|
||||
|
||||
runUrl('sys/init/2.vfs.lua')
|
||||
|
||||
-- install file system
|
||||
fs.mount('', 'gitfs', GIT_REPO)
|
||||
end
|
||||
_G.requireInjector = run('sys/modules/opus/injector.lua')
|
||||
|
||||
local s, m = pcall(run, 'sys/apps/shell.lua', 'sys/kernel.lua', ...)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user