--- rpms/e-smith-base/sme8/e-smith-base-5.2.0_added_verification_of_pptp_clients_against_dhcp.patch 2014/04/23 20:04:56 1.2 +++ rpms/e-smith-base/sme8/e-smith-base-5.2.0_added_verification_of_pptp_clients_against_dhcp.patch 2014/05/03 13:18:58 1.3 @@ -1,59 +1,83 @@ -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 ---- 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/root/usr/lib/perl5/site_perl/esmith/console/configure.pm 2014-04-23 20:50:33.256817438 +0200 -@@ -7,6 +7,8 @@ - use esmith::db; - use esmith::ethernet; - use Net::IPv4Addr qw(:all); +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 +--- 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 ++++ 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 +@@ -48,6 +48,10 @@ + Number of PPTP clients + + ++ NUMBER_OF_PPTP_CLIENTS_MUST_BE_LESSER_THAN_NUMBER_OF_IP_IN_DHCP_RANGE ++ The number of pptp clients is greater than the number of reserved IP for DHCP. You should take a smaller number. ++ ++ + LABEL_SSH_PORT + TCP Port for secure shell access + +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 +--- e-smith-base-5.2.0-old/root/etc/e-smith/web/functions/remoteaccess 2014-04-05 17:51:15.278940872 +0200 ++++ e-smith-base-5.2.0/root/etc/e-smith/web/functions/remoteaccess 2014-04-06 09:20:55.799381623 +0200 +@@ -113,7 +113,7 @@ + + + +- + + DESC_PPTP +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 +--- 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 ++++ 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 +@@ -31,6 +31,7 @@ + use File::Basename; + use Exporter; + use Carp; +use Socket qw( inet_aton ); + + our @ISA = qw(esmith::FormMagick Exporter); + +@@ -40,7 +41,7 @@ + show_valid_from_list add_new_valid_from remove_valid_from + validate_network_and_mask ip_number_or_blank subnet_mask_or_blank + show_telnet_section get_serial_console show_ftp_section +- get_ipsecrw_sessions show_ipsecrw_section ++ get_ipsecrw_sessions show_ipsecrw_section pptp_and_dhcp_range + ); + + +@@ -370,6 +371,36 @@ + + =pod + ++=head2 pptp_and_dhcp_range ++ ++Validate the input of pptp session if it is not superior than the maximum number of ip between dhcpd_start and dhcpd_end ++ ++=cut ++ ++sub pptp_and_dhcp_range ++{ ++ my $self = shift; ++ my $val = shift || 0; ++ my $dhcp_status = $db->get_prop('dhcpd','status') || 'disabled'; ++ my $dhcp_end = $db->get_prop('dhcpd','end') || ''; ++ my $dhcp_start = $db->get_prop('dhcpd','start') || ''; ++ ++ if ( $dhcp_status eq 'enabled' ) ++ { ++ my $ip_start = unpack 'N', inet_aton($dhcp_start); ++ my $ip_end = unpack 'N', inet_aton($dhcp_end); ++ my $ip_count = $ip_end - $ip_start; ++ return 'OK' if( $val < $ip_count ); ++ return $self->localise('NUMBER_OF_PPTP_CLIENTS_MUST_BE_LESSER_THAN_NUMBER_OF_IP_IN_DHCP_RANGE'); ++ } ++ else ++ { ++ return 'OK'; ++ } ++} ++ ++=pod + + =head2 _get_valid_from - our @adapters; - 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."); + Reads the ValidFrom property of config entry httpd-admin and returns a list