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-2009, 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 ########################################################################
21 cat "${SYSSHAREDIR}/VERSION"
24 # failure function. exits with code 255, unless specified otherwise.
26 [ "$1" ] && echo "$1" >&2
30 # write output to stderr based on specified LOG_LEVEL the first
31 # parameter is the priority of the output, and everything else is what
32 # is echoed to stderr. If there is nothing else, then output comes
33 # from stdin, and is not prefaced by log prefix.
41 # don't include SILENT in alllevels: it's handled separately
42 # list in decreasing verbosity (all caps).
43 # separate with $IFS explicitly, since we do some fancy footwork
45 alllevels="DEBUG${IFS}VERBOSE${IFS}INFO${IFS}ERROR"
47 # translate lowers to uppers in global log level
48 LOG_LEVEL=$(echo "$LOG_LEVEL" | tr "[:lower:]" "[:upper:]")
50 # just go ahead and return if the log level is silent
51 if [ "$LOG_LEVEL" = 'SILENT' ] ; then
55 for level in $alllevels ; do
56 if [ "$LOG_LEVEL" = "$level" ] ; then
60 if [ -z "$found" ] ; then
65 # get priority from first parameter, translating all lower to
67 priority=$(echo "$1" | tr "[:lower:]" "[:upper:]")
70 # scan over available levels
71 for level in $alllevels ; do
72 # output if the log level matches, set output to true
73 # this will output for all subsequent loops as well.
74 if [ "$LOG_LEVEL" = "$level" ] ; then
77 if [ "$priority" = "$level" -a "$output" = 'true' ] ; then
82 fi | sed 's/^/'"${LOG_PREFIX}"'/' >&2
87 # run command as monkeysphere user
88 su_monkeysphere_user() {
89 # our main goal here is to run the given command as the the
90 # monkeysphere user, but without prompting for any sort of
91 # authentication. If this is not possible, we should just fail.
93 # FIXME: our current implementation is overly restrictive, because
94 # there may be some su PAM configurations that would allow su
95 # "$MONKEYSPHERE_USER" -c "$@" to Just Work without prompting,
96 # allowing specific users to invoke commands which make use of
99 # chpst (from runit) would be nice to use, but we don't want to
100 # introduce an extra dependency just for this. This may be a
101 # candidate for re-factoring if we switch implementation languages.
104 # if monkeysphere user, run the command under bash
105 "$MONKEYSPHERE_USER")
109 # if root, su command as monkeysphere user
111 su "$MONKEYSPHERE_USER" -c "$@"
116 log error "non-privileged user."
121 # cut out all comments(#) and blank lines from standard input
123 grep -v -e "^[[:space:]]*#" -e '^$' "$1"
126 # cut a specified line from standard input
128 head --line="$1" "$2" | tail -1
131 # make a temporary directory
133 mktemp -d ${TMPDIR:-/tmp}/monkeysphere.XXXXXXXXXX
136 # make a temporary file
138 mktemp ${TMPDIR:-/tmp}/monkeysphere.XXXXXXXXXX
141 # this is a wrapper for doing lock functions.
143 # it lets us depend on either lockfile-progs (preferred) or procmail's
144 # lockfile, and should
146 local use_lockfileprogs=true
150 if ! ( type lockfile-create &>/dev/null ) ; then
151 if ! ( type lockfile &>/dev/null ); then
152 failure "Neither lockfile-create nor lockfile are in the path!"
159 if [ -n "$use_lockfileprogs" ] ; then
160 lockfile-create "$file" || failure "unable to lock '$file'"
162 lockfile -r 20 "${file}.lock" || failure "unable to lock '$file'"
164 log debug "lock created on '$file'."
167 if [ -n "$use_lockfileprogs" ] ; then
168 lockfile-touch --oneshot "$file"
172 log debug "lock touched on '$file'."
175 if [ -n "$use_lockfileprogs" ] ; then
176 lockfile-remove "$file"
180 log debug "lock removed on '$file'."
183 failure "bad argument for lock subfunction '$action'"
188 # for portability, between gnu date and BSD date.
189 # arguments should be: number longunits format
191 # e.g. advance_date 20 seconds +%F
199 # try things the GNU way first
200 if date -d "$number $longunits" "$format" &>/dev/null; then
201 date -d "$number $longunits" "$format"
203 # otherwise, convert to (a limited version of) BSD date syntax:
227 # this is a longshot, and will likely fail; oh well.
228 shortunits="$longunits"
230 date "-v+${number}${shortunits}" "$format"
235 # check that characters are in a string (in an AND fashion).
236 # used for checking key capability
237 # check_capability capability a [b...]
246 if echo "$usage" | grep -q -v "$capcheck" ; then
255 if type md5sum &>/dev/null ; then
257 elif type md5 &>/dev/null ; then
260 failure "Neither md5sum nor md5 are in the path!"
264 # convert escaped characters in pipeline from gpg output back into
266 # FIXME: undo all escape character translation in with-colons gpg
272 # convert nasty chars into gpg-friendly form in pipeline
273 # FIXME: escape everything, not just colons!
278 # prompt for GPG-formatted expiration, and emit result on stdout
279 get_gpg_expiration() {
284 if [ -z "$keyExpire" -a "$PROMPT" = 'true' ]; then
286 Please specify how long the key should be valid.
287 0 = key does not expire
288 <n> = key expires in n days
289 <n>w = key expires in n weeks
290 <n>m = key expires in n months
291 <n>y = key expires in n years
293 while [ -z "$keyExpire" ] ; do
294 read -p "Key is valid for? (0) " keyExpire
295 if ! test_gpg_expire ${keyExpire:=0} ; then
296 echo "invalid value" >&2
300 elif ! test_gpg_expire "$keyExpire" ; then
301 failure "invalid key expiration value '$keyExpire'."
307 passphrase_prompt() {
312 if [ "$DISPLAY" ] && type "${SSH_ASKPASS:-ssh-askpass}" >/dev/null; then
313 printf 'Launching "%s"\n' "${SSH_ASKPASS:-ssh-askpass}" | log info
314 printf '(with prompt "%s")\n' "$prompt" | log debug
315 "${SSH_ASKPASS:-ssh-askpass}" "$prompt" > "$fifo"
317 read -s -p "$prompt" PASS
318 # Uses the builtin echo, so should not put the passphrase into
319 # the process table. I think. --dkg
320 echo "$PASS" > "$fifo"
324 # remove all lines with specified string from specified file
333 if [ -z "$file" -o -z "$string" ] ; then
337 if [ ! -e "$file" ] ; then
341 # if the string is in the file...
342 if grep -q -F "$string" "$file" 2>/dev/null ; then
343 tempfile=$(mktemp "${file}.XXXXXXX") || \
344 failure "Unable to make temp file '${file}.XXXXXXX'"
346 # remove the line with the string, and return 0
347 grep -v -F "$string" "$file" >"$tempfile"
348 cat "$tempfile" > "$file"
357 # remove all lines with MonkeySphere strings in file
358 remove_monkeysphere_lines() {
364 # return error if file does not exist
365 if [ ! -e "$file" ] ; then
369 # just return ok if the file is empty, since there aren't any
371 if [ ! -s "$file" ] ; then
375 tempfile=$(mktemp "${file}.XXXXXXX") || \
376 failure "Could not make temporary file '${file}.XXXXXXX'."
378 egrep -v '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$' \
380 cat "$tempfile" > "$file"
384 # translate ssh-style path variables %h and %u
385 translate_ssh_variables() {
392 # get the user's home directory
393 userHome=$(getent passwd "$uname" | cut -d: -f6)
395 # translate '%u' to user name
396 path=${path/\%u/"$uname"}
397 # translate '%h' to user home directory
398 path=${path/\%h/"$userHome"}
403 # test that a string to conforms to GPG's expiration format
405 echo "$1" | egrep -q "^[0-9]+[mwy]?$"
408 # check that a file is properly owned, and that all it's parent
409 # directories are not group/other writable
410 check_key_file_permissions() {
418 # function to check that the given permission corresponds to writability
426 log debug "checking path permission '$path'..."
428 # return 255 if cannot stat file
429 if ! stat=$(ls -ld "$path" 2>/dev/null) ; then
430 log error "could not stat path '$path'."
434 owner=$(echo "$stat" | awk '{ print $3 }')
435 gAccess=$(echo "$stat" | cut -c6)
436 oAccess=$(echo "$stat" | cut -c9)
438 # return 1 if path has invalid owner
439 if [ "$owner" != "$uname" -a "$owner" != 'root' ] ; then
440 log error "improper ownership on path '$path':"
441 log error " $owner != ($uname|root)"
445 # return 2 if path has group or other writability
446 if is_write "$gAccess" || is_write "$oAccess" ; then
447 log error "improper group or other writability on path '$path':"
448 log error " group: $gAccess, other: $oAccess"
452 # return zero if all clear, or go to next path
453 if [ "$path" = '/' ] ; then
457 check_key_file_permissions "$uname" $(dirname "$path")
461 ### CONVERSION UTILITIES
463 # output the ssh key for a given key ID
469 gpg --export "$keyID" | openpgp2ssh "$keyID" 2>/dev/null
472 # output known_hosts line from ssh key
478 # FIXME this does not properly deal with IPv6 hosts using the
479 # standard port (because it's unclear whether their final
480 # colon-delimited address section is a port number or an address
486 # specify the host and port properly for new ssh known_hosts
488 if [ "$port" != "$host" ] ; then
489 host="[${host}]:${port}"
491 printf "%s %s MonkeySphere%s\n" "$host" "$key" "$DATE"
494 # output authorized_keys line from ssh key
495 ssh2authorized_keys() {
502 printf "%s MonkeySphere%s %s\n" "$key" "$DATE" "$userID"
505 # convert key from gpg to ssh known_hosts format
514 key=$(gpg2ssh "$keyID")
516 # NOTE: it seems that ssh-keygen -R removes all comment fields from
517 # all lines in the known_hosts file. why?
518 # NOTE: just in case, the COMMENT can be matched with the
520 # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
521 printf "%s %s MonkeySphere%s\n" "$host" "$key" "$DATE"
524 # convert key from gpg to ssh authorized_keys format
525 gpg2authorized_keys() {
533 key=$(gpg2ssh "$keyID")
535 # NOTE: just in case, the COMMENT can be matched with the
537 # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
538 printf "%s MonkeySphere%s %s\n" "$key" "$DATE" "$userID"
543 # retrieve all keys with given user id from keyserver
544 # FIXME: need to figure out how to retrieve all matching keys
545 # (not just first N (5 in this case))
550 if [ "$CHECK_KEYSERVER" != 'true' ] ; then
556 log verbose " checking keyserver $KEYSERVER... "
558 gpg --quiet --batch --with-colons \
559 --command-fd 0 --keyserver "$KEYSERVER" \
560 --search ="$userID" &>/dev/null
566 ########################################################################
567 ### PROCESSING FUNCTIONS
569 # userid and key policy checking
570 # the following checks policy on the returned keys
571 # - checks that full key has appropriate valididy (u|f)
572 # - checks key has specified capability (REQUIRED_*_KEY_CAPABILITY)
573 # - checks that requested user ID has appropriate validity
574 # (see /usr/share/doc/gnupg/DETAILS.gz)
575 # output is one line for every found key, in the following format:
579 # "flag" is an acceptability flag, 0 = ok, 1 = bad
580 # "sshKey" is the translated gpg key
582 # all log output must go to stderr, as stdout is used to pass the
583 # flag:sshKey to the calling function.
585 # expects global variable: "MODE"
589 local requiredCapability
590 local requiredPubCapability
605 # set the required key capability based on the mode
606 if [ "$MODE" = 'known_hosts' ] ; then
607 requiredCapability="$REQUIRED_HOST_KEY_CAPABILITY"
608 elif [ "$MODE" = 'authorized_keys' ] ; then
609 requiredCapability="$REQUIRED_USER_KEY_CAPABILITY"
611 requiredPubCapability=$(echo "$requiredCapability" | tr "[:lower:]" "[:upper:]")
613 # fetch the user ID if necessary/requested
614 gpg_fetch_userid "$userID"
616 # output gpg info for (exact) userid and store
617 gpgOut=$(gpg --list-key --fixed-list-mode --with-colon \
618 --with-fingerprint --with-fingerprint \
619 ="$userID" 2>/dev/null) || returnCode="$?"
621 # if the gpg query return code is not 0, return 1
622 if [ "$returnCode" -ne 0 ] ; then
623 log verbose " no primary keys found."
627 # loop over all lines in the gpg output and process.
628 echo "$gpgOut" | cut -d: -f1,2,5,10,12 | \
629 while IFS=: read -r type validity keyid uidfpr usage ; do
630 # process based on record type
632 'pub') # primary keys
633 # new key, wipe the slate
640 log verbose " primary key found: $keyid"
642 # if overall key is not valid, skip
643 if [ "$validity" != 'u' -a "$validity" != 'f' ] ; then
644 log debug " - unacceptable primary key validity ($validity)."
647 # if overall key is disabled, skip
648 if check_capability "$usage" 'D' ; then
649 log debug " - key disabled."
652 # if overall key capability is not ok, skip
653 if ! check_capability "$usage" $requiredPubCapability ; then
654 log debug " - unacceptable primary key capability ($usage)."
658 # mark overall key as ok
661 # mark primary key as ok if capability is ok
662 if check_capability "$usage" $requiredCapability ; then
667 if [ "$lastKey" != pub ] ; then
668 log verbose " ! got a user ID after a sub key?! user IDs should only follow primary keys!"
671 # if an acceptable user ID was already found, skip
672 if [ "$uidOK" = 'true' ] ; then
675 # if the user ID does matches...
676 if [ "$(echo "$uidfpr" | gpg_unescape)" = "$userID" ] ; then
677 # and the user ID validity is ok
678 if [ "$validity" = 'u' -o "$validity" = 'f' ] ; then
679 # mark user ID acceptable
682 log debug " - unacceptable user ID validity ($validity)."
688 # output a line for the primary key
690 if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
691 log verbose " * acceptable primary key."
692 if [ -z "$sshKey" ] ; then
693 log error " ! primary key could not be translated (not RSA?)."
698 log debug " - unacceptable primary key."
699 if [ -z "$sshKey" ] ; then
700 log debug " ! primary key could not be translated (not RSA?)."
707 # unset acceptability of last key
712 # don't bother with sub keys if the primary key is not valid
713 if [ "$keyOK" != true ] ; then
717 # don't bother with sub keys if no user ID is acceptable:
718 if [ "$uidOK" != true ] ; then
722 # if sub key validity is not ok, skip
723 if [ "$validity" != 'u' -a "$validity" != 'f' ] ; then
724 log debug " - unacceptable sub key validity ($validity)."
727 # if sub key capability is not ok, skip
728 if ! check_capability "$usage" $requiredCapability ; then
729 log debug " - unacceptable sub key capability ($usage)."
736 'fpr') # key fingerprint
737 fingerprint="$uidfpr"
739 sshKey=$(gpg2ssh "$fingerprint")
741 # if the last key was the pub key, skip
742 if [ "$lastKey" = pub ] ; then
746 # output a line for the sub key
748 if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
749 log verbose " * acceptable sub key."
750 if [ -z "$sshKey" ] ; then
751 log error " ! sub key could not be translated (not RSA?)."
756 log debug " - unacceptable sub key."
757 if [ -z "$sshKey" ] ; then
758 log debug " ! sub key could not be translated (not RSA?)."
765 done | sort -t: -k1 -n -r
766 # NOTE: this last sort is important so that the "good" keys (key
767 # flag '0') come last. This is so that they take precedence when
768 # being processed in the key files over "bad" keys (key flag '1')
771 # process a single host in the known_host file
772 process_host_known_hosts() {
782 # set the key processing mode
783 export MODE='known_hosts'
786 userID="ssh://${host}"
788 log verbose "processing: $host"
794 for line in $(process_user_id "${userID}") ; do
795 # note that key was found
798 ok=$(echo "$line" | cut -d: -f1)
799 sshKey=$(echo "$line" | cut -d: -f2)
801 if [ -z "$sshKey" ] ; then
805 # remove any old host key line, and note if removed nothing is
807 remove_line "$KNOWN_HOSTS" "$sshKey" || noKey=true
809 # if key OK, add new host line
810 if [ "$ok" -eq '0' ] ; then
811 # note that key was found ok
812 nKeysOK=$((nKeysOK+1))
815 if [ "$HASH_KNOWN_HOSTS" = 'true' ] ; then
816 # FIXME: this is really hackish cause ssh-keygen won't
817 # hash from stdin to stdout
818 tmpfile=$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX)
819 ssh2known_hosts "$host" "$sshKey" > "$tmpfile"
820 ssh-keygen -H -f "$tmpfile" 2>/dev/null
821 cat "$tmpfile" >> "$KNOWN_HOSTS"
822 rm -f "$tmpfile" "${tmpfile}.old"
824 ssh2known_hosts "$host" "$sshKey" >> "$KNOWN_HOSTS"
827 # log if this is a new key to the known_hosts file
828 if [ "$noKey" ] ; then
829 log info "* new key for $host added to known_hosts file."
834 # if at least one key was found...
835 if [ "$nKeys" -gt 0 ] ; then
836 # if ok keys were found, return 0
837 if [ "$nKeysOK" -gt 0 ] ; then
843 # if no keys were found, return 1
849 # update the known_hosts file for a set of hosts listed on command
851 update_known_hosts() {
859 # the number of hosts specified on command line
865 # touch the known_hosts file so that the file permission check
866 # below won't fail upon not finding the file
867 (umask 0022 && touch "$KNOWN_HOSTS")
869 # check permissions on the known_hosts file path
870 check_key_file_permissions $(whoami) "$KNOWN_HOSTS" || failure
872 # create a lockfile on known_hosts:
873 lock create "$KNOWN_HOSTS"
874 # FIXME: we're discarding any pre-existing EXIT trap; is this bad?
875 trap "lock remove $KNOWN_HOSTS" EXIT
877 # note pre update file checksum
878 fileCheck="$(file_hash "$KNOWN_HOSTS")"
882 process_host_known_hosts "$host" || returnCode="$?"
884 case "$returnCode" in
886 nHostsOK=$((nHostsOK+1))
889 nHostsBAD=$((nHostsBAD+1))
893 # touch the lockfile, for good measure.
894 lock touch "$KNOWN_HOSTS"
897 # remove the lockfile and the trap
898 lock remove "$KNOWN_HOSTS"
901 # note if the known_hosts file was updated
902 if [ "$(file_hash "$KNOWN_HOSTS")" != "$fileCheck" ] ; then
903 log debug "known_hosts file updated."
906 # if an acceptable host was found, return 0
907 if [ "$nHostsOK" -gt 0 ] ; then
909 # else if no ok hosts were found...
911 # if no bad host were found then no hosts were found at all,
913 if [ "$nHostsBAD" -eq 0 ] ; then
915 # else if at least one bad host was found, return 2
922 # process hosts from a known_hosts file
923 process_known_hosts() {
926 # exit if the known_hosts file does not exist
927 if [ ! -e "$KNOWN_HOSTS" ] ; then
928 failure "known_hosts file '$KNOWN_HOSTS' does not exist."
931 log debug "processing known_hosts file:"
932 log debug " $KNOWN_HOSTS"
934 hosts=$(meat "$KNOWN_HOSTS" | cut -d ' ' -f 1 | grep -v '^|.*$' | tr , ' ' | tr '\n' ' ')
936 if [ -z "$hosts" ] ; then
937 log debug "no hosts to process."
941 # take all the hosts from the known_hosts file (first
942 # field), grep out all the hashed hosts (lines starting
944 update_known_hosts $hosts
947 # process uids for the authorized_keys file
948 process_uid_authorized_keys() {
955 # set the key processing mode
956 export MODE='authorized_keys'
960 log verbose "processing: $userID"
966 for line in $(process_user_id "$userID") ; do
967 # note that key was found
970 ok=$(echo "$line" | cut -d: -f1)
971 sshKey=$(echo "$line" | cut -d: -f2)
973 if [ -z "$sshKey" ] ; then
977 # remove the old host key line
978 remove_line "$AUTHORIZED_KEYS" "$sshKey"
980 # if key OK, add new host line
981 if [ "$ok" -eq '0' ] ; then
982 # note that key was found ok
983 nKeysOK=$((nKeysOK+1))
985 ssh2authorized_keys "$userID" "$sshKey" >> "$AUTHORIZED_KEYS"
989 # if at least one key was found...
990 if [ "$nKeys" -gt 0 ] ; then
991 # if ok keys were found, return 0
992 if [ "$nKeysOK" -gt 0 ] ; then
998 # if no keys were found, return 1
1004 # update the authorized_keys files from a list of user IDs on command
1006 update_authorized_keys() {
1014 # the number of ids specified on command line
1020 log debug "updating authorized_keys file:"
1021 log debug " $AUTHORIZED_KEYS"
1023 # check permissions on the authorized_keys file path
1024 check_key_file_permissions $(whoami) "$AUTHORIZED_KEYS" || failure
1026 # create a lockfile on authorized_keys
1027 lock create "$AUTHORIZED_KEYS"
1028 # FIXME: we're discarding any pre-existing EXIT trap; is this bad?
1029 trap "lock remove $AUTHORIZED_KEYS" EXIT
1031 # note pre update file checksum
1032 fileCheck="$(file_hash "$AUTHORIZED_KEYS")"
1034 # remove any monkeysphere lines from authorized_keys file
1035 remove_monkeysphere_lines "$AUTHORIZED_KEYS"
1038 # process the user ID, change return code if key not found for
1040 process_uid_authorized_keys "$userID" || returnCode="$?"
1043 case "$returnCode" in
1045 nIDsOK=$((nIDsOK+1))
1048 nIDsBAD=$((nIDsBAD+1))
1052 # touch the lockfile, for good measure.
1053 lock touch "$AUTHORIZED_KEYS"
1056 # remove the lockfile and the trap
1057 lock remove "$AUTHORIZED_KEYS"
1062 # note if the authorized_keys file was updated
1063 if [ "$(file_hash "$AUTHORIZED_KEYS")" != "$fileCheck" ] ; then
1064 log debug "authorized_keys file updated."
1067 # if an acceptable id was found, return 0
1068 if [ "$nIDsOK" -gt 0 ] ; then
1070 # else if no ok ids were found...
1072 # if no bad ids were found then no ids were found at all, and
1074 if [ "$nIDsBAD" -eq 0 ] ; then
1076 # else if at least one bad id was found, return 2
1083 # process an authorized_user_ids file for authorized_keys
1084 process_authorized_user_ids() {
1089 authorizedUserIDs="$1"
1091 # exit if the authorized_user_ids file is empty
1092 if [ ! -e "$authorizedUserIDs" ] ; then
1093 failure "authorized_user_ids file '$authorizedUserIDs' does not exist."
1096 log debug "processing authorized_user_ids file:"
1097 log debug " $authorizedUserIDs"
1099 # check permissions on the authorized_user_ids file path
1100 check_key_file_permissions $(whoami) "$authorizedUserIDs" || failure
1102 if ! meat "$authorizedUserIDs" >/dev/null ; then
1103 log debug " no user IDs to process."
1109 # extract user IDs from authorized_user_ids file
1111 for line in $(meat "$authorizedUserIDs") ; do
1112 userIDs["$nline"]="$line"
1116 update_authorized_keys "${userIDs[@]}"
1119 # takes a gpg key or keys on stdin, and outputs a list of
1120 # fingerprints, one per line:
1121 list_primary_fingerprints() {
1122 local fake=$(msmktempdir)
1123 GNUPGHOME="$fake" gpg --no-tty --quiet --import
1124 GNUPGHOME="$fake" gpg --with-colons --fingerprint --list-keys | \
1125 awk -F: '/^fpr:/{ print $10 }'
1130 check_cruft_file() {
1134 if [ -e "$loc" ] ; then
1135 printf "! The file '%s' is no longer used by\n monkeysphere (as of version %s), and can be removed.\n\n" "$loc" "$version" | log info
1139 check_upgrade_dir() {
1143 if [ -d "$loc" ] ; then
1144 printf "The presence of directory '%s' indicates that you have\nnot yet completed a monkeysphere upgrade.\nYou should probably run the following script:\n %s/transitions/%s\n\n" "$loc" "$SYSSHAREDIR" "$version" | log info
1148 ## look for cruft from old versions of the monkeysphere, and notice if
1149 ## upgrades have not been run:
1151 check_upgrade_dir "${SYSCONFIGDIR}/gnupg-host" 0.23
1152 check_upgrade_dir "${SYSCONFIGDIR}/gnupg-authentication" 0.23
1154 check_cruft_file "${SYSCONFIGDIR}/gnupg-authentication.conf" 0.23
1155 check_cruft_file "${SYSCONFIGDIR}/gnupg-host.conf" 0.23
1158 for foo in "${SYSDATADIR}/backup-from-"*"-transition" ; do
1159 if [ -d "$foo" ] ; then
1160 printf "! %s\n" "$foo" | log info
1164 if [ "$found" ] ; then
1165 printf "The directories above are backups left over from a monkeysphere transition.\nThey may contain copies of sensitive data (host keys, certifier lists), but\nthey are no longer needed by monkeysphere.\nYou may remove them at any time.\n\n" | log info