]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
zoneconf: Fix bug in NIC assignment; Change visibility of unused zones
authorFlorian Bührle <flo@erdlof.org>
Sat, 11 May 2019 11:28:12 +0000 (13:28 +0200)
committerFlorian Bührle <flo@erdlof.org>
Sat, 11 May 2019 11:28:12 +0000 (13:28 +0200)
Fix a bug that allows users to add multiple NICs to non-bridged zones.
This fix includes a new error message.

Unused zones are now invisible instead of grey.

html/cgi-bin/zoneconf.cgi
langs/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl

index 3b711d5209a37721d53aa7aff313a86d46a6ebea..adb3d29676e2181f89a51fdbc0791f972c543994 100644 (file)
@@ -164,6 +164,11 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
                my $slave_string = "";
                my $zone_mode = $cgiparams{"MODE $uc"};
                my $VALIDATE_vlancount = 0;
+               my $VALIDATE_zoneslaves = 0;
+
+               if ($zone_mode eq "") { # If this zone is not activated, we don't check it
+                       next;
+               }
 
                $ethsettings{"${uc}_MACADDR"} = "";
                $ethsettings{"${uc}_MODE"} = "";
@@ -201,16 +206,22 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
                        if (! ($nic_access eq "NONE")) {
                                if ($VALIDATE_nic_check{"RESTRICT $mac"}) { # If this interface is already assigned to RED in PPP mode, throw an error
                                        $VALIDATE_error = $Lang::tr{"zoneconf val ppp assignment error"};
-                                       next;
+                                       last;
+                               }
+
+                               if ($zone_mode ne "BRIDGE" && $VALIDATE_zoneslaves > 0) {
+                                       $VALIDATE_error = $Lang::tr{"zoneconf val zoneslave amount error"};
+                                       last;
                                }
 
                                $VALIDATE_nic_check{"ACC $mac"} = 1;
+                               $VALIDATE_zoneslaves++;
                        }
 
                        if ($nic_access eq "NATIVE") {
                                if ($VALIDATE_nic_check{"NATIVE $mac"}) {
                                        $VALIDATE_error = $Lang::tr{"zoneconf val native assignment error"};
-                                       next;
+                                       last;
                                }
 
                                $VALIDATE_nic_check{"NATIVE $mac"} = 1;
@@ -225,16 +236,16 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
 
                                if ($VALIDATE_nic_check{"VLAN $mac $vlan_tag"}) {
                                        $VALIDATE_error = $Lang::tr{"zoneconf val vlan tag assignment error"};
-                                       next;
+                                       last;
                                }
 
                                $VALIDATE_nic_check{"VLAN $mac $vlan_tag"} = 1;
 
                                if (! looks_like_number($vlan_tag)) {
-                                       next;
+                                       last;
                                }
                                if ($vlan_tag < 1 || $vlan_tag > 4095) {
-                                       next;
+                                       last;
                                }
 
                                my $rnd_mac = &Network::random_mac();
@@ -253,7 +264,7 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
 
                if ($VALIDATE_vlancount > 1) {
                        $VALIDATE_error = $Lang::tr{"zoneconf val vlan amount assignment error"};
-                       next;
+                       last;
                }
 
                chop($slave_string);
@@ -305,22 +316,15 @@ foreach (@nics) {
 print "</tr>";
 
 foreach (@zones) {
-       print "<tr>";
        my $uc = uc $_;
-
        my $dev_name = $ethsettings{"${uc}_DEV"};
 
-       if ($dev_name eq "") { # If the zone is not activated, color it light grey
-               print "<td class='h disabled'>$uc</td>";
-
-               foreach (@nics) {
-                       print "<td class='disabled'/>";
-               }
-
-               print "</tr>";
+       if ($dev_name eq "") { # If the zone is not activated, don't show it
                next;
        }
 
+       print "<tr>";
+
        if ($uc eq "RED") {
                my $red_type = $ethsettings{"RED_TYPE"};
                my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP"));
index 305776dd66e85e8313e1f22066211ea19d127110..ba7771ab68c59ce34233153901c273c082858d2a 100644 (file)
 'zoneconf val ppp assignment error' => 'Die Netzwerkkarte, die von RED im PPP-Modus verwendet wird, kann keiner anderen Zone zugeordnet werden.',
 'zoneconf val vlan amount assignment error' => 'Pro Zone kann nur ein VLAN verwendet werden.',
 'zoneconf val vlan tag assignment error' => 'Pro Netzwerkkarte kann derselbe VLAN-Tag nur einmal verwendet werden.',
+'zoneconf val zoneslave amount error' => 'Wenn eine Zone nicht im Brückenmodus ist, kann ihr nur eine Netzwerkkarte zugewiesen werden.',
 );
 
 #EOF
index 5667d2004aa3cbbb8f1f04402325e2080549cb6d..8dbd134339ffe7157f67c2993f7f275bcd652bbf 100644 (file)
 'zoneconf val ppp assignment error' => 'The NIC used for RED in PPP mode cannot be accessed by any other zone.',
 'zoneconf val vlan amount assignment error' => 'A zone cannot have more than one VLAN assigned.',
 'zoneconf val vlan tag assignment error' => 'You cannot use the same VLAN tag more than once per NIC.',
+'zoneconf val zoneslave amount error' => 'A zone that is not in bridge mode can\'t have more than one NIC assigned',
 );
 
 #EOF