From nobody Tue Aug 20 10:12:07 2024 X-Original-To: dev-commits-src-main@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 4Wp4yH4wTgz5Spjd; Tue, 20 Aug 2024 10:12:07 +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 4Wp4yH4SrTz4BtC; Tue, 20 Aug 2024 10:12:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724148727; 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=pB3BRIiJS1tZT415bEBBg/B9e6COBTtABvD+dc1ZKIg=; b=q8XtDRYGCTaKo6nBwxRDJu3nKQfSC3NbkH2eHa2bMEwtWDRvhlJjNedajE6ymtSyF2HXeK m4eknriZ3c7sXY086MtH1j3SIhje5+om2cngF/X7Vo4pPp212g62TkaWWPLod92Edn/B8a CLhM66kMy/0QUBncZAu63cIDzJOEAbDw/MrjOUAAf67dcja964AYFdw6hMnLoFehP/fZU9 qx5B1b5Y7EwC7lqtiZAAMZ0cK4N0IH6jsL6bs/gOPDPNjUEFfIYzs7h05EecQyrBXRqWlv eo6qZHuIpY7ti9KSuIJoFOvuOJRVBAc+vt0BR5hq//bYvl0BoQHUDkzu1fUqmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724148727; a=rsa-sha256; cv=none; b=FdtRB7l6dG2FfB0C+dpwubwxmd16I2tVzm/huTgSR8iHSRMNxZkWj4uJlR4VXNCMQy670O 88aEaDu5ec36Vcuag05zg7VVDMv0A67WVf6bQKnIExuAFw7LJYykFCHrM4tQd25J18sich uYo60QaWGZBJqdV/j90TYVGCDm+d4gYtlilHtbTTLV/v6ySj10gjvrgFZPwf3e7kr3Qx7v sE5DshnOMSoQYP7MfIF405OBknp5+HhDzYbR1EgYB9u6/kmVYCp5q9gDRQfNFXqKFbqTvc 1PC05XxwO/6nIHZ3hZKjunVYjCNRgEYjUyM1bT/F9vNQcI6dTOdin16OypwRqQ== 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=1724148727; 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=pB3BRIiJS1tZT415bEBBg/B9e6COBTtABvD+dc1ZKIg=; b=Jg4PCZdDLMFBQAANRYqMtMBO9SbZVMztBRW9pcRThvjfHKeXRKsBS3Ajwo7TJVc7ioV0KQ fqry3Kw78d/mR66Pb/XyaUMnJLJjBwgnV2kpgSw7nnUFvjbP9AA1KVFgSgiaSZJDqlHBGr qSM8//wjKgYo8CI27QuvD1qTVoh1TOVFXQ5K5gBgFExxAKP6ROh+CmEzSwuarDlxtaWAEp i2ljQRvqr1GMdK1kld7N9gSRCQzeDNGMnHeepV1utLU6w1q67pm0Een4Ihjl+TBvzbTfpj YN8w3nivRFyaCtUqi7vlN597r8EYS5yrfyfSi1HYjgN5m5NclaXFIjbMrNrUZA== 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 4Wp4yH44pRzwck; Tue, 20 Aug 2024 10:12:07 +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 47KAC7pR099577; Tue, 20 Aug 2024 10:12:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47KAC7wM099574; Tue, 20 Aug 2024 10:12:07 GMT (envelope-from git) Date: Tue, 20 Aug 2024 10:12:07 GMT Message-Id: <202408201012.47KAC7wM099574@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 19fb9ad74651 - main - nuageinit: readd ssh key parsing when key is in meta_data.json List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 19fb9ad746517c7af9d79a982334b2550f285355 Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=19fb9ad746517c7af9d79a982334b2550f285355 commit 19fb9ad746517c7af9d79a982334b2550f285355 Author: Baptiste Daroussin AuthorDate: 2024-08-20 10:04:01 +0000 Commit: Baptiste Daroussin CommitDate: 2024-08-20 10:08:29 +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 --- 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 <