summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-12-03 19:40:22 -0500
committerjoe <joe@jerkface.net>2013-12-03 19:40:22 -0500
commitf9af7493658c3cdb7be2d84c0de818ab3eae7443 (patch)
tree5ce3ca60b4a1d2b0448a17b8a313caff92f59d66 /kiki.hs
parentacdda18dfd2357f8bf6d7a12d793ca46f22a89c6 (diff)
Corrected accounting of newness of TrustPackets.
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs31
1 files changed, 17 insertions, 14 deletions
diff --git a/kiki.hs b/kiki.hs
index dd487da..3ecb8b8 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -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
987flattenKeys :: Bool -> KeyDB -> Message 987flattenKeys :: Bool -> KeyDB -> Message
988flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop isPublic . snd) (prefilter . Map.assocs $ db) 988flattenKeys 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
1000flattenTop :: Bool -> KeyData -> [MappedPacket] 1000flattenTop :: FilePath -> Bool -> KeyData -> [MappedPacket]
1001flattenTop ispub (KeyData key sigs uids subkeys) = 1001flattenTop 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
1005flattenUid :: Bool -> OriginMap -> (String,[SigAndTrust]) -> [MappedPacket] 1005flattenUid :: FilePath -> Bool -> OriginMap -> (String,[SigAndTrust]) -> [MappedPacket]
1006flattenUid ispub om (str,sigs) = MappedPacket (UserIDPacket str) om : concatMap (unsig ispub) sigs 1006flattenUid fname ispub om (str,sigs) =
1007 MappedPacket (UserIDPacket str) om : concatMap (unsig fname ispub) sigs
1007 1008
1008flattenSub :: Bool -> SubKey -> [MappedPacket] 1009flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket]
1009flattenSub ispub (SubKey key sigs) = unk ispub key: concatMap (unsig ispub) sigs 1010flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatMap (unsig fname ispub) sigs
1010 1011
1011unk :: Bool -> MappedPacket -> MappedPacket 1012unk :: Bool -> MappedPacket -> MappedPacket
1012unk isPublic = if isPublic then toPacket secretToPublic else id 1013unk 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
1014unsig :: Bool -> SigAndTrust -> [MappedPacket] 1015
1015unsig isPublic (sig,trustmap) = [sig]++ map (flip MappedPacket Map.empty) ( take 1 . Map.elems $ Map.filterWithKey f trustmap) 1016unsig :: FilePath -> Bool -> SigAndTrust -> [MappedPacket]
1017unsig 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
1020ifSecret (SecretKeyPacket {}) t f = t 1023ifSecret (SecretKeyPacket {}) t f = t
1021ifSecret _ t f = f 1024ifSecret _ 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) ++