From nobody Tue Sep 3 07:08:23 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 4WycCq5JHjz5W53m; Tue, 03 Sep 2024 07:08:23 +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 4WycCq2cPBz4TCW; Tue, 3 Sep 2024 07:08:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725347303; 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=g2DUqSlFMr/cG7YCIxvMdr0AVkgtofs3oiX+CYeeBKA=; b=Yu1CApy12zTnNMYxtgk1RaMvi5CHo7NefYL8f5W+cnHqlmSsHS+rwISsKAs4K4iKHtIAQj 1cvR/vItOkfFHhQBIwsbl/lQ+g+Uf1SRIIhW0SDXoOZFV+JxPIPJL0vH5gNzDniGUj91Tp yQrCKEudrWTgAhC+1nzdkv55cJ/NDlOZLofbw3lBE2KBEp/NIuqQ4c6gC43E2+C5yjvGYU vbNqFNM0WGrKZX+kl0BPReoIpF/C89CdusGoRkJT463GOl4tm32As5aFRj7EfEuRUV35dk wwH0Q3wGyv/SNoZFuvmJfvSPDGrYs14toprU4mriU9KEqfJC+u0YbbGoyub1Zw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725347303; a=rsa-sha256; cv=none; b=mDihtEHMnv6fEI93BuaxZ1BNBLJL/WoCxGiusbB7cye8lLMtm6tMTqAEoJtKA4l5ARbJF+ 2/5wfrGIgiAPyplVpVDfOvIVPBZMtL6NPTSzjKwgWvCA8qFfs4/5MIrDktYekR1+YllOvI qms8YFbzTZjuOiHSpesGbnyot1aUXzjePPQr2P9NtCogMRKWsdEv9SeUfGKnwrWzZuZQeC +KzkFRvPLhZATs21IUWN43YdddoETXByLsO4J5Wf1LG/oiuoopDPH4R4jOfjRdvqF0NAyi 0p392GLz7JHlMRynnYLjnmWQ/aA7Q3CQpyWBGzxbGLF5iqVVsJOxgKl6c7RDOQ== 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=1725347303; 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=g2DUqSlFMr/cG7YCIxvMdr0AVkgtofs3oiX+CYeeBKA=; b=VseuE84gBqhY8pLOZQH+NesC6Hodt6R/Jn4CF1QdtwkgM1sUdZJhMU9fWSX4QvAz0G1JAQ rM4IUF7ZnNWyMvjWKFcIXg1f7ziCbDpjdi4zvTQ9vOb+Tv9v/DUGnWyxxl2/G2CTGaYYmi GVz/4NSRRyHw9vTmY0Ww0cY3mZgE/poVeAy+05wgzLNZW0vqXm6QLJft1xf8IedZrMVVV2 ct1M/kqhhkbp2VycfYAU9h0kO7i9CgrJlmdoZkIptBhWiitV+RRd//bNLfqcdNNGUSNIux ucthIhX5FR4a5pTOHb97d1avxAeZ0/CyRHdcmt82Zqdx78Qxh2HJMTVpnPWTPw== 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 4WycCq2CDpzWlS; Tue, 3 Sep 2024 07:08:23 +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 48378NgQ069252; Tue, 3 Sep 2024 07:08:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48378NR8069249; Tue, 3 Sep 2024 07:08:23 GMT (envelope-from git) Date: Tue, 3 Sep 2024 07:08:23 GMT Message-Id: <202409030708.48378NR8069249@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: 3a73c77f2d86 - stable/14 - nuageinit: readd ssh key parsing when key is in meta_data.json 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: 3a73c77f2d862f2754483ab26e252befc4f8f4e6 Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3a73c77f2d862f2754483ab26e252befc4f8f4e6 commit 3a73c77f2d862f2754483ab26e252befc4f8f4e6 Author: Baptiste Daroussin AuthorDate: 2024-08-20 10:04:01 +0000 Commit: Baptiste Daroussin CommitDate: 2024-09-03 07:05:24 +0000 nuageinit: readd ssh key parsing when key is in meta_data.json in openstack when no user is specified but a sshkey is provided the information is stored in meta_data.json under "public_keys" PR: 280461 Reported by: tdb (cherry picked from commit 19fb9ad746517c7af9d79a982334b2550f285355) --- libexec/nuageinit/nuageinit | 6 +++++ libexec/nuageinit/tests/nuageinit.sh | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index f268f9b0f52c..622e294bb531 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -164,6 +164,12 @@ if citype == "config-2" then nuage.err("nuageinit: error parsing config-2: meta_data.json: " .. err) end local obj = parser:get_object() + if obj.public_keys then + local homedir = nuage.adduser(default_user) + for _,v in pairs(obj.public_keys) do + nuage.addsshkey(homedir, v) + end + end nuage.sethostname(obj["hostname"]) -- network diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index c6a86bc15486..b5078e256853 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -8,6 +8,7 @@ atf_test_case nocloud_network atf_test_case config2 atf_test_case config2_pubkeys atf_test_case config2_pubkeys_user_data +atf_test_case config2_pubkeys_meta_data atf_test_case config2_network atf_test_case config2_network_static_v4 @@ -242,6 +243,52 @@ EOF atf_check -o inline:"ssh-rsa AAAAB3NzaC1y...== Generated by Nova\n" cat home/freebsd/.ssh/authorized_keys } +config2_pubkeys_meta_data_body() +{ + here=$(pwd) + export NUAGE_FAKE_ROOTDIR=$(pwd) + if [ $(id -u) -ne 0 ]; then + atf_skip "root required" + fi + mkdir -p media/nuageinit + cat > media/nuageinit/meta_data.json < etc/master.passwd < etc/group <