diff options
author | joe <joe@jerkface.net> | 2015-06-23 12:55:43 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2015-06-23 12:55:43 -0400 |
commit | 4525b9f9a90f87fb17174ba594abbcff3df0a5d6 (patch) | |
tree | 1274a9981d82abaf5b490b33550871cf039fe07f | |
parent | 29ac6350e08bad1c41a73965a12a06cd5e985641 (diff) |
Implemented command to delete subkeys
-rw-r--r-- | KeyRing.hs | 4 | ||||
-rw-r--r-- | kiki.hs | 44 |
2 files changed, 35 insertions, 13 deletions
@@ -626,7 +626,7 @@ data KikiReportAction = | |||
626 | | UnableToExport KeyAlgorithm String | 626 | | UnableToExport KeyAlgorithm String |
627 | | FailedFileWrite | 627 | | FailedFileWrite |
628 | | HostsDiff ByteString | 628 | | HostsDiff ByteString |
629 | | DeletedPacket Packet | 629 | | DeletedPacket String |
630 | deriving Show | 630 | deriving Show |
631 | 631 | ||
632 | uncamel :: String -> String | 632 | uncamel :: String -> String |
@@ -2147,7 +2147,7 @@ performManipulations doDecrypt rt wk manip = do | |||
2147 | return $ packet mp : concatMap (\(p,ts) -> packet p : Map.elems ts) sigs | 2147 | return $ packet mp : concatMap (\(p,ts) -> packet p : Map.elems ts) sigs |
2148 | ctx = InputFileContext (rtSecring rt) (rtPubring rt) | 2148 | ctx = InputFileContext (rtSecring rt) (rtPubring rt) |
2149 | rings = [HomeSec, HomePub] >>= resolveInputFile ctx | 2149 | rings = [HomeSec, HomePub] >>= resolveInputFile ctx |
2150 | return $ KikiSuccess (kd' , report ++ [ (f,DeletedPacket p) | f <- rings, p <- ps ]) | 2150 | return $ KikiSuccess (kd' , report ++ [ (f,DeletedPacket $ showPacket p) | f <- rings, p <- ps ]) |
2151 | 2151 | ||
2152 | initializeMissingPEMFiles :: | 2152 | initializeMissingPEMFiles :: |
2153 | KeyRingOperation | 2153 | KeyRingOperation |
@@ -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 () | 761 | buildStreamInfo :: KeyFilter -> FileType -> StreamInfo |
762 | buildStreamInfo rtyp ftyp = StreamInfo { typ = ftyp | ||
763 | , fill = rtyp | ||
764 | , spill = KF_All | ||
765 | , access = AutoAccess | ||
766 | , initializer = Nothing | ||
767 | , transforms = [] } | ||
768 | |||
769 | sync :: Bool -> Bool -> Bool -> String -> [String] -> IO () | ||
762 | sync bExport bImport bSecret cmdarg args_raw = do | 770 | sync 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 | ||
881 | kiki :: String -> [String] -> IO () | ||
879 | kiki "sync-secret" args_raw = | 882 | kiki "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 | ||
1316 | kiki "delete" args | "--help" `elem` args = do | 1319 | kiki "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 () |
1324 | kiki "delete" args = do | 1327 | kiki "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 | ||
1327 | splitArg :: String -> Either (String,Maybe String) String | 1349 | splitArg :: String -> Either (String,Maybe String) String |
1328 | splitArg arg = | 1350 | splitArg arg = |