git: 12e584c11e25 - stable/14 - nuageinit: use pw(8) instead of getent(1)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Jun 2024 08:57:43 UTC
The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=12e584c11e25d10ec86a1124b7d350f8a26b67db commit 12e584c11e25d10ec86a1124b7d350f8a26b67db Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2024-06-05 08:34:25 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2024-06-27 08:55:06 +0000 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 (cherry picked from commit 83fcab792c9d7f13f7e8bd73cf1850ba74f49341) --- libexec/nuageinit/nuage.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index 55486ae2b122..020b54b0776c 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -72,7 +72,12 @@ local function adduser(pwd) warnmsg("Argument should be a table") return nil 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") f:close() if pwdstr:len() ~= 0 then @@ -109,8 +114,7 @@ local function adduser(pwd) precmd = "echo "..pwd.plain_text_passwd .. "| " postcmd = " -H 0 " end - local root = os.getenv("NUAGE_FAKE_ROOTDIR") - local cmd = precmd .. "pw " + cmd = precmd .. "pw " if root then cmd = cmd .. "-R " .. root .. " " end @@ -140,7 +144,12 @@ local function addgroup(grp) warnmsg("Argument should be a table") return false 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") f:close() if grpstr:len() ~= 0 then @@ -151,8 +160,7 @@ local function addgroup(grp) local list = splitlist(grp.members) extraargs = " -M " .. table.concat(list, ',') end - local root = os.getenv("NUAGE_FAKE_ROOTDIR") - local cmd = "pw " + cmd = "pw " if root then cmd = cmd .. "-R " .. root .. " " end