summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-28 19:56:38 -0400
committerjoe <joe@jerkface.net>2014-04-28 19:56:38 -0400
commitbe6c8b5872adb07bae6a9476d505887a01d9b193 (patch)
treeb26b7baa2e23b2667a29e0f9cf4efb7f89c879ef /kiki.hs
parentde9f80091979d14fad74ad1be0e6276313eb5d3c (diff)
completely initialize StreamInfo structs
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs25
1 files changed, 18 insertions, 7 deletions
diff --git a/kiki.hs b/kiki.hs
index 93b9d7a..d695afc 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -808,21 +808,25 @@ sync bExport bImport bSecret cmdarg args_raw = do
808 let keypairs = catMaybes keypairs0 808 let keypairs = catMaybes keypairs0
809 homespec = join . take 1 <$> Map.lookup "--homedir" margs 809 homespec = join . take 1 <$> Map.lookup "--homedir" margs
810 passfd = fmap (FileDesc . read) passphrase_fd 810 passfd = fmap (FileDesc . read) passphrase_fd
811 reftyp = if bExport then KF_All 811 reftyp = if bExport then KF_Subkeys
812 else KF_None 812 else KF_None
813 pems = flip map keypairs 813 pems = flip map keypairs
814 $ \(usage,path,cmd) -> 814 $ \(usage,path,cmd) ->
815 let cmd' = mfilter (not . null) (Just cmd) 815 let cmd' = mfilter (not . null) (Just cmd)
816 in if bExport 816 in if bExport
817 then (ArgFile path, StreamInfo { fill = KF_All 817 then (ArgFile path, StreamInfo { fill = KF_Match usage
818 , spill = KF_Match usage
818 , typ = PEMFile usage 819 , typ = PEMFile usage
820 , access = Sec
819 , initializer = cmd' }) 821 , initializer = cmd' })
820 else if isNothing cmd' 822 else if isNothing cmd'
821 then (ArgFile path, buildStreamInfo KF_None (PEMFile usage)) 823 then (ArgFile path, buildStreamInfo KF_None (PEMFile usage))
822 else error "Unexpected PEM file initializer." 824 else error "Unexpected PEM file initializer."
823 walts = map (\fname -> (ArgFile fname, buildStreamInfo reftyp WalletFile)) 825 walts = map (\fname -> ( ArgFile fname
826 , (buildStreamInfo reftyp WalletFile) { access = Sec }))
824 wallets 827 wallets
825 rings = map (\fname -> (ArgFile fname, buildStreamInfo reftyp (KeyRingFile passfd))) 828 rings = map (\fname -> ( ArgFile fname
829 , buildStreamInfo reftyp $ KeyRingFile passfd))
826 keyrings_ 830 keyrings_
827 hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs 831 hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs
828 where decorate fname = (ArgFile fname, buildStreamInfo reftyp Hosts) 832 where decorate fname = (ArgFile fname, buildStreamInfo reftyp Hosts)
@@ -841,7 +845,11 @@ sync bExport bImport bSecret cmdarg args_raw = do
841 $ Map.lookup "--import" margs 845 $ Map.lookup "--import" margs
842 importifauth_f = fmap (const KF_Authentic) 846 importifauth_f = fmap (const KF_Authentic)
843 $ Map.lookup "--import-if-authentic" margs 847 $ Map.lookup "--import-if-authentic" margs
844 buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp, fill = rtyp } 848 buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp
849 , fill = rtyp
850 , spill = KF_All
851 , access = AutoAccess
852 , initializer = Nothing }
845 kikiOp = KeyRingOperation 853 kikiOp = KeyRingOperation
846 { kFiles = Map.fromList $ 854 { kFiles = Map.fromList $
847 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All 855 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All
@@ -945,11 +953,14 @@ kiki "show" args = do
945 walts = [] 953 walts = []
946 streaminfo = StreamInfo { fill = KF_None 954 streaminfo = StreamInfo { fill = KF_None
947 , typ = KeyRingFile passfd 955 , typ = KeyRingFile passfd
956 , spill = KF_All
957 , initializer = Nothing
958 , access = AutoAccess
948 } 959 }
949 kikiOp = KeyRingOperation 960 kikiOp = KeyRingOperation
950 { kFiles = Map.fromList $ 961 { kFiles = Map.fromList $
951 [ ( HomeSec, streaminfo ) 962 [ ( HomeSec, streaminfo { access = Sec })
952 , ( HomePub, streaminfo ) 963 , ( HomePub, streaminfo { access = Pub })
953 ] 964 ]
954 ++ rings 965 ++ rings
955 ++ pems 966 ++ pems