]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids-functions.pl: Add private function to cleanup the rules directory.
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 12 Oct 2018 13:12:10 +0000 (15:12 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Fri, 12 Oct 2018 13:12:10 +0000 (15:12 +0200)
This private function is used to remove any files which are stored in the
IDS rules directory and prevent from any old (unneeded or conflicting) files
after an update or complete change of the ruleset source.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/ids-functions.pl

index e7cd5b2b36a4799517c217243fdf38aeb0ae7f98..73a1add5c6064fa7af0e74a14557bcc39d44bc07 100644 (file)
@@ -443,4 +443,23 @@ sub _check_rulesdir_permissions() {
        }
 }
 
+#
+## Private function to cleanup the directory which contains
+## the IDS rules, before extracting and modifing the new ruleset.
+#
+sub _cleanup_rulesdir() {
+       # Loop through the rules-directory.
+       while ($item = glob($rulespath/*)) {
+               # Skip element if it is a directory.
+               next if -d $item;
+
+               # Delete the current processed item, if not, exit this function
+               # and return an error message.
+               unlink($item) or return "Could not delete $item. $!\n";
+       }
+
+       # Return noting;
+       return;
+}
+
 1;