2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere gen-subkey subcommand
6 # The monkeysphere scripts are written by:
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 # They are Copyright 2008-2009, and are all released under the GPL,
14 # generate a subkey with the 'a' usage flags set
32 if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then
33 failure "Unknown option '$1'.
34 Type '$PGRM help' for usage."
41 # check that the keyID is unique
42 keyID=$(check_gpg_sec_key_id "$@")
44 # check that an authentication subkey does not already exist
45 check_gpg_authentication_subkey "$keyID"
47 # generate the list of commands that will be passed to edit-key
63 # setup the temp fifo dir for retrieving the key password
64 log debug "creating password fifo..."
65 fifoDir=$(msmktempdir)
66 (umask 077 && mkfifo "$fifoDir/pass")
68 # FIXME: are we adequately cleaning up any trailing gpg process here?
69 trap "rm -rf $fifoDir; kill %% || true" EXIT
70 echo "$editCommands" | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --edit-key "$keyID" &
72 log debug "Prompting for passphrase"
73 # FIXME: this needs to fail more gracefully if the passphrase is incorrect
74 passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass"
75 log info "Generating subkey. This may take a long time..."