/home/user owned by user, user starts in cwd /home/user

This commit is contained in:
2026-02-23 23:05:13 -06:00
parent b015d5880a
commit a6d2f6dca7
11 changed files with 199 additions and 46 deletions

View File

@@ -95,14 +95,20 @@ end
local function chownPath(path)
local stat = syscall.stat(path)
if not stat then
print(name .. ": cannot stat '" .. path .. "': No such file or directory")
print(name .. ": cannot stat '" .. path .. "': no such file or directory")
return false
end
local uid = newUid ~= nil and newUid or stat.owner
local gid = newGid ~= nil and newGid or stat.group
local ok, err = pcall(syscall.chown, path, uid, gid)
if not ok then
print(name .. ": cannot change owner of '" .. path .. "': " .. tostring(err))
local msg = tostring(err)
if msg:find("EPERM") or msg:find("EACCES") then
msg = "operation not permitted (must be root)"
elseif msg:find("ENOENT") then
msg = "no such file or directory"
end
print(name .. ": cannot change owner of '" .. path .. "': " .. msg)
return false
end
return true