public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
* [git.ipfire.org] IPFire 2.x development tree branch, next, updated. cad86575323c49037aff053210325cfdf98deafa
@ 2022-03-05 19:28 Peter Müller
  0 siblings, 0 replies; only message in thread
From: Peter Müller @ 2022-03-05 19:28 UTC (permalink / raw)
  To: ipfire-scm

[-- Attachment #1: Type: text/plain, Size: 3987 bytes --]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".

The branch, next has been updated
       via  cad86575323c49037aff053210325cfdf98deafa (commit)
       via  2b12a010d7ea97996a3b7accaab0316cb71de515 (commit)
      from  ade2424f6b8458e1d3998e8c5946826604975ff9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cad86575323c49037aff053210325cfdf98deafa
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date:   Sat Mar 5 18:53:10 2022 +0100

    ids-functions.pl: Do not create an empty ignored settings file.
    
    The file will be created by the WUI, when adding the first host.
    
    Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>

commit 2b12a010d7ea97996a3b7accaab0316cb71de515
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date:   Sat Mar 5 16:27:17 2022 +0100

    ids-functions.pl: Merge same named rulefiles during extract.
    
    In case a rulestarball contains several same-named rulefiles
    they have been overwritten each time and so only contained the content
    from the last extracted one.
    
    Now the content of those files will be merged by appending the content
    to the first extracted one for each time.
    
    Fixes #12792.
    
    Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>

-----------------------------------------------------------------------

Summary of changes:
 config/cfgroot/ids-functions.pl | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

Difference in files:
diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl
index d15973a38..468efc668 100644
--- a/config/cfgroot/ids-functions.pl
+++ b/config/cfgroot/ids-functions.pl
@@ -153,7 +153,6 @@ sub check_and_create_filelayout() {
 	unless (-f "$suricata_default_rulefiles_file") { &create_empty_file($suricata_default_rulefiles_file); }
 	unless (-f "$ids_settings_file") { &create_empty_file($ids_settings_file); }
 	unless (-f "$providers_settings_file") { &create_empty_file($providers_settings_file); }
-	unless (-f "$ignored_file") { &create_empty_file($ignored_file); }
 	unless (-f "$whitelist_file" ) { &create_empty_file($whitelist_file); }
 }
 
@@ -583,8 +582,38 @@ sub extractruleset ($) {
 				next;
 			}
 
-			# Extract the file to the temporary directory.
-			$tar->extract_file("$packed_file", "$destination");
+			# Check if the destination file exists.
+			unless(-e "$destination") {
+				# Extract the file to the temporary directory.
+				$tar->extract_file("$packed_file", "$destination");
+			} else {
+				# Load perl module to deal with temporary files.
+				use File::Temp;
+
+				# Generate temporary file name, located in the temporary rules directory and a suffix of ".tmp".
+				my $tmp = File::Temp->new( SUFFIX => ".tmp", DIR => "$tmp_rules_directory", UNLINK => 0 );
+				my $tmpfile = $tmp->filename();
+
+				# Extract the file to the new temporary file name.
+				$tar->extract_file("$packed_file", "$tmpfile");
+
+				# Open the the existing file.
+				open(DESTFILE, ">>", "$destination") or die "Could not open $destination. $!\n";
+				open(TMPFILE, "<", "$tmpfile") or die "Could not open $tmpfile. $!\n";
+
+				# Loop through the content of the temporary file.
+				while (<TMPFILE>) {
+					# Append the content line by line to the destination file.
+					print DESTFILE "$_";
+				}
+
+				# Close the file handles.
+				close(TMPFILE);
+				close(DESTFILE);
+
+				# Remove the temporary file.
+				unlink("$tmpfile");
+			}
 		}
 	}
 }


hooks/post-receive
--
IPFire 2.x development tree

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-05 19:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 19:28 [git.ipfire.org] IPFire 2.x development tree branch, next, updated. cad86575323c49037aff053210325cfdf98deafa Peter Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox