From nobody Tue Oct 08 07:07:49 2024 X-Original-To: dev-commits-src-all@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 4XN6Y16dBHz5Z54B; Tue, 08 Oct 2024 07:07:49 +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 4XN6Y14v9pz42bt; Tue, 8 Oct 2024 07:07:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728371269; 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=ACBL69GwZuE3NKrZ0RB5l/W5WkDBLfmIzuDHZTNX/FE=; b=lieZa/FUpcsYBd46TH8UrH3L9haUm7qRYHZXC/SWgaWE9qjWLDsO1CLw4umvNc77dBW+JA GDajntiHjrCedd3C2D2xWh1fw8sa0Ven66qrXmZfyKsnA2LvXLbFSfHKovqk4zZFhPV7de naw/n/4CVwJAGwUZvWx6IrnkLrOBM5gVc690hlsOkV02n6daMr12DrmizB3Pl6+40F4OBv mQtmkSpuccPObBakJmu5VHDEQspTwc958VwsOwjSSdRdGGQC8e51zUOF6k0pmHtIxkbs+l r0Ika7raC6Om18N976hrZ01+BO1Ydia4GAnwrqOwSG9GRjUDBgsrdKGB5Nz+Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728371269; 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=ACBL69GwZuE3NKrZ0RB5l/W5WkDBLfmIzuDHZTNX/FE=; b=oUEubhH1dzMQa61BhnGF68bYmrlFoqD33GaKm9uf8m8yvOQorUQdQcVXXL5fU8Xwk6z/mr EmZkl9P00I0tC77gDiYz0ZYmLzVhgS1NNoNvPgDaV3+j9b5XEDOk+/4KsNhhn+46Yk2n9+ WPrRcSqaS13wFbgs7TCEGbjiBgbD1vPY1VTN/DnPFKbDrmiGzZ9NILOPb7NmZGgTxrGaWQ GQ3bmbJCVx5KHz+brpYnYOECxMQqblRX9SWFN+iKcxV103p3Fpu3Ifiai5b6ARSFhD1sKE K5AJMUwMFpoHMifvVjXnqbUnFpvAHqijQM6gdAwLCIWRXv3nsaTNGVutBRkv/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728371269; a=rsa-sha256; cv=none; b=vVfD+bRADKlFN4q5IZeu96+UNlZWJbK2U8B4WGVp4Ogcfvj00MrOrKgM6nukK1M1T16PWA 3eSf2sN/slE2Bd2F39Y9g3Neg1nZvGnl7miWglc5So5UiPlYq3jyL0+qFle4RAoVRyWl9H L7jsp51qFzNKqjVF+1bgtan5ez56U6IcKgFbH1fq5Co7cmNwKsWw2EyZlkqRJYVQUsZyle Yw9a8dUcXpv2bLnjYu8X+Ko7hAiN6MkgCHc5Q8YQkHnqDEyrByILrElANkPfw0tgfqkyEp mrRtwrwlIAN8+Vfu04Bzsl0Pz/oUzMiCcV2EGD0ZIj7ihovBVVkeTyYKYQdFjA== 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 4XN6Y13ckYzLGN; Tue, 8 Oct 2024 07:07:49 +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 49877nwH051609; Tue, 8 Oct 2024 07:07:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49877nLG051606; Tue, 8 Oct 2024 07:07:49 GMT (envelope-from git) Date: Tue, 8 Oct 2024 07:07:49 GMT Message-Id: <202410080707.49877nLG051606@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: 9881d68b1ea7 - stable/14 - nuageinit: Fix passwords List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 9881d68b1ea763efd6db7c7aecbe47176851582b Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=9881d68b1ea763efd6db7c7aecbe47176851582b commit 9881d68b1ea763efd6db7c7aecbe47176851582b Author: Jose Luis Duran AuthorDate: 2024-07-30 01:28:18 +0000 Commit: Baptiste Daroussin CommitDate: 2024-10-08 07:04:01 +0000 nuageinit: Fix passwords The hashed password usually contains a "$" sign, which, when used on a shell, must be escaped. Also, the plain text password may contain special characters that require escaping. Add a quick fix by enclosing it in single quotes. Note that if the plain text password contains a "'", it will still fail. This will be properly fixed in later commits. Some here documents require the document to be a string literal, especially when passing invalid characters. Enclose it in single quotes. Signed-off-by: Jose Luis Duran (cherry picked from commit b9ce743c5447e90c2c97f4d49e048c301f708527) --- libexec/nuageinit/nuage.lua | 8 ++++---- libexec/nuageinit/tests/nuageinit.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index c27b66b23be2..4e21405a443b 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -120,11 +120,11 @@ local function adduser(pwd) local precmd = "" local postcmd = "" if pwd.passwd then - precmd = "echo " .. pwd.passwd .. "| " - postcmd = " -H 0 " + precmd = "echo '" .. pwd.passwd .. "' | " + postcmd = " -H 0" elseif pwd.plain_text_passwd then - precmd = "echo " .. pwd.plain_text_passwd .. "| " - postcmd = " -h 0 " + precmd = "echo '" .. pwd.plain_text_passwd .. "' | " + postcmd = " -h 0" end cmd = precmd .. "pw " if root then diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index 6b8ea7ff3328..434fb3095929 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -81,7 +81,7 @@ EOF wheel:*:0:root users:*:1: EOF - cat > media/nuageinit/user-data << EOF + cat > media/nuageinit/user-data << 'EOF' #cloud-config groups: - admingroup: [root,sys] @@ -103,11 +103,11 @@ cloud-users:*:1002: freebsd:*:1003: foobar:*:1004: EOF - cat > expectedpasswd << EOF + cat > expectedpasswd << 'EOF' root:*:0:0::0:0:Charlie &:/root:/bin/csh sys:*:1:0::0:0:Sys:/home/sys:/bin/csh freebsd:freebsd:1001:1003::0:0:FreeBSD User:/home/freebsd:/bin/sh -foobar:H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/:1002:1004::0:0:Foo B. Bar:/home/foobar:/bin/sh +foobar:$6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/:1002:1004::0:0:Foo B. Bar:/home/foobar:/bin/sh EOF sed -i "" "s/freebsd:.*:1001/freebsd:freebsd:1001/" ${here}/etc/master.passwd atf_check -o file:expectedpasswd cat ${here}/etc/master.passwd