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.Concurrent
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import Data.Char
|
||||||
|
|
||||||
type KeyId = String
|
type KeyId = String
|
||||||
|
|
||||||
|
@ -158,9 +159,9 @@ pipeLazy (GpgCmd cmd) params feeder reader = do
|
||||||
- GnuPG's manpage.) -}
|
- GnuPG's manpage.) -}
|
||||||
findPubKeys :: GpgCmd -> String -> IO KeyIds
|
findPubKeys :: GpgCmd -> String -> IO KeyIds
|
||||||
findPubKeys cmd for
|
findPubKeys cmd for
|
||||||
-- "subkey!" tells gpg to force use of a specific subkey,
|
-- pass forced subkey through as-is rather than
|
||||||
-- so pass it through as-is rather than looking up the master key.
|
-- looking up the master key.
|
||||||
| "!" `isSuffixOf` for = return $ KeyIds [for]
|
| isForcedSubKey for = return $ KeyIds [for]
|
||||||
| otherwise = KeyIds . parse . lines <$> readStrict cmd params
|
| otherwise = KeyIds . parse . lines <$> readStrict cmd params
|
||||||
where
|
where
|
||||||
params = [Param "--with-colons", Param "--list-public-keys", Param for]
|
params = [Param "--with-colons", Param "--list-public-keys", Param for]
|
||||||
|
@ -168,6 +169,10 @@ findPubKeys cmd for
|
||||||
keyIdField ("pub":_:_:_:f:_) = Just f
|
keyIdField ("pub":_:_:_:f:_) = Just f
|
||||||
keyIdField _ = Nothing
|
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
|
type UserId = String
|
||||||
|
|
||||||
{- All of the user's secret keys, with their UserIds.
|
{- All of the user's secret keys, with their UserIds.
|
||||||
|
|
Loading…
Reference in a new issue