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>
(cherry picked from commit 8ca29af7c6d4759ce019ec9d0cd3eae4511a6804)
... | ... |
@@ -42,12 +42,6 @@ if [ $? -ne 0 ]; then |
42 | 42 |
exit 77 |
43 | 43 |
fi |
44 | 44 |
|
45 |
-TRUE_EXEC=`which true` |
|
46 |
-if [ $? -ne 0 ]; then |
|
47 |
- echo "$0: true not found in \$PATH" >&2 |
|
48 |
- exit 77 |
|
49 |
-fi |
|
50 |
- |
|
51 | 45 |
if [ ! -x "${top_builddir}/src/openvpn/openvpn" ] |
52 | 46 |
then |
53 | 47 |
echo "no (executable) openvpn binary in current build tree. FAIL." >&2 |
... | ... |
@@ -102,7 +96,13 @@ else |
102 | 102 |
# We have to use sudo. Make sure that we (hopefully) do not have |
103 | 103 |
# to ask the users password during the test. This is done to |
104 | 104 |
# prevent timing issues, e.g. when the waits for openvpn to start |
105 |
- $RUN_SUDO $TRUE_EXEC |
|
105 |
+ if $RUN_SUDO $KILL_EXEC -0 $$ |
|
106 |
+ then |
|
107 |
+ echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good." |
|
108 |
+ else |
|
109 |
+ echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2 |
|
110 |
+ exit 77 |
|
111 |
+ fi |
|
106 | 112 |
fi |
107 | 113 |
fi |
108 | 114 |
|