From f9af7493658c3cdb7be2d84c0de818ab3eae7443 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 3 Dec 2013 19:40:22 -0500 Subject: Corrected accounting of newness of TrustPackets. --- kiki.hs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'kiki.hs') 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) "Unable to merge subkey signature: "++(words (show sig) >>= take 1) flattenKeys :: Bool -> KeyDB -> Message -flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop isPublic . snd) (prefilter . Map.assocs $ db) +flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPublic . snd) (prefilter . Map.assocs $ db) where prefilter = if isPublic then id else filter isSecret where @@ -997,25 +997,28 @@ flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop isPublic isSecret _ = False -flattenTop :: Bool -> KeyData -> [MappedPacket] -flattenTop ispub (KeyData key sigs uids subkeys) = - unk ispub key : ( concatMap (flattenUid ispub (snd uids)) (Map.assocs (fst uids)) - ++ concatMap (flattenSub ispub) (Map.elems subkeys)) +flattenTop :: FilePath -> Bool -> KeyData -> [MappedPacket] +flattenTop fname ispub (KeyData key sigs uids subkeys) = + unk ispub key : ( concatMap (flattenUid fname ispub (snd uids)) (Map.assocs (fst uids)) + ++ concatMap (flattenSub fname ispub) (Map.elems subkeys)) -flattenUid :: Bool -> OriginMap -> (String,[SigAndTrust]) -> [MappedPacket] -flattenUid ispub om (str,sigs) = MappedPacket (UserIDPacket str) om : concatMap (unsig ispub) sigs +flattenUid :: FilePath -> Bool -> OriginMap -> (String,[SigAndTrust]) -> [MappedPacket] +flattenUid fname ispub om (str,sigs) = + MappedPacket (UserIDPacket str) om : concatMap (unsig fname ispub) sigs -flattenSub :: Bool -> SubKey -> [MappedPacket] -flattenSub ispub (SubKey key sigs) = unk ispub key: concatMap (unsig ispub) sigs +flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket] +flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatMap (unsig fname ispub) sigs unk :: Bool -> MappedPacket -> MappedPacket unk isPublic = if isPublic then toPacket secretToPublic else id where toPacket f (MappedPacket p m) = MappedPacket (f p) m -unsig :: Bool -> SigAndTrust -> [MappedPacket] -unsig isPublic (sig,trustmap) = [sig]++ map (flip MappedPacket Map.empty) ( take 1 . Map.elems $ Map.filterWithKey f trustmap) + +unsig :: FilePath -> Bool -> SigAndTrust -> [MappedPacket] +unsig fname isPublic (sig,trustmap) = + [sig]++ map (asMapped (-1)) ( take 1 . Map.elems $ Map.filterWithKey f trustmap) where - f "%secring" _ = not isPublic - f _ _ = isPublic + f n _ = n==fname -- && trace ("fname=n="++show n) True + asMapped n p = MappedPacket p (Map.singleton fname (origin p n)) ifSecret (SecretKeyPacket {}) t f = t ifSecret _ t f = f @@ -1040,7 +1043,7 @@ writeOutKeyrings db = do let x = do d@(KeyData p _ _ _) <- filter (fromfile f) ks n <- maybeToList $ Map.lookup f (locations p) - flattenTop (originallyPublic n) d + flattenTop f (originallyPublic n) d changes = filter notnew x where notnew p = isNothing (Map.lookup f $ locations p) unlines $ ( (f ++ ":") : map (showPacket . packet) x) ++ -- cgit v1.2.3