3 # Monkeysphere host add-hostname subcommand
5 # The monkeysphere scripts are written by:
6 # Jameson Rollins <jrollins@fifthhorseman.net>
7 # Jamie McClelland <jm@mayfirst.org>
8 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
10 # They are Copyright 2008, and are all released under the GPL, version 3
13 # add hostname user ID to server key
24 failure "You must specify a hostname to add."
29 fingerprint=$(fingerprint_server_key)
31 # match to only ultimately trusted user IDs
32 tmpuidMatch="u:$(echo $userID | gpg_escape)"
34 # find the index of the requsted user ID
35 # NOTE: this is based on circumstantial evidence that the order of
36 # this output is the appropriate index
37 if line=$(gpg_host --list-keys --with-colons --fixed-list-mode "0x${fingerprint}!" \
38 | egrep '^(uid|uat):' | cut -f2,10 -d: | grep -n -x -F "$tmpuidMatch") ; then
39 failure "Host userID '$userID' already exists."
42 echo "The following user ID will be added to the host key:"
44 read -p "Are you sure you would like to add this user ID? (y/N) " OK; OK=${OK:=N}
45 if [ ${OK/y/Y} != 'Y' ] ; then
46 failure "User ID not added."
49 # edit-key script command to add user ID
50 adduidCommand=$(cat <<EOF
59 # execute edit-key script
60 if echo "$adduidCommand" | \
61 gpg_host --quiet --command-fd 0 --edit-key "0x${fingerprint}!" ; then
63 # update the trustdb for the authentication keyring
64 gpg_authentication "--check-trustdb"
69 echo "NOTE: User ID added to key, but key not published."
70 echo "Run '$PGRM publish-key' to publish the new user ID."
72 failure "Problem adding user ID."