From mboxrd@z Thu Jan 1 00:00:00 1970 From: Erik Kapfer To: development@lists.ipfire.org Subject: [PATCH v2] Firewall initscript: Restore Tor IPTable rules by manual firewall restart Date: Tue, 16 Jan 2024 15:27:04 +0000 Message-ID: <20240116152650.3478281-1-erik.kapfer@ipfire.org> In-Reply-To: <20240116150810.3477551-1-erik.kapfer@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4765146011556404732==" List-Id: --===============4765146011556404732== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable If the firewall will be manually restart via '/etc/init.d/firewall restart', the IPTable rules for the Tor relay will be deleted since 'iptables_init' only flushes and creates inbound and unbound chains for Tor but does not restore t= he ruleset from Tor initscript. For reference and tests please see --> https://community.ipfire.org/t/tor-stop-working-without-stop-the-process-or-g= ive-an-error-message/10697 Signed-off-by: Erik Kapfer --- src/initscripts/system/firewall | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/initscripts/system/firewall b/src/initscripts/system/firewall index 50f2b3e02..3aab7dd75 100644 --- a/src/initscripts/system/firewall +++ b/src/initscripts/system/firewall @@ -25,6 +25,9 @@ eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) eval $(/usr/local/bin/readhash /var/ipfire/optionsfw/settings) +if [ -r "/var/ipfire/tor/settings" ]; then + eval $(/usr/local/bin/readhash /var/ipfire/tor/settings) +fi IFACE=3D`/bin/cat /var/ipfire/red/iface 2> /dev/null | /usr/bin/tr -d '\012'` if [ -z $IFACE ]; then IFACE=3D"red0" @@ -387,6 +390,11 @@ iptables_init() { # run captivectrl /usr/local/bin/captivectrl =20 + # If a Tor relay is enabled apply firewall rules + if [ "${TOR_RELAY_ENABLED}" =3D "on" -a -n "${TOR_RELAY_PORT}" ]; then + /usr/local/bin/torctrl restart 1> /dev/null + fi + # POLICY CHAIN iptables -N POLICYIN iptables -A INPUT -j POLICYIN --=20 2.43.0 --===============4765146011556404732==--