From: David Sommerseth Date: Sat, 17 Sep 2016 09:20:26 +0000 (+0300) Subject: t_client.sh: Make OpenVPN write PID file to avoid various sudo issues X-Git-Tag: contains~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=057b70f1642336b7eb939f8515de791d515b8d04;p=thirdparty%2Fopenvpn.git t_client.sh: Make OpenVPN write PID file to avoid various sudo issues This resolves an issue where $! returns the PID of the sudo process instead of the PID of OpenVPN and when sudo does not properly propagate signales down to OpenVPN. Trac: #738 Signed-off-by: David Sommerseth Acked-by: Gert Doering Message-Id: <1474104026-20615-1-git-send-email-davids@openvpn.net> URL: http://www.mail-archive.com/search?l=mid&q=1474104026-20615-1-git-send-email-davids@openvpn.net Signed-off-by: Gert Doering (cherry picked from commit e0926ebfe55347843af701216be9598827a1367a) --- diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in index 032d0d501..293539574 100755 --- a/tests/t_client.sh.in +++ b/tests/t_client.sh.in @@ -233,10 +233,14 @@ do continue fi + pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid" + openvpn_conf="$openvpn_conf --writepid $pidfile" echo " run openvpn $openvpn_conf" echo "# src/openvpn/openvpn $openvpn_conf" >$LOGDIR/$SUF:openvpn.log $RUN_SUDO "${top_builddir}/src/openvpn/openvpn" $openvpn_conf >>$LOGDIR/$SUF:openvpn.log & - opid=$! + sleep 3 # Wait for OpenVPN to initialize and have had time to write the pid file + opid=`cat $pidfile` + echo " OpenVPN running with PID $opid" # make sure openvpn client is terminated in case shell exits trap "$RUN_SUDO kill $opid" 0