From parmelan-guest at users.alioth.debian.org Thu Mar 17 14:11:28 2016 From: parmelan-guest at users.alioth.debian.org (parmelan-guest at users.alioth.debian.org) Date: Thu, 17 Mar 2016 14:11:28 +0000 Subject: pf-tools/pf-tools-0.33-stable: 4 new changesets Message-ID: details: http://hg.debian.org/hg/pf-tools/pf-tools-0.33-stable/rev/e44d57a90538 changeset: 556:e44d57a90538 user: Thomas Parmelan date: Thu Mar 17 14:56:44 2016 +0100 description: Always sort keys before using them in Init_lib_net(). details: http://hg.debian.org/hg/pf-tools/pf-tools-0.33-stable/rev/4d19eb20abe2 changeset: 557:4d19eb20abe2 user: Thomas Parmelan date: Thu Mar 17 14:57:03 2016 +0100 description: Add tools/dump-distribs and tools/dump-subnets to the source repository. details: http://hg.debian.org/hg/pf-tools/pf-tools-0.33-stable/rev/c76e8b8589c4 changeset: 558:c76e8b8589c4 user: Thomas Parmelan date: Thu Mar 17 14:57:24 2016 +0100 description: releasing package pf-tools version 0.33.26-1 details: http://hg.debian.org/hg/pf-tools/pf-tools-0.33-stable/rev/d01269f05f97 changeset: 559:d01269f05f97 user: Thomas Parmelan date: Thu Mar 17 14:57:24 2016 +0100 description: tagging package pf-tools version 0.33.26-1 diffstat: .hgtags | 1 + debian/changelog | 12 +++++ lib/PFTools/Net.pm | 4 +- tools/dump-distribs | 84 +++++++++++++++++++++++++++++++++++++++++ tools/dump-subnets | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 204 insertions(+), 2 deletions(-) diffs (245 lines): diff -r f417f3a1fb52 -r d01269f05f97 .hgtags --- a/.hgtags Thu Mar 07 15:37:21 2013 +0100 +++ b/.hgtags Thu Mar 17 14:57:24 2016 +0100 @@ -2,3 +2,4 @@ 82b295cfe2174230e2cb1cf3965970917ed92d75 0.33.22-1 87ffc2caf7c2ab8f0e3e6ebb8fcac2af66d04673 0.33.24-1 77d660d6254e2bac8641180d38881ce14f518634 debian-0.33.25-1 +c76e8b8589c43ea2f356f6878f240a23c52ea3a8 debian-0.33.26-1 diff -r f417f3a1fb52 -r d01269f05f97 debian/changelog --- a/debian/changelog Thu Mar 07 15:37:21 2013 +0100 +++ b/debian/changelog Thu Mar 17 14:57:24 2016 +0100 @@ -1,3 +1,15 @@ +pf-tools (0.33.26-1) unstable; urgency=medium + + * Always sort keys before using them in Init_lib_net(). In the Good Old + Days, Perl always used the same order for hash keys iterations (even if it + was not guaranteed), but this is not the case anymore in Jessie. Without + this explicit sort, the output of mk_privatezone and mk_dhcp is not always + in the same order when running on a Jessie host, which makes the output of + "update-config --diff" unusable. + * Add tools/dump-distribs and tools/dump-subnets to the source repository. + + -- Thomas Parmelan Thu, 17 Mar 2016 14:36:38 +0100 + pf-tools (0.33.25-1) unstable; urgency=low * Remove vmether black magic "feature": when mk_dhcp is run in a VM it diff -r f417f3a1fb52 -r d01269f05f97 lib/PFTools/Net.pm --- a/lib/PFTools/Net.pm Thu Mar 07 15:37:21 2013 +0100 +++ b/lib/PFTools/Net.pm Thu Mar 17 14:57:24 2016 +0100 @@ -825,7 +825,7 @@ $C = Load_conf( $fic_conf, 0 ); # Calcul de la conf reseau et de la zone - foreach $s ( keys %$C ) { + foreach $s ( sort keys %$C ) { if ( $C->{$s}->{'type'} =~ /network$/ ) { Add_network( $Z, $C->{$s}, $s ); } @@ -839,7 +839,7 @@ # Calcul de la conf serveur # (Il doit obligatoirement etre fait en seconde passe # il utilise les donnees reseau et zone) - foreach $s ( keys %$C ) { + foreach $s ( sort keys %$C ) { if ( $C->{$s}->{'type'} =~ /server$/ ) { Add_server( $Z, $C->{$s}, $s ); } diff -r f417f3a1fb52 -r d01269f05f97 tools/dump-distribs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/dump-distribs Thu Mar 17 14:57:24 2016 +0100 @@ -0,0 +1,84 @@ +#!/usr/bin/perl +# +# Copyright (C) 2014 Thomas Parmelan +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +use strict; +use warnings; + +use English qw( -no_match_vars ); # Avoids regex performance penalty +use File::Basename; +use Getopt::Long qw( :config ignore_case_always bundling ); + +use PFTools::Net; +use PFTools::Update; + +my @options_specifications = ( + 'help', + 'source|s=s', +); + +# default values +my $options = { + 'help' => 0, + 'source' => q{private-network}, +}; + +my $program = basename $PROGRAM_NAME; + +GetOptions( $options, @options_specifications ) + or die "Didn't grok options (see --help).\n"; + +if ( $options->{'help'} ) { + Do_help(); + exit 0; +} + +if ( not $options->{'source'} ) { + die q{ERROR: --source is mandatory}; +} + +if (@ARGV) { + die q{ERROR: No arguments expected (see --help).}; +} + +my $global_config = Init_lib_net( Get_source( $options->{'source'} ) ); +my $server_list = $global_config->{'SERVERS'}->{'BY_NAME'}; + +foreach my $server_type ( sort keys %{$server_list} ) { + my $server_type_ref = $server_list->{$server_type}; + foreach my $server_name ( sort keys %{ $server_type_ref->{'SRVLIST'} } ) { + my $server_ref = $server_type_ref->{'SRVLIST'}->{$server_name}; + my $distrib = $server_ref->{'distrib'}; + if ($distrib) { + print join( q{:}, $server_name, $distrib ), qq{\n}; + } + } +} + + +sub Do_help { + print STDERR << "# ENDHELP"; +$program + +Usage: $program [options] + -h, --help print help and exit + -s, --source: source file [default: $options->{'source'}] + +# ENDHELP +} + diff -r f417f3a1fb52 -r d01269f05f97 tools/dump-subnets --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/dump-subnets Thu Mar 17 14:57:24 2016 +0100 @@ -0,0 +1,105 @@ +#!/usr/bin/perl +# +# Copyright (C) 2014 Thomas Parmelan +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +use strict; +use warnings; + +use English qw( -no_match_vars ); # Avoids regex performance penalty +use File::Basename; +use Getopt::Long qw( :config ignore_case_always bundling ); +use Net::IP; + +use PFTools::Net; +use PFTools::Update; + +my @options_specifications = ( + 'help', + 'source|s=s', +); + +# default values +my $options = { + 'help' => 0, + 'source' => q{private-network}, +}; + +my $program = basename $PROGRAM_NAME; + +GetOptions( $options, @options_specifications ) + or die "Didn't grok options (see --help).\n"; + +if ( $options->{'help'} ) { + Do_help(); + exit 0; +} + +if ( not $options->{'source'} ) { + die q{ERROR: --source is mandatory}; +} + +if (@ARGV) { + die q{ERROR: No arguments expected (see --help).}; +} + +my $global_config = Init_lib_net( Get_source( $options->{'source'} ) ); +my $subnet_list = $global_config->{'NETWORK'}->{'BY_ADDR'}; + +foreach my $subnet_key ( + map { $_->[0] } + sort { $a->[1] <=> $b->[1] } + map { + [ $_, eval { Net::IP->new($_)->intip } ] + } + keys %{$subnet_list} + ) +{ + my $subnet_ref = $subnet_list->{$subnet_key}; + + foreach my $attribute (qw( name network prefix tag comment )) { + if ( not defined $subnet_ref->{$attribute} ) { + warn + qq{WARN: attribute '$attribute' not defined for subnet $subnet_key}; + $subnet_ref->{$attribute} = q{UNKNOWN}; + } + } + + my $network = $subnet_ref->{'network'}; + if ( $network ne $subnet_key ) { + warn qq{WARN: Whoa there, network $network != subnet $subnet_key}; + } + + my $subnet = join q{/}, $network, $subnet_ref->{'prefix'}; + + print join( q{;}, + $subnet, $subnet_ref->{'name'}, $subnet_ref->{'tag'}, + $subnet_ref->{'comment'} ), + qq{\n}; +} + +sub Do_help { + print STDERR << "# ENDHELP"; +$program + +Usage: $program [options] + -h, --help print help and exit + -s, --source: source file [default: $options->{'source'}] + +# ENDHELP +} +