summaryrefslogtreecommitdiff
path: root/ymir
diff options
context:
space:
mode:
Diffstat (limited to 'ymir')
-rw-r--r--ymir/mlmmj-expose.nix6
1 files changed, 4 insertions, 2 deletions
diff --git a/ymir/mlmmj-expose.nix b/ymir/mlmmj-expose.nix
index df1374ae..15d846dc 100644
--- a/ymir/mlmmj-expose.nix
+++ b/ymir/mlmmj-expose.nix
@@ -40,7 +40,7 @@ let
40 setCurrentDirectory listDir 40 setCurrentDirectory listDir
41 key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) 41 key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e)
42 let ((map toLower -> ident), (map toLower -> recipient)) = read . CLBS.unpack $ decryptMsg CBC key extension 42 let ((map toLower -> ident), (map toLower -> recipient)) = read . CLBS.unpack $ decryptMsg CBC key extension
43 identities <- (lines <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) 43 identities <- getIdentities
44 unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’" 44 unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’"
45 subscribers <- getSubscribers 45 subscribers <- getSubscribers
46 unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’" 46 unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’"
@@ -63,7 +63,7 @@ let
63 (dropTrailingPathSeparator -> listDir) : (map toLower -> ident) : (map (map toLower) -> recipients) -> do 63 (dropTrailingPathSeparator -> listDir) : (map toLower -> ident) : (map (map toLower) -> recipients) -> do
64 setCurrentDirectory listDir 64 setCurrentDirectory listDir
65 key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) 65 key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e)
66 identities <- (lines <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) 66 identities <- getIdentities
67 unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’" 67 unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’"
68 subscribers <- getSubscribers 68 subscribers <- getSubscribers
69 forM_ recipients (\recipient -> do { 69 forM_ recipients (\recipient -> do {
@@ -72,6 +72,8 @@ let
72 }) 72 })
73 _ -> hPutStrLn stderr ("Called without expected arguments (<listDirectory> <senderIdentity> [<recipient> [...]])") >> exitWith (ExitFailure 2) 73 _ -> hPutStrLn stderr ("Called without expected arguments (<listDirectory> <senderIdentity> [<recipient> [...]])") >> exitWith (ExitFailure 2)
74 _ -> hPutStrLn stderr ("Called under unsupported name ‘" ++ progName ++ "’") >> exitWith (ExitFailure 2) 74 _ -> hPutStrLn stderr ("Called under unsupported name ‘" ++ progName ++ "’") >> exitWith (ExitFailure 2)
75 getIdentities :: IO [String]
76 getIdentities = (filter (not . null) . lines <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e)
75 77
76 getSubscribers :: IO [String] 78 getSubscribers :: IO [String]
77 getSubscribers = map (map toLower) . concat <$> mapM (flip catchIOError (\e -> if isDoesNotExistError e then return [] else ioError e) . readDir) ["subscribers.d", "digesters.d"] 79 getSubscribers = map (map toLower) . concat <$> mapM (flip catchIOError (\e -> if isDoesNotExistError e then return [] else ioError e) . readDir) ["subscribers.d", "digesters.d"]