From d644dd0595949d5388bf4bb2dcfc1d5fa29f5f17 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 7 Jul 2019 15:11:08 -0400 Subject: use a type for the return value of getHostnames --- kiki.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'kiki.hs') diff --git a/kiki.hs b/kiki.hs index 47462a7..cd0f516 100644 --- a/kiki.hs +++ b/kiki.hs @@ -1665,7 +1665,7 @@ tarContent rt spec pubpem knownhosts secpem = ipsecs ++ sshs ++ secrets "root" ipsecs = do (kk,ipsec,sigs) <- selectPublicKeyAndSigs (KeyUidMatch "",Just "ipsec") (rtKeyDB rt) let kd = (rtKeyDB rt Map.! kk) - (addr,(onames,ns)) = getHostnames kd + Hostnames addr onames ns _ = getHostnames kd oname <- onames return ("etc/ipsec.d/certs/" ++ Char8.unpack oname ++ ".pem", pubpem ns addr ipsec sigs) @@ -1698,10 +1698,15 @@ tarContent rt spec pubpem knownhosts secpem = ipsecs ++ sshs ++ secrets "root" sshsvr = spem (dir "etc/ssh/ssh_host_rsa_key") <$> lookupSecret "ssh-host" kd ipseckey = do k <- lookupSecret "ipsec" kd - oname <- fst . snd $ getHostnames kd - return $ spem (dir $ "etc/ipsec.d/private/"++Char8.unpack oname++".pem") k + keyName <- ipsecKeyNames (getHostnames kd) + return $ spem (dir $ keyName) k torkey ++ sshcli ++ sshsvr ++ ipseckey +ipsecKeyNames :: Hostnames -> [String] +ipsecKeyNames (Hostnames _ onames _ _) = do + oname <- Char8.unpack <$> onames + return $ "etc/ipsec.d/private/"++oname++".pem" + tarT :: ([[String]],Map.Map String [String]) -> IO () tarT (sargs,margs) = do KikiResult rt report <- runKeyRing $ minimalOp $ parseCommonArgs margs @@ -1747,7 +1752,7 @@ tarC (sargs,margs) = do knownhost (kk,hostkey,sigs) = Char8.intercalate "," ns <> " " <> Char8.pack (sshblobFromPacket hostkey) where ns = onames ++ others - (_,(onames,others)) = getHostnames $ rtKeyDB rt Map.! kk + Hostnames _ onames others _ = getHostnames $ rtKeyDB rt Map.! kk build_secret :: Num t => KeyRingRuntime -> Packet -> (t, Either (IO (Maybe Char8.ByteString)) b) build_secret rt k = ( fromIntegral $ timestamp k -- cgit v1.2.3