tighten forced subkey matching
Someone might have a name or email address ending in a bang..
This commit is contained in:
parent
a7d18b04c3
commit
77ba430b38
1 changed files with 8 additions and 3 deletions
|
@ -22,6 +22,7 @@ import Utility.Format (decode_c)
|
|||
import Control.Concurrent
|
||||
import Control.Monad.IO.Class
|
||||
import qualified Data.Map as M
|
||||
import Data.Char
|
||||
|
||||
type KeyId = String
|
||||
|
||||
|
@ -158,9 +159,9 @@ pipeLazy (GpgCmd cmd) params feeder reader = do
|
|||
- GnuPG's manpage.) -}
|
||||
findPubKeys :: GpgCmd -> String -> IO KeyIds
|
||||
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]
|
||||
-- pass forced subkey through as-is rather than
|
||||
-- looking up the master key.
|
||||
| isForcedSubKey for = return $ KeyIds [for]
|
||||
| otherwise = KeyIds . parse . lines <$> readStrict cmd params
|
||||
where
|
||||
params = [Param "--with-colons", Param "--list-public-keys", Param for]
|
||||
|
@ -168,6 +169,10 @@ findPubKeys cmd for
|
|||
keyIdField ("pub":_:_:_:f:_) = Just f
|
||||
keyIdField _ = Nothing
|
||||
|
||||
{- "subkey!" tells gpg to force use of a specific subkey -}
|
||||
isForcedSubKey :: String -> Bool
|
||||
isForcedSubKey s = "!" `isSuffixOf` s && all isHexDigit (drop 1 s)
|
||||
|
||||
type UserId = String
|
||||
|
||||
{- All of the user's secret keys, with their UserIds.
|
||||
|
|
Loading…
Reference in a new issue