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.
This commit is contained in:
Joey Hess 2017-05-24 14:08:02 -04:00
parent dd65ea52c3
commit 35465b6062
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 29 additions and 1 deletions

View file

@ -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 ':')