IDS: Add GREEN and BLUE addresses to the list of DNS servers.

Message ID 20200403145912.9808-1-stefan.schantl@ipfire.org
State Accepted
Commit 7b97359b99add6f343a4687d5f2f6a8a86304b4f
Headers
Series IDS: Add GREEN and BLUE addresses to the list of DNS servers. |

Commit Message

Stefan Schantl April 3, 2020, 2:59 p.m. UTC
  Fixes #12349.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 config/cfgroot/ids-functions.pl | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
  

Comments

Peter Müller April 5, 2020, 7:51 a.m. UTC | #1
Reviewed-by: Peter Müller <peter.mueller@ipfire.org>

> Fixes #12349.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
>  config/cfgroot/ids-functions.pl | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl
> index 5bc3e77ec..f124b12be 100644
> --- a/config/cfgroot/ids-functions.pl
> +++ b/config/cfgroot/ids-functions.pl
> @@ -718,13 +718,28 @@ sub generate_dns_servers_file() {
>  	# Get the used DNS servers.
>  	my @nameservers = &General::get_nameservers();
>  
> +	# Get network settings.
> +	my %netsettings;
> +	&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
> +
>  	# Format dns servers declaration.
>  	my $line = "";
>  
>  	# Check if the system has configured nameservers.
>  	if (@nameservers) {
> +		# Add the GREEN address as DNS servers.
> +		push(@nameservers, $netsettings{'GREEN_ADDRESS'});
> +
> +		# Check if a BLUE zone exists.
> +		if ($netsettings{'BLUE_ADDRESS'}) {
> +			# Add the BLUE address to the array of nameservers.
> +			push(@nameservers, $netsettings{'BLUE_ADDRESS'});
> +		}
> +
> +		# Generate the line which will be written to the DNS servers file.
>  		$line = join(",", @nameservers);
>  	} else {
> +		# External net simply contains (any).
>  		$line = "\$EXTERNAL_NET";
>  	}
>  
>
  

Patch

diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl
index 5bc3e77ec..f124b12be 100644
--- a/config/cfgroot/ids-functions.pl
+++ b/config/cfgroot/ids-functions.pl
@@ -718,13 +718,28 @@  sub generate_dns_servers_file() {
 	# Get the used DNS servers.
 	my @nameservers = &General::get_nameservers();
 
+	# Get network settings.
+	my %netsettings;
+	&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
+
 	# Format dns servers declaration.
 	my $line = "";
 
 	# Check if the system has configured nameservers.
 	if (@nameservers) {
+		# Add the GREEN address as DNS servers.
+		push(@nameservers, $netsettings{'GREEN_ADDRESS'});
+
+		# Check if a BLUE zone exists.
+		if ($netsettings{'BLUE_ADDRESS'}) {
+			# Add the BLUE address to the array of nameservers.
+			push(@nameservers, $netsettings{'BLUE_ADDRESS'});
+		}
+
+		# Generate the line which will be written to the DNS servers file.
 		$line = join(",", @nameservers);
 	} else {
+		# External net simply contains (any).
 		$line = "\$EXTERNAL_NET";
 	}