From nobody Thu Jun 27 08:57:43 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4W8ssM5N0Qz5PGDd; Thu, 27 Jun 2024 08:57:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4W8ssM4qQjz4W3Z; Thu, 27 Jun 2024 08:57:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719478663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dTgXnt8e+X0VM/REYVfNUThSLqyIlEJbRbQQ/TwfTN8=; b=pUzAJbhsDaHGgx9i/MbksWvNZQBWlZtdcAfX6+Eme+bvLXMg0Frm0FDms5PQB8Go9+ypE+ bq2mWYf9lcWysTK12B0VGpJAur1xPyzJatBz0sYr7iHintSQWcjBs06mzzweImJnZ97EG2 jFxhWpMw2hrXImJoShbyJCv25gELUrRX8LfdlVEB/5mH45LffZiFm2NER52VDS1fYY3yqj JFPEqstctha43bVe1rqYK9mDYugrXWMd8Oaj1rDw/uhArn72aiSjwGeDv/KwD+L1lbhIqh 9VjVDmgZYBuCCGqawZoEFjibY0D377cf63+YHEGodhq32V9ODUc8cfjwsPQ3UA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719478663; a=rsa-sha256; cv=none; b=YRB5eg0K2eruIrW3vetUIeKyr2e+cOOANaAm1qPU/97I0dNO7JT9a7k6H5zPCuuv0lxigB 3hTZzzti2ezsgiEZNSMi06N/2gaGvp78qvvzh9t9B/cgK7A4ut/ymwq5dnNA4RNsOUU4H0 S5aYasGhxD8K2ZTAp5um+DG3EncktxpIdWMDhYj6xfBlM2wl40NeTxzbcUU3aafUlvWOzp iEaucqBletkMj/pL00TrlvcvHLAO46nLHLCNBydC6e+f7P58w1Nt1t3tb7yG1BeSKV6YRm 4deS1EUnLIvjmzk/nWq3QVtIOkj6N/lPri9k4whgPdH/E5hfjAm6ZCWIJVAYww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719478663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dTgXnt8e+X0VM/REYVfNUThSLqyIlEJbRbQQ/TwfTN8=; b=xvolaexJ3FsKERrm5n5W3NIdh7OQmDRTHcyGQmGbaJSJCxPqupta6qSSiZP9yHklcyUeDU OlGClsSBT3ZyxTxlEJA3cwsoELb1E2i5sRp0Vd34SIKXbBQ/TrIVJZcDocIy4loysUbSbo RNuY+THtUQFegG5RQloPATLj3v/y7iDek123ANU4Ybd0bXGN2enf+Nn8FSo0n04s+XWN+c cu/xSEoosZ93hNE/HpfzYjJUAIpzzW0LyeOG9XpR39f6d02zJOLMYdzbAViD800DheTNbM 1/KT4+P+orufyqftgpEs2ZoB8UUsaspqhHVZn/RdPPB2V8xrn5eIgyCKPaQgAQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4W8ssM47lyz1L5m; Thu, 27 Jun 2024 08:57:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45R8vhcT010485; Thu, 27 Jun 2024 08:57:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45R8vheu010483; Thu, 27 Jun 2024 08:57:43 GMT (envelope-from git) Date: Thu, 27 Jun 2024 08:57:43 GMT Message-Id: <202406270857.45R8vheu010483@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 12e584c11e25 - stable/14 - nuageinit: use pw(8) instead of getent(1) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 12e584c11e25d10ec86a1124b7d350f8a26b67db Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=12e584c11e25d10ec86a1124b7d350f8a26b67db commit 12e584c11e25d10ec86a1124b7d350f8a26b67db Author: Baptiste Daroussin AuthorDate: 2024-06-05 08:34:25 +0000 Commit: Baptiste Daroussin 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