]> git.proxmox.com Git - pmg-api.git/commitdiff
PMG/Config.pm: fix ipv6 address quoting for postfix mynetworks
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 26 Jan 2018 06:26:19 +0000 (07:26 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 26 Jan 2018 06:26:19 +0000 (07:26 +0100)
PMG/Config.pm

index 8b1c2dcfe15e8940352a448f466b0f2ec775e10e..956963997a87449683756e8b4c4bcb4da85797bd 100755 (executable)
@@ -1013,17 +1013,27 @@ sub get_template_vars {
     my $mynetworks = [ '127.0.0.0/8', '[::1]/128' ];
 
     if (my $int_net_cidr = PMG::Utils::find_local_network_for_ip($int_ip, 1)) {
-       push @$mynetworks, $int_net_cidr;
+       if ($int_net_cidr =~ m/^($IPV6RE)\/(\d+)$/) {
+           push @$mynetworks, "[$1]/$2";
+       } else {
+           push @$mynetworks, $int_net_cidr;
+       }
     } else {
        if ($int_ip =~ m/^$IPV6RE$/) {
-           push @$mynetworks, "$int_ip/128";
+           push @$mynetworks, "[$int_ip]/128";
        } else {
            push @$mynetworks, "$int_ip/32";
        }
     }
 
     my $netlist = PVE::INotify::read_file('mynetworks');
-    push @$mynetworks, keys %$netlist;
+    foreach my $cidr (keys %$netlist) {
+       if ($cidr =~ m/^($IPV6RE)\/(\d+)$/) {
+           push @$mynetworks, "[$1]/$2";
+       } else {
+           push @$mynetworks, $cidr;
+       }
+    }
 
     push @$mynetworks, @$transportnets;