+monkeysphere (0.18-1) UNRELEASED; urgency=low
+
+ * Fix bugs in authorized_{user_ids,keys} file permission checking.
+
+ -- Jameson Graef Rollins <jrollins@phys.columbia.edu> Tue, 28 Oct 2008 14:36:16 -0400
+
monkeysphere (0.17-1) experimental; urgency=low
[ Jameson Graef Rollins ]
Section: net
Priority: extra
Maintainer: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
-Uploaders: Jameson Rollins <jrollins@fifthhorseman.net>
+Uploaders: Jameson Graef Rollins <jrollins@phys.columbia.edu>
Build-Depends: debhelper (>= 7.0), libgnutls-dev (>= 2.4.0)
Standards-Version: 3.8.0.1
Homepage: http://web.monkeysphere.info/
# failure function. exits with code 255, unless specified otherwise.
failure() {
- echo "$1" >&2
+ [ "$1" ] && echo "$1" >&2
exit ${2:-'255'}
}
# check that a file is properly owned, and that all it's parent
# directories are not group/other writable
check_key_file_permissions() {
- local user
+ local uname
local path
+ local stat
local access
local gAccess
local oAccess
[ "$1" = "w" ]
}
- user="$1"
+ uname="$1"
path="$2"
- # return 0 is path does not exist
- [ -e "$path" ] || return 0
+ # return 255 if cannot stat file
+ if ! stat=$(ls -ld "$path" 2>/dev/null) ; then
+ log error "could not stat path '$path'."
+ return 255
+ fi
- owner=$(ls -l "$path" | awk '{ print $3 }')
- gAccess=$(ls -l "$path" | cut -c6)
- oAccess=$(ls -l "$path" | cut -c9)
+ owner=$(echo "$stat" | awk '{ print $3 }')
+ gAccess=$(echo "$stat" | cut -c6)
+ oAccess=$(echo "$stat" | cut -c9)
- # check owner
- if [ "$owner" != "$user" -a "$owner" != 'root' ] ; then
+ # return 1 if path has invalid owner
+ if [ "$owner" != "$uname" -a "$owner" != 'root' ] ; then
+ log error "improper ownership on path '$path'."
return 1
fi
- # check group/other writability
+ # return 2 if path has group or other writability
if is_write "$gAccess" || is_write "$oAccess" ; then
+ log error "improper group or other writability on path '$path'."
return 2
fi
+ # return zero if all clear, or go to next path
if [ "$path" = '/' ] ; then
return 0
else
- check_key_file_permissions $(dirname "$path")
+ check_key_file_permissions "$uname" $(dirname "$path")
fi
}
log debug "processing authorized_user_ids file..."
if ! meat "$authorizedUserIDs" > /dev/null ; then
- log debug "no user IDs to process."
+ log debug " no user IDs to process."
return
fi
MODE='authorized_keys'
# check permissions on the authorized_user_ids file path
- if ! check_key_file_permissions "$USER" "$AUTHORIZED_USER_IDS" ; then
- failure "Improper permissions on authorized_user_ids file path."
- fi
+ check_key_file_permissions "$USER" "$AUTHORIZED_USER_IDS" || failure
# check permissions on the authorized_keys file path
- if ! check_key_file_permissions "$USER" "$AUTHORIZED_KEYS" ; then
- failure "Improper permissions on authorized_keys file path."
- fi
+ check_key_file_permissions "$USER" "$AUTHORIZED_KEYS" || failure
# exit if the authorized_user_ids file is empty
if [ ! -e "$AUTHORIZED_USER_IDS" ] ; then
". ${SYSSHAREDIR}/common; process_authorized_user_ids $TMP_AUTHORIZED_USER_IDS"
RETURN="$?"
else
- log error "Improper permissions on path '$AUTHORIZED_USER_IDS'."
+ log verbose "not processing authorized_user_ids."
fi
fi
log verbose "adding raw authorized_keys file... "
cat "$rawAuthorizedKeys" >> "$AUTHORIZED_KEYS"
else
- log error "Improper permissions on path '$RAW_AUTHORIZED_KEYS'. Not added to authorized_keys file."
+ log verbose "not adding raw authorized_keys file."
fi
fi
(umask 077 && \
gpg_host --export-secret-key "$fingerprint" | \
openpgp2ssh "$fingerprint" > "${SYSDATADIR}/ssh_host_rsa_key")
- log info "Private SSH host key output to file: ${SYSDATADIR}/ssh_host_rsa_key"
+ log info "private SSH host key output to file: ${SYSDATADIR}/ssh_host_rsa_key"
}
# extend the lifetime of a host key: