From 71bc7071094ef56bca518f1eb4660718a0c9d0b0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 1 Apr 2016 23:40:39 -0400 Subject: verify use of gpg key having a prompt here makes it clearer to the user why gpg is prompting for a passphrase. --- src/Propellor/DotDir.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/Propellor/DotDir.hs') diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index 92c20654..bf7550d5 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -64,7 +64,7 @@ welcomeBanner = putStr $ unlines $ map prettify , " - Welcome to -- ~ / | / ) _.-'-._" , " - Propellor! -- `/-==__ _/__|/__=-| ( ~_" , " `--------------------------- * ~ | | '--------'" - , " (o) `" + , " (o) `" , "" , "" ] @@ -90,7 +90,7 @@ prompt p cs = do section :: IO () section = do putStrLn "" - putStrLn "---------------------------------------------------------------------------------" + putStrLn "------------------------------------------------------------------------------" putStrLn "" setup :: IO () @@ -111,11 +111,13 @@ setup = do section putStrLn "Let's try building the propellor configuration, to make sure it will work..." + putStrLn "" buildPropellor Nothing + putStrLn "" putStrLn "Great! Propellor is bootstrapped." section - putStrLn "Propellor uses gpg to encrypt private data about the systems it manages," + putStrLn "Propellor can use gpg to encrypt private data about the systems it manages," putStrLn "and to sign git commits." gpg <- getGpgBin ifM (inPath gpg) @@ -146,14 +148,21 @@ setupGpgKey = do putStrLn "" case ks of [] -> makeGpgKey - [(k, _)] -> propellorAddKey k + [(k, d)] -> do + putStrLn $ "You have one gpg key: " ++ desckey k d + prompt "Should propellor use that key?" + [ ("Y", propellorAddKey k) + , ("N", putStrLn $ "Skipping gpg setup. If you change your mind, run: propellor --add-key " ++ k) + ] _ -> do let nks = zip ks (map show ([1..] :: [Integer])) putStrLn "I see you have several gpg keys:" forM_ nks $ \((k, d), n) -> - putStrLn $ " " ++ n ++ " " ++ d ++ " (keyid " ++ k ++ ")" + putStrLn $ " " ++ n ++ " " ++ desckey k d prompt "Which of your gpg keys should propellor use?" (map (\((k, _), n) -> (n, propellorAddKey k)) nks) + where + desckey k d = d ++ " (keyid " ++ k ++ ")" makeGpgKey :: IO () makeGpgKey = do @@ -199,6 +208,7 @@ minimalConfig = do where cabalcontent = [ "-- This is a cabal file to use to build your propellor configuration." + , "-- https://propellor.branchable.com/" , "" , "Name: config" , "Cabal-Version: >= 1.6" -- cgit v1.2.3