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
31 if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then
32 failure "Unknown option '$1'.
33 Type '$PGRM help' for usage."
40 # check that the keyID is unique
41 keyID=$(check_gpg_sec_key_id "$@")
43 # check that an authentication subkey does not already exist
44 check_gpg_authentication_subkey "$keyID"
46 # generate the list of commands that will be passed to edit-key
47 editCommands=$(cat <<EOF
60 # setup the temp fifo dir for retrieving the key password
61 log debug "creating password fifo..."
62 fifoDir=$(msmktempdir)
63 trap "rm -rf $fifoDir" EXIT
64 (umask 077 && mkfifo "$fifoDir/pass")
66 log verbose "generating subkey..."
67 echo "$editCommands" | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --edit-key "$keyID" &
69 # FIXME: this needs to fail more gracefully if the passphrase is incorrect
70 passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass"