summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-28 17:41:00 -0400
committerjoe <joe@jerkface.net>2014-04-28 17:41:00 -0400
commit67e72b1bcb9cf4a4d1bcfde6a3f87ed2dc2ff209 (patch)
tree4efcc8fc2ab99cc0b1fa2a7b0a885f319c672266 /kiki.hs
parent794661caa80061d8d20988497867d36c46397f96 (diff)
changed kFiles to use StreamInfo as element type.
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs32
1 files changed, 21 insertions, 11 deletions
diff --git a/kiki.hs b/kiki.hs
index f5e3863..d9e12b6 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -808,22 +808,24 @@ 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 MutableRef Nothing 811 reftyp = if bExport then KF_All
812 else ConstRef 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, (MutableRef cmd', PEMFile usage)) 817 then (ArgFile path, StreamInfo { fill = KF_All
818 , typ = PEMFile usage
819 , initializer = cmd' })
818 else if isNothing cmd' 820 else if isNothing cmd'
819 then (ArgFile path, (ConstRef, PEMFile usage)) 821 then (ArgFile path, buildStreamInfo KF_None (PEMFile usage))
820 else error "Unexpected PEM file initializer." 822 else error "Unexpected PEM file initializer."
821 walts = map (\fname -> (ArgFile fname, (reftyp, WalletFile))) 823 walts = map (\fname -> (ArgFile fname, buildStreamInfo reftyp WalletFile))
822 wallets 824 wallets
823 rings = map (\fname -> (ArgFile fname, (reftyp, KeyRingFile passfd))) 825 rings = map (\fname -> (ArgFile fname, buildStreamInfo reftyp (KeyRingFile passfd)))
824 keyrings_ 826 keyrings_
825 hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs 827 hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs
826 where decorate fname = (ArgFile fname, (reftyp, Hosts)) 828 where decorate fname = (ArgFile fname, buildStreamInfo reftyp Hosts)
827 importStyle = maybe (\_ _ -> subkeysOnly) 829 importStyle = maybe (\_ _ -> subkeysOnly)
828 (\f rt kd -> f rt kd >> importPublic) 830 (\f rt kd -> f rt kd >> importPublic)
829 $ mplus import_f importifauth_f 831 $ mplus import_f importifauth_f
@@ -832,10 +834,15 @@ sync bExport bImport bSecret cmdarg args_raw = do
832 return $ \rt kd -> Just () 834 return $ \rt kd -> Just ()
833 importifauth_f = do Map.lookup "--import-if-authentic" margs 835 importifauth_f = do Map.lookup "--import-if-authentic" margs
834 return guardAuthentic 836 return guardAuthentic
837 buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp, fill = rtyp }
835 kikiOp = KeyRingOperation 838 kikiOp = KeyRingOperation
836 { kFiles = Map.fromList $ 839 { kFiles = Map.fromList $
837 [ ( HomeSec, (if bSecret && bImport then MutableRef Nothing else ConstRef, KeyRingFile passfd) ) 840 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All
838 , ( HomePub, (if bImport then MutableRef Nothing else ConstRef, KeyRingFile Nothing) ) 841 else KF_None)
842 (KeyRingFile passfd) )
843 , ( HomePub, buildStreamInfo (if bImport then KF_All
844 else KF_None)
845 (KeyRingFile Nothing) )
839 ] 846 ]
840 ++ rings 847 ++ rings
841 ++ if bSecret then pems else [] 848 ++ if bSecret then pems else []
@@ -929,10 +936,13 @@ kiki "show" args = do
929 rings = [] 936 rings = []
930 hosts = [] 937 hosts = []
931 walts = [] 938 walts = []
939 streaminfo = StreamInfo { fill = KF_None
940 , typ = KeyRingFile passfd
941 }
932 kikiOp = KeyRingOperation 942 kikiOp = KeyRingOperation
933 { kFiles = Map.fromList $ 943 { kFiles = Map.fromList $
934 [ ( HomeSec, (ConstRef, KeyRingFile passfd) ) 944 [ ( HomeSec, streaminfo )
935 , ( HomePub, (ConstRef, KeyRingFile Nothing) ) 945 , ( HomePub, streaminfo )
936 ] 946 ]
937 ++ rings 947 ++ rings
938 ++ pems 948 ++ pems