From 09e9b793dd1c76264a744ca32fde2b7c21d36748 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Jan 2015 19:43:06 -0400 Subject: propellor spin --- src/Propellor/Property/Dns.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs index 63752590..1c1f64ba 100644 --- a/src/Propellor/Property/Dns.hs +++ b/src/Propellor/Property/Dns.hs @@ -81,6 +81,7 @@ setupPrimary zonefile mknamedconffile hosts domain soa rs = (addNamedConf conf) satisfy = do sshfps <- concat <$> mapM genSSHFP indomain + liftIO $ print sshfps let zone = partialzone { zHosts = zHosts partialzone ++ rs ++ sshfps } ifM (liftIO $ needupdate zone) @@ -425,14 +426,17 @@ genSSHFP :: Host -> Propellor [(BindDomain, Record)] genSSHFP h = map (\r -> (AbsDomain hostname, r)) . concat <$> (gen =<< get) where hostname = hostName h - get = fromHost [h] hostname Ssh.getPubKey - gen = liftIO . mapM go . M.elems . fromMaybe M.empty - go pubkey = withTmpFile "sshfp" $ \tmp tmph -> do + get = fromHost [h] hostname Ssh.getPubKey + gen = liftIO . mapM genSSHFP' . M.elems . fromMaybe M.empty + +genSSHFP' :: String -> IO [Record] +genSSHFP' pubkey = withTmpFile "sshfp" $ \tmp tmph -> do hPutStrLn tmph pubkey hClose tmph s <- catchDefaultIO "" $ readProcess "ssh-keygen" ["-r", "dummy", "-f", tmp] return $ mapMaybe (parse . words) $ lines s + where parse ("dummy":"IN":"SSHFP":x:y:s:[]) = do x' <- readish x y' <- readish y -- cgit v1.2.3