mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 21:05:08 +00:00
nuageinit: use pw(8) instead of getent(1)
pw(8) allows to seek for users in a custom rootdir, which makes it easier for a testsuite MFC After: 3 days
This commit is contained in:
parent
41dfea24ee
commit
83fcab792c
|
@ -72,7 +72,12 @@ local function adduser(pwd)
|
||||||
warnmsg("Argument should be a table")
|
warnmsg("Argument should be a table")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local f = io.popen("getent passwd "..pwd.name)
|
local root = os.getenv("NUAGE_FAKE_ROOTDIR")
|
||||||
|
local cmd = "pw "
|
||||||
|
if root then
|
||||||
|
cmd = cmd .. "-R " .. root .. " "
|
||||||
|
end
|
||||||
|
local f = io.popen(cmd .. " usershow " ..pwd.name .. " -7 2>/dev/null")
|
||||||
local pwdstr = f:read("*a")
|
local pwdstr = f:read("*a")
|
||||||
f:close()
|
f:close()
|
||||||
if pwdstr:len() ~= 0 then
|
if pwdstr:len() ~= 0 then
|
||||||
|
@ -109,8 +114,7 @@ local function adduser(pwd)
|
||||||
precmd = "echo "..pwd.plain_text_passwd .. "| "
|
precmd = "echo "..pwd.plain_text_passwd .. "| "
|
||||||
postcmd = " -H 0 "
|
postcmd = " -H 0 "
|
||||||
end
|
end
|
||||||
local root = os.getenv("NUAGE_FAKE_ROOTDIR")
|
cmd = precmd .. "pw "
|
||||||
local cmd = precmd .. "pw "
|
|
||||||
if root then
|
if root then
|
||||||
cmd = cmd .. "-R " .. root .. " "
|
cmd = cmd .. "-R " .. root .. " "
|
||||||
end
|
end
|
||||||
|
@ -140,7 +144,12 @@ local function addgroup(grp)
|
||||||
warnmsg("Argument should be a table")
|
warnmsg("Argument should be a table")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local f = io.popen("getent group "..grp.name)
|
local root = os.getenv("NUAGE_FAKE_ROOTDIR")
|
||||||
|
local cmd = "pw "
|
||||||
|
if root then
|
||||||
|
cmd = cmd .. "-R " .. root .. " "
|
||||||
|
end
|
||||||
|
local f = io.popen(cmd .. " groupshow " ..grp.name .. " 2>/dev/null")
|
||||||
local grpstr = f:read("*a")
|
local grpstr = f:read("*a")
|
||||||
f:close()
|
f:close()
|
||||||
if grpstr:len() ~= 0 then
|
if grpstr:len() ~= 0 then
|
||||||
|
@ -151,8 +160,7 @@ local function addgroup(grp)
|
||||||
local list = splitlist(grp.members)
|
local list = splitlist(grp.members)
|
||||||
extraargs = " -M " .. table.concat(list, ',')
|
extraargs = " -M " .. table.concat(list, ',')
|
||||||
end
|
end
|
||||||
local root = os.getenv("NUAGE_FAKE_ROOTDIR")
|
cmd = "pw "
|
||||||
local cmd = "pw "
|
|
||||||
if root then
|
if root then
|
||||||
cmd = cmd .. "-R " .. root .. " "
|
cmd = cmd .. "-R " .. root .. " "
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue