From: Florian Bührle Date: Sat, 11 May 2019 11:28:12 +0000 (+0200) Subject: zoneconf: Fix bug in NIC assignment; Change visibility of unused zones X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=f60b61e04d156476e5429aa76a71cc833ddf92bd zoneconf: Fix bug in NIC assignment; Change visibility of unused zones 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. --- diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 3b711d5209..adb3d29676 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -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 ""; foreach (@zones) { - print ""; my $uc = uc $_; - my $dev_name = $ethsettings{"${uc}_DEV"}; - if ($dev_name eq "") { # If the zone is not activated, color it light grey - print "$uc"; - - foreach (@nics) { - print ""; - } - - print ""; + if ($dev_name eq "") { # If the zone is not activated, don't show it next; } + print ""; + if ($uc eq "RED") { my $red_type = $ethsettings{"RED_TYPE"}; my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP")); diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 305776dd66..ba7771ab68 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2892,6 +2892,7 @@ '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 diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 5667d2004a..8dbd134339 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2941,6 +2941,7 @@ '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