SSHFP records are also generated for CNAMES of hosts.

This commit is contained in:
Joey Hess 2015-01-04 21:26:21 -04:00
parent 04f2fe947e
commit 763a0ad303
2 changed files with 14 additions and 4 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
propellor (1.3.2) UNRELEASED; urgency=medium
* SSHFP records are also generated for CNAMES of hosts.
-- Joey Hess <id@joeyh.name> Sun, 04 Jan 2015 21:25:42 -0400
propellor (1.3.1) unstable; urgency=medium propellor (1.3.1) unstable; urgency=medium
* Fix bug that prevented deploying ssh host keys when the file for the * Fix bug that prevented deploying ssh host keys when the file for the

View File

@ -80,7 +80,7 @@ setupPrimary zonefile mknamedconffile hosts domain soa rs =
baseprop = Property ("dns primary for " ++ domain) satisfy baseprop = Property ("dns primary for " ++ domain) satisfy
(addNamedConf conf) (addNamedConf conf)
satisfy = do satisfy = do
sshfps <- concat <$> mapM genSSHFP indomain sshfps <- concat <$> mapM (genSSHFP domain) indomain
let zone = partialzone let zone = partialzone
{ zHosts = zHosts partialzone ++ rs ++ sshfps } { zHosts = zHosts partialzone ++ rs ++ sshfps }
ifM (liftIO $ needupdate zone) ifM (liftIO $ needupdate zone)
@ -514,12 +514,16 @@ getNamedConf = asks $ fromNamedConfMap . _namedconf . hostInfo
-- ssh public keys. -- ssh public keys.
-- --
-- This is done using ssh-keygen, so sadly needs IO. -- This is done using ssh-keygen, so sadly needs IO.
genSSHFP :: Host -> Propellor [(BindDomain, Record)] genSSHFP :: Domain -> Host -> Propellor [(BindDomain, Record)]
genSSHFP h = map (\r -> (AbsDomain hostname, r)) . concat <$> (gen =<< get) genSSHFP domain h = concatMap mk . concat <$> (gen =<< get)
where where
hostname = hostName h
get = fromHost [h] hostname Ssh.getPubKey get = fromHost [h] hostname Ssh.getPubKey
gen = liftIO . mapM genSSHFP' . M.elems . fromMaybe M.empty gen = liftIO . mapM genSSHFP' . M.elems . fromMaybe M.empty
mk r = map (\d -> (d, r)) (AbsDomain hostname : cnames)
cnames = filter (inDomain domain) $
mapMaybe getCNAME $ S.toList $ _dns info
hostname = hostName h
info = hostInfo h
genSSHFP' :: String -> IO [Record] genSSHFP' :: String -> IO [Record]
genSSHFP' pubkey = withTmpFile "sshfp" $ \tmp tmph -> do genSSHFP' pubkey = withTmpFile "sshfp" $ \tmp tmph -> do