diff options
-rw-r--r-- | kiki.hs | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -985,7 +985,7 @@ merge db filename (Message ps) = foldl mergeit db (zip [0..] qs) | |||
985 | "Unable to merge subkey signature: "++(words (show sig) >>= take 1) | 985 | "Unable to merge subkey signature: "++(words (show sig) >>= take 1) |
986 | 986 | ||
987 | flattenKeys :: Bool -> KeyDB -> Message | 987 | flattenKeys :: Bool -> KeyDB -> Message |
988 | flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop isPublic . snd) (prefilter . Map.assocs $ db) | 988 | flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPublic . snd) (prefilter . Map.assocs $ db) |
989 | where | 989 | where |
990 | prefilter = if isPublic then id else filter isSecret | 990 | prefilter = if isPublic then id else filter isSecret |
991 | where | 991 | where |
@@ -997,25 +997,28 @@ flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop isPublic | |||
997 | isSecret _ = False | 997 | isSecret _ = False |
998 | 998 | ||
999 | 999 | ||
1000 | flattenTop :: Bool -> KeyData -> [MappedPacket] | 1000 | flattenTop :: FilePath -> Bool -> KeyData -> [MappedPacket] |
1001 | flattenTop ispub (KeyData key sigs uids subkeys) = | 1001 | flattenTop fname ispub (KeyData key sigs uids subkeys) = |
1002 | unk ispub key : ( concatMap (flattenUid ispub (snd uids)) (Map.assocs (fst uids)) | 1002 | unk ispub key : ( concatMap (flattenUid fname ispub (snd uids)) (Map.assocs (fst uids)) |
1003 | ++ concatMap (flattenSub ispub) (Map.elems subkeys)) | 1003 | ++ concatMap (flattenSub fname ispub) (Map.elems subkeys)) |
1004 | 1004 | ||
1005 | flattenUid :: Bool -> OriginMap -> (String,[SigAndTrust]) -> [MappedPacket] | 1005 | flattenUid :: FilePath -> Bool -> OriginMap -> (String,[SigAndTrust]) -> [MappedPacket] |
1006 | flattenUid ispub om (str,sigs) = MappedPacket (UserIDPacket str) om : concatMap (unsig ispub) sigs | 1006 | flattenUid fname ispub om (str,sigs) = |
1007 | MappedPacket (UserIDPacket str) om : concatMap (unsig fname ispub) sigs | ||
1007 | 1008 | ||
1008 | flattenSub :: Bool -> SubKey -> [MappedPacket] | 1009 | flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket] |
1009 | flattenSub ispub (SubKey key sigs) = unk ispub key: concatMap (unsig ispub) sigs | 1010 | flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatMap (unsig fname ispub) sigs |
1010 | 1011 | ||
1011 | unk :: Bool -> MappedPacket -> MappedPacket | 1012 | unk :: Bool -> MappedPacket -> MappedPacket |
1012 | unk isPublic = if isPublic then toPacket secretToPublic else id | 1013 | unk isPublic = if isPublic then toPacket secretToPublic else id |
1013 | where toPacket f (MappedPacket p m) = MappedPacket (f p) m | 1014 | where toPacket f (MappedPacket p m) = MappedPacket (f p) m |
1014 | unsig :: Bool -> SigAndTrust -> [MappedPacket] | 1015 | |
1015 | unsig isPublic (sig,trustmap) = [sig]++ map (flip MappedPacket Map.empty) ( take 1 . Map.elems $ Map.filterWithKey f trustmap) | 1016 | unsig :: FilePath -> Bool -> SigAndTrust -> [MappedPacket] |
1017 | unsig fname isPublic (sig,trustmap) = | ||
1018 | [sig]++ map (asMapped (-1)) ( take 1 . Map.elems $ Map.filterWithKey f trustmap) | ||
1016 | where | 1019 | where |
1017 | f "%secring" _ = not isPublic | 1020 | f n _ = n==fname -- && trace ("fname=n="++show n) True |
1018 | f _ _ = isPublic | 1021 | asMapped n p = MappedPacket p (Map.singleton fname (origin p n)) |
1019 | 1022 | ||
1020 | ifSecret (SecretKeyPacket {}) t f = t | 1023 | ifSecret (SecretKeyPacket {}) t f = t |
1021 | ifSecret _ t f = f | 1024 | ifSecret _ t f = f |
@@ -1040,7 +1043,7 @@ writeOutKeyrings db = do | |||
1040 | let x = do | 1043 | let x = do |
1041 | d@(KeyData p _ _ _) <- filter (fromfile f) ks | 1044 | d@(KeyData p _ _ _) <- filter (fromfile f) ks |
1042 | n <- maybeToList $ Map.lookup f (locations p) | 1045 | n <- maybeToList $ Map.lookup f (locations p) |
1043 | flattenTop (originallyPublic n) d | 1046 | flattenTop f (originallyPublic n) d |
1044 | changes = filter notnew x | 1047 | changes = filter notnew x |
1045 | where notnew p = isNothing (Map.lookup f $ locations p) | 1048 | where notnew p = isNothing (Map.lookup f $ locations p) |
1046 | unlines $ ( (f ++ ":") : map (showPacket . packet) x) ++ | 1049 | unlines $ ( (f ++ ":") : map (showPacket . packet) x) ++ |