From 94efc2744b7d6288dd08b7e3f74337345ae0efb0 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 6 May 2014 01:40:43 -0400 Subject: reporting for per-file transformations --- KeyRing.hs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/KeyRing.hs b/KeyRing.hs index 023c027..ffd8183 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -266,21 +266,20 @@ data StreamInfo = StreamInfo { access :: Access -- 'WalletFile': -- -- * The 'spill' setting is ignored and the file's contents are shared. - -- (TODO) + -- (TODO) -- -- 'Hosts': -- -- * The 'spill' setting is ignored and the file's contents are shared. - -- (TODO) + -- (TODO) -- , initializer :: Maybe String -- ^ If 'typ' is 'PEMFile' and an 'initializer' string is set, then it is -- interpretted as a shell command that may be used to create the key if it -- does not exist. , transforms :: [Transform] - -- ^ Ignored. TODO: The intention is that we may indicate per-file - -- transformations that occur before the contents of a file are spilled - -- into the common pool. + -- ^ Per-file transformations that occur before the contents of a file are + -- spilled into the common pool. } @@ -1274,19 +1273,20 @@ buildKeyDB ctx grip0 keyring = do , rtRingAccess = accs , rtKeyDB = Map.empty } - transformed <- + transformed0 <- let trans f (info,ps) = do let manip = combineTransforms (transforms info) rt1 = rt0 { rtKeyDB = merge Map.empty f ps } - acc = True + acc = Just Sec /= Map.lookup f accs r <- performManipulations doDecrypt rt1 mwk manip - return $ either (const (info,ps)) - (\(rt2,report) -> (info,flattenKeys acc $ rtKeyDB rt2)) - $ functorToEither r - in Map.traverseWithKey trans spilled + try r $ \(rt2,report) -> do + return $ KikiSuccess (report,(info,flattenKeys acc $ rtKeyDB rt2)) + in fmap sequenceA $ Map.traverseWithKey trans spilled + try transformed0 $ \transformed -> do let db_rings = Map.foldlWithKey' mergeIt Map.empty transformed where - mergeIt db f (info,ps) = merge db f ps + mergeIt db f (_,(info,ps)) = merge db f ps + reportTrans = concat $ Map.elems $ fmap fst transformed -- Wallets let importWalletKey wk db' (top,fname,sub,tag) = do @@ -1332,7 +1332,7 @@ buildKeyDB ctx grip0 keyring = do try r $ \((db,hs),reportHosts) -> do return $ KikiSuccess ( (db, grip, mwk, hs, accs, doDecrypt, unspilled) - , reportWallets ++ reportPEMs ) + , reportTrans ++ reportWallets ++ reportPEMs ++ reportHosts ) torhash :: Packet -> String torhash key = fromMaybe "" $ derToBase32 <$> derRSA key -- cgit v1.2.3