mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 16:57:00 +08:00
tests: converted part of the test suite to run with cwrap
That allows several tests to run as non-root.
This commit is contained in:
@@ -22,9 +22,21 @@
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#this test can only be run as root
|
||||
id|grep root >/dev/null 2>&1
|
||||
if [ $? != 0 ];then
|
||||
exit 77
|
||||
|
||||
OPENCONNECT=/usr/sbin/openconnect
|
||||
|
||||
if test -z "$NO_NEED_ROOT";then
|
||||
id|grep root >/dev/null 2>&1
|
||||
if [ $? != 0 ];then
|
||||
exit 77
|
||||
fi
|
||||
else
|
||||
SOCKDIR=${srcdir}/sockwrap.$$.tmp
|
||||
mkdir -p $SOCKDIR
|
||||
export SOCKET_WRAPPER_DIR=$SOCKDIR
|
||||
export SOCKET_WRAPPER_DEFAULT_IFACE=2
|
||||
ADDRESS=127.0.0.$SOCKET_WRAPPER_DEFAULT_IFACE
|
||||
OPENCONNECT="eval LD_PRELOAD=libsocket_wrapper.so /usr/sbin/openconnect"
|
||||
fi
|
||||
|
||||
if ! test -x /usr/sbin/openconnect;then
|
||||
@@ -32,7 +44,6 @@ if ! test -x /usr/sbin/openconnect;then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
OPENCONNECT=/usr/sbin/openconnect
|
||||
|
||||
fail() {
|
||||
PID=$1
|
||||
@@ -54,8 +65,24 @@ launch_server() {
|
||||
fi
|
||||
}
|
||||
|
||||
launch_sr_server() {
|
||||
LD_PRELOAD=libsocket_wrapper.so:libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* >/dev/null 2>&1 &
|
||||
LOCALPID="$!";
|
||||
trap "[ ! -z \"${LOCALPID}\" ] && kill ${LOCALPID};" 15
|
||||
wait "${LOCALPID}"
|
||||
LOCALRET="$?"
|
||||
if [ "${LOCALRET}" != "0" ] && [ "${LOCALRET}" != "143" ] ; then
|
||||
# Houston, we'v got a problem...
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
launch_simple_sr_server() {
|
||||
LD_PRELOAD=libsocket_wrapper.so:libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
launch_simple_server() {
|
||||
$SERV $* >/dev/null 2>&1 &
|
||||
$PRELOAD_CMD $SERV $* >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
launch_debug_server() {
|
||||
@@ -75,4 +102,10 @@ wait_server() {
|
||||
sleep 5
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
kill $PID
|
||||
wait
|
||||
test -n "$SOCKDIR" && rm -rf $SOCKDIR
|
||||
}
|
||||
|
||||
trap "fail \"Failed to launch the server, aborting test... \"" 10
|
||||
|
||||
Reference in New Issue
Block a user