From 910ef222d06496c934e3b08d593bf7d65a4012fc Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 24 Oct 2012 00:26:16 +0200 Subject: [PATCH] =?UTF-8?q?prepare-node-join:=20Use=20public=20key=20direc?= =?UTF-8?q?tly=20for=20auth=E2=80=A6=5Fkeys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A public key already includes the necessary prefix (βssh-rsaβ or βssh-dssβ), so there is no need to add it again. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/tools/prepare_node_join.py | 13 ++----------- test/ganeti.tools.prepare_node_join_unittest.py | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/tools/prepare_node_join.py b/lib/tools/prepare_node_join.py index b1270f53c..097103788 100644 --- a/lib/tools/prepare_node_join.py +++ b/lib/tools/prepare_node_join.py @@ -58,11 +58,6 @@ _DATA_CHECK = ht.TStrictDict(False, True, { constants.SSHS_SSH_ROOT_KEY: _SSH_KEY_LIST, }) -_SSHK_TO_SSHAK = { - constants.SSHK_RSA: constants.SSHAK_RSA, - constants.SSHK_DSA: constants.SSHAK_DSS, - } - _SSH_DAEMON_KEYFILES = { constants.SSHK_RSA: (pathutils.SSH_HOST_RSA_PUB, pathutils.SSH_HOST_RSA_PRIV), @@ -70,9 +65,6 @@ _SSH_DAEMON_KEYFILES = { (pathutils.SSH_HOST_DSA_PUB, pathutils.SSH_HOST_DSA_PRIV), } -assert frozenset(_SSHK_TO_SSHAK.keys()) == constants.SSHK_ALL -assert frozenset(_SSHK_TO_SSHAK.values()) == constants.SSHAK_ALL - class JoinError(errors.GenericError): """Local class for reporting errors. @@ -312,9 +304,8 @@ def UpdateSshRoot(data, dry_run, _homedir_fn=None): if dry_run: logging.info("This is a dry run, not modifying %s", auth_keys_file) else: - for (kind, public_key, _) in keys: - line = "%s %s" % (_SSHK_TO_SSHAK[kind], public_key) - utils.AddAuthorizedKey(auth_keys_file, line) + for (_, _, public_key) in keys: + utils.AddAuthorizedKey(auth_keys_file, public_key) def LoadData(raw): diff --git a/test/ganeti.tools.prepare_node_join_unittest.py b/test/ganeti.tools.prepare_node_join_unittest.py index b629f7728..bbc363441 100755 --- a/test/ganeti.tools.prepare_node_join_unittest.py +++ b/test/ganeti.tools.prepare_node_join_unittest.py @@ -287,7 +287,7 @@ class TestUpdateSshRoot(unittest.TestCase): def testUpdate(self): data = { constants.SSHS_SSH_ROOT_KEY: [ - (constants.SSHK_DSA, "pubdsa", "privatedsa"), + (constants.SSHK_DSA, "ssh-dss pubdsa", "privatedsa"), ] } @@ -299,7 +299,7 @@ class TestUpdateSshRoot(unittest.TestCase): self.assertEqual(utils.ReadFile(utils.PathJoin(self.sshdir, "id_dsa")), "privatedsa") self.assertEqual(utils.ReadFile(utils.PathJoin(self.sshdir, "id_dsa.pub")), - "pubdsa") + "ssh-dss pubdsa") self.assertEqual(utils.ReadFile(utils.PathJoin(self.sshdir, "authorized_keys")), "ssh-dss pubdsa\n") -- GitLab