diff options
author | joe <joe@jerkface.net> | 2015-06-23 15:03:08 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2015-06-23 15:03:08 -0400 |
commit | 8c270f0c8600e872cd2c617e77e3e305462bb4c2 (patch) | |
tree | 60b93c2426d41747cc8bb83cd6d988e219ad4ee1 /kiki.hs | |
parent | a4592a399181aa27bde2ff954eb1077735474566 (diff) | |
parent | f93783738f4fefc62c17ad2fd7893f6639b932e1 (diff) |
Merge branch 'delete-key'
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 48 |
1 files changed, 41 insertions, 7 deletions
@@ -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 | ||
@@ -1313,6 +1316,36 @@ kiki "init-key" args = do | |||
1313 | 1316 | ||
1314 | mapM_ installConctact cs | 1317 | mapM_ installConctact cs |
1315 | 1318 | ||
1319 | kiki "delete" args | "--help" `elem` args = do | ||
1320 | putStr . unlines $ | ||
1321 | [ "kiki delete <fingerprint> ..." | ||
1322 | , "" | ||
1323 | , " Delete the subkeys specified by the given fingerprints along" | ||
1324 | , " with all associated signatures and trust markers." | ||
1325 | ] | ||
1326 | return () | ||
1327 | kiki "delete" args = do | ||
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 | ||
1348 | |||
1316 | splitArg :: String -> Either (String,Maybe String) String | 1349 | splitArg :: String -> Either (String,Maybe String) String |
1317 | splitArg arg = | 1350 | splitArg arg = |
1318 | case hyphens of | 1351 | case hyphens of |
@@ -1341,6 +1374,7 @@ commands = | |||
1341 | , ( "working-key", "show the current working master key and its subkeys" ) | 1374 | , ( "working-key", "show the current working master key and its subkeys" ) |
1342 | , ( "merge", "low level import/export operation" ) | 1375 | , ( "merge", "low level import/export operation" ) |
1343 | , ( "init-key", "initialize the samizdat key ring") | 1376 | , ( "init-key", "initialize the samizdat key ring") |
1377 | , ( "delete", "Delete a subkey and its associated signatures" ) | ||
1344 | ] | 1378 | ] |
1345 | 1379 | ||
1346 | interp vars raw = es >>= interp1 | 1380 | interp vars raw = es >>= interp1 |