]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
t_net.sh: execute sleep after checking exit code of previous command
authorAntonio Quartulli <a@unstable.cc>
Thu, 19 Sep 2019 20:22:57 +0000 (22:22 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 19 Sep 2019 20:36:14 +0000 (22:36 +0200)
Ensure to check the exit code of the mktun command *before* running
sleep, otherwise '$?' will resolve to the exit code of sleep itself,
thus nullifying the check.

Reported-by: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20190919202257.19405-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18845.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
tests/t_net.sh

index 97e947ab5fe2e5eb7b2eb84fb1a84fa639057abd..49790f0f4ecc9dcd6ab0d56b0a2648ddcbc14101 100755 (executable)
@@ -35,17 +35,17 @@ reload_dummy()
     $RUN_SUDO $openvpn --dev $IFACE --dev-type tun --rmtun >/dev/null
     $RUN_SUDO $openvpn --dev $IFACE --dev-type tun --mktun >/dev/null
 
+    if [ $? -ne 0 ]; then
+        echo "can't create interface $IFACE"
+        exit 1
+    fi
+
     # it seems that tun devices will settle on NO-CARRIER while not connected to
     # any process, but this won't happen immediately. To avoid having the
     # NO-CARRIER bit appear in the middle of the tests - which would compromise
     # the results - let's wait 1 sec here for it to settle.
     sleep 1
 
-    if [ $? -ne 0 ]; then
-        echo "can't create interface $IFACE"
-        exit 1
-    fi
-
     #ip link set dev $IFACE address 00:11:22:33:44:55
 }