summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-05-06 02:27:44 -0400
committerjoe <joe@jerkface.net>2014-05-06 02:27:44 -0400
commit3da9f37f578fe6462a3a69e739bb7e21d78f4b89 (patch)
tree2faeb12c491ee5a96965e02610f4f764f64d8ff6
parent4f495163b6ff423baee8306098152a0435dcdc89 (diff)
Implemented --passphrase-fd for 'merge' command
-rw-r--r--kiki.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/kiki.hs b/kiki.hs
index 5017b38..c84bce2 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -874,7 +874,8 @@ kiki "show" args = do
874 874
875kiki "merge" [] = do 875kiki "merge" [] = do
876 putStr . unlines $ 876 putStr . unlines $
877 [ "kiki merge ( --home[=HOMEDIR]" 877 [ "kiki merge [ --passphrase-fd=FD ]"
878 , " ( --home[=HOMEDIR]"
878 , " | --type=(keyring|pem|wallet|hosts)" 879 , " | --type=(keyring|pem|wallet|hosts)"
879 , " | --access=[auto|secret|public]" 880 , " | --access=[auto|secret|public]"
880 , " | --flow=(fill|spill|sync)[,(subkeys|match=SPEC)]" 881 , " | --flow=(fill|spill|sync)[,(subkeys|match=SPEC)]"
@@ -954,6 +955,16 @@ kiki "merge" args = do
954 ( flow { transforms = filter (/=Autosign) (transforms flow) } 955 ( flow { transforms = filter (/=Autosign) (transforms flow) }
955 , op { opTransforms = filter (/=Autosign) (opTransforms op) } ) 956 , op { opTransforms = filter (/=Autosign) (opTransforms op) } )
956 957
958 doPassphrase :: StreamInfo -> KeyRingOperation -> String -> (StreamInfo,KeyRingOperation)
959 doPassphrase flow op pass =
960 if Map.null (opFiles op)
961 then ( flow
962 , op { opPassphrases = PassphraseSpec Nothing Nothing pfd
963 : opPassphrases op } )
964 else error "passphrase-fd must come before any file arguments or --home"
965 where
966 pfd = FileDesc (read pass)
967
957 buildOp (False,(flow,op)) fname = (False,doFile flow op fname) 968 buildOp (False,(flow,op)) fname = (False,doFile flow op fname)
958 buildOp (True,(flow,op)) arg@(splitArg->parsed) = 969 buildOp (True,(flow,op)) arg@(splitArg->parsed) =
959 case parsed of 970 case parsed of
@@ -970,6 +981,7 @@ kiki "merge" args = do
970 Left ("autosign",Just "n") -> doAutosign False flow op 981 Left ("autosign",Just "n") -> doAutosign False flow op
971 Left ("autosign",Just "no") -> doAutosign False flow op 982 Left ("autosign",Just "no") -> doAutosign False flow op
972 Left ("autosign",Just "false")-> doAutosign False flow op 983 Left ("autosign",Just "false")-> doAutosign False flow op
984 Left ("passphrase-fd",Just pass) -> doPassphrase flow op pass
973 Left ("create",Just cmd) -> 985 Left ("create",Just cmd) ->
974 ( flow { initializer = if null cmd then Nothing else Just cmd } 986 ( flow { initializer = if null cmd then Nothing else Just cmd }
975 , op ) 987 , op )