/[smeserver]/rpms/e-smith-base/sme8/e-smith-base-5.2.0_added_verification_of_pptp_clients_against_dhcp.patch
ViewVC logotype

Diff of /rpms/e-smith-base/sme8/e-smith-base-5.2.0_added_verification_of_pptp_clients_against_dhcp.patch

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

Revision 1.2 by stephdl, Wed Apr 23 20:04:56 2014 UTC Revision 1.3 by stephdl, Sat May 3 13:18:58 2014 UTC
# Line 1  Line 1 
1  diff -Nur e-smith-base-5.2.0-old/root/usr/lib/perl5/site_perl/esmith/console/configure.pm e-smith-base-5.2.0/root/usr/lib/perl5/site_perl/esmith/console/configure.pm  diff -Nur e-smith-base-5.2.0-old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/remoteaccess e-smith-base-5.2.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/remoteaccess
2  --- e-smith-base-5.2.0-old/root/usr/lib/perl5/site_perl/esmith/console/configure.pm     2014-04-05 17:51:15.298943308 +0200  --- e-smith-base-5.2.0-old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/remoteaccess 2014-04-05 17:51:15.278940872 +0200
3  +++ e-smith-base-5.2.0/root/usr/lib/perl5/site_perl/esmith/console/configure.pm 2014-04-23 20:50:33.256817438 +0200  +++ e-smith-base-5.2.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/remoteaccess     2014-04-06 10:27:07.542188253 +0200
4  @@ -7,6 +7,8 @@  @@ -48,6 +48,10 @@
5   use esmith::db;          <trans>Number of PPTP clients</trans>
6   use esmith::ethernet;       </entry>
7   use Net::IPv4Addr qw(:all);       <entry>
8    +       <base>NUMBER_OF_PPTP_CLIENTS_MUST_BE_LESSER_THAN_NUMBER_OF_IP_IN_DHCP_RANGE</base>
9    +       <trans>The number of pptp clients is greater than the number of reserved IP for DHCP. You should take a smaller number.</trans>
10    +    </entry>
11    +    <entry>
12             <base>LABEL_SSH_PORT</base>
13             <trans>TCP Port for secure shell access</trans>
14         </entry>
15    diff -Nur e-smith-base-5.2.0-old/root/etc/e-smith/web/functions/remoteaccess e-smith-base-5.2.0/root/etc/e-smith/web/functions/remoteaccess
16    --- e-smith-base-5.2.0-old/root/etc/e-smith/web/functions/remoteaccess  2014-04-05 17:51:15.278940872 +0200
17    +++ e-smith-base-5.2.0/root/etc/e-smith/web/functions/remoteaccess      2014-04-06 09:20:55.799381623 +0200
18    @@ -113,7 +113,7 @@
19    
20             <subroutine src="show_ipsecrw_section()"/>
21    
22    -       <field type="text" id="pptpSessions" size="3" validation="zero_or_positive()"
23    +       <field type="text" id="pptpSessions" size="3" validation="zero_or_positive(), pptp_and_dhcp_range ()"
24                value="get_pptp_sessions()">
25                <label>LABEL_PPTP</label>
26                <description>DESC_PPTP</description>
27    diff -Nur e-smith-base-5.2.0-old/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/remoteaccess.pm e-smith-base-5.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/remoteaccess.pm
28    --- e-smith-base-5.2.0-old/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/remoteaccess.pm 2014-04-05 17:51:15.298943308 +0200
29    +++ e-smith-base-5.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/remoteaccess.pm     2014-04-06 10:25:12.267521705 +0200
30    @@ -31,6 +31,7 @@
31     use File::Basename;
32     use Exporter;
33     use Carp;
34  +use Socket qw( inet_aton );  +use Socket qw( inet_aton );
35    
36     our @ISA = qw(esmith::FormMagick Exporter);
37    
38    @@ -40,7 +41,7 @@
39                    show_valid_from_list add_new_valid_from remove_valid_from
40                    validate_network_and_mask ip_number_or_blank subnet_mask_or_blank
41                    show_telnet_section get_serial_console show_ftp_section
42    -               get_ipsecrw_sessions show_ipsecrw_section
43    +               get_ipsecrw_sessions show_ipsecrw_section pptp_and_dhcp_range
44     );
45    
46    
47    @@ -370,6 +371,36 @@
48    
49     =pod
50    
51    +=head2 pptp_and_dhcp_range
52    +
53    +Validate the input of pptp session if it is not superior than the maximum number of ip between dhcpd_start and dhcpd_end
54    +
55    +=cut
56    +
57    +sub pptp_and_dhcp_range
58    +{
59    +  my $self = shift;
60    +  my $val = shift || 0;
61    +  my $dhcp_status     = $db->get_prop('dhcpd','status') || 'disabled';
62    +  my $dhcp_end        = $db->get_prop('dhcpd','end') || '';
63    +  my $dhcp_start      = $db->get_prop('dhcpd','start') || '';
64    +
65    +    if ( $dhcp_status eq 'enabled' )
66    +        {
67    +        my $ip_start     = unpack 'N', inet_aton($dhcp_start);
68    +        my $ip_end       = unpack 'N', inet_aton($dhcp_end);
69    +        my $ip_count     = $ip_end - $ip_start;
70    +        return 'OK' if( $val < $ip_count );
71    +        return $self->localise('NUMBER_OF_PPTP_CLIENTS_MUST_BE_LESSER_THAN_NUMBER_OF_IP_IN_DHCP_RANGE');
72    +        }
73    +    else
74    +        {
75    +        return 'OK';
76    +        }
77    +}
78    +
79    +=pod
80  +  +
81     =head2 _get_valid_from
82    
83   our @adapters;   Reads the ValidFrom property of config entry httpd-admin and returns a list
  our $console;  
 @@ -1852,7 +1854,7 @@  
          (  
           title => gettext("Select end of DHCP host number range"),  
           text  =>  
 -         gettext("Please enter the last host address in this range. If you are using the standard server defaults and have no particular preference, you should keep the default value."),  
 +         gettext("Please enter the last host address in this range. If you are using the standard server defaults and have no particular preference, you should keep the default value. Think to add enough ip for pptp sessions."),  
           value   => $serverEnd  
          );  
   
 @@ -1862,6 +1864,12 @@  
      {  
          if ( isValidIP($choice) )  
          {  
 +        # retrieve values to verifiy if ip_count > pptp_sessions  
 +        my $ip_start      = unpack 'N', inet_aton($serverStart);  
 +        my $ip_end        = unpack 'N', inet_aton($choice);  
 +        my $ip_count      = $ip_end - $ip_start;  
 +        my $pptp_sessions = $db->get_prop('pptpd','sessions');  
 +  
             my $dhcp_net = ipv4_network($choice, $priv_mask);  
             if ($dhcp_net eq $priv_net)  
             {  
 @@ -1872,8 +1880,8 @@  
                 # beginning.  
                 if (cmpIP($serverStart, $choice) < 0)  
                 {  
 -                   if ((cmpIP($priv_ip, $serverStart) < 0) ||  
 -                       (cmpIP($choice, $priv_ip) < 0))  
 +                   if (((cmpIP($priv_ip, $serverStart) < 0) ||  
 +                       (cmpIP($choice, $priv_ip) < 0)) && ($ip_count > $pptp_sessions))  
                     {  
                         # need to check for valid range as well.  
                         unless ($choice eq $serverEnd)  
 @@ -1882,6 +1890,13 @@  
                         }  
                         goto DNS_FORWARDER;  
                     }  
 +            # We want to verify that the number of pptp_IP reserved is not superior  
 +            # than the number of dhcp_IP set in the range  
 +            elsif ($ip_count <= $pptp_sessions)  
 +            {  
 +            $errmsg = gettext("There is not enough IP in the range to include all your pptp sessions");  
 +            $choice = $pptp_sessions . ' allowed pptp clients';  
 +            }  
                     else  
                     {  
                         $errmsg = gettext("The IP range cannot include our private network address.");  


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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