+# export the monkeysphere OpenPGP pub key file
+update_pgp_pub_file() {
+ log debug "updating openpgp public key file '$HOST_KEY_FILE'..."
+ gpg_host --export --armor --export-options export-minimal \
+ $(gpg_host --list-secret-keys --with-colons --fingerprint | grep ^fpr | cut -f10 -d:) \
+ > "$HOST_KEY_FILE"
+}
+
+# check that the service name is well formed
+check_service_name() {
+ local name="$1"
+ log error "FIX ME: check service name"
+}
+
+# fail if host key not present
+check_no_keys() {
+ [ -s "$HOST_KEY_FILE" ] \
+ || failure "You don't appear to have a Monkeysphere host key on this server.
+Please run 'monkeysphere-host import-key' import a key."
+}
+
+# key input to functions, outputs full fingerprint of specified key if
+# found
+check_key_input() {
+ local keyID="$1"
+ # array of fingerprints
+ local fprs=($(list_primary_fingerprints <"$HOST_KEY_FILE"))
+
+ case ${#fprs[@]} in
+ 0)
+ failure "You don't appear to have any Monkeysphere host keys.
+Please run 'monkeysphere-host import-key' to import a key."
+ ;;
+ 1)
+ :
+ ;;
+ *)
+ if [ -z "$keyID" ] ; then
+ failure "Your host keyring contains multiple keys.
+Please specify one to act on (see 'monkeysphere-host show-keys')."
+ fi
+ ;;
+ esac
+ printf '%s\n' "${fprs[@]}" | grep "${keyID}$" \
+ || failure "Host key '$keyID' not found."
+}
+
+# return 0 if user ID was found.
+# return 1 if user ID not found.
+check_key_userid() {
+ local keyID="$1"
+ local userID="$2"
+ local tmpuidMatch
+
+ # match to only "unknown" user IDs (host has no need for ultimate trust)
+ tmpuidMatch="uid:-:$(echo $userID | gpg_escape)"