]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/cfgroot/ids-functions.pl
ids-functions.pl: Fix generating DNS_SERVERS
[people/pmueller/ipfire-2.x.git] / config / cfgroot / ids-functions.pl
index 3cfe837dbc0c1441a41fc1499dcdc3158547cf8c..186c39ac78f27fb0f7165895248287d012824674 100644 (file)
@@ -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);