aboutsummaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-05-24 14:08:02 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-05-24 14:08:02 -0400
commitda79965be64f26c5038b415cf90d28b9926f3e54 (patch)
tree04c4648d7f3e149f512331f0cfbc4fdf7ccb8e6b /Utility
parent8d2aea082e5a7981238bb6068ae5a2624e16028c (diff)
initremote, enableremote: Support gpg subkeys suffixed with an exclamation mark, which forces gpg to use a specific subkey.
This commit was sponsored by Peter Hogg on Patreon.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Gpg.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs
index 336711b3f..c20be754f 100644
--- a/Utility/Gpg.hs
+++ b/Utility/Gpg.hs
@@ -157,7 +157,11 @@ pipeLazy (GpgCmd cmd) params feeder reader = do
- a key id, or a name; See the section 'HOW TO SPECIFY A USER ID' of
- GnuPG's manpage.) -}
findPubKeys :: GpgCmd -> String -> IO KeyIds
-findPubKeys cmd for = KeyIds . parse . lines <$> readStrict cmd params
+findPubKeys cmd for
+ -- "subkey!" tells gpg to force use of a specific subkey,
+ -- so pass it through as-is rather than looking up the master key.
+ | "!" `isSuffixOf` for = return $ KeyIds [for]
+ | otherwise = KeyIds . parse . lines <$> readStrict cmd params
where
params = [Param "--with-colons", Param "--list-public-keys", Param for]
parse = mapMaybe (keyIdField . splitc ':')