]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/cfgroot/ids-functions.pl
ids-functions.pl: Add function to create empty files
[ipfire-2.x.git] / config / cfgroot / ids-functions.pl
index 0e1f2876b0c7d0ca0701e11817d324fc304557fc..6f7f3ee7ef7eb07857a5982607c13fdf734a70b6 100644 (file)
@@ -189,7 +189,7 @@ sub oinkmaster () {
        openlog('oinkmaster', 'cons,pid', 'user');
 
        # Call oinkmaster to generate ruleset.
-       open(OINKMASTER, "/usr/local/bin/oinkmaster.pl -v -s -u file://$rulestarball -C $settingsdir/oinkmaster.conf -o $rulespath|");
+       open(OINKMASTER, "/usr/local/bin/oinkmaster.pl -v -s -u file://$rulestarball -C $settingsdir/oinkmaster.conf -o $rulespath|") or die "Could not execute oinkmaster $!\n";
 
        # Log output of oinkmaster to syslog.
        while(<OINKMASTER>) {
@@ -355,4 +355,26 @@ sub call_suricatactrl ($) {
        return;
 }
 
+#
+## Function to create a new empty file.
+#
+sub create_empty_file($) {
+       my ($file) = @_;
+
+       # Check if the given file exists.
+       if(-e $file) {
+               # Do nothing to prevent from overwriting existing files.
+               return;
+       }
+
+       # Open the file for writing.
+       open(FILE, ">$file") or die "Could not write to $file. $!\n";
+
+       # Close file handle.
+       close(FILE);
+
+       # Return true.
+       return 1;
+}
+
 1;