[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipfire-development
Subject:    [PATCH v2] CU185-update.sh: Add drop hostile in & out logging entries if not already present
From:       Adolf Belka <adolf.belka () ipfire ! org>
Date:       2024-03-25 17:44:56
Message-ID: 20240325174456.35715-1-adolf.belka () ipfire ! org
[Download RAW message or body]

- This v2 patch corrects that the previous script was looking for =on. If a user had
   modified the preferences to change it to =off then the script would have resulted in
   both =on and =off versions being in the settings file.
- This patch ensures that those people who updated to CU184 before the CU184-update.sh
   patch fix to add the logging entries was added will get their optionsfw settings file
   correctly updated with CU185
- This only adds the LOGDROPHOSTILEIN & LOGDROPHOSTILEOUT entries if they do not already
   exist in the optionsfw settings file.
- This change also does the check for LOGDROPHOSTILEIN and LOGDROPHOSTILEOUT as two
   separate checks and then runs the firewall update command

Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 config/rootfiles/core/185/update.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/config/rootfiles/core/185/update.sh b/config/rootfiles/core/185/update.sh
index ec4d8ab82..002f92bbb 100644
--- a/config/rootfiles/core/185/update.sh
+++ b/config/rootfiles/core/185/update.sh
@@ -117,11 +117,17 @@ chown nobody:nobody /var/ipfire/ovpn/ovpnconfig
 
 # Check if the drop hostile in and out logging options need to be added
 # into the optionsfw settings file and apply to firewall
-if ! [ $(grep "LOGDROPHOSTILEIN=on" /var/ipfire/optionsfw/settings) ] && \
-   ! [ $(grep "LOGDROPHOSTILEOUT=on" /var/ipfire/optionsfw/settings) ]; then
-        sed -i '$ a\LOGDROPHOSTILEIN=on' /var/ipfire/optionsfw/settings
-        sed -i '$ a\LOGDROPHOSTILEOUT=on' /var/ipfire/optionsfw/settings
-        /usr/local/bin/firewallctrl
+optionsfw=""
+if ! [ $(grep "^LOGDROPHOSTILEIN=" /var/ipfire/optionsfw/settings) ]; then
+    sed -i '$ a\LOGDROPHOSTILEIN=on' /var/ipfire/optionsfw/settings
+    optionsfw="updated"
+fi
+if ! [ $(grep "^LOGDROPHOSTILEOUT=" /var/ipfire/optionsfw/settings) ]; then
+    sed -i '$ a\LOGDROPHOSTILEOUT=on' /var/ipfire/optionsfw/settings
+    optionsfw="updated"
+fi
+if ! [ -z "$optionsfw" ]; then
+    /usr/local/bin/firewallctrl
 fi
 
 # Rebuild initial ramdisks
-- 
2.44.0

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic