/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

@@ -64,12 +64,18 @@ local newGid = resolveGid(groupStr)
local function chgrpPath(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 ok, err = pcall(syscall.chown, path, stat.owner, newGid)
if not ok then
print(name .. ": cannot change group 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 group of '" .. path .. "': " .. msg)
return false
end
return true