From b76118c32ceb03b40945805e42bd7514f7007f1f Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Thu, 30 Jan 2020 12:51:31 +0100 Subject: [PATCH] ids-functions.pl: Fix generating DNS_SERVERS The configuration file has an invalid syntax which causes suricata to fail to start. There was no comma inserted between DNS servers when there was more than two of them. This is now fixed in this patch.. Signed-off-by: Michael Tremer Signed-off-by: Arne Fitzenreiter --- config/cfgroot/ids-functions.pl | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index 3cfe837dbc..186c39ac78 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -712,32 +712,18 @@ sub generate_dns_servers_file() { my @nameservers = &General::get_nameservers(); # Format dns servers declaration. - my $line = "\"\["; + my $line = ""; # Check if the system has configured nameservers. if (@nameservers) { - # Loop through the array of nameservers. - foreach my $server (@nameservers) { - # Add the DNS server to the line. - $line = "$line" . "$server"; - - # Check if the current DNS server was the last in the array. - if ($server ne $nameservers[-1]) { - # Add "," for the next DNS server. - $line = "$line" . "\,"; - } - } + $line = join(",", @nameservers); } else { # The responsible DNS servers on red are directly used, and because we are not able # to specify each single DNS server address here, we currently have to thread each # address which is not part of the HOME_NET as possible DNS server. - $line = "$line" . "!\$HOME_NET"; - + $line = "!\$HOME_NET"; } - # Close the line... - $line = "$line" . "\]\""; - # Open file to store the used DNS server addresses. open(FILE, ">$dns_servers_file") or die "Could not open $dns_servers_file. $!\n"; @@ -749,7 +735,7 @@ sub generate_dns_servers_file() { print FILE "#Autogenerated file. Any custom changes will be overwritten!\n"; # Print the generated DNS declaration to the file. - print FILE "DNS_SERVERS:\t$line\n"; + print FILE "DNS_SERVERS:\t\"[$line]\"\n"; # Close file handle. close(FILE); -- 2.39.2