/usr/share/monkeysphere/m/gen_subkey is in monkeysphere 0.37-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | # -*-shell-script-*-
# This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
# Monkeysphere gen-subkey subcommand
#
# The monkeysphere scripts are written by:
# Jameson Rollins <jrollins@finestructure.net>
# Jamie McClelland <jm@mayfirst.org>
# Daniel Kahn Gillmor <dkg@fifthhorseman.net>
#
# They are Copyright 2008-2009, and are all released under the GPL,
# version 3 or later.
# generate a subkey with the 'a' usage flags set
gen_subkey(){
local keyLength
local gpgSecOut
local keyID
local editCommands
local fifoDir
local keyType
# get options
while true ; do
case "$1" in
-l|--length)
keyLength="$2"
shift 2
;;
*)
if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then
failure "Unknown option '$1'.
Type '$PGRM help' for usage."
fi
break
;;
esac
done
# check that the keyID is unique
keyID=$(check_gpg_sec_key_id "$@")
# check that an authentication subkey does not already exist
check_gpg_authentication_subkey "$keyID"
# determine which keyType to use from gpg version
keyType=7
case $(gpg --version | head -1 | awk '{ print $3 }' | cut -d. -f1) in
1)
if is_gpg_version_greater_equal 1.4.10 ; then
keyType=8
fi
;;
2)
if is_gpg_version_greater_equal 2.0.13 ; then
keyType=8
fi
;;
*)
keyType=8
;;
esac
# generate the list of commands that will be passed to edit-key
editCommands="addkey
$keyType
S
E
A
Q
$keyLength
0
save"
# setup the temp fifo dir for retrieving the key password
log debug "creating password fifo..."
fifoDir=$(msmktempdir)
(umask 077 && mkfifo "$fifoDir/pass")
# FIXME: are we adequately cleaning up any trailing gpg process here?
trap "rm -rf $fifoDir; kill %% || true" EXIT
echo "$editCommands" | gpg_user --batch --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --edit-key "$keyID" &
log debug "Prompting for passphrase"
# FIXME: this needs to fail more gracefully if the passphrase is incorrect
passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass"
log info "Generating subkey. This may take a long time..."
trap - EXIT
rm -rf "$fifoDir"
wait
log verbose "done."
}
|