[ Jameson Graef Rollins ]
* Fix bugs in authorized_{user_ids,keys} file permission checking.
+ * Add new monkeysphere tmpdir to enable atomic moves of authorized_keys
+ files.
+ * chown authorized_keys files to `whoami`, for compatibility with test
+ suite.
[ Daniel Kahn Gillmor ]
* update install to ensure placement of
* choose either --quick-random or --debug-quick-random depending on
which gpg supports for the test suite.
- -- Daniel Kahn Gillmor <dkg@fifthhorseman.net> Tue, 28 Oct 2008 17:58:25 -0400
+ -- Jameson Graef Rollins <jrollins@phys.columbia.edu> Tue, 28 Oct 2008 19:19:20 -0400
monkeysphere (0.17-1) experimental; urgency=low
SYSDATADIR=${MONKEYSPHERE_SYSDATADIR:-"/var/lib/monkeysphere"}
export SYSDATADIR
+# monkeysphere temp directory, in sysdatadir to enable atomic moves of
+# authorized_keys files
+MSTMPDIR="${SYSDATADIR}/tmp"
+export MSTMPDIR
+
# UTC date in ISO 8601 format if needed
DATE=$(date -u '+%FT%T')
log verbose "----- user: $uname -----"
# make temporary directory
- TMPLOC=$(mktemp -d ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX)
+ TMPLOC=$(mktemp -d ${MSTMPDIR}/tmp.XXXXXXXXXX)
# trap to delete temporary directory on exit
trap "rm -rf $TMPLOC" EXIT
# authorized_keys file as the user in question, so the
# file must be readable by that user at least.
# FIXME: is there a better way to do this?
- chown root "$AUTHORIZED_KEYS"
+ chown $(whoami) "$AUTHORIZED_KEYS"
chgrp $(getent passwd "$uname" | cut -f4 -d:) "$AUTHORIZED_KEYS"
chmod g+r "$AUTHORIZED_KEYS"
GNUPGHOME="$TEMPDIR"/admin/.gnupg gpg "$@"
}
-launch_sshd() {
+ssh_test() {
umask 0077
+
+ # start the ssh daemon on the socket
socat EXEC:"/usr/sbin/sshd -f ${SSHD_CONFIG} -i -D -e" "UNIX-LISTEN:${SOCKET}" 2> "$TEMPDIR"/sshd.log &
- export SSHD_PID=$!
+ SSHD_PID="$!"
# wait until the socket is created before continuing
while [ ! -S "$SOCKET" ] ; do
sleep 1
done
-}
-ssh_test() {
+ # make a client connection to the socket
ssh-agent bash -c \
"monkeysphere subkey-to-ssh-agent && ssh -F $TEMPDIR/testuser/.ssh/config testhost true"
+ RETURN="$?"
+
+ # kill the previous sshd process if it's still running
+ kill "$SSHD_PID"
+
+ return "$RETURN"
}
failed_cleanup() {
}
cleanup() {
- if [ "$SSHD_PID" ] && ( ps "$SSHD_PID" >/dev/null ) ; then
- echo "### stopping still-running sshd..."
- kill "$SSHD_PID"
- fi
-
echo "### removing temp dir..."
rm -rf "$TEMPDIR"
export MONKEYSPHERE_SYSSHAREDIR="$TESTDIR"/../src
export MONKEYSPHERE_MONKEYSPHERE_USER="$USER"
export MONKEYSPHERE_CHECK_KEYSERVER=false
+export MONKEYSPHERE_LOG_LEVEL=DEBUG
export SSHD_CONFIG="$TEMPDIR"/sshd_config
export SOCKET="$TEMPDIR"/ssh-socket
echo y | monkeysphere-server add-identity-certifier "$TEMPDIR"/admin/.gnupg/pubkey.gpg
# initialize base sshd_config
+echo "### configuring sshd..."
cp etc/ssh/sshd_config "$SSHD_CONFIG"
# write the sshd_config
cat <<EOF >> "$SSHD_CONFIG"
AuthorizedKeysFile ${MONKEYSPHERE_SYSDATADIR}/authorized_keys/%u
EOF
-# launch test sshd with the new host key.
-echo "### starting sshd..."
-launch_sshd
-
### TESTUSER TESTS
# generate an auth subkey for the test user
export GNUPGHOME="$TEMPDIR"/testuser/.gnupg
export SSH_ASKPASS="$TEMPDIR"/testuser/.ssh/askpass
export MONKEYSPHERE_HOME="$TEMPDIR"/testuser/.monkeysphere
-
monkeysphere gen-subkey --expire 0
# add server key to testuser keychain
# connect to test sshd, using monkeysphere-ssh-proxycommand to verify
# the identity before connection. This should work in both directions!
-echo "### testuser connecting to sshd socket..."
+echo "### ssh connection test for success..."
ssh_test
-# kill the previous sshd process if it's still running
-kill "$SSHD_PID"
-
-# now remove the testuser's authorized_user_ids file and reupdate
-# authorized_keys file...
+# remove the testuser's authorized_user_ids file and update
+# authorized_keys file, this is to make sure that the ssh
+# authentication FAILS...
echo "### removing testuser authorized_user_ids and reupdating authorized_keys..."
rm -f "$TEMPDIR"/testuser/.monkeysphere/authorized_user_ids
monkeysphere-server update-users "$USER"
-# restart the sshd
-echo "### restarting sshd..."
-launch_sshd
-
-# and make sure the user can no longer connect
-echo "### testuser attempting to connect to sshd socket..."
-ssh_test || SSH_RETURN="$?"
-if [ "$SSH_RETURN" != '255' ] ; then
+# make sure the user can NOT connect
+echo "### ssh connection test for server authentication denial..."
+ssh_test
+if [ "$?" != '255' ] ; then
exit
fi