#!/bin/sh
#set -x
me="$1" ; shift
next="$1"
if test ! -z "$me" ; then 
	rm -f /usr/lib/openssh/ptest/regress/done
	echo "HOSTNAME host_$me"
	echo "AUTHINFO"
	cat $SSH_USER_AUTH
fi
echo AGENT
ssh-add -L | egrep "^ssh" | cut -d" " -f-2 | env LC_ALL=C sort
if test -z "$next" ; then 
	touch /usr/lib/openssh/ptest/regress/done
	echo "FINISH"
	e=0
else
	echo NEXT
	/usr/lib/openssh/ptest/regress/ssh-log-wrapper.sh -F /usr/lib/openssh/ptest/regress/ssh_proxy_noid -oIdentityFile=/usr/lib/openssh/ptest/regress/user_a 		host_$next /usr/lib/openssh/ptest/regress/command "$@"
	e=$?
fi
echo "COMPLETE \"$me\""
if test ! -z "$me" ; then 
	if test ! -f /usr/lib/openssh/ptest/regress/done ; then
		echo "DONE MARKER MISSING"
		test $e -eq 0 && e=63
	fi
fi
exit $e
