added setuid syscall

This commit is contained in:
2026-01-30 18:47:37 -05:00
parent cb73f49962
commit c9ac447484
3 changed files with 11 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ for i,v in ipairs(files) do
kernel.log("Error loading startup script '" .. filepath .. "': " .. err, "ERROR") kernel.log("Error loading startup script '" .. filepath .. "': " .. err, "ERROR")
else else
syscall.spawn(function() syscall.spawn(function()
syscall.setuid(1)
syscall.IO_bind("eventQueue:"..tostring(i)) syscall.IO_bind("eventQueue:"..tostring(i))
local spot = #eventQueues+1 local spot = #eventQueues+1
eventQueues[spot]="eventQueue:"..tostring(i) eventQueues[spot]="eventQueue:"..tostring(i)

View File

@@ -207,6 +207,11 @@ function sys.exit(code)
end end
end end
function sys.setuid(uid)
if kernel.uid~=0 then error("EACCES") end
kernel.currentTask.uid=uid
end
local sysc=kernel.syscalls local sysc=kernel.syscalls
sysc["spawn"]=sys.spawn sysc["spawn"]=sys.spawn
sysc["sleep"]=sys.sleep sysc["sleep"]=sys.sleep
@@ -221,6 +226,7 @@ sysc["getTasks"]=sys.getTasks
sysc["setEnviron"]=sys.setEnviron sysc["setEnviron"]=sys.setEnviron
sysc["getEnviron"]=sys.getEnviron sysc["getEnviron"]=sys.getEnviron
sysc["exit"]=sys.exit sysc["exit"]=sys.exit
sysc["setuid"]=sys.setuid
kernel._G.sleep=function(...)coroutine.yield("syscall","sleep",...)end kernel._G.sleep=function(...)coroutine.yield("syscall","sleep",...)end
local function reapDeadTasks() local function reapDeadTasks()
@@ -291,7 +297,6 @@ function kernel.main()
end end
if task.status == "R" then if task.status == "R" then
kernel.currentTask = task kernel.currentTask = task
kernel.vfs.cwd = task.cwd
kernel.user = task.user kernel.user = task.user
kernel.uid = task.uid kernel.uid = task.uid
kernel.process = task.name kernel.process = task.name

View File

@@ -22,8 +22,11 @@ preempt<bool>
enable/disable preemptive multitasking enable/disable preemptive multitasking
debugSyscalls<bool> debugSyscalls<bool>
logs syscalls and thier return values aswell as what task executed them logs syscalls and their return values aswell as what task executed them
logTaskExit<bool> logTaskExit<bool>
logs task exits and errors logs task exits and errors
showModLoad<bool>
log mofule loads
``` ```