]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
block.sh: Add cleanup statement to avoid exit and let the server blocked (#4967)
authorJorge Pereira <jpereira@users.noreply.github.com>
Thu, 6 Apr 2023 19:51:39 +0000 (16:51 -0300)
committerGitHub <noreply@github.com>
Thu, 6 Apr 2023 19:51:39 +0000 (15:51 -0400)
src/tests/tls/block.sh

index f397eaa19bc79a977cbcdcb556b7230ce4ce3f44..20d8babf2d2b5ab091e6e921a037ac808002249b 100755 (executable)
@@ -9,6 +9,17 @@ if [ $UID -ne 0 ]; then
         exit 1
 fi
 
+# avoid keep the server blocked
+function trap_ctrlc ()
+{
+        echo "Ctrl-C caught...performing clean up"
+
+        iptables -D INPUT -p tcp --dport 2083 -j REJECT 1> /dev/null 2>&1
+        exit 0
+}
+
+trap "trap_ctrlc" 2
+
 MAXWAIT=5
 while true; do
         _wait="$((RANDOM % MAXWAIT))"