summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2015-06-23 12:55:43 -0400
committerjoe <joe@jerkface.net>2015-06-23 12:55:43 -0400
commit4525b9f9a90f87fb17174ba594abbcff3df0a5d6 (patch)
tree1274a9981d82abaf5b490b33550871cf039fe07f /kiki.hs
parent29ac6350e08bad1c41a73965a12a06cd5e985641 (diff)
Implemented command to delete subkeys
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs44
1 files changed, 33 insertions, 11 deletions
diff --git a/kiki.hs b/kiki.hs
index 17cbeb1..6eb5954 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -758,7 +758,15 @@ parseKeySpecs = map $ \specfile -> do
758 let cmd = (drop 1 . reverse . drop 1) bdmcb 758 let cmd = (drop 1 . reverse . drop 1) bdmcb
759 Just (spec,file,cmd) 759 Just (spec,file,cmd)
760 760
761--kiki :: (Eq a, Data.String.IsString a) => a -> [String] -> IO () 761buildStreamInfo :: KeyFilter -> FileType -> StreamInfo
762buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp
763 , fill = rtyp
764 , spill = KF_All
765 , access = AutoAccess
766 , initializer = Nothing
767 , transforms = [] }
768
769sync :: Bool -> Bool -> Bool -> String -> [String] -> IO ()
762sync bExport bImport bSecret cmdarg args_raw = do 770sync bExport bImport bSecret cmdarg args_raw = do
763 let (sargs,margs) = processArgs sargspec polyVariadicArgs "--keyrings" args_raw 771 let (sargs,margs) = processArgs sargspec polyVariadicArgs "--keyrings" args_raw
764 sargspec = [ ("--import",0) 772 sargspec = [ ("--import",0)
@@ -828,12 +836,6 @@ sync bExport bImport bSecret cmdarg args_raw = do
828 $ Map.lookup "--import" margs 836 $ Map.lookup "--import" margs
829 importifauth_f = fmap (const KF_Authentic) 837 importifauth_f = fmap (const KF_Authentic)
830 $ Map.lookup "--import-if-authentic" margs 838 $ Map.lookup "--import-if-authentic" margs
831 buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp
832 , fill = rtyp
833 , spill = KF_All
834 , access = AutoAccess
835 , initializer = Nothing
836 , transforms = [] }
837 kikiOp = KeyRingOperation 839 kikiOp = KeyRingOperation
838 { opFiles = Map.fromList $ 840 { opFiles = Map.fromList $
839 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All 841 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All
@@ -876,6 +878,7 @@ sync bExport bImport bSecret cmdarg args_raw = do
876 putStrLn $ fname ++ ": " ++ reportString act 878 putStrLn $ fname ++ ": " ++ reportString act
877 879
878 880
881kiki :: String -> [String] -> IO ()
879kiki "sync-secret" args_raw = 882kiki "sync-secret" args_raw =
880 sync True True True "sync-secret" args_raw 883 sync True True True "sync-secret" args_raw
881 884
@@ -1315,14 +1318,33 @@ kiki "init-key" args = do
1315 1318
1316kiki "delete" args | "--help" `elem` args = do 1319kiki "delete" args | "--help" `elem` args = do
1317 putStr . unlines $ 1320 putStr . unlines $
1318 [ "kiki delete <fingerprint>" 1321 [ "kiki delete <fingerprint> ..."
1319 , "" 1322 , ""
1320 , " Delete the subkey specified by the given fingerprint along" 1323 , " Delete the subkeys specified by the given fingerprints along"
1321 , " with all of its associated signatures and trust markers." 1324 , " with all associated signatures and trust markers."
1322 ] 1325 ]
1323 return () 1326 return ()
1324kiki "delete" args = do 1327kiki "delete" args = do
1325 putStr "NOT IMPLEMENTED" 1328 let (sargs,margs) = processArgs sargspec polyVariadicArgs "--delete" args
1329 where sargspec = []
1330 polyVariadicArgs = ["--delete"]
1331 passfd = fmap (FileDesc . read) passphrase_fd
1332 where passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs
1333 fps = fromMaybe [] $ Map.lookup "--delete" margs
1334 homespec = join . take 1 <$> Map.lookup "--homedir" margs
1335 kikiOp = KeyRingOperation
1336 { opFiles = Map.fromList $
1337 [ ( HomeSec, buildStreamInfo KF_All KeyRingFile )
1338 , ( HomePub, buildStreamInfo KF_All KeyRingFile )
1339 ]
1340 , opPassphrases = do pfile <- maybeToList passfd
1341 return $ PassphraseSpec Nothing Nothing pfile
1342 , opTransforms = map DeleteSubKey fps
1343 , opHome = homespec
1344 }
1345 KikiResult rt report <- runKeyRing kikiOp
1346 forM_ report $ \(fname,act) -> do
1347 putStrLn $ fname ++ ": " ++ reportString act
1326 1348
1327splitArg :: String -> Either (String,Maybe String) String 1349splitArg :: String -> Either (String,Maybe String) String
1328splitArg arg = 1350splitArg arg =