- knownHosts="$1"
- cacheDir="$2"
-
- # take all the hosts from the known_hosts file (first field),
- # grep out all the hashed hosts (lines starting with '|')...
- cut -d ' ' -f 1 "$knownHosts" | \
- grep -v '^|.*$' | \
- while IFS=, read -r -a hosts ; do
- # ...and process each host
- for host in ${hosts[*]} ; do
- process_host "$host" "$cacheDir"
- done
+ log "processing known_hosts file..."
+
+ hosts=$(meat "$KNOWN_HOSTS" | cut -d ' ' -f 1 | grep -v '^|.*$' | tr , ' ' | tr '\n' ' ')
+
+ # take all the hosts from the known_hosts file (first
+ # field), grep out all the hashed hosts (lines starting
+ # with '|')...
+ update_known_hosts $hosts
+}
+
+# process uids for the authorized_keys file
+process_uid_authorized_keys() {
+ local userID
+ local ok
+ local keyid
+ local idOK
+ local idRemoved
+
+ userID="$1"
+
+ log "processing user ID: $userID"
+
+ for line in $(process_user_id "$userID") ; do
+ ok=$(echo "$line" | cut -d: -f1)
+ keyid=$(echo "$line" | cut -d: -f2)
+
+ sshKey=$(gpg2ssh "$keyid")
+
+ # remove the old host key line
+ remove_line "$AUTHORIZED_KEYS" "$sshKey" && idRemoved=true
+
+ # if key OK, add new host line
+ if [ "$ok" -eq '0' ] ; then
+ ssh2authorized_keys "$userID" "$sshKey" >> "$AUTHORIZED_KEYS"
+
+ # note that at least one ok id was found
+ idOK=true
+ fi