[2/4] backup.pl: Remove any 3coresec ipblocklists from old backups being restored

Message ID 20250424142041.3443255-2-adolf.belka@ipfire.org
State Staged
Commit 74be89cf589f93aea0f0aade3a5dcba8bcbb3ea2
Headers
Series [1/4] sources: remove the 3CORESEC ipblocklist entries from the sources file |

Commit Message

Adolf Belka April 24, 2025, 2:20 p.m. UTC
  - This patch ensures that any restore from an old backup cointaining the 3coresec lists
   will not restore the ipblocklist associated files for those lists.

Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 config/backup/backup.pl | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
  

Patch

diff --git a/config/backup/backup.pl b/config/backup/backup.pl
index 0cfbd4fc3..b36296ee8 100644
--- a/config/backup/backup.pl
+++ b/config/backup/backup.pl
@@ -252,11 +252,14 @@  restore_backup() {
 			-out /etc/httpd/server.crt &>/dev/null
 	fi
 
-	# Remove any entry for ALIENVAULT, SPAMHAUS_EDROP or ABUSECH_BOTNETC2 from the ipblocklist modified file
+	# Remove any entry for ALIENVAULT, SPAMHAUS_EDROP, ABUSECH_BOTNETC2 or 3CORESEC from the ipblocklist modified file
 	# and the associated ipblocklist files from the /var/lib/ipblocklist directory
 	sed -i '/ALIENVAULT=/d' /var/ipfire/ipblocklist/modified
 	sed -i '/SPAMHAUS_EDROP=/d' /var/ipfire/ipblocklist/modified
 	sed -i '/ABUSECH_BOTNETC2=/d' /var/ipfire/ipblocklist/modified
+	sed -i '/3CORESEC_SSH=/d' /var/ipfire/ipblocklist/modified
+	sed -i '/3CORESEC_SCAN=/d' /var/ipfire/ipblocklist/modified
+	sed -i '/3CORESEC_WEB=/d' /var/ipfire/ipblocklist/modified
 	if [ -e /var/lib/ipblocklist/ALIENVAULT.conf ]; then
 		rm /var/lib/ipblocklist/ALIENVAULT.conf
 	fi
@@ -266,6 +269,15 @@  restore_backup() {
 	if [ -e /var/lib/ipblocklist/ABUSECH_BOTNETC2.conf ]; then
 		rm /var/lib/ipblocklist/ABUSECH_BOTNETC2.conf
 	fi
+	if [ -e /var/lib/ipblocklist/3CORESEC_SSH.conf ]; then
+		rm /var/lib/ipblocklist/3CORESEC_SSH.conf
+	fi
+	if [ -e /var/lib/ipblocklist/3CORESEC_SCAN.conf ]; then
+		rm /var/lib/ipblocklist/3CORESEC_SCAN.conf
+	fi
+	if [ -e /var/lib/ipblocklist/3CORESEC_WEB.conf ]; then
+		rm /var/lib/ipblocklist/3CORESEC_WEB.conf
+	fi
 
 	# The collectd directory structure was changed but not all changes
 	# are done by the official migration script generator