]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
make t_client robust against sudoers misconfiguration
authorGert Doering <gert@greenie.muc.de>
Sun, 2 Oct 2016 13:19:23 +0000 (15:19 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 4 Oct 2016 09:31:25 +0000 (11:31 +0200)
Instead of testing (and priming) sudo with "true", prime with
"kill -0 $$" (just test signalling ourselves).  If this fails,
we won't be able to kill the openvpn process we're going to
start later on -> thus, SKIP on failure.

This helps with misconfigured setups (especially on the buildbots)
that can correctly start openvpn but then not stop it later on -
leaving openvpn processes dangling around, requiring manual
intervention.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20161002131923.36681-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12585.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
tests/t_client.sh.in

index d1c5d8737342339469134e8c9bc6f78342a61aae..b2428b96aaad12a586a3212c6ea8a09565cde2e2 100755 (executable)
@@ -42,12 +42,6 @@ if [ $? -ne 0 ]; then
     exit 77
 fi
 
-TRUE_EXEC=`which true`
-if [ $? -ne 0 ]; then
-    echo "$0: true not found in \$PATH" >&2
-    exit 77
-fi
-
 if [ ! -x "${top_builddir}/src/openvpn/openvpn" ]
 then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
@@ -102,7 +96,13 @@ else
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-        $RUN_SUDO $TRUE_EXEC
+       if $RUN_SUDO $KILL_EXEC -0 $$
+       then
+           echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+       else
+           echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+           exit 77
+       fi
     fi
 fi