/home/user owned by user, user starts in cwd /home/user
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user