From d8950d3ccdf51f308aa93f06c16f26b15a6c55c4 Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 31 Aug 2016 22:16:21 -0400 Subject: New command to rename subkeys. --- kiki.hs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'kiki.hs') diff --git a/kiki.hs b/kiki.hs index 5c27c36..9796c3d 100644 --- a/kiki.hs +++ b/kiki.hs @@ -1554,6 +1554,37 @@ kiki "delete" args = do forM_ report $ \(fname,act) -> do putStrLn $ fname ++ ": " ++ reportString act +kiki "rename" args | "--help" `elem` args = do + putStr . unlines $ + [ "kiki rename [--homedir ] [--passphrase-fd ] " + , "" + , " Reassigns a key usage tag from old-tag to new-tag." + , " The old signature will be replaced and a new one formed." + ] + return () +kiki "rename" args = do + let (sargs,margs) = processArgs sargspec polyVariadicArgs "--rename" args + where sargspec = [("--homedir",1)] + polyVariadicArgs = ["--rename"] + passfd = fmap (FileDesc . read) passphrase_fd + where passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs + (oldtag:newtag:_) = fromMaybe [] $ Map.lookup "--rename" margs + homespec = join . take 1 <$> Map.lookup "--homedir" margs + kikiOp = KeyRingOperation + { opFiles = Map.fromList $ + [ ( HomeSec, buildStreamInfo KF_All KeyRingFile ) + , ( HomePub, buildStreamInfo KF_All KeyRingFile ) + ] + , opPassphrases = withAgent $ do pfile <- maybeToList passfd + return $ PassphraseSpec Nothing Nothing pfile + , opTransforms = [ RenameSubkeys oldtag newtag] + , opHome = homespec + } + KikiResult rt report <- runKeyRing kikiOp + forM_ report $ \(fname,act) -> do + putStrLn $ fname ++ ": " ++ reportString act + + kiki "tar" args | "--help" `elem` args = do putStr . unlines $ [ "kiki tar (-c|-t) [--secrets SPEC] [--passphrase-fd FD] [--homedir HOMEDIR]" @@ -1752,7 +1783,7 @@ commands = -- , ( "init-key", "initialize the samizdat key ring") , ( "init", "Initialize kiki") , ( "delete", "Delete a subkey and its associated signatures" ) - -- TODO: , ( "rename", "Change the usage tag on a specified subkey" ) + , ( "rename", "Change the usage tag on a specified subkey" ) -- also repairs signature and adds missing cross-certification. , ( "tar", "import or export system key files in tar format" ) ] -- cgit v1.2.3