From 5f4b5000c85294d5bafa3e1d6cb52058e6b7ec96 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Fri, 5 Mar 2021 12:18:13 -0800 Subject: [PATCH] Fix sshfp record printing Previously if you ran `sshfp.py foo.opendev.org x.y.z.a` it would spit out records that look like: foo.opendev.org IN SSHFP 1 1 stuffstuffstuff The problem with this is when you copy this output into the zone file the lack of a terminating '.' means the record will actually be for foo.opendev.org.opendev.org. We address this by splitting on '.' and taking the first element. This will still be broken for hosts named foo.bar.opendev.org but for now is a decent improvement. Change-Id: Ib12f66c30e20a62d14d0d0ddd485e28f7f7ab518 --- launch/sshfp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/launch/sshfp.py b/launch/sshfp.py index 2babf7673d..01eae58681 100755 --- a/launch/sshfp.py +++ b/launch/sshfp.py @@ -38,9 +38,10 @@ def generate_sshfp_records(hostname, ip, local): ret = '' first = True + dns_hostname = hostname.split('.')[0] for f in fingerprints: ret += '%s%s\t\tIN\tSSHFP\t%s %s %s' % \ - ("\n" if not first else '', hostname, f[0], f[1], f[2]) + ("\n" if not first else '', dns_hostname, f[0], f[1], f[2]) first = False return ret