From mboxrd@z Thu Jan 1 00:00:00 1970 From: git@ipfire.org To: ipfire-scm@lists.ipfire.org Subject: [git.ipfire.org] IPFire 2.x development tree branch, next, updated. ed91d763e6851923d5d5e3b044776ae7194ac2b8 Date: Wed, 11 Jan 2017 17:25:52 +0000 Message-ID: <20170111172553.256C21078E80@git01.ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7979448523713661550==" List-Id: --===============7979448523713661550== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree". The branch, next has been updated via ed91d763e6851923d5d5e3b044776ae7194ac2b8 (commit) via 3713af1e276dfb167abf29783ee85a64e865e845 (commit) via 8f23ce8e53d5b016cbb05e24566739983c89894a (commit) via ff6cc71107ae50e913c87a9bc77b3af4b31ec932 (commit) via 4f857eea41e1e5cce0bd7a48f1e0d6bafc33cb7e (commit) from 00d2007b040fdddd3455e4172bb7a19409d95ca2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ed91d763e6851923d5d5e3b044776ae7194ac2b8 Author: Michael Tremer Date: Wed Jan 11 17:21:46 2017 +0000 core109: Ship recently updated perl files =20 Signed-off-by: Michael Tremer commit 3713af1e276dfb167abf29783ee85a64e865e845 Author: Michael Tremer Date: Wed Jan 11 17:18:46 2017 +0000 network-functions.pl: Add tests for the new equals function =20 Signed-off-by: Michael Tremer commit 8f23ce8e53d5b016cbb05e24566739983c89894a Author: Michael Tremer Date: Wed Jan 11 17:09:42 2017 +0000 network-functions.pl: Fix code formatting =20 Signed-off-by: Michael Tremer commit ff6cc71107ae50e913c87a9bc77b3af4b31ec932 Author: Alexander Marx Date: Tue Jan 10 15:13:58 2017 +0100 BUG11278: enable creation from subnets of internal networks =20 In firewallgroups it was not possible to create new networks that are sub= nets of IPFire internal networks. Now this is possible for all internal networks. =20 Signed-off-by: Alexander Marx Signed-off-by: Michael Tremer commit 4f857eea41e1e5cce0bd7a48f1e0d6bafc33cb7e Author: Alexander Marx Date: Tue Jan 10 14:12:27 2017 +0100 BUG11278: Cleanup function for network check =20 Deleted some code which is also used in another function =20 Signed-off-by: Alexander Marx Signed-off-by: Michael Tremer ----------------------------------------------------------------------- Summary of changes: config/cfgroot/general-functions.pl | 18 +++++++----------- config/cfgroot/network-functions.pl | 30 ++++++++++++++++++++++++++++++ config/rootfiles/core/109/filelists/files | 2 ++ 3 files changed, 39 insertions(+), 11 deletions(-) Difference in files: diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-fun= ctions.pl index 298e68c..081e4e3 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -540,13 +540,9 @@ sub checksubnets return $errormessage; } } - - #check if we use one of ipfire's networks (green,orange,blue) - &readhash("${General::swroot}/ethernet/settings", \%ownnet); - if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne= '0.0.0.0') && &IpInSubnet($ip,$ownnet{'GREEN_NETADDRESS'},&iporsubtodec($own= net{'GREEN_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err green'};return $e= rrormessage;} - if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne= '0.0.0.0') && &IpInSubnet($ip,$ownnet{'ORANGE_NETADDRESS'},&iporsubtodec($ow= nnet{'ORANGE_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err orange'};return= $errormessage;} - if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0= .0.0.0') && &IpInSubnet($ip,$ownnet{'BLUE_NETADDRESS'},&iporsubtodec($ownnet{= 'BLUE_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err blue'};return $errorme= ssage;} - if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0= .0.0.0') && &IpInSubnet($ip,$ownnet{'RED_NETADDRESS'},&iporsubtodec($ownnet{'= RED_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err red'};return $errormessa= ge;} +=09 + #call check_net_internal + &General::check_net_internal($ccdnet); } =20 sub check_net_internal{ @@ -557,10 +553,10 @@ sub check_net_internal{ $cidr=3D&iporsubtocidr($cidr); #check if we use one of ipfire's networks (green,orange,blue) &readhash("${General::swroot}/ethernet/settings", \%ownnet); - if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne= '0.0.0.0') && &IpInSubnet($ip,$ownnet{'GREEN_NETADDRESS'},&iporsubtodec($own= net{'GREEN_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err green'};return $e= rrormessage;} - if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne= '0.0.0.0') && &IpInSubnet($ip,$ownnet{'ORANGE_NETADDRESS'},&iporsubtodec($ow= nnet{'ORANGE_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err orange'};return= $errormessage;} - if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0= .0.0.0') && &IpInSubnet($ip,$ownnet{'BLUE_NETADDRESS'},&iporsubtodec($ownnet{= 'BLUE_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err blue'};return $errorme= ssage;} - if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0= .0.0.0') && &IpInSubnet($ip,$ownnet{'RED_NETADDRESS'},&iporsubtodec($ownnet{'= RED_NETMASK'}))){ $errormessage=3D$Lang::tr{'ccd err red'};return $errormessa= ge;} + if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne= '0.0.0.0') && &Network::network_equal("$ownnet{'GREEN_NETADDRESS'}/$ownnet{'= GREEN_NETMASK'}",$network)){ $errormessage=3D$Lang::tr{'ccd err green'};retur= n $errormessage;} + if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne= '0.0.0.0') && &Network::network_equal("$ownnet{'ORANGE_NETADDRESS'}/$ownnet{= 'ORANGE_NETMASK'}",$network)){ $errormessage=3D$Lang::tr{'ccd err orange'};re= turn $errormessage;} + if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0= .0.0.0') && &Network::network_equal("$ownnet{'BLUE_NETADDRESS'}/$ownnet{'BLUE= _NETMASK'}",$network)){ $errormessage=3D$Lang::tr{'ccd err blue'};return $err= ormessage;} + if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.= 0.0.0') && &Network::network_equal("$ownnet{'RED_NETADDRESS'}/$ownnet{'RED_NE= TMASK'}",$network)){ $errormessage=3D$Lang::tr{'ccd err red'};return $errorme= ssage;} } =20 sub validport diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-fun= ctions.pl index 70fa5ed..5f53704 100644 --- a/config/cfgroot/network-functions.pl +++ b/config/cfgroot/network-functions.pl @@ -102,6 +102,22 @@ sub bin2ip($) { return $address; } =20 +# Takes two network addresses, compares them against each other +# and returns true if equal or false if not +sub network_equal { + my $network1 =3D shift; + my $network2 =3D shift; + + my $bin1 =3D &network2bin($network1); + my $bin2 =3D &network2bin($network2); + + if ($bin1 eq $bin2) { + return 1; + } + + return 0; +} + # Takes a network in either a.b.c.d/a.b.c.d or a.b.c.d/e notation # and will return an 32 bit integer representing the start # address and an other one representing the network mask. @@ -352,12 +368,26 @@ sub testsuite() { $result =3D &find_next_ip_address("1.2.3.4", 2); assert($result eq "1.2.3.6"); =20 + $result =3D &network_equal("192.168.0.0/24", "192.168.0.0/255.255.255.0"); + assert($result); + + $result =3D &network_equal("192.168.0.0/24", "192.168.0.0/25"); + assert(!$result); + + $result =3D &network_equal("192.168.0.0/24", "192.168.0.128/25"); + assert(!$result); + + $result =3D &network_equal("192.168.0.1/24", "192.168.0.XXX/24"); + assert($result); + $result =3D &ip_address_in_network("10.0.1.4", "10.0.0.0/8"); assert($result); =20 $result =3D &ip_address_in_network("192.168.30.11", "192.168.30.0/255.255.2= 55.0"); assert($result); =20 + print "Testsuite completed successfully!\n"; + return 0; } =20 diff --git a/config/rootfiles/core/109/filelists/files b/config/rootfiles/cor= e/109/filelists/files index 182b816..0d5de8f 100644 --- a/config/rootfiles/core/109/filelists/files +++ b/config/rootfiles/core/109/filelists/files @@ -5,3 +5,5 @@ lib/udev/network-hotplug-bridges lib/udev/network-hotplug-rename usr/local/bin/backupiso usr/local/bin/syslogdctrl +var/ipfire/general-functions.pl +var/ipfire/network-functions.pl hooks/post-receive -- IPFire 2.x development tree --===============7979448523713661550==--