diff options
author | joe <joe@jerkface.net> | 2014-04-11 22:02:48 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-11 22:02:48 -0400 |
commit | b9c338d14e8d95164dfe3719abb4cf8064e22bd2 (patch) | |
tree | 69b8daa9efbcc25be940fd8b19585521f870ad4f /kiki.hs | |
parent | a6064eab0e9524ff9221d2079b7e425b3f9a70ba (diff) |
process secring/pubring separately from others
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -1305,24 +1305,34 @@ writeOutKeyrings lkmap db = do | |||
1305 | -- warn $ "writing "++f | 1305 | -- warn $ "writing "++f |
1306 | L.writeFile f (encode m) | 1306 | L.writeFile f (encode m) |
1307 | 1307 | ||
1308 | cross_merge doDecrypt homespec keyrings_ wallets f = do | 1308 | cross_merge doDecrypt homespec keyrings wallets f = do |
1309 | (homedir,secring,pubring,grip0) <- getHomeDir homespec | 1309 | let readp n = fmap (n,) (readPacketsFromFile n) |
1310 | let keyrings = secring:pubring:keyrings_ | 1310 | readw wk n = fmap (n,) (readPacketsFromWallet wk n) |
1311 | 1311 | ||
1312 | let relock = do | 1312 | let relock keyrings = do |
1313 | (fsns,failed_locks) <- lockFiles keyrings | 1313 | (fsns,failed_locks) <- lockFiles keyrings |
1314 | (wsns,failed_wlocks) <- lockFiles wallets | 1314 | (wsns,failed_wlocks) <- lockFiles wallets |
1315 | forM_ (failed_locks++failed_wlocks) $ \f -> warn $ "Failed to lock: " ++ f | 1315 | forM_ (failed_locks++failed_wlocks) $ \f -> warn $ "Failed to lock: " ++ f |
1316 | return (fsns,wsns,failed_locks,failed_wlocks) | 1316 | return (fsns,wsns,failed_locks,failed_wlocks) |
1317 | sec_n:_ = keyrings | 1317 | sec_n:_ = keyrings |
1318 | (fsns,wsns,failed_locks,failed_wlocks) <- relock | 1318 | |
1319 | (homedir,secring,pubring,grip0) <- getHomeDir homespec | ||
1320 | |||
1321 | (fsns0,wsns0,failed_locks0,failed_wlocks0) <- relock [secring,pubring] | ||
1322 | db00 <- do | ||
1323 | ms0 <- mapM readp (map snd fsns0++failed_locks0) | ||
1324 | return $ foldl' (uncurry . merge) Map.empty ms0 | ||
1325 | |||
1326 | (fsns,wsns,failed_locks,failed_wlocks) <- relock keyrings | ||
1327 | wsns <- return $ wsns0 ++ wsns | ||
1328 | failed_locks <- return $ failed_locks0 ++ failed_locks | ||
1329 | failed_wlocks <- return $ failed_wlocks0 ++ failed_wlocks | ||
1330 | |||
1319 | -- let (lks,fs) = unzip fsns | 1331 | -- let (lks,fs) = unzip fsns |
1320 | -- forM_ fs $ \f -> warn $ "locked: " ++ f | 1332 | -- forM_ fs $ \f -> warn $ "locked: " ++ f |
1321 | let readp n = fmap (n,) (readPacketsFromFile n) | ||
1322 | readw wk n = fmap (n,) (readPacketsFromWallet wk n) | ||
1323 | let pass n (fsns,failed_locks) = do | 1333 | let pass n (fsns,failed_locks) = do |
1324 | ms <- mapM readp (map snd fsns++failed_locks) | 1334 | ms <- mapM readp (map snd fsns++failed_locks) |
1325 | let db0 = foldl' (uncurry . merge) Map.empty ms | 1335 | let db0 = foldl' (uncurry . merge) db00 ms |
1326 | fstkey = listToMaybe $ mapMaybe isSecringKey ms | 1336 | fstkey = listToMaybe $ mapMaybe isSecringKey ms |
1327 | where isSecringKey (fn,Message ps) | 1337 | where isSecringKey (fn,Message ps) |
1328 | | fn==sec_n = listToMaybe ps | 1338 | | fn==sec_n = listToMaybe ps |