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() {
96 # if monkeysphere user, run the command under bash
101 # if root, su command as monkeysphere user
103 su "$MONKEYSPHERE_USER" -c "$@"
108 log error "non-privileged user."
113 # cut out all comments(#) and blank lines from standard input
115 grep -v -e "^[[:space:]]*#" -e '^$' "$1"
118 # cut a specified line from standard input
120 head --line="$1" "$2" | tail -1
123 # this is a wrapper for doing lock functions.
125 # it lets us depend on either lockfile-progs (preferred) or procmail's
126 # lockfile, and should
128 local use_lockfileprogs=true
132 if ! ( which lockfile-create >/dev/null 2>/dev/null ) ; then
133 if ! ( which lockfile >/dev/null ); then
134 failure "Neither lockfile-create nor lockfile are in the path!"
141 if [ -n "$use_lockfileprogs" ] ; then
142 lockfile-create "$file" || failure "unable to lock '$file'"
144 lockfile -r 20 "${file}.lock" || failure "unable to lock '$file'"
146 log debug "lock created on '$file'."
149 if [ -n "$use_lockfileprogs" ] ; then
150 lockfile-touch --oneshot "$file"
154 log debug "lock touched on '$file'."
157 if [ -n "$use_lockfileprogs" ] ; then
158 lockfile-remove "$file"
162 log debug "lock removed on '$file'."
165 failure "bad argument for lock subfunction '$action'"
170 # for portability, between gnu date and BSD date.
171 # arguments should be: number longunits format
173 # e.g. advance_date 20 seconds +%F
181 # try things the GNU way first
182 if date -d "$number $longunits" "$format" >/dev/null 2>&1; then
183 date -d "$number $longunits" "$format"
185 # otherwise, convert to (a limited version of) BSD date syntax:
209 # this is a longshot, and will likely fail; oh well.
210 shortunits="$longunits"
212 date "-v+${number}${shortunits}" "$format"
217 # check that characters are in a string (in an AND fashion).
218 # used for checking key capability
219 # check_capability capability a [b...]
228 if echo "$usage" | grep -q -v "$capcheck" ; then
237 md5sum "$1" 2> /dev/null
240 # convert escaped characters in pipeline from gpg output back into
242 # FIXME: undo all escape character translation in with-colons gpg
248 # convert nasty chars into gpg-friendly form in pipeline
249 # FIXME: escape everything, not just colons!
254 # prompt for GPG-formatted expiration, and emit result on stdout
255 get_gpg_expiration() {
260 if [ -z "$keyExpire" ]; then
262 Please specify how long the key should be valid.
263 0 = key does not expire
264 <n> = key expires in n days
265 <n>w = key expires in n weeks
266 <n>m = key expires in n months
267 <n>y = key expires in n years
269 while [ -z "$keyExpire" ] ; do
270 read -p "Key is valid for? (0) " keyExpire
271 if ! test_gpg_expire ${keyExpire:=0} ; then
272 echo "invalid value" >&2
276 elif ! test_gpg_expire "$keyExpire" ; then
277 failure "invalid key expiration value '$keyExpire'."
283 passphrase_prompt() {
288 if [ "$DISPLAY" ] && which "${SSH_ASKPASS:-ssh-askpass}" >/dev/null; then
289 "${SSH_ASKPASS:-ssh-askpass}" "$prompt" > "$fifo"
291 read -s -p "$prompt" PASS
292 # Uses the builtin echo, so should not put the passphrase into
293 # the process table. I think. --dkg
294 echo "$PASS" > "$fifo"
298 test_gnu_dummy_s2k_extension() {
300 # this block contains a demonstration private key that has had the
301 # primary key stripped out using the GNU S2K extension known as
302 # "gnu-dummy" (see /usr/share/doc/gnupg/DETAILS.gz). The subkey is
303 # present in cleartext, however.
305 # openpgp2ssh will be able to deal with this based on whether the
306 # local copy of GnuTLS contains read_s2k support that can handle it.
308 # read up on that here:
310 # http://lists.gnu.org/archive/html/gnutls-devel/2008-08/msg00005.html
313 -----BEGIN PGP PRIVATE KEY BLOCK-----
314 Version: GnuPG v1.4.9 (GNU/Linux)
316 lQCVBEO3YdABBACRqqEnucag4+vyZny2M67Pai5+5suIRRvY+Ly8Ms5MvgCi3EVV
317 xT05O/+0ShiRaf+QicCOFrhbU9PZzzU+seEvkeW2UCu4dQfILkmj+HBEIltGnHr3
318 G0yegHj5pnqrcezERURf2e17gGFWX91cXB9Cm721FPXczuKraphKwCA9PwARAQAB
319 /gNlAkdOVQG0OURlbW9uc3RyYXRpb24gS2V5IGZvciBTMksgR05VIGV4dGVuc2lv
320 biAxMDAxIC0tIGdudS1kdW1teYi8BBMBAgAmBQJDt2HQAhsDBQkB4TOABgsJCAcD
321 AgQVAggDBBYCAwECHgECF4AACgkQQZUwSa4UDezTOQP/TMQXUVrWzHYZGopoPZ2+
322 ZS3qddiznBHsgb7MGYg1KlTiVJSroDUBCHIUJvdQKZV9zrzrFl47D07x6hGyUPHV
323 aZXvuITW8t1o5MMHkCy3pmJ2KgfDvdUxrBvLfgPMICA4c6zA0mWquee43syEW9NY
324 g3q61iPlQwD1J1kX1wlimLCdAdgEQ7dh0AEEANAwa63zlQbuy1Meliy8otwiOa+a
325 mH6pxxUgUNggjyjO5qx+rl25mMjvGIRX4/L1QwIBXJBVi3SgvJW1COZxZqBYqj9U
326 8HVT07mWKFEDf0rZLeUE2jTm16cF9fcW4DQhW+sfYm+hi2sY3HeMuwlUBK9KHfW2
327 +bGeDzVZ4pqfUEudABEBAAEAA/0bemib+wxub9IyVFUp7nPobjQC83qxLSNzrGI/
328 RHzgu/5CQi4tfLOnwbcQsLELfker2hYnjsLrT9PURqK4F7udrWEoZ1I1LymOtLG/
329 4tNZ7Mnul3wRC2tCn7FKx8sGJwGh/3li8vZ6ALVJAyOia5TZ/buX0+QZzt6+hPKk
330 7MU1WQIA4bUBjtrsqDwro94DvPj3/jBnMZbXr6WZIItLNeVDUcM8oHL807Am97K1
331 ueO/f6v1sGAHG6lVPTmtekqPSTWBfwIA7CGFvEyvSALfB8NUa6jtk27NCiw0csql
332 kuhCmwXGMVOiryKEfegkIahf2bAd/gnWHPrpWp7bUE20v8YoW22I4wIAhnm5Wr5Q
333 Sy7EHDUxmJm5TzadFp9gq08qNzHBpXSYXXJ3JuWcL1/awUqp3tE1I6zZ0hZ38Ia6
334 SdBMN88idnhDPqPoiKUEGAECAA8FAkO3YdACGyAFCQHhM4AACgkQQZUwSa4UDezm
335 vQP/ZhK+2ly9oI2z7ZcNC/BJRch0/ybQ3haahII8pXXmOThpZohr/LUgoWgCZdXg
336 vP6yiszNk2tIs8KphCAw7Lw/qzDC2hEORjWO4f46qk73RAgSqG/GyzI4ltWiDhqn
337 vnQCFl3+QFSe4zinqykHnLwGPMXv428d/ZjkIc2ju8dRsn4=
339 -----END PGP PRIVATE KEY BLOCK-----
340 " | openpgp2ssh 4129E89D17C1D591 >/dev/null 2>/dev/null
344 # remove all lines with specified string from specified file
353 if [ -z "$file" -o -z "$string" ] ; then
357 if [ ! -e "$file" ] ; then
361 # if the string is in the file...
362 if grep -q -F "$string" "$file" 2> /dev/null ; then
363 tempfile=$(mktemp "${file}.XXXXXXX") || \
364 failure "Unable to make temp file '${file}.XXXXXXX'"
366 # remove the line with the string, and return 0
367 grep -v -F "$string" "$file" >"$tempfile"
368 cat "$tempfile" > "$file"
377 # remove all lines with MonkeySphere strings in file
378 remove_monkeysphere_lines() {
384 if [ -z "$file" ] ; then
388 if [ ! -e "$file" ] ; then
392 tempfile=$(mktemp "${file}.XXXXXXX") || \
393 failure "Could not make temporary file '${file}.XXXXXXX'."
395 egrep -v '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$' \
397 cat "$tempfile" > "$file"
401 # translate ssh-style path variables %h and %u
402 translate_ssh_variables() {
409 # get the user's home directory
410 userHome=$(getent passwd "$uname" | cut -d: -f6)
412 # translate '%u' to user name
413 path=${path/\%u/"$uname"}
414 # translate '%h' to user home directory
415 path=${path/\%h/"$userHome"}
420 # test that a string to conforms to GPG's expiration format
422 echo "$1" | egrep -q "^[0-9]+[mwy]?$"
425 # check that a file is properly owned, and that all it's parent
426 # directories are not group/other writable
427 check_key_file_permissions() {
435 # function to check that the given permission corresponds to writability
443 log debug "checking path permission '$path'..."
445 # return 255 if cannot stat file
446 if ! stat=$(ls -ld "$path" 2>/dev/null) ; then
447 log error "could not stat path '$path'."
451 owner=$(echo "$stat" | awk '{ print $3 }')
452 gAccess=$(echo "$stat" | cut -c6)
453 oAccess=$(echo "$stat" | cut -c9)
455 # return 1 if path has invalid owner
456 if [ "$owner" != "$uname" -a "$owner" != 'root' ] ; then
457 log error "improper ownership on path '$path'."
461 # return 2 if path has group or other writability
462 if is_write "$gAccess" || is_write "$oAccess" ; then
463 log error "improper group or other writability on path '$path'."
467 # return zero if all clear, or go to next path
468 if [ "$path" = '/' ] ; then
471 check_key_file_permissions "$uname" $(dirname "$path")
475 ### CONVERSION UTILITIES
477 # output the ssh key for a given key ID
483 gpg --export "$keyID" | openpgp2ssh "$keyID" 2> /dev/null
486 # output known_hosts line from ssh key
495 echo -n "$key" | tr -d '\n'
496 echo " MonkeySphere${DATE}"
499 # output authorized_keys line from ssh key
500 ssh2authorized_keys() {
507 echo -n "$key" | tr -d '\n'
508 echo " MonkeySphere${DATE} ${userID}"
511 # convert key from gpg to ssh known_hosts format
519 # NOTE: it seems that ssh-keygen -R removes all comment fields from
520 # all lines in the known_hosts file. why?
521 # NOTE: just in case, the COMMENT can be matched with the
523 # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
525 gpg2ssh "$keyID" | tr -d '\n'
526 echo " MonkeySphere${DATE}"
529 # convert key from gpg to ssh authorized_keys format
530 gpg2authorized_keys() {
537 # NOTE: just in case, the COMMENT can be matched with the
539 # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
540 gpg2ssh "$keyID" | tr -d '\n'
541 echo " MonkeySphere${DATE} ${userID}"
546 # retrieve all keys with given user id from keyserver
547 # FIXME: need to figure out how to retrieve all matching keys
548 # (not just first N (5 in this case))
553 if [ "$CHECK_KEYSERVER" != 'true' ] ; then
559 log verbose " checking keyserver $KEYSERVER... "
561 gpg --quiet --batch --with-colons \
562 --command-fd 0 --keyserver "$KEYSERVER" \
563 --search ="$userID" > /dev/null 2>&1
569 ########################################################################
570 ### PROCESSING FUNCTIONS
572 # userid and key policy checking
573 # the following checks policy on the returned keys
574 # - checks that full key has appropriate valididy (u|f)
575 # - checks key has specified capability (REQUIRED_*_KEY_CAPABILITY)
576 # - checks that requested user ID has appropriate validity
577 # (see /usr/share/doc/gnupg/DETAILS.gz)
578 # output is one line for every found key, in the following format:
582 # "flag" is an acceptability flag, 0 = ok, 1 = bad
583 # "sshKey" is the translated gpg key
585 # all log output must go to stderr, as stdout is used to pass the
586 # flag:sshKey to the calling function.
588 # expects global variable: "MODE"
591 local requiredCapability
592 local requiredPubCapability
607 # set the required key capability based on the mode
608 if [ "$MODE" = 'known_hosts' ] ; then
609 requiredCapability="$REQUIRED_HOST_KEY_CAPABILITY"
610 elif [ "$MODE" = 'authorized_keys' ] ; then
611 requiredCapability="$REQUIRED_USER_KEY_CAPABILITY"
613 requiredPubCapability=$(echo "$requiredCapability" | tr "[:lower:]" "[:upper:]")
615 # fetch the user ID if necessary/requested
616 gpg_fetch_userid "$userID"
618 # output gpg info for (exact) userid and store
619 gpgOut=$(gpg --list-key --fixed-list-mode --with-colon \
620 --with-fingerprint --with-fingerprint \
621 ="$userID" 2>/dev/null)
623 # if the gpg query return code is not 0, return 1
624 if [ "$?" -ne 0 ] ; then
625 log verbose " no primary keys found."
629 # loop over all lines in the gpg output and process.
630 echo "$gpgOut" | cut -d: -f1,2,5,10,12 | \
631 while IFS=: read -r type validity keyid uidfpr usage ; do
632 # process based on record type
634 'pub') # primary keys
635 # new key, wipe the slate
642 log verbose " primary key found: $keyid"
644 # if overall key is not valid, skip
645 if [ "$validity" != 'u' -a "$validity" != 'f' ] ; then
646 log debug " - unacceptable primary key validity ($validity)."
649 # if overall key is disabled, skip
650 if check_capability "$usage" 'D' ; then
651 log debug " - key disabled."
654 # if overall key capability is not ok, skip
655 if ! check_capability "$usage" $requiredPubCapability ; then
656 log debug " - unacceptable primary key capability ($usage)."
660 # mark overall key as ok
663 # mark primary key as ok if capability is ok
664 if check_capability "$usage" $requiredCapability ; then
669 if [ "$lastKey" != pub ] ; then
670 log verbose " ! got a user ID after a sub key?! user IDs should only follow primary keys!"
673 # if an acceptable user ID was already found, skip
674 if [ "$uidOK" = 'true' ] ; then
677 # if the user ID does matches...
678 if [ "$(echo "$uidfpr" | gpg_unescape)" = "$userID" ] ; then
679 # and the user ID validity is ok
680 if [ "$validity" = 'u' -o "$validity" = 'f' ] ; then
681 # mark user ID acceptable
684 log debug " - unacceptable user ID validity ($validity)."
690 # output a line for the primary key
692 if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
693 log verbose " * acceptable primary key."
694 if [ -z "$sshKey" ] ; then
695 log error " ! primary key could not be translated (not RSA or DSA?)."
700 log debug " - unacceptable primary key."
701 if [ -z "$sshKey" ] ; then
702 log debug " ! primary key could not be translated (not RSA or DSA?)."
709 # unset acceptability of last key
714 # don't bother with sub keys if the primary key is not valid
715 if [ "$keyOK" != true ] ; then
719 # don't bother with sub keys if no user ID is acceptable:
720 if [ "$uidOK" != true ] ; then
724 # if sub key validity is not ok, skip
725 if [ "$validity" != 'u' -a "$validity" != 'f' ] ; then
726 log debug " - unacceptable sub key validity ($validity)."
729 # if sub key capability is not ok, skip
730 if ! check_capability "$usage" $requiredCapability ; then
731 log debug " - unacceptable sub key capability ($usage)."
738 'fpr') # key fingerprint
739 fingerprint="$uidfpr"
741 sshKey=$(gpg2ssh "$fingerprint")
743 # if the last key was the pub key, skip
744 if [ "$lastKey" = pub ] ; then
748 # output a line for the sub key
750 if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
751 log verbose " * acceptable sub key."
752 if [ -z "$sshKey" ] ; then
753 log error " ! sub key could not be translated (not RSA or DSA?)."
758 log debug " - unacceptable sub key."
759 if [ -z "$sshKey" ] ; then
760 log debug " ! sub key could not be translated (not RSA or DSA?)."
767 done | sort -t: -k1 -n -r
768 # NOTE: this last sort is important so that the "good" keys (key
769 # flag '0') come last. This is so that they take precedence when
770 # being processed in the key files over "bad" keys (key flag '1')
773 # process a single host in the known_host file
774 process_host_known_hosts() {
785 userID="ssh://${host}"
787 log verbose "processing: $host"
793 for line in $(process_user_id "${userID}") ; do
794 # note that key was found
797 ok=$(echo "$line" | cut -d: -f1)
798 sshKey=$(echo "$line" | cut -d: -f2)
800 if [ -z "$sshKey" ] ; then
804 # remove any old host key line, and note if removed nothing is
806 remove_line "$KNOWN_HOSTS" "$sshKey" || noKey=true
808 # if key OK, add new host line
809 if [ "$ok" -eq '0' ] ; then
810 # note that key was found ok
811 nKeysOK=$((nKeysOK+1))
814 if [ "$HASH_KNOWN_HOSTS" = 'true' ] ; then
815 # FIXME: this is really hackish cause ssh-keygen won't
816 # hash from stdin to stdout
817 tmpfile=$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX)
818 ssh2known_hosts "$host" "$sshKey" > "$tmpfile"
819 ssh-keygen -H -f "$tmpfile" 2> /dev/null
820 cat "$tmpfile" >> "$KNOWN_HOSTS"
821 rm -f "$tmpfile" "${tmpfile}.old"
823 ssh2known_hosts "$host" "$sshKey" >> "$KNOWN_HOSTS"
826 # log if this is a new key to the known_hosts file
827 if [ "$noKey" ] ; then
828 log info "* new key for $host added to known_hosts file."
833 # if at least one key was found...
834 if [ "$nKeys" -gt 0 ] ; then
835 # if ok keys were found, return 0
836 if [ "$nKeysOK" -gt 0 ] ; then
842 # if no keys were found, return 1
848 # update the known_hosts file for a set of hosts listed on command
850 update_known_hosts() {
857 # the number of hosts specified on command line
863 # create a lockfile on known_hosts:
864 lock create "$KNOWN_HOSTS"
865 # FIXME: we're discarding any pre-existing EXIT trap; is this bad?
866 trap "lock remove $KNOWN_HOSTS" EXIT
868 # note pre update file checksum
869 fileCheck="$(file_hash "$KNOWN_HOSTS")"
873 process_host_known_hosts "$host"
877 nHostsOK=$((nHostsOK+1))
880 nHostsBAD=$((nHostsBAD+1))
884 # touch the lockfile, for good measure.
885 lock touch "$KNOWN_HOSTS"
888 # remove the lockfile and the trap
889 lock remove "$KNOWN_HOSTS"
892 # note if the known_hosts file was updated
893 if [ "$(file_hash "$KNOWN_HOSTS")" != "$fileCheck" ] ; then
894 log debug "known_hosts file updated."
897 # if an acceptable host was found, return 0
898 if [ "$nHostsOK" -gt 0 ] ; then
900 # else if no ok hosts were found...
902 # if no bad host were found then no hosts were found at all,
904 if [ "$nHostsBAD" -eq 0 ] ; then
906 # else if at least one bad host was found, return 2
913 # process hosts from a known_hosts file
914 process_known_hosts() {
917 log debug "processing known_hosts file..."
919 hosts=$(meat "$KNOWN_HOSTS" | cut -d ' ' -f 1 | grep -v '^|.*$' | tr , ' ' | tr '\n' ' ')
921 if [ -z "$hosts" ] ; then
922 log debug "no hosts to process."
926 # take all the hosts from the known_hosts file (first
927 # field), grep out all the hashed hosts (lines starting
929 update_known_hosts $hosts
932 # process uids for the authorized_keys file
933 process_uid_authorized_keys() {
942 log verbose "processing: $userID"
948 for line in $(process_user_id "$userID") ; do
949 # note that key was found
952 ok=$(echo "$line" | cut -d: -f1)
953 sshKey=$(echo "$line" | cut -d: -f2)
955 if [ -z "$sshKey" ] ; then
959 # remove the old host key line
960 remove_line "$AUTHORIZED_KEYS" "$sshKey"
962 # if key OK, add new host line
963 if [ "$ok" -eq '0' ] ; then
964 # note that key was found ok
965 nKeysOK=$((nKeysOK+1))
967 ssh2authorized_keys "$userID" "$sshKey" >> "$AUTHORIZED_KEYS"
971 # if at least one key was found...
972 if [ "$nKeys" -gt 0 ] ; then
973 # if ok keys were found, return 0
974 if [ "$nKeysOK" -gt 0 ] ; then
980 # if no keys were found, return 1
986 # update the authorized_keys files from a list of user IDs on command
988 update_authorized_keys() {
995 # the number of ids specified on command line
1001 # create a lockfile on authorized_keys
1002 lock create "$AUTHORIZED_KEYS"
1003 # FIXME: we're discarding any pre-existing EXIT trap; is this bad?
1004 trap "lock remove $AUTHORIZED_KEYS" EXIT
1006 # note pre update file checksum
1007 fileCheck="$(file_hash "$AUTHORIZED_KEYS")"
1009 # remove any monkeysphere lines from authorized_keys file
1010 remove_monkeysphere_lines "$AUTHORIZED_KEYS"
1013 # process the user ID, change return code if key not found for
1015 process_uid_authorized_keys "$userID"
1020 nIDsOK=$((nIDsOK+1))
1023 nIDsBAD=$((nIDsBAD+1))
1027 # touch the lockfile, for good measure.
1028 lock touch "$AUTHORIZED_KEYS"
1031 # remove the lockfile and the trap
1032 lock remove "$AUTHORIZED_KEYS"
1037 # note if the authorized_keys file was updated
1038 if [ "$(file_hash "$AUTHORIZED_KEYS")" != "$fileCheck" ] ; then
1039 log debug "authorized_keys file updated."
1042 # if an acceptable id was found, return 0
1043 if [ "$nIDsOK" -gt 0 ] ; then
1045 # else if no ok ids were found...
1047 # if no bad ids were found then no ids were found at all, and
1049 if [ "$nIDsBAD" -eq 0 ] ; then
1051 # else if at least one bad id was found, return 2
1058 # process an authorized_user_ids file for authorized_keys
1059 process_authorized_user_ids() {
1064 authorizedUserIDs="$1"
1066 log debug "processing authorized_user_ids file..."
1068 if ! meat "$authorizedUserIDs" > /dev/null ; then
1069 log debug " no user IDs to process."
1075 # extract user IDs from authorized_user_ids file
1077 for line in $(meat "$authorizedUserIDs") ; do
1078 userIDs["$nline"]="$line"
1082 update_authorized_keys "${userIDs[@]}"