diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-02 02:26:03 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-02 02:26:03 +0200 |
commit | 63d07ed055ec4cb92aff1cac666288720d52d65f (patch) | |
tree | dd591ac1dcce454f8a863565818e3f781a2556ad | |
parent | 53e1a9e8343de1b7bbedff1568a6f4a306875bd8 (diff) | |
download | nixos-63d07ed055ec4cb92aff1cac666288720d52d65f.tar nixos-63d07ed055ec4cb92aff1cac666288720d52d65f.tar.gz nixos-63d07ed055ec4cb92aff1cac666288720d52d65f.tar.bz2 nixos-63d07ed055ec4cb92aff1cac666288720d52d65f.tar.xz nixos-63d07ed055ec4cb92aff1cac666288720d52d65f.zip |
better storage format
-rw-r--r-- | ymir/mlmmj-expose.nix | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ymir/mlmmj-expose.nix b/ymir/mlmmj-expose.nix index 6673c06c..3481308d 100644 --- a/ymir/mlmmj-expose.nix +++ b/ymir/mlmmj-expose.nix | |||
@@ -41,7 +41,7 @@ let | |||
41 | setCurrentDirectory listDir | 41 | setCurrentDirectory listDir |
42 | key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) | 42 | key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) |
43 | let ((map toLower -> ident), (map toLower -> recipient)) = read . CLBS.unpack $ decryptMsg CBC key extension | 43 | let ((map toLower -> ident), (map toLower -> recipient)) = read . CLBS.unpack $ decryptMsg CBC key extension |
44 | identities <- (read <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) | 44 | identities <- (lines <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) |
45 | unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’" | 45 | unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’" |
46 | subscribers <- getSubscribers | 46 | subscribers <- getSubscribers |
47 | unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’" | 47 | unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’" |
@@ -56,7 +56,7 @@ let | |||
56 | identities <- (read <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) | 56 | identities <- (read <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) |
57 | case ident `elem` identities of | 57 | case ident `elem` identities of |
58 | True -> putStrLn "Identity is already known" | 58 | True -> putStrLn "Identity is already known" |
59 | False -> writeFile "exposed.ids" . show $ ident : identities | 59 | False -> writeFile "exposed.ids" . unlines $ ident : identities |
60 | _ -> hPutStrLn stderr ("Called without expected arguments (<listDirectory> <senderIdentity>)") >> exitWith (ExitFailure 2) | 60 | _ -> hPutStrLn stderr ("Called without expected arguments (<listDirectory> <senderIdentity>)") >> exitWith (ExitFailure 2) |
61 | "mlmmj-get-exposed" -> do | 61 | "mlmmj-get-exposed" -> do |
62 | args <- getArgs | 62 | args <- getArgs |
@@ -64,7 +64,7 @@ let | |||
64 | [listDir, (map toLower -> ident), (map toLower -> recipient)] -> do | 64 | [listDir, (map toLower -> ident), (map toLower -> recipient)] -> do |
65 | setCurrentDirectory listDir | 65 | setCurrentDirectory listDir |
66 | key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) | 66 | key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) |
67 | identities <- (read <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) | 67 | identities <- (lines <$> readFile "exposed.ids") `catchIOError` (\e -> if isDoesNotExistError e then return [] else ioError e) |
68 | unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’" | 68 | unless (ident `elem` identities) . die $ "Unknown sender: ‘" ++ ident ++ "’" |
69 | subscribers <- getSubscribers | 69 | subscribers <- getSubscribers |
70 | unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’" | 70 | unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’" |