nuageinit: Replace os.execute with Lua libraries
Prefer posix.sys.stat's chmod() to os.execute(). While here, change the name of the locals to be more descriptive. Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
This commit is contained in:
committed by
Baptiste Daroussin
parent
d71e2c037c
commit
9b2d92addc
@@ -3,8 +3,9 @@
|
||||
--
|
||||
-- Copyright(c) 2022 Baptiste Daroussin <bapt@FreeBSD.org>
|
||||
|
||||
local unistd = require("posix.unistd")
|
||||
local sys_stat = require("posix.sys.stat")
|
||||
local lfs = require("lfs")
|
||||
local pu = require("posix.unistd")
|
||||
|
||||
local function warnmsg(str)
|
||||
io.stderr:write(str .. "\n")
|
||||
@@ -206,12 +207,12 @@ local function addsshkey(homedir, key)
|
||||
f:write(key .. "\n")
|
||||
f:close()
|
||||
if chownak then
|
||||
os.execute("chmod 0600 " .. ak_path)
|
||||
pu.chown(ak_path, dirattrs.uid, dirattrs.gid)
|
||||
sys_stat.chmod(ak_path, 384)
|
||||
unistd.chown(ak_path, dirattrs.uid, dirattrs.gid)
|
||||
end
|
||||
if chowndotssh then
|
||||
os.execute("chmod 0700 " .. dotssh_path)
|
||||
pu.chown(dotssh_path, dirattrs.uid, dirattrs.gid)
|
||||
sys_stat.chmod(dotssh_path, 448)
|
||||
unistd.chown(dotssh_path, dirattrs.uid, dirattrs.gid)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user