+# update an authorized_keys file after first processing the
+# authorized_user_ids file
+update_authorized_keys() {
+ local cacheDir
+ local msAuthorizedKeys
+ local userAuthorizedKeys
+
+ cacheDir="$1"
+ msAuthorizedKeys="$2"
+ userAuthorizedKeys="$3"
+
+ process_authorized_ids "$AUTHORIZED_USER_IDS" "$cacheDir"
+
+ # write output key file
+ log "writing monkeysphere authorized_keys file... "
+ touch "$msAuthorizedKeys"
+ if [ "$(ls "$cacheDir")" ] ; then
+ log -n "adding gpg keys... "
+ cat "$cacheDir"/* > "$msAuthorizedKeys"
+ echo "done."
+ else
+ log "no gpg keys to add."
+ fi
+ if [ "$userAuthorizedKeys" -a -s "$userAuthorizedKeys" ] ; then
+ log -n "adding user authorized_keys file... "
+ cat "$userAuthorizedKeys" >> "$msAuthorizedKeys"
+ echo "done."
+ fi
+ log "monkeysphere authorized_keys file generated: $msAuthorizedKeys"
+}
+
+# process an authorized_*_ids file
+# go through line-by-line, extract each userid, and process
+process_authorized_ids() {
+ local authorizedIDs
+ local cacheDir
+ local userID
+
+ authorizedIDs="$1"
+ cacheDir="$2"
+
+ # clean out keys file and remake keys directory
+ rm -rf "$cacheDir"
+ mkdir -p "$cacheDir"
+
+ # loop through all user ids in file
+ # FIXME: needs to handle authorized_keys options
+ cat "$authorizedIDs" | meat | \
+ while read -r userID ; do
+ # process the userid
+ log "processing userid: '$userID'"
+ process_user_id "$userID" "$cacheDir" > /dev/null
+ done
+}
+
+# EXPERIMENTAL (unused) process userids found in authorized_keys file