From: Dirk Brenken Date: Sun, 26 Mar 2023 20:52:05 +0000 (+0200) Subject: banip: update to 0.8.2-4 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7852691b801dd0a4db690e9e51dd23eaa7d226d9;p=feed%2Fpackages.git banip: update to 0.8.2-4 * fixed a race condition if the service is in a disabled state Signed-off-by: Dirk Brenken (cherry picked from commit 6b1df72e64628dbeb68a2b5fd2cfb68db87a2d2f) --- diff --git a/net/banip/Makefile b/net/banip/Makefile index 9983e08b06..ca8b5fa372 100644 --- a/net/banip/Makefile +++ b/net/banip/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=banip PKG_VERSION:=0.8.2 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/banip/files/banip-functions.sh b/net/banip/files/banip-functions.sh index 692a9bd49e..fc3c732256 100644 --- a/net/banip/files/banip-functions.sh +++ b/net/banip/files/banip-functions.sh @@ -168,9 +168,15 @@ f_log() { fi fi if [ "${class}" = "err" ]; then - f_genstatus "error" - [ "${ban_mailnotification}" = "1" ] && [ -n "${ban_mailreceiver}" ] && [ -x "${ban_mailcmd}" ] && f_mail + "${ban_nftcmd}" delete table inet banIP >/dev/null 2>&1 + if [ "${ban_enabled}" = "1" ]; then + f_genstatus "error" + [ "${ban_mailnotification}" = "1" ] && [ -n "${ban_mailreceiver}" ] && [ -x "${ban_mailcmd}" ] && f_mail + else + f_genstatus "disabled" + fi f_rmdir "${ban_tmpdir}" + f_rmpid rm -rf "${ban_lock}" exit 1 fi @@ -859,7 +865,6 @@ f_genstatus() { fi runtime="action: ${ban_action:-"-"}, duration: ${duration:-"-"}, date: $(date "+%Y-%m-%d %H:%M:%S")" fi - f_system [ ${ban_splitsize:-"0"} -gt "0" ] && split="1" : >"${ban_rtfile}" @@ -1034,7 +1039,6 @@ f_report() { local detail set_details jsnval timestamp autoadd_allow autoadd_block sum_sets sum_setinput sum_setforwardwan sum_setforwardlan sum_setelements sum_cntinput sum_cntforwardwan sum_cntforwardlan [ -z "${ban_dev}" ] && f_conf - f_system f_mkdir "${ban_reportdir}" report_jsn="${ban_reportdir}/ban_report.jsn" report_txt="${ban_reportdir}/ban_report.txt" @@ -1196,9 +1200,6 @@ f_report() { f_search() { local table_sets ip proto run_search search="${1}" - f_system - run_search="/var/run/banIP.search" - if [ -n "${search}" ]; then ip="$(printf "%s" "${search}" | "${ban_awkcmd}" 'BEGIN{RS="(([0-9]{1,3}\\.){3}[0-9]{1,3})+"}{printf "%s",RT}')" [ -n "${ip}" ] && proto="v4" @@ -1217,6 +1218,7 @@ f_search() { printf "%s\n" " Looking for IP '${ip}' on $(date "+%Y-%m-%d %H:%M:%S")" printf "%s\n" " ---" cnt="1" + run_search="/var/run/banIP.search" for set in ${table_sets}; do ( if "${ban_nftcmd}" get element inet banIP "${set}" "{ ${ip} }" >/dev/null 2>&1; then @@ -1241,7 +1243,6 @@ f_search() { f_survey() { local set_elements set="${1}" - f_system [ -n "${set}" ] && set_elements="$("${ban_nftcmd}" -j list set inet banIP "${set}" 2>/dev/null | jsonfilter -qe '@.nftables[*].set.elem[*]')" if [ -z "${set}" ] || [ -z "${set_elements}" ]; then @@ -1279,6 +1280,7 @@ f_mail() { # check banIP availability and initial sourcing # +f_system if [ "${ban_action}" != "stop" ]; then if [ -r "/lib/functions.sh" ] && [ -r "/lib/functions/network.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]; then . "/lib/functions.sh"