summaryrefslogtreecommitdiff
path: root/src/Propellor/Gpg.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-04-02 15:33:48 -0400
committerJoey Hess <joeyh@joeyh.name>2016-04-02 15:33:48 -0400
commitdce7e7bd72fa82ef7461535288b53d89db807566 (patch)
treecf97100b90cddfd988d069059222df4bb8459bc5 /src/Propellor/Gpg.hs
parentbeba93baede04835687e1caeefead24f173d9048 (diff)
parent48608a48bd91743776cf3d4abb2172b806d4b917 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Gpg.hs')
-rw-r--r--src/Propellor/Gpg.hs17
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]