From 88964924ef148fb3f1ba31f6cef168562956937b Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 11 Mar 2006 20:35:36 +0000 Subject: [PATCH] Ticket #854 fixes * Compute the correct amount of ng interface for pptp and pppoe * Restart mpd processes in one function so that duplicates do not end up in mpd.conf file --- etc/inc/filter.inc | 18 ++++++++++++++++-- etc/inc/vpn.inc | 17 +++++++++-------- etc/rc.bootup | 7 ++----- usr/local/www/vpn_pppoe.php | 2 +- usr/local/www/vpn_pppoe_users.php | 2 +- usr/local/www/vpn_pppoe_users_edit.php | 2 +- usr/local/www/vpn_pptp.php | 2 +- usr/local/www/vpn_pptp_users.php | 2 +- 8 files changed, 32 insertions(+), 20 deletions(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 26e4328b3d..6310295376 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -235,8 +235,22 @@ function filter_generate_aliases() { $aliases .= "# System Aliases \n"; $aliases .= "lan = \"{ {$config['interfaces']['lan']['if']}{$lan_aliases} }\"\n"; $aliases .= "wan = \"{ " . get_real_wan_interface() . "{$wan_aliases} }\"\n"; - $aliases .= "pptp = \"{ ng1 ng2 ng3 ng4 ng5 ng6 ng7 ng8 ng9 ng10 ng11 ng12 ng13 ng14 }\"\n"; - $aliases .= "pppoe = \"{ ng1 ng2 ng3 ng4 ng5 ng6 ng7 ng8 ng9 ng10 ng11 ng12 ng13 ng14 }\"\n"; + + /* build pptp alias */ + $aliases .= "pptp = \"{ "; + for($x=0; $x<$g["n_pptp_units"]; $x++) { + $aliases .= "ng{$x} "; + } + $counter = $x; + $aliases .= "}\" \n"; + + /* build pppoe alias */ + $aliases .= "pppoe = \"{ "; + for($x=0; $x<$g["n_pppoe_units"]; $x++) { + $counter++; + $aliases .= "ng{$counter} "; + } + $aliases .= "}\" \n"; $ifdescrs = array(); for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc index b52561bf90..2df79c109e 100644 --- a/etc/inc/vpn.inc +++ b/etc/inc/vpn.inc @@ -33,6 +33,15 @@ /* include all configuration functions */ require_once("functions.inc"); +/* master setup for vpn (mpd) */ +function vpn_setup() { + /* start pptpd */ + vpn_pptpd_configure(); + + /* start pppoe server */ + vpn_pppoe_configure(); +} + function vpn_ipsec_failover_configure() { global $config, $g; @@ -836,14 +845,6 @@ function vpn_pppoe_configure() { return 0; echo "Configuring PPPoE VPN service... "; - } else { - /* kill mpd */ - killbypid("{$g['varrun_path']}/mpd-vpn.pid"); - - /* wait for process to die */ - sleep(2); - - vpn_pptpd_configure(); } /* make sure mpd-vpn directory exists */ diff --git a/etc/rc.bootup b/etc/rc.bootup index 94d93c513f..7f86de5f79 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -220,11 +220,8 @@ /* start the NTP client */ system_ntp_configure(); - /* start pptpd */ - vpn_pptpd_configure(); - - /* start pppoe server */ - vpn_pppoe_configure(); + /* setup pppoe and pptp */ + vpn_setup(); /* start the captive portal */ captiveportal_configure(); diff --git a/usr/local/www/vpn_pppoe.php b/usr/local/www/vpn_pppoe.php index d50db67648..1331b42987 100755 --- a/usr/local/www/vpn_pppoe.php +++ b/usr/local/www/vpn_pppoe.php @@ -119,7 +119,7 @@ if ($_POST) { $retval = 0; config_lock(); - $retval = vpn_pppoe_configure(); + $retval = vpn_setup(); config_unlock(); $savemsg = get_std_save_message($retval); diff --git a/usr/local/www/vpn_pppoe_users.php b/usr/local/www/vpn_pppoe_users.php index ddf43794fd..fb446e3560 100755 --- a/usr/local/www/vpn_pppoe_users.php +++ b/usr/local/www/vpn_pppoe_users.php @@ -44,7 +44,7 @@ if ($_POST) { $retval = 0; config_lock(); - $retval = vpn_pppoe_configure(); + $retval = vpn_setup(); config_unlock(); $savemsg = get_std_save_message($retval); diff --git a/usr/local/www/vpn_pppoe_users_edit.php b/usr/local/www/vpn_pppoe_users_edit.php index 9e142b4059..3542c182ea 100755 --- a/usr/local/www/vpn_pppoe_users_edit.php +++ b/usr/local/www/vpn_pppoe_users_edit.php @@ -103,7 +103,7 @@ if ($_POST) { write_config(); config_lock(); - $retval = vpn_pppoe_configure(); + $retval = vpn_setup(); config_unlock(); header("Location: vpn_pppoe_users.php"); diff --git a/usr/local/www/vpn_pptp.php b/usr/local/www/vpn_pptp.php index 33b5e7df5d..26449e747f 100755 --- a/usr/local/www/vpn_pptp.php +++ b/usr/local/www/vpn_pptp.php @@ -127,7 +127,7 @@ if ($_POST) { $retval = 0; config_lock(); - $retval = vpn_pptpd_configure(); + $retval = vpn_setup(); config_unlock(); $savemsg = get_std_save_message($retval); diff --git a/usr/local/www/vpn_pptp_users.php b/usr/local/www/vpn_pptp_users.php index 03dbe8f240..b342f0df21 100755 --- a/usr/local/www/vpn_pptp_users.php +++ b/usr/local/www/vpn_pptp_users.php @@ -43,7 +43,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; config_lock(); - $retval = vpn_pptpd_configure(); + $retval = vpn_setup(); config_unlock(); $savemsg = get_std_save_message($retval); if ($retval == 0) {