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
22 failure "You must specify a hostname to add."
27 fingerprint=$(fingerprint_server_key)
29 # match to only ultimately trusted user IDs
30 tmpuidMatch="u:$(echo $userID | gpg_escape)"
32 # find the index of the requsted user ID
33 # NOTE: this is based on circumstantial evidence that the order of
34 # this output is the appropriate index
35 if line=$(gpg_host --list-keys --with-colons --fixed-list-mode "0x${fingerprint}!" \
36 | egrep '^(uid|uat):' | cut -f2,10 -d: | grep -n -x -F "$tmpuidMatch") ; then
37 failure "Host userID '$userID' already exists."
40 echo "The following user ID will be added to the host key:"
42 read -p "Are you sure you would like to add this user ID? (y/N) " OK; OK=${OK:=N}
43 if [ ${OK/y/Y} != 'Y' ] ; then
44 failure "User ID not added."
47 # edit-key script command to add user ID
48 adduidCommand=$(cat <<EOF
57 # execute edit-key script
58 if echo "$adduidCommand" | \
59 gpg_host --quiet --command-fd 0 --edit-key "0x${fingerprint}!" ; then
61 # update the trustdb for the authentication keyring
62 gpg_authentication "--check-trustdb"
67 echo "NOTE: User ID added to key, but key not published."
68 echo "Run '$PGRM publish-key' to publish the new user ID."
70 failure "Problem adding user ID."