summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2016-04-30 02:58:04 -0400
committerJames Crayne <jim.crayne@gmail.com>2016-04-30 02:58:04 -0400
commite69a1a1f1991c2ce879aaba187002a7b5a5f6827 (patch)
treef5e47fdf81e6a4dcafb7e9a54bb528f2c784f3a0 /kiki.hs
parentc2cf1002fa6f48cc699f6c5925272a2ddb28bd64 (diff)
comments and type signatures
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/kiki.hs b/kiki.hs
index 325fc7f..eabfbf3 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -1000,6 +1000,7 @@ parseCommonArgs margs = CommonArgsParsed { cap_homespec = homespec, cap_passfd =
1000 homespec = join . take 1 <$> Map.lookup "--homedir" margs 1000 homespec = join . take 1 <$> Map.lookup "--homedir" margs
1001 passfd = fmap (FileDesc . read) passphrase_fd 1001 passfd = fmap (FileDesc . read) passphrase_fd
1002 1002
1003parseKeySpecs :: [String] -> [Maybe (String,String,String)]
1003parseKeySpecs = map $ \specfile -> do 1004parseKeySpecs = map $ \specfile -> do
1004 let (spec,efilecmd) = break (=='=') specfile 1005 let (spec,efilecmd) = break (=='=') specfile
1005 guard $ take 1 efilecmd=="=" 1006 guard $ take 1 efilecmd=="="
@@ -1046,12 +1047,13 @@ sync bExport bImport bSecret cmdarg args_raw = do
1046 -- putStrLn $ "margs = " ++ show (Map.assocs margs) 1047 -- putStrLn $ "margs = " ++ show (Map.assocs margs)
1047 unkeysRef <- newIORef Map.empty 1048 unkeysRef <- newIORef Map.empty
1048 pwRef <- newIORef Nothing 1049 pwRef <- newIORef Nothing
1049 let keypairs0 = parseKeySpecs specs 1050 let keypairs0 = parseKeySpecs specs -- [Maybe (usage,path,cmd)]
1050 specs = fromMaybe [] $ Map.lookup "--pems" margs 1051 specs = fromMaybe [] $ Map.lookup "--pems" margs
1051 keyrings_ = fromMaybe [] $ Map.lookup "--keyrings" margs 1052 keyrings_ = fromMaybe [] $ Map.lookup "--keyrings" margs
1052 wallets = fromMaybe [] $ Map.lookup "--wallets" margs 1053 wallets = fromMaybe [] $ Map.lookup "--wallets" margs
1053 passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs 1054 passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs
1054 1055
1056 -- Report first encountered error in Specs
1055 forM_ (take 1 $ filter (isNothing . fst) 1057 forM_ (take 1 $ filter (isNothing . fst)
1056 $ zip keypairs0 specs ) $ \(_,badspec) -> do 1058 $ zip keypairs0 specs ) $ \(_,badspec) -> do
1057 warn $ "Syntax error in key pair specification " ++ show badspec 1059 warn $ "Syntax error in key pair specification " ++ show badspec
@@ -1064,8 +1066,9 @@ sync bExport bImport bSecret cmdarg args_raw = do
1064 let keypairs = catMaybes keypairs0 1066 let keypairs = catMaybes keypairs0
1065 homespec = join . take 1 <$> Map.lookup "--homedir" margs 1067 homespec = join . take 1 <$> Map.lookup "--homedir" margs
1066 passfd = fmap (FileDesc . read) passphrase_fd 1068 passfd = fmap (FileDesc . read) passphrase_fd
1067 reftyp = if bExport then KF_Subkeys 1069 -- reftyp is used as value for 'fill field' in StreamInfo, walts and rings
1068 else KF_None 1070 reftyp = if bExport then KF_Subkeys -- export to rings when they have master present
1071 else KF_None -- export nothing
1069 pems = flip map keypairs 1072 pems = flip map keypairs
1070 $ \(usage,path,cmd) -> 1073 $ \(usage,path,cmd) ->
1071 let cmd' = mfilter (not . null) (Just cmd) 1074 let cmd' = mfilter (not . null) (Just cmd)
@@ -1092,7 +1095,7 @@ sync bExport bImport bSecret cmdarg args_raw = do
1092 keyrings_ 1095 keyrings_
1093 hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs 1096 hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs
1094 where decorate fname = (ArgFile fname, buildStreamInfo reftyp Hosts) 1097 where decorate fname = (ArgFile fname, buildStreamInfo reftyp Hosts)
1095 pubfill = maybe KF_Subkeys id 1098 pubfill = maybe KF_Subkeys id -- Note: --import overrides --import-if-authentic
1096 $ mplus import_f importifauth_f 1099 $ mplus import_f importifauth_f
1097 where 1100 where
1098 import_f = fmap (const KF_All) 1101 import_f = fmap (const KF_All)