/[smeserver]/rpms/e-smith-base/sme10/e-smith-base-5.8.0-bz6536-bz10974-validate_subnet.patch
ViewVC logotype

Contents of /rpms/e-smith-base/sme10/e-smith-base-5.8.0-bz6536-bz10974-validate_subnet.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Sun Jun 28 03:11:07 2020 UTC (4 years, 4 months ago) by jpp
Branch: MAIN
CVS Tags: e-smith-base-5_8_0-71_el7_sme, e-smith-base-5_8_0-67_el7_sme, e-smith-base-5_8_0-64_el7_sme, e-smith-base-5_8_0-69_el7_sme, e-smith-base-5_8_0-70_el7_sme, e-smith-base-5_8_0-60_el7_sme, e-smith-base-5_8_0-65_el7_sme, e-smith-base-5_8_0-83_el7_sme, e-smith-base-5_8_0-96_el7_sme, e-smith-base-5_8_0-95_el7_sme, e-smith-base-5_8_0-80_el7_sme, e-smith-base-5_8_0-85_el7_sme, e-smith-base-5_8_0-50_el7_sme, e-smith-base-5_8_0-81_el7_sme, e-smith-base-5_8_0-82_el7_sme, e-smith-base-5_8_0-88_el7_sme, e-smith-base-5_8_0-54_el7_sme, e-smith-base-5_8_0-99_el7_sme, e-smith-base-5_8_0-94_el7_sme, e-smith-base-5_8_0-98_el7_sme, e-smith-base-5_8_0-97_el7_sme, e-smith-base-5_8_0-92_el7_sme, e-smith-base-5_8_0-75_el7_sme, e-smith-base-5_8_0-78_el7_sme, e-smith-base-5_8_0-90_el7_sme, e-smith-base-5_8_0-93_el7_sme, e-smith-base-5_8_0-55_el7_sme, e-smith-base-5_8_0-61_el7_sme, e-smith-base-5_8_0-52_el7_sme, e-smith-base-5_8_0-62_el7_sme, e-smith-base-5_8_0-74_el7_sme, e-smith-base-5_8_0-77_el7_sme, e-smith-base-5_8_0-63_el7_sme, e-smith-base-5_8_0-73_el7_sme, e-smith-base-5_8_0-76_el7_sme, e-smith-base-5_8_0-79_el7_sme, e-smith-base-5_8_0-91_el7_sme, e-smith-base-5_8_0-58_el7_sme, e-smith-base-5_8_0-86_el7_sme, e-smith-base-5_8_0-47_el7_sme, e-smith-base-5_8_0-59_el7_sme, e-smith-base-5_8_0-87_el7_sme, e-smith-base-5_8_0-53_el7_sme, e-smith-base-5_8_0-49_el7_sme, e-smith-base-5_8_0-48_el7_sme, e-smith-base-5_8_0-66_el7_sme, e-smith-base-5_8_0-68_el7_sme, e-smith-base-5_8_0-72_el7_sme, e-smith-base-5_8_0-84_el7_sme, e-smith-base-5_8_0-89_el7_sme, e-smith-base-5_8_0-51_el7_sme
Changes since 1.1: +2 -2 lines
* Sat Jun 27 2020 Jean-Philipe Pialasse <tests@pialasse.com> 5.8.0-47.sme
- validate submask on remote access panel [SME: 6536]
  accept netmask bit and convert it
- validate subnet mask on local network panel [SME: 10974]
  accept netmask bit and convert it

1 diff -Nur e-smith-base-5.8.0.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/localnetworks.pm e-smith-base-5.8.0/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/localnetworks.pm
2 --- e-smith-base-5.8.0.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/localnetworks.pm 2006-03-14 11:20:43.000000000 -0500
3 +++ e-smith-base-5.8.0/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/localnetworks.pm 2020-06-27 22:39:20.952000000 -0400
4 @@ -18,6 +18,7 @@
5 use Exporter;
6 use Carp;
7 use Net::IPv4Addr;
8 +use Net::Netmask;
9
10 our @ISA = qw(esmith::FormMagick Exporter);
11
12 @@ -287,14 +288,14 @@
13 sub subnet_mask
14 {
15 my ( $fm, $data ) = @_;
16 - if ( CGI::FormMagick::Validator::ip_number( $fm, $data ) eq "OK" )
17 + # we test for a valid mask or bit mask
18 + my $tip="192.168.50.1";
19 + my $block = new Net::Netmask("$tip/$data") or return "INVALID_SUBNET_MASK";
20 + if ($block->mask() eq "$data" || $block->bits() eq "$data")
21 {
22 return "OK";
23 }
24 - else
25 - {
26 - return "INVALID_SUBNET_MASK";
27 - }
28 + return "INVALID_SUBNET_MASK";
29 }
30
31 =head1 ADDING AND REMOVING NETWORKS
32 @@ -308,6 +309,10 @@
33 my ($fm) = @_;
34 my $networkAddress = $fm->{cgi}->param('networkAddress');
35 my $networkMask = $fm->{cgi}->param('networkMask');
36 + # we transform bit mask to regular mask
37 + my $block = new Net::Netmask("$networkAddress/$networkMask");
38 + $networkMask = $block->mask();
39 +
40 my $networkRouter = $fm->{cgi}->param('networkRouter');
41
42 my $network_db = esmith::NetworksDB->open()
43 diff -Nur e-smith-base-5.8.0.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/remoteaccess.pm e-smith-base-5.8.0/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/remoteaccess.pm
44 --- e-smith-base-5.8.0.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/remoteaccess.pm 2016-02-04 18:14:13.000000000 -0500
45 +++ e-smith-base-5.8.0/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/remoteaccess.pm 2020-06-27 22:39:20.948000000 -0400
46 @@ -32,6 +32,7 @@
47 use Exporter;
48 use Carp;
49 use Socket qw( inet_aton );
50 +use Net::Netmask;
51
52 our @ISA = qw(esmith::FormMagick Exporter);
53
54 @@ -450,8 +451,15 @@
55 sub subnet_mask_or_blank
56 {
57 my ($self, $mask) = @_;
58 -
59 - if ($self->ip_number_or_blank($mask) eq 'OK')
60 + if (!defined($mask) || $mask eq "")
61 + {
62 + return "OK";
63 + }
64 + chomp $mask ;
65 + # we test for a valid mask or bit mask
66 + my $tip="192.168.50.1";
67 + my $block = new Net::Netmask("$tip/$mask") or return "INVALID_SUBNET_MASK";
68 + if ($block->mask() eq "$mask" || $block->bits() eq "$mask")
69 {
70 return "OK";
71 }
72 @@ -479,6 +487,10 @@
73 my $net = $q->param('validFromNetwork');
74 my $mask = $q->param('validFromMask');
75
76 + # we transform bit mask to regular mask
77 + my $block = new Net::Netmask("$net/$mask");
78 + $mask = $block->mask();
79 +
80 # do nothing if no network was added
81 return 1 unless ($net && $mask);
82

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed