2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Shared sh functions for the monkeysphere
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 # Copyright 2008, released under the GPL, version 3 or later
13 # all-caps variables are meant to be user supplied (ie. from config
14 # file) and are considered global
16 ########################################################################
20 SYSCONFIGDIR=${MONKEYSPHERE_SYSCONFIGDIR:-"/etc/monkeysphere"}
23 # monkeysphere version
26 ########################################################################
29 # failure function. exits with code 255, unless specified otherwise.
31 [ "$1" ] && echo "$1" >&2
35 # write output to stderr based on specified LOG_LEVEL the first
36 # parameter is the priority of the output, and everything else is what
37 # is echoed to stderr. If there is nothing else, then output comes
38 # from stdin, and is not prefaced by log prefix.
46 # don't include SILENT in alllevels: it's handled separately
47 # list in decreasing verbosity (all caps).
48 # separate with $IFS explicitly, since we do some fancy footwork
50 alllevels="DEBUG${IFS}VERBOSE${IFS}INFO${IFS}ERROR"
52 # translate lowers to uppers in global log level
53 LOG_LEVEL=$(echo "$LOG_LEVEL" | tr "[:lower:]" "[:upper:]")
55 # just go ahead and return if the log level is silent
56 if [ "$LOG_LEVEL" = 'SILENT' ] ; then
60 for level in $alllevels ; do
61 if [ "$LOG_LEVEL" = "$level" ] ; then
65 if [ -z "$found" ] ; then
70 # get priority from first parameter, translating all lower to
72 priority=$(echo "$1" | tr "[:lower:]" "[:upper:]")
75 # scan over available levels
76 for level in $alllevels ; do
77 # output if the log level matches, set output to true
78 # this will output for all subsequent loops as well.
79 if [ "$LOG_LEVEL" = "$level" ] ; then
82 if [ "$priority" = "$level" -a "$output" = 'true' ] ; then
93 # run command as monkeysphere user
94 su_monkeysphere_user() {
95 # if the current user is the monkeysphere user, then just eval
97 if [ $(id -un) = "$MONKEYSPHERE_USER" ] ; then
100 # otherwise su command as monkeysphere user
102 su "$MONKEYSPHERE_USER" -c "$@"
106 # cut out all comments(#) and blank lines from standard input
108 grep -v -e "^[[:space:]]*#" -e '^$' "$1"
111 # cut a specified line from standard input
113 head --line="$1" "$2" | tail -1
116 # this is a wrapper for doing lock functions.
118 # it lets us depend on either lockfile-progs (preferred) or procmail's
119 # lockfile, and should
121 local use_lockfileprogs=true
125 if ! ( which lockfile-create >/dev/null 2>/dev/null ) ; then
126 if ! ( which lockfile >/dev/null ); then
127 failure "Neither lockfile-create nor lockfile are in the path!"
134 if [ -n "$use_lockfileprogs" ] ; then
135 lockfile-create "$file" || failure "unable to lock '$file'"
137 lockfile -r 20 "${file}.lock" || failure "unable to lock '$file'"
141 if [ -n "$use_lockfileprogs" ] ; then
142 lockfile-touch --oneshot "$file"
148 if [ -n "$use_lockfileprogs" ] ; then
149 lockfile-remove "$file"
155 failure "bad argument for lock subfunction '$action'"
160 # for portability, between gnu date and BSD date.
161 # arguments should be: number longunits format
163 # e.g. advance_date 20 seconds +%F
171 # try things the GNU way first
172 if date -d "$number $longunits" "$format" >/dev/null 2>&1; then
173 date -d "$number $longunits" "$format"
175 # otherwise, convert to (a limited version of) BSD date syntax:
199 # this is a longshot, and will likely fail; oh well.
200 shortunits="$longunits"
202 date "-v+${number}${shortunits}" "$format"
207 # check that characters are in a string (in an AND fashion).
208 # used for checking key capability
209 # check_capability capability a [b...]
218 if echo "$usage" | grep -q -v "$capcheck" ; then
227 md5sum "$1" 2> /dev/null
230 # convert escaped characters in pipeline from gpg output back into
232 # FIXME: undo all escape character translation in with-colons gpg
238 # convert nasty chars into gpg-friendly form in pipeline
239 # FIXME: escape everything, not just colons!
244 # prompt for GPG-formatted expiration, and emit result on stdout
245 get_gpg_expiration() {
250 if [ -z "$keyExpire" ]; then
252 Please specify how long the key should be valid.
253 0 = key does not expire
254 <n> = key expires in n days
255 <n>w = key expires in n weeks
256 <n>m = key expires in n months
257 <n>y = key expires in n years
259 while [ -z "$keyExpire" ] ; do
260 read -p "Key is valid for? (0) " keyExpire
261 if ! test_gpg_expire ${keyExpire:=0} ; then
262 echo "invalid value" >&2
266 elif ! test_gpg_expire "$keyExpire" ; then
267 failure "invalid key expiration value '$keyExpire'."
273 passphrase_prompt() {
278 if [ "$DISPLAY" ] && which "${SSH_ASKPASS:-ssh-askpass}" >/dev/null; then
279 "${SSH_ASKPASS:-ssh-askpass}" "$prompt" > "$fifo"
281 read -s -p "$prompt" PASS
282 # Uses the builtin echo, so should not put the passphrase into
283 # the process table. I think. --dkg
284 echo "$PASS" > "$fifo"
288 test_gnu_dummy_s2k_extension() {
290 # this block contains a demonstration private key that has had the
291 # primary key stripped out using the GNU S2K extension known as
292 # "gnu-dummy" (see /usr/share/doc/gnupg/DETAILS.gz). The subkey is
293 # present in cleartext, however.
295 # openpgp2ssh will be able to deal with this based on whether the
296 # local copy of GnuTLS contains read_s2k support that can handle it.
298 # read up on that here:
300 # http://lists.gnu.org/archive/html/gnutls-devel/2008-08/msg00005.html
303 -----BEGIN PGP PRIVATE KEY BLOCK-----
304 Version: GnuPG v1.4.9 (GNU/Linux)
306 lQCVBEO3YdABBACRqqEnucag4+vyZny2M67Pai5+5suIRRvY+Ly8Ms5MvgCi3EVV
307 xT05O/+0ShiRaf+QicCOFrhbU9PZzzU+seEvkeW2UCu4dQfILkmj+HBEIltGnHr3
308 G0yegHj5pnqrcezERURf2e17gGFWX91cXB9Cm721FPXczuKraphKwCA9PwARAQAB
309 /gNlAkdOVQG0OURlbW9uc3RyYXRpb24gS2V5IGZvciBTMksgR05VIGV4dGVuc2lv
310 biAxMDAxIC0tIGdudS1kdW1teYi8BBMBAgAmBQJDt2HQAhsDBQkB4TOABgsJCAcD
311 AgQVAggDBBYCAwECHgECF4AACgkQQZUwSa4UDezTOQP/TMQXUVrWzHYZGopoPZ2+
312 ZS3qddiznBHsgb7MGYg1KlTiVJSroDUBCHIUJvdQKZV9zrzrFl47D07x6hGyUPHV
313 aZXvuITW8t1o5MMHkCy3pmJ2KgfDvdUxrBvLfgPMICA4c6zA0mWquee43syEW9NY
314 g3q61iPlQwD1J1kX1wlimLCdAdgEQ7dh0AEEANAwa63zlQbuy1Meliy8otwiOa+a
315 mH6pxxUgUNggjyjO5qx+rl25mMjvGIRX4/L1QwIBXJBVi3SgvJW1COZxZqBYqj9U
316 8HVT07mWKFEDf0rZLeUE2jTm16cF9fcW4DQhW+sfYm+hi2sY3HeMuwlUBK9KHfW2
317 +bGeDzVZ4pqfUEudABEBAAEAA/0bemib+wxub9IyVFUp7nPobjQC83qxLSNzrGI/
318 RHzgu/5CQi4tfLOnwbcQsLELfker2hYnjsLrT9PURqK4F7udrWEoZ1I1LymOtLG/
319 4tNZ7Mnul3wRC2tCn7FKx8sGJwGh/3li8vZ6ALVJAyOia5TZ/buX0+QZzt6+hPKk
320 7MU1WQIA4bUBjtrsqDwro94DvPj3/jBnMZbXr6WZIItLNeVDUcM8oHL807Am97K1
321 ueO/f6v1sGAHG6lVPTmtekqPSTWBfwIA7CGFvEyvSALfB8NUa6jtk27NCiw0csql
322 kuhCmwXGMVOiryKEfegkIahf2bAd/gnWHPrpWp7bUE20v8YoW22I4wIAhnm5Wr5Q
323 Sy7EHDUxmJm5TzadFp9gq08qNzHBpXSYXXJ3JuWcL1/awUqp3tE1I6zZ0hZ38Ia6
324 SdBMN88idnhDPqPoiKUEGAECAA8FAkO3YdACGyAFCQHhM4AACgkQQZUwSa4UDezm
325 vQP/ZhK+2ly9oI2z7ZcNC/BJRch0/ybQ3haahII8pXXmOThpZohr/LUgoWgCZdXg
326 vP6yiszNk2tIs8KphCAw7Lw/qzDC2hEORjWO4f46qk73RAgSqG/GyzI4ltWiDhqn
327 vnQCFl3+QFSe4zinqykHnLwGPMXv428d/ZjkIc2ju8dRsn4=
329 -----END PGP PRIVATE KEY BLOCK-----
330 " | openpgp2ssh 4129E89D17C1D591 >/dev/null 2>/dev/null
334 # remove all lines with specified string from specified file
343 if [ -z "$file" -o -z "$string" ] ; then
347 if [ ! -e "$file" ] ; then
351 # if the string is in the file...
352 if grep -q -F "$string" "$file" 2> /dev/null ; then
353 tempfile=$(mktemp "${file}.XXXXXXX") || \
354 failure "Unable to make temp file '${file}.XXXXXXX'"
356 # remove the line with the string, and return 0
357 grep -v -F "$string" "$file" >"$tempfile"
358 cat "$tempfile" > "$file"
367 # remove all lines with MonkeySphere strings in file
368 remove_monkeysphere_lines() {
374 if [ -z "$file" ] ; then
378 if [ ! -e "$file" ] ; then
382 tempfile=$(mktemp "${file}.XXXXXXX") || \
383 failure "Could not make temporary file '${file}.XXXXXXX'."
385 egrep -v '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$' \
387 cat "$tempfile" > "$file"
391 # translate ssh-style path variables %h and %u
392 translate_ssh_variables() {
399 # get the user's home directory
400 userHome=$(getent passwd "$uname" | cut -d: -f6)
402 # translate '%u' to user name
403 path=${path/\%u/"$uname"}
404 # translate '%h' to user home directory
405 path=${path/\%h/"$userHome"}
410 # test that a string to conforms to GPG's expiration format
412 echo "$1" | egrep -q "^[0-9]+[mwy]?$"
415 # check that a file is properly owned, and that all it's parent
416 # directories are not group/other writable
417 check_key_file_permissions() {
425 # function to check that the given permission corresponds to writability
433 # return 255 if cannot stat file
434 if ! stat=$(ls -ld "$path" 2>/dev/null) ; then
435 log error "could not stat path '$path'."
439 owner=$(echo "$stat" | awk '{ print $3 }')
440 gAccess=$(echo "$stat" | cut -c6)
441 oAccess=$(echo "$stat" | cut -c9)
443 # return 1 if path has invalid owner
444 if [ "$owner" != "$uname" -a "$owner" != 'root' ] ; then
445 log error "improper ownership on path '$path'."
449 # return 2 if path has group or other writability
450 if is_write "$gAccess" || is_write "$oAccess" ; then
451 log error "improper group or other writability on path '$path'."
455 # return zero if all clear, or go to next path
456 if [ "$path" = '/' ] ; then
459 check_key_file_permissions "$uname" $(dirname "$path")
463 ### CONVERSION UTILITIES
465 # output the ssh key for a given key ID
471 gpg --export "$keyID" | openpgp2ssh "$keyID" 2> /dev/null
474 # output known_hosts line from ssh key
483 echo -n "$key" | tr -d '\n'
484 echo " MonkeySphere${DATE}"
487 # output authorized_keys line from ssh key
488 ssh2authorized_keys() {
495 echo -n "$key" | tr -d '\n'
496 echo " MonkeySphere${DATE} ${userID}"
499 # convert key from gpg to ssh known_hosts format
507 # NOTE: it seems that ssh-keygen -R removes all comment fields from
508 # all lines in the known_hosts file. why?
509 # NOTE: just in case, the COMMENT can be matched with the
511 # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
513 gpg2ssh "$keyID" | tr -d '\n'
514 echo " MonkeySphere${DATE}"
517 # convert key from gpg to ssh authorized_keys format
518 gpg2authorized_keys() {
525 # NOTE: just in case, the COMMENT can be matched with the
527 # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
528 gpg2ssh "$keyID" | tr -d '\n'
529 echo " MonkeySphere${DATE} ${userID}"
534 # retrieve all keys with given user id from keyserver
535 # FIXME: need to figure out how to retrieve all matching keys
536 # (not just first N (5 in this case))
541 if [ "$CHECK_KEYSERVER" != 'true' ] ; then
547 log verbose " checking keyserver $KEYSERVER... "
549 gpg --quiet --batch --with-colons \
550 --command-fd 0 --keyserver "$KEYSERVER" \
551 --search ="$userID" > /dev/null 2>&1
557 ########################################################################
558 ### PROCESSING FUNCTIONS
560 # userid and key policy checking
561 # the following checks policy on the returned keys
562 # - checks that full key has appropriate valididy (u|f)
563 # - checks key has specified capability (REQUIRED_*_KEY_CAPABILITY)
564 # - checks that requested user ID has appropriate validity
565 # (see /usr/share/doc/gnupg/DETAILS.gz)
566 # output is one line for every found key, in the following format:
570 # "flag" is an acceptability flag, 0 = ok, 1 = bad
571 # "sshKey" is the translated gpg key
573 # all log output must go to stderr, as stdout is used to pass the
574 # flag:sshKey to the calling function.
576 # expects global variable: "MODE"
579 local requiredCapability
580 local requiredPubCapability
595 # set the required key capability based on the mode
596 if [ "$MODE" = 'known_hosts' ] ; then
597 requiredCapability="$REQUIRED_HOST_KEY_CAPABILITY"
598 elif [ "$MODE" = 'authorized_keys' ] ; then
599 requiredCapability="$REQUIRED_USER_KEY_CAPABILITY"
601 requiredPubCapability=$(echo "$requiredCapability" | tr "[:lower:]" "[:upper:]")
603 # fetch the user ID if necessary/requested
604 gpg_fetch_userid "$userID"
606 # output gpg info for (exact) userid and store
607 gpgOut=$(gpg --list-key --fixed-list-mode --with-colon \
608 --with-fingerprint --with-fingerprint \
609 ="$userID" 2>/dev/null)
611 # if the gpg query return code is not 0, return 1
612 if [ "$?" -ne 0 ] ; then
613 log verbose " no primary keys found."
617 # loop over all lines in the gpg output and process.
618 echo "$gpgOut" | cut -d: -f1,2,5,10,12 | \
619 while IFS=: read -r type validity keyid uidfpr usage ; do
620 # process based on record type
622 'pub') # primary keys
623 # new key, wipe the slate
630 log verbose " primary key found: $keyid"
632 # if overall key is not valid, skip
633 if [ "$validity" != 'u' -a "$validity" != 'f' ] ; then
634 log debug " - unacceptable primary key validity ($validity)."
637 # if overall key is disabled, skip
638 if check_capability "$usage" 'D' ; then
639 log debug " - key disabled."
642 # if overall key capability is not ok, skip
643 if ! check_capability "$usage" $requiredPubCapability ; then
644 log debug " - unacceptable primary key capability ($usage)."
648 # mark overall key as ok
651 # mark primary key as ok if capability is ok
652 if check_capability "$usage" $requiredCapability ; then
657 if [ "$lastKey" != pub ] ; then
658 log verbose " ! got a user ID after a sub key?! user IDs should only follow primary keys!"
661 # if an acceptable user ID was already found, skip
662 if [ "$uidOK" = 'true' ] ; then
665 # if the user ID does matches...
666 if [ "$(echo "$uidfpr" | gpg_unescape)" = "$userID" ] ; then
667 # and the user ID validity is ok
668 if [ "$validity" = 'u' -o "$validity" = 'f' ] ; then
669 # mark user ID acceptable
672 log debug " - unacceptable user ID validity ($validity)."
678 # output a line for the primary key
680 if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
681 log verbose " * acceptable primary key."
682 if [ -z "$sshKey" ] ; then
683 log error " ! primary key could not be translated (not RSA or DSA?)."
688 log debug " - unacceptable primary key."
689 if [ -z "$sshKey" ] ; then
690 log debug " ! primary key could not be translated (not RSA or DSA?)."
697 # unset acceptability of last key
702 # don't bother with sub keys if the primary key is not valid
703 if [ "$keyOK" != true ] ; then
707 # don't bother with sub keys if no user ID is acceptable:
708 if [ "$uidOK" != true ] ; then
712 # if sub key validity is not ok, skip
713 if [ "$validity" != 'u' -a "$validity" != 'f' ] ; then
714 log debug " - unacceptable sub key validity ($validity)."
717 # if sub key capability is not ok, skip
718 if ! check_capability "$usage" $requiredCapability ; then
719 log debug " - unacceptable sub key capability ($usage)."
726 'fpr') # key fingerprint
727 fingerprint="$uidfpr"
729 sshKey=$(gpg2ssh "$fingerprint")
731 # if the last key was the pub key, skip
732 if [ "$lastKey" = pub ] ; then
736 # output a line for the sub key
738 if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
739 log verbose " * acceptable sub key."
740 if [ -z "$sshKey" ] ; then
741 log error " ! sub key could not be translated (not RSA or DSA?)."
746 log debug " - unacceptable sub key."
747 if [ -z "$sshKey" ] ; then
748 log debug " ! sub key could not be translated (not RSA or DSA?)."
755 done | sort -t: -k1 -n -r
756 # NOTE: this last sort is important so that the "good" keys (key
757 # flag '0') come last. This is so that they take precedence when
758 # being processed in the key files over "bad" keys (key flag '1')
761 # process a single host in the known_host file
762 process_host_known_hosts() {
773 userID="ssh://${host}"
775 log verbose "processing: $host"
781 for line in $(process_user_id "${userID}") ; do
782 # note that key was found
785 ok=$(echo "$line" | cut -d: -f1)
786 sshKey=$(echo "$line" | cut -d: -f2)
788 if [ -z "$sshKey" ] ; then
792 # remove any old host key line, and note if removed nothing is
794 remove_line "$KNOWN_HOSTS" "$sshKey" || noKey=true
796 # if key OK, add new host line
797 if [ "$ok" -eq '0' ] ; then
798 # note that key was found ok
799 nKeysOK=$((nKeysOK+1))
802 if [ "$HASH_KNOWN_HOSTS" = 'true' ] ; then
803 # FIXME: this is really hackish cause ssh-keygen won't
804 # hash from stdin to stdout
805 tmpfile=$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX)
806 ssh2known_hosts "$host" "$sshKey" > "$tmpfile"
807 ssh-keygen -H -f "$tmpfile" 2> /dev/null
808 cat "$tmpfile" >> "$KNOWN_HOSTS"
809 rm -f "$tmpfile" "${tmpfile}.old"
811 ssh2known_hosts "$host" "$sshKey" >> "$KNOWN_HOSTS"
814 # log if this is a new key to the known_hosts file
815 if [ "$noKey" ] ; then
816 log info "* new key for $host added to known_hosts file."
821 # if at least one key was found...
822 if [ "$nKeys" -gt 0 ] ; then
823 # if ok keys were found, return 0
824 if [ "$nKeysOK" -gt 0 ] ; then
830 # if no keys were found, return 1
836 # update the known_hosts file for a set of hosts listed on command
838 update_known_hosts() {
845 # the number of hosts specified on command line
851 # create a lockfile on known_hosts:
852 lock create "$KNOWN_HOSTS"
853 # FIXME: we're discarding any pre-existing EXIT trap; is this bad?
854 trap "lock remove $KNOWN_HOSTS" EXIT
856 # note pre update file checksum
857 fileCheck="$(file_hash "$KNOWN_HOSTS")"
861 process_host_known_hosts "$host"
865 nHostsOK=$((nHostsOK+1))
868 nHostsBAD=$((nHostsBAD+1))
872 # touch the lockfile, for good measure.
873 lock touch "$KNOWN_HOSTS"
876 # remove the lockfile and the trap
877 lock remove "$KNOWN_HOSTS"
880 # note if the known_hosts file was updated
881 if [ "$(file_hash "$KNOWN_HOSTS")" != "$fileCheck" ] ; then
882 log debug "known_hosts file updated."
885 # if an acceptable host was found, return 0
886 if [ "$nHostsOK" -gt 0 ] ; then
888 # else if no ok hosts were found...
890 # if no bad host were found then no hosts were found at all,
892 if [ "$nHostsBAD" -eq 0 ] ; then
894 # else if at least one bad host was found, return 2
901 # process hosts from a known_hosts file
902 process_known_hosts() {
905 log debug "processing known_hosts file..."
907 hosts=$(meat "$KNOWN_HOSTS" | cut -d ' ' -f 1 | grep -v '^|.*$' | tr , ' ' | tr '\n' ' ')
909 if [ -z "$hosts" ] ; then
910 log debug "no hosts to process."
914 # take all the hosts from the known_hosts file (first
915 # field), grep out all the hashed hosts (lines starting
917 update_known_hosts $hosts
920 # process uids for the authorized_keys file
921 process_uid_authorized_keys() {
930 log verbose "processing: $userID"
936 for line in $(process_user_id "$userID") ; do
937 # note that key was found
940 ok=$(echo "$line" | cut -d: -f1)
941 sshKey=$(echo "$line" | cut -d: -f2)
943 if [ -z "$sshKey" ] ; then
947 # remove the old host key line
948 remove_line "$AUTHORIZED_KEYS" "$sshKey"
950 # if key OK, add new host line
951 if [ "$ok" -eq '0' ] ; then
952 # note that key was found ok
953 nKeysOK=$((nKeysOK+1))
955 ssh2authorized_keys "$userID" "$sshKey" >> "$AUTHORIZED_KEYS"
959 # if at least one key was found...
960 if [ "$nKeys" -gt 0 ] ; then
961 # if ok keys were found, return 0
962 if [ "$nKeysOK" -gt 0 ] ; then
968 # if no keys were found, return 1
974 # update the authorized_keys files from a list of user IDs on command
976 update_authorized_keys() {
983 # the number of ids specified on command line
989 # create a lockfile on authorized_keys
990 lock create "$AUTHORIZED_KEYS"
991 # FIXME: we're discarding any pre-existing EXIT trap; is this bad?
992 trap "lock remove $AUTHORIZED_KEYS" EXIT
994 # note pre update file checksum
995 fileCheck="$(file_hash "$AUTHORIZED_KEYS")"
997 # remove any monkeysphere lines from authorized_keys file
998 remove_monkeysphere_lines "$AUTHORIZED_KEYS"
1001 # process the user ID, change return code if key not found for
1003 process_uid_authorized_keys "$userID"
1008 nIDsOK=$((nIDsOK+1))
1011 nIDsBAD=$((nIDsBAD+1))
1015 # touch the lockfile, for good measure.
1016 lock touch "$AUTHORIZED_KEYS"
1019 # remove the lockfile and the trap
1020 lock remove "$AUTHORIZED_KEYS"
1023 # note if the authorized_keys file was updated
1024 if [ "$(file_hash "$AUTHORIZED_KEYS")" != "$fileCheck" ] ; then
1025 log debug "authorized_keys file updated."
1028 # if an acceptable id was found, return 0
1029 if [ "$nIDsOK" -gt 0 ] ; then
1031 # else if no ok ids were found...
1033 # if no bad ids were found then no ids were found at all, and
1035 if [ "$nIDsBAD" -eq 0 ] ; then
1037 # else if at least one bad id was found, return 2
1044 # process an authorized_user_ids file for authorized_keys
1045 process_authorized_user_ids() {
1050 authorizedUserIDs="$1"
1052 log debug "processing authorized_user_ids file..."
1054 if ! meat "$authorizedUserIDs" > /dev/null ; then
1055 log debug " no user IDs to process."
1061 # extract user IDs from authorized_user_ids file
1063 for line in $(meat "$authorizedUserIDs") ; do
1064 userIDs["$nline"]="$line"
1068 update_authorized_keys "${userIDs[@]}"