diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-04-01 19:34:27 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-04-01 19:48:23 -0400 |
| commit | 93b083f3a1204a7cf4452b5ebd589dd77d25dbac (patch) | |
| tree | a08ca00a9df02bdf6c68be127cdc6256805a40b4 /src/Propellor | |
| parent | ccfdfcab60753eb6eb6ab1c6a6ad6203b8adfdcf (diff) | |
setup gpg key in initial setup process
Diffstat (limited to 'src/Propellor')
| -rw-r--r-- | src/Propellor/Gpg.hs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs index 55d89d29..4e6ceb79 100644 --- a/src/Propellor/Gpg.hs +++ b/src/Propellor/Gpg.hs @@ -32,14 +32,21 @@ getGpgBin = do -- Lists the keys in propellor's keyring. listPubKeys :: IO [KeyId] listPubKeys = do - gpgbin <- getGpgBin keyring <- privDataKeyring - parse . lines <$> readProcess gpgbin (listopts keyring) + map fst <$> listKeys ("--list-public-keys" : useKeyringOpts keyring) + +listSecretKeys :: IO [(KeyId, String)] +listSecretKeys = listKeys ["--list-secret-keys"] + +listKeys :: [String] -> IO [(KeyId, String)] +listKeys ps = do + gpgbin <- getGpgBin + parse . lines <$> readProcess gpgbin listopts where - listopts keyring = useKeyringOpts keyring ++ - ["--with-colons", "--list-public-keys"] + listopts = ps ++ ["--with-colons"] parse = mapMaybe (keyIdField . split ":") - keyIdField ("pub":_:_:_:f:_) = Just f + keyIdField (t:_:_:_:f:_:_:_:_:n:_) + | t == "pub" || t == "sec" = Just (f, n) keyIdField _ = Nothing useKeyringOpts :: FilePath -> [String] |
