From nobody Wed Jan 15 09:53:50 2025 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 4YY1Xv18yLz5lBrK; Wed, 15 Jan 2025 09:53:51 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YY1Xv0JlKz3HSd; Wed, 15 Jan 2025 09:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736934831; 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=gsZoi9o4ep2UJUPkHrP4FlRcSTvoq/KDfmxvyTUp0aw=; b=qAEtKX1bxx+iFn+Hy1dMsCBPfMZWkpFJspaFsvn5TuOkgrsyHtWEBbmbGLZdJg7zd92kb6 N8JQvZQLr9JYdI3IL8Y2s7WC93KoJUzswydZfidGoPiiviytVLnGaM04iKFFrHU/c5GLY2 JvfxPGSm11A6L8oO5n/MKO5KAKcG8yK4oh9tx8xgH2KgKVScoLX861cbKUf67aOYuJ49fG /rxPhgXwj1l6glY+3K5bb80vXqgA0ir4tB137kDi9TfPC8ETJiW3QHe/sr86cXXkPy8jgz dZXkqyDtfq7rkZIHApbK01FQb+bieUgikGOmmx7SEpPvIdO/meU0AQD+RtD70A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736934831; 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=gsZoi9o4ep2UJUPkHrP4FlRcSTvoq/KDfmxvyTUp0aw=; b=t85aZSuPmAXFg2JdROr5nq0MjiUCXJbyj8dJZCQpSQu1ctZ9gOtbi7ip3rGNo9iVB4a8QS UdvPv2T83QrNBBS+GfsSenmeR3j4uKhZw9KhF8wDePpMqq4b3MaBaLfDNUfXvRhPCDeYOP LetJsJe7IoC0QiqFqrdOmn6L0v7775q3JnbNrd3k5d9Z29dLiicFr0VdCAvmuurdEoQwzW FexngD7xe9J9C1jgvLgTIIg1louW+jSBfI0HtPLBbp9zWRQs1vxC5YYquHRdWZv/uTA5LK GoA3RpChkmdcRe1Elsg32oyeW9GPQAhOzyWP0Vpv3wZikBZEEGaLBNZdXMmn5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736934831; a=rsa-sha256; cv=none; b=vcfFKByUGYNqkzyEAl2irvhtSuumnOlR3eBi6F/YfpYBBUmdjy05YB2YAUQ8RdfHl1kj+u Y5EbRxgh0phhpb7hZtlJjI1Ol+7t1Pt0WZOLjHDfFPm4MPuAaFmwLp6Vt5bPV9YW5cQEBs qB4x9x8GXRIdmtnR0LSdLtjdHCnrDa5yd9RH7ti3qhwylYoQ3HX7znLHspIgR8a3h3+Jpd j/YrCX+itZDVzD3cndTwgcs5KadxXew50BWXgBkbVYQi84T2sZd1lVQIqXnisuFxrym163 v624+C1bwIV0TAhTrG7vwOfoFB28zMbMotBbCL3v5AzpcclwQKQXRmO8ZeRSmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YY1Xt6mR1zhq8; Wed, 15 Jan 2025 09:53:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50F9ro3A070724; Wed, 15 Jan 2025 09:53:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50F9roQc070721; Wed, 15 Jan 2025 09:53:50 GMT (envelope-from git) Date: Wed, 15 Jan 2025 09:53:50 GMT Message-Id: <202501150953.50F9roQc070721@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: 68f025feeb11 - stable/14 - nuageinit: use io.popen instead of pipes in shell for password 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: 68f025feeb11e05382e9a9feb5105b23ffe7c30c Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=68f025feeb11e05382e9a9feb5105b23ffe7c30c commit 68f025feeb11e05382e9a9feb5105b23ffe7c30c Author: Baptiste Daroussin AuthorDate: 2024-11-20 09:39:50 +0000 Commit: Baptiste Daroussin CommitDate: 2025-01-15 09:53:39 +0000 nuageinit: use io.popen instead of pipes in shell for password using echo in a sh(1) command line, requires many escaping to be done right, using io.popen we don't need to do this escaping anymore. (cherry picked from commit 3e502866073f8d922eecb9016920a56b90c35e38) --- libexec/nuageinit/nuage.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index 4e21405a443b..978de02a63fc 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -119,11 +119,12 @@ local function adduser(pwd) end local precmd = "" local postcmd = "" + local input = nil if pwd.passwd then - precmd = "echo '" .. pwd.passwd .. "' | " + input = pwd.passwd postcmd = " -H 0" elseif pwd.plain_text_passwd then - precmd = "echo '" .. pwd.plain_text_passwd .. "' | " + input = pwd.plain_text_passwd postcmd = " -h 0" end cmd = precmd .. "pw " @@ -134,7 +135,11 @@ local function adduser(pwd) cmd = cmd .. extraargs .. " -c '" .. pwd.gecos cmd = cmd .. "' -d '" .. pwd.homedir .. "' -s " .. pwd.shell .. postcmd - local r = os.execute(cmd) + local f = io.popen(cmd, "w") + if input then + f:write(input) + end + local r = f:close(cmd) if not r then warnmsg("fail to add user " .. pwd.name) warnmsg(cmd)