From 3acdb13917eec19eb530e58312ec83a0369a67e5 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 15 Dec 2017 10:00:31 +0000 Subject: [PATCH] openvpn: restore sanity in this wizard system; closes #1644 --- src/etc/inc/certs.inc | 14 +- src/etc/inc/plugins.inc.d/openvpn/wizard.inc | 37 ++--- src/wizard/openvpn.xml | 151 ++++++++++--------- src/wizard/system.xml | 5 + 4 files changed, 107 insertions(+), 100 deletions(-) diff --git a/src/etc/inc/certs.inc b/src/etc/inc/certs.inc index f23da4a90..1748eb588 100644 --- a/src/etc/inc/certs.inc +++ b/src/etc/inc/certs.inc @@ -27,10 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -global $openssl_digest_algs; $openssl_digest_algs = array("sha1", "sha224", "sha256", "sha384", "sha512"); -global $openssl_crl_status; $openssl_crl_status = array( OCSP_REVOKED_STATUS_NOSTATUS => "No Status (default)", OCSP_REVOKED_STATUS_UNSPECIFIED => "Unspecified", @@ -45,7 +43,6 @@ $openssl_crl_status = array( function &lookup_ca($refid) { global $config; - $false = false; if (is_array($config['ca'])) { foreach ($config['ca'] as & $ca) { @@ -55,13 +52,12 @@ function &lookup_ca($refid) } } - return $false; + return false; } function &lookup_ca_by_subject($subject) { global $config; - $false = false; if (is_array($config['ca'])) { foreach ($config['ca'] as & $ca) { @@ -72,13 +68,12 @@ function &lookup_ca_by_subject($subject) } } - return $false; + return false; } function &lookup_cert($refid) { global $config; - $false = false; if (is_array($config['cert'])) { foreach ($config['cert'] as & $cert) { @@ -88,13 +83,12 @@ function &lookup_cert($refid) } } - return $false; + return false; } function &lookup_crl($refid) { global $config; - $false = false; if (is_array($config['crl'])) { foreach ($config['crl'] as & $crl) { @@ -104,7 +98,7 @@ function &lookup_crl($refid) } } - return $false; + return false; } function ca_chain_array(&$cert) diff --git a/src/etc/inc/plugins.inc.d/openvpn/wizard.inc b/src/etc/inc/plugins.inc.d/openvpn/wizard.inc index 2293645e0..1980848ca 100644 --- a/src/etc/inc/plugins.inc.d/openvpn/wizard.inc +++ b/src/etc/inc/plugins.inc.d/openvpn/wizard.inc @@ -44,15 +44,16 @@ function has_special_chars($text) function step1_submitphpaction() { global $stepid, $config; + if ($_POST['authtype'] == "local") { $stepid = 4; - $config['ovpnserver']['step1']['type'] = "local"; + $config['wizardtemp']['step1']['type'] = "local"; } elseif ($_POST['authtype'] == "ldap") { $stepid = 0; } elseif ($_POST['authtype'] == "radius") { $stepid = 2; - $config['ovpnserver']['step1']['type'] = "radius"; - unset($config['ovpnserver']['step1']['uselist']); + $config['wizardtemp']['step1']['type'] = "radius"; + unset($config['wizardtemp']['step1']['uselist']); } } @@ -97,9 +98,9 @@ function step3_submitphpaction() /* Default LDAP port is 389 for TCP and 636 for SSL */ if (empty($_POST['port'])) { if ($_POST['transport'] == "tcp") { - $config['ovpnserver']['step2']['port'] = 389; + $config['wizardtemp']['step2']['port'] = 389; } elseif ($_POST['transport'] == "ssl") { - $config['ovpnserver']['step2']['port'] = 636; + $config['wizardtemp']['step2']['port'] = 636; } } elseif (!is_port($_POST['port'])) { $input_errors[] = gettext('Please enter a valid port number.'); @@ -119,7 +120,7 @@ function step3_submitphpaction() $input_errors[] = gettext('Please enter a valid IP address or hostname for the authentication server.'); $stepid--; } else { - $config['ovpnserver']['step2']['uselist'] = "on"; + $config['wizardtemp']['step2']['uselist'] = "on"; $_POST['uselist'] = "on"; $stepid += 2; } @@ -165,7 +166,7 @@ function step5_submitphpaction() /* Default RADIUS Auth port = 1812 */ if (empty($_POST['port'])) { - $config['ovpnserver']['step2']['port'] = 1812; + $config['wizardtemp']['step2']['port'] = 1812; } elseif (!is_port($_POST['port'])) { $input_errors[] = gettext('Please enter a valid port number.'); $stepid--; @@ -183,7 +184,7 @@ function step5_submitphpaction() $input_errors[] = gettext('Please enter a valid IP address or hostname for the authentication server.'); $stepid--; } else { - $config['ovpnserver']['step2']['uselist'] = "on"; + $config['wizardtemp']['step2']['uselist'] = "on"; $_POST['uselist'] = "on"; } } @@ -203,10 +204,10 @@ function step6_submitphpaction() if (isset($_POST['next'])) { $_POST['uselist'] = ""; - unset($config['ovpnserver']['step6']['uselist']); + unset($config['wizardtemp']['step6']['uselist']); $stepid++; } else { - $config['ovpnserver']['step6']['uselist'] = "on"; + $config['wizardtemp']['step6']['uselist'] = "on"; $_POST['uselist'] = "on"; } } @@ -242,7 +243,7 @@ function step7_submitphpaction() $input_errors[] = gettext('Please enter only a two-letter ISO country code'); $stepid--; } else { - $config['ovpnserver']['step6']['uselist'] = "on"; + $config['wizardtemp']['step6']['uselist'] = "on"; $_POST['uselist'] = "on"; } } @@ -263,10 +264,10 @@ function step8_submitphpaction() if (isset($_POST['next'])) { $_POST['uselist'] = ""; - unset($config['ovpnserver']['step9']['uselist']); + unset($config['wizardtemp']['step9']['uselist']); $stepid++; } else { - $config['ovpnserver']['step6']['uselist'] = "on"; + $config['wizardtemp']['step6']['uselist'] = "on"; $_POST['uselist'] = "on"; } } @@ -275,7 +276,7 @@ function step9_stepbeforeformdisplay() { global $config, $pkg, $stepid; - $pconfig = $config['ovpnserver']; + $pconfig = $config['wizardtemp']; if (isset($pconfig['step6']['uselist'])) { $country = $pconfig['step6']['country']; @@ -344,8 +345,9 @@ function step9_submitphpaction() $stepid--; } elseif (strlen($_POST['country']) != 2) { $input_errors[] = gettext('Please enter only a two-letter ISO country code'); + $stepid--; } else { - $config['ovpnserver']['step9']['uselist'] = "on"; + $config['wizardtemp']['step9']['uselist'] = "on"; $_POST['uselist'] = "on"; } } @@ -483,9 +485,9 @@ function step12_submitphpaction() { global $config; - $pconfig = $config['ovpnserver']; + $pconfig = $config['wizardtemp']; - if (!is_array($config['ovpnserver'])) { + if (!is_array($config['wizardtemp'])) { $message = "No configuration found please retry again."; header(url_safe('Location: /wizard.php?xml=openvpn&stepid=1&message=%s'. array($message))); exit; @@ -739,6 +741,7 @@ function step12_submitphpaction() $a_server = &config_read_array('openvpn', 'openvpn-server'); $a_server[] = $server; + unset($config['wizardtemp']); write_config(); openvpn_configure_single($server['vpnid']); diff --git a/src/wizard/openvpn.xml b/src/wizard/openvpn.xml index 912bf64c9..e7deac7ab 100644 --- a/src/wizard/openvpn.xml +++ b/src/wizard/openvpn.xml @@ -43,7 +43,7 @@ Type of Server authtype If you are unsure, leave this set to "Local User Access." - ovpnserver->step1->type + wizardtemp->step1->type