2 Commits
Author SHA1 Message Date
spsf 93c3bab263 allow hypervisor to kill non-owned processes 2026-02-21 14:09:12 -05:00
spsf 5bd16b8fd4 su kill error handling 2026-02-21 14:07:35 -05:00
2 changed files with 7 additions and 13 deletions
+7 -4
View File
@@ -1,6 +1,5 @@
--:Minify:--
local fs = require("sys.fs")
local targetUser = ({ ... })[1] or "root"
local currentUid = syscall.getuid()
@@ -72,6 +71,10 @@ if not shellFn then
return
end
syscall.kill(syscall.getppid())
syscall.spawn(shellFn, targetUser .. ":" .. shell, syscall.getEnviron())
syscall.exit(0)
local success, err = syscall.kill(syscall.getppid())
if success then
syscall.spawn(shellFn, targetUser .. ":" .. shell, syscall.getEnviron())
syscall.exit(0)
else
print("su: "..err)
end
@@ -129,9 +129,6 @@ function sys.kill(pid)
if not tasks[tostring(pid)] then
return false, "Task does not exist"
elseif not isEqualToAny(tasks[tostring(pid)].pid, table.unpack(children)) and kernel.uid ~= 0 then
return false, "You do not own this task"
elseif tasks[tostring(pid)].status == "Z" then
return false, "Task is already dead"
@@ -148,9 +145,6 @@ function sys.stop(pid)
if not tasks[tostring(pid)] then
return false, "Task does not exist"
elseif not isEqualToAny(tasks[tostring(pid)].pid, table.unpack(children)) and kernel.uid ~= 0 then
return false, "You do not own this task"
elseif tasks[tostring(pid)].status ~= "R" then
return false, "Cannot stop non running task"
@@ -166,9 +160,6 @@ function sys.continue(pid)
if not tasks[tostring(pid)] then
return false, "Task does not exist"
elseif not isEqualToAny(tasks[tostring(pid)].pid, table.unpack(children)) and kernel.uid ~= 0 then
return false, "You do not own this task"
elseif tasks[tostring(pid)].status ~= "T" then
return false, "Task is not stopped"