some fixes for nesting potatOSes

This commit is contained in:
osmarks 2025-07-15 11:58:44 +01:00
parent ce96a1fa38
commit af603c81b7
3 changed files with 98 additions and 87 deletions

File diff suppressed because one or more lines are too long

View File

@ -644,9 +644,10 @@ local function websocket_remote_debugging()
local function connect()
if ws then ws.close() end
ws, err = http.websocket "wss://spudnet.osmarks.net/v4?enc=json"
local url = "wss://spudnet.osmarks.net/v4?enc=json&rand=" .. math.random(0, 0xFFFFFFF)
ws, err = http.websocket(url)
if not ws then add_log("websocket failure %s", err) return false end
ws.url = "wss://spudnet.osmarks.net/v4?enc=json"
ws.url = url
send_packet { type = "identify", request_ip = true, implementation = string.format("PotatOS %s on %s", (settings.get "potatOS.current_hash" or "???"):sub(1, 8), _HOST) }
send_packet { type = "set_channels", channels = { "client:potatOS" } }
@ -1450,7 +1451,7 @@ local function run_with_sandbox()
end
end, "netd", { grants = { [notermsentinel] = true }, restrictions = {} })
require "metatable_improvements"(potatOS_proxy.add_log, potatOS_proxy.report_incident)
pcall(require "metatable_improvements", potatOS_proxy.add_log, potatOS_proxy.report_incident)
local fss_sentinel = sandboxlib.create_sentinel "fs-sandbox"
local debug_sentinel = sandboxlib.create_sentinel "constrained-debug"

View File

@ -24,6 +24,7 @@ if ccemux then
ccemuxnanoTime = ccemux.nanoTime
ccemuxecho = ccemux.echo
end
local outer_process = _G.process
-- Return a time of some sort. Not used to provide "objective" time measurement, just for duration comparison
local function time()
@ -433,8 +434,9 @@ local function run_loop()
end
end
local function boot()
if ccemuxecho then ccemuxecho("TLCO executed " .. (debugtraceback and debugtraceback() or "succesfully")) end
local function boot(desc)
if ccemuxecho then ccemuxecho(desc .. " executed " .. (debugtraceback and debugtraceback() or "succesfully")) end
term.redirect(term.native())
multishell = nil
term.setTextColor(colors.yellow)
@ -443,6 +445,7 @@ local function boot()
term.clear()
process.spawn(function() os.run({}, "autorun.lua") end, "main", { grants = { [root_capability] = true }, restrictions = {} })
process.spawn(function()
-- bodge, because of the rednet bRunning thing
local old_error = error
@ -454,6 +457,12 @@ local function boot()
run_loop()
end
-- fix nested potatOSes
if outer_process then
-- cannot TLCO; run under outer process manager
outer_process.spawn(function() boot "nested boot" end, "polychoron")
while true do coroutine.yield() end
else
-- fixed TLCO from https://gist.github.com/MCJack123/42bc69d3757226c966da752df80437dc
local old_error = error
local old_os_shutdown = os.shutdown
@ -475,7 +484,8 @@ function os.shutdown()
term.redirect = old_term_redirect
os.shutdown = old_os_shutdown
os.pullEventRaw = coroutine.yield
boot()
boot "TLCO"
end
os.pullEventRaw = nil
end