summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@phys.columbia.edu>2008-10-28 19:20:14 -0400
committerJameson Graef Rollins <jrollins@phys.columbia.edu>2008-10-28 19:20:14 -0400
commitf7242749c484cac12aacf8bcfe19bdea72c89aaa (patch)
tree749d7a9c960d5deb4697cb8b8257be9f1edc980e
parentbee6028687945fd7d8d6eab98c26def2ecadf8b1 (diff)
chown authorized_keys files as jrollins, and add monkeysphere tmpdir in SYSDATADIR, for atomic moves of authorized_keys.
-rw-r--r--debian/changelog6
-rw-r--r--debian/dirs1
-rwxr-xr-xsrc/monkeysphere-server9
-rwxr-xr-xtests/basic49
4 files changed, 34 insertions, 31 deletions
diff --git a/debian/changelog b/debian/changelog
index 30b33f0..78266d5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ monkeysphere (0.18-1) UNRELEASED; urgency=low
[ 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
@@ -9,7 +13,7 @@ monkeysphere (0.18-1) UNRELEASED; urgency=low
* 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
diff --git a/debian/dirs b/debian/dirs
index e9390a7..b2bd77c 100644
--- a/debian/dirs
+++ b/debian/dirs
@@ -1,5 +1,6 @@
var/lib/monkeysphere
var/lib/monkeysphere/authorized_keys
+var/lib/monkeysphere/tmp
usr/bin
usr/sbin
usr/share
diff --git a/src/monkeysphere-server b/src/monkeysphere-server
index b6bf78b..846eb81 100755
--- a/src/monkeysphere-server
+++ b/src/monkeysphere-server
@@ -20,6 +20,11 @@ export SYSSHAREDIR
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')
@@ -173,7 +178,7 @@ update_users() {
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
@@ -244,7 +249,7 @@ update_users() {
# 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"
diff --git a/tests/basic b/tests/basic
index d82719d..067a02c 100755
--- a/tests/basic
+++ b/tests/basic
@@ -19,20 +19,27 @@ gpgadmin() {
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() {
@@ -52,11 +59,6 @@ get_gpg_prng_arg() {
}
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"
@@ -88,6 +90,7 @@ export MONKEYSPHERE_SYSCONFIGDIR="$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
@@ -150,6 +153,7 @@ echo "### adding admin as certifier..."
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"
@@ -157,10 +161,6 @@ HostKey ${MONKEYSPHERE_SYSDATADIR}/ssh_host_rsa_key
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
@@ -168,7 +168,6 @@ echo "### generating key for testuser..."
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
@@ -183,26 +182,20 @@ monkeysphere-server update-users "$USER"
# 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