From be6c8b5872adb07bae6a9476d505887a01d9b193 Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 28 Apr 2014 19:56:38 -0400 Subject: completely initialize StreamInfo structs --- KeyRing.hs | 1 + kiki.hs | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/KeyRing.hs b/KeyRing.hs index 62e46a8..26fb820 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -8,6 +8,7 @@ module KeyRing ( runKeyRing , StreamInfo(..) + , Access(..) , KeyFilter(..) , KeyRingOperation(..) , KikiResult(..) 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 let keypairs = catMaybes keypairs0 homespec = join . take 1 <$> Map.lookup "--homedir" margs passfd = fmap (FileDesc . read) passphrase_fd - reftyp = if bExport then KF_All + reftyp = if bExport then KF_Subkeys else KF_None pems = flip map keypairs $ \(usage,path,cmd) -> let cmd' = mfilter (not . null) (Just cmd) in if bExport - then (ArgFile path, StreamInfo { fill = KF_All + then (ArgFile path, StreamInfo { fill = KF_Match usage + , spill = KF_Match usage , typ = PEMFile usage + , access = Sec , initializer = cmd' }) else if isNothing cmd' then (ArgFile path, buildStreamInfo KF_None (PEMFile usage)) else error "Unexpected PEM file initializer." - walts = map (\fname -> (ArgFile fname, buildStreamInfo reftyp WalletFile)) + walts = map (\fname -> ( ArgFile fname + , (buildStreamInfo reftyp WalletFile) { access = Sec })) wallets - rings = map (\fname -> (ArgFile fname, buildStreamInfo reftyp (KeyRingFile passfd))) + rings = map (\fname -> ( ArgFile fname + , buildStreamInfo reftyp $ KeyRingFile passfd)) keyrings_ hosts = maybe [] (map decorate) $ Map.lookup "--hosts" margs where decorate fname = (ArgFile fname, buildStreamInfo reftyp Hosts) @@ -841,7 +845,11 @@ sync bExport bImport bSecret cmdarg args_raw = do $ Map.lookup "--import" margs importifauth_f = fmap (const KF_Authentic) $ Map.lookup "--import-if-authentic" margs - buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp, fill = rtyp } + buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp + , fill = rtyp + , spill = KF_All + , access = AutoAccess + , initializer = Nothing } kikiOp = KeyRingOperation { kFiles = Map.fromList $ [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All @@ -945,11 +953,14 @@ kiki "show" args = do walts = [] streaminfo = StreamInfo { fill = KF_None , typ = KeyRingFile passfd + , spill = KF_All + , initializer = Nothing + , access = AutoAccess } kikiOp = KeyRingOperation { kFiles = Map.fromList $ - [ ( HomeSec, streaminfo ) - , ( HomePub, streaminfo ) + [ ( HomeSec, streaminfo { access = Sec }) + , ( HomePub, streaminfo { access = Pub }) ] ++ rings ++ pems -- cgit v1.2.3