Skip to contentSkip to conversation

make t_client robust against sudoers misconfiguration

PATCH In review Gert Doering 2 participants 3 messages Oct 2, 2016 – Oct 4, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make t_client robust against sudoers misconfiguration

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.

---
 tests/t_client.sh.in | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tests/t_client.sh.in +7 -7
index 2b9bacf..a97e9be 100755
@@ -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
 
Signature · 1 line
2.9.0
#1 lore raw

Am 02.10.16 um 15:19 schrieb Gert Doering:

Quoted 37 lines

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.

---
 tests/t_client.sh.in | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tests/t_client.sh.in +0 -7
index 2b9bacf..a97e9be 100755
@@ -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

tests/t_client.sh.in else · line 108

Quoted 10 lines
tests/t_client.sh.in +7 -0
+	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
 

Looks good, ACK from me.

Arne

#2 lore raw
In reply to Gert Doering

Patch has been applied to the following branches

commit 8ca29af7c6d4759ce019ec9d0cd3eae4511a6804 (master) commit 0bd4ef0a18c65bfbd4e5b08735d7bb67dd010b97 (release/2.3)

Author: Gert Doering
Date:   Sun Oct 2 15:19:23 2016 +0200
     make t_client robust against sudoers misconfiguration

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg12585.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering