mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 00:07:27 +00:00
etc: last batch for #1733
This commit is contained in:
parent
b0aa1be38d
commit
566fe52edc
@ -302,10 +302,11 @@ EOD;
|
||||
if ($lanif) {
|
||||
$new = false;
|
||||
|
||||
if (!is_array($config['interfaces']['lan'])) {
|
||||
$config['interfaces']['lan'] = array();
|
||||
if (!isset($config['interfaces']['lan'])) {
|
||||
$new = true;
|
||||
}
|
||||
|
||||
config_read_array('interfaces', 'lan');
|
||||
$config['interfaces']['lan']['if'] = $lanif;
|
||||
$config['interfaces']['lan']['enable'] = true;
|
||||
|
||||
@ -319,31 +320,19 @@ EOD;
|
||||
$config['interfaces']['lan']['subnetv6'] = '64';
|
||||
}
|
||||
|
||||
if (!isset($config['dhcpd']['lan'])) {
|
||||
$config['dhcpd']['lan'] = array();
|
||||
$config['dhcpd']['lan']['range'] = array();
|
||||
}
|
||||
config_read_array('dhcpd', 'lan', 'range');
|
||||
$config['dhcpd']['lan']['enable'] = true;
|
||||
$config['dhcpd']['lan']['range']['from'] = '192.168.1.100';
|
||||
$config['dhcpd']['lan']['range']['to'] = '192.168.1.199';
|
||||
if (!is_array($config['nat'])) {
|
||||
$config['nat'] = array();
|
||||
}
|
||||
if (!is_array($config['nat']['outbound'])) {
|
||||
$config['nat']['outbound'] = array();
|
||||
}
|
||||
|
||||
config_read_array('nat', 'outbound');
|
||||
$config['nat']['outbound']['mode'] = 'automatic';
|
||||
}
|
||||
|
||||
if (match_wireless_interface($lanif)) {
|
||||
if (is_array($config['interfaces']['lan']) &&
|
||||
(!is_array($config['interfaces']['lan']['wireless']))) {
|
||||
$config['interfaces']['lan']['wireless'] = array();
|
||||
}
|
||||
} else {
|
||||
if (isset($config['interfaces']['lan'])) {
|
||||
unset($config['interfaces']['lan']['wireless']);
|
||||
}
|
||||
config_read_array('interfaces', 'lan', 'wireless');
|
||||
} elseif (isset($config['interfaces']['lan']['wireless'])) {
|
||||
unset($config['interfaces']['lan']['wireless']);
|
||||
}
|
||||
} else {
|
||||
if (isset($config['interfaces']['lan']['if'])) {
|
||||
@ -364,9 +353,7 @@ EOD;
|
||||
}
|
||||
|
||||
if ($wanif) {
|
||||
if (!is_array($config['interfaces']['wan'])) {
|
||||
$config['interfaces']['wan'] = array();
|
||||
}
|
||||
config_read_array('interfaces', 'wan');
|
||||
$config['interfaces']['wan']['if'] = $wanif;
|
||||
$config['interfaces']['wan']['enable'] = true;
|
||||
$config['interfaces']['wan']['ipaddr'] = 'dhcp';
|
||||
@ -377,14 +364,9 @@ EOD;
|
||||
}
|
||||
|
||||
if (match_wireless_interface($wanif)) {
|
||||
if (is_array($config['interfaces']['wan']) &&
|
||||
(!is_array($config['interfaces']['wan']['wireless']))) {
|
||||
$config['interfaces']['wan']['wireless'] = array();
|
||||
}
|
||||
} else {
|
||||
if (isset($config['interfaces']['wan'])) {
|
||||
unset($config['interfaces']['wan']['wireless']);
|
||||
}
|
||||
config_read_array('interfaces', 'wan', 'wireless');
|
||||
} elseif (isset($config['interfaces']['wan']['wireless'])) {
|
||||
unset($config['interfaces']['wan']['wireless']);
|
||||
}
|
||||
} else {
|
||||
if (isset($config['interfaces']['wan'])) {
|
||||
@ -393,15 +375,12 @@ EOD;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($optif); $i++) {
|
||||
if (!is_array($config['interfaces']['opt' . ($i+1)]))
|
||||
$config['interfaces']['opt' . ($i+1)] = array();
|
||||
|
||||
config_read_array('interfaces', 'opt' . ($i+1));
|
||||
$config['interfaces']['opt' . ($i+1)]['if'] = $optif[$i];
|
||||
|
||||
if (match_wireless_interface($optif[$i])) {
|
||||
if (!is_array($config['interfaces']['opt' . ($i+1)]['wireless']))
|
||||
$config['interfaces']['opt' . ($i+1)]['wireless'] = array();
|
||||
} else {
|
||||
config_read_array('interfaces', 'opt' . ($i+1), 'wireless');
|
||||
} elseif (isset($config['interfaces']['opt' . ($i+1)]['wireless'])) {
|
||||
unset($config['interfaces']['opt' . ($i+1)]['wireless']);
|
||||
}
|
||||
|
||||
@ -474,7 +453,8 @@ EOD;
|
||||
}
|
||||
}
|
||||
|
||||
$config['vlans']['vlan'] = array();
|
||||
config_read_array('vlans', 'vlan');
|
||||
|
||||
echo "\n";
|
||||
|
||||
$vlanif = 0;
|
||||
|
||||
@ -4444,9 +4444,7 @@ function is_interface_wireless($interface)
|
||||
$friendly = convert_real_interface_to_friendly_interface_name($interface);
|
||||
if (!isset($config['interfaces'][$friendly]['wireless'])) {
|
||||
if (match_wireless_interface($interface)) {
|
||||
if (isset($config['interfaces'][$friendly])) {
|
||||
$config['interfaces'][$friendly]['wireless'] = array();
|
||||
}
|
||||
config_read_array('interfaces', $friendly, 'wireless');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -148,9 +148,6 @@ function plugins_interfaces()
|
||||
if (isset($stale_interfaces[$intf_ref])) {
|
||||
unset($stale_interfaces[$intf_ref]);
|
||||
}
|
||||
if (empty($config['interfaces'][$intf_ref])) {
|
||||
$config['interfaces'][$intf_ref] = array();
|
||||
}
|
||||
if (isset($config['interfaces'][$intf_ref][0])) {
|
||||
// undo stupid listags() turning our item into a new array, see src/etc/inc/xmlparse.inc
|
||||
$intf_config = &config_read_array('interfaces', $intf_ref, 0);
|
||||
|
||||
@ -174,9 +174,7 @@ function ntpd_configure_do($start_ntpd = true, $verbose = false)
|
||||
|
||||
@mkdir($statsdir, 0755);
|
||||
|
||||
if (!isset($config['ntpd']) || !is_array($config['ntpd'])) {
|
||||
$config['ntpd'] = array();
|
||||
}
|
||||
config_read_array('ntpd');
|
||||
|
||||
$ntpcfg = "#\n";
|
||||
$ntpcfg .= "# Autogenerated configuration file\n";
|
||||
|
||||
@ -514,11 +514,9 @@ function step12_submitphpaction()
|
||||
$auth['radius_secret'] = $pconfig['step2']['password'];
|
||||
$auth['radius_srvcs'] = "auth";
|
||||
}
|
||||
if (!is_array($config['system']['authserver'])) {
|
||||
$config['system']['authserver'] = array();
|
||||
}
|
||||
|
||||
$config['system']['authserver'][] = $auth;
|
||||
$a_auth = &config_read_array('system', 'authserver');
|
||||
$a_auth[] = $auth;
|
||||
} elseif (!isset($pconfig['step2']['uselist']) && empty($pconfig['step2']['authserv'])) {
|
||||
$message = "Please choose an authentication server.";
|
||||
header(url_safe('Location: /wizard.php?xml=openvpn&stepid=1&message=%s', array($message)));
|
||||
@ -542,11 +540,9 @@ function step12_submitphpaction()
|
||||
'commonName' => $pconfig['step6']['certca']);
|
||||
|
||||
ca_create($ca, $pconfig['step6']['keylength'], $pconfig['step6']['lifetime'], $dn, "sha256");
|
||||
if (!is_array($config['ca'])) {
|
||||
$config['ca'] = array();
|
||||
}
|
||||
|
||||
$config['ca'][] = $ca;
|
||||
$a_ca = &config_read_array('ca');
|
||||
$a_ca[] = $ca;
|
||||
} elseif (!isset($pconfig['step6']['uselist']) && empty($pconfig['step6']['authcertca'])) {
|
||||
$message = "Please choose a Certificate Authority.";
|
||||
header(url_safe('Location: /wizard.php?xml=openvpn&stepid=5&message=%s', array($message)));
|
||||
@ -572,11 +568,8 @@ function step12_submitphpaction()
|
||||
|
||||
cert_create($cert, $ca['refid'], $pconfig['step9']['keylength'], $pconfig['step9']['lifetime'], $dn, 'sha256', 'server_cert');
|
||||
|
||||
if (!is_array($config['cert'])) {
|
||||
$config['cert'] = array();
|
||||
}
|
||||
|
||||
$config['cert'][] = $cert;
|
||||
$a_cert = &config_read_array('cert');
|
||||
$a_cert[] = $cert;
|
||||
} elseif (!isset($pconfig['step9']['uselist']) && empty($pconfig['step9']['authcertname'])) {
|
||||
$message = "Please choose a Certificate.";
|
||||
header(url_safe('Location: /wizard.php?xml=openvpn&stepid=7&message=%s', array($message)));
|
||||
@ -725,11 +718,8 @@ function step12_submitphpaction()
|
||||
$config['filter']['rule'][] = $rule;
|
||||
}
|
||||
|
||||
if (!isset($config['openvpn']['openvpn-server'])) {
|
||||
$config['openvpn']['openvpn-server'] = array();
|
||||
}
|
||||
|
||||
$config['openvpn']['openvpn-server'][] = $server;
|
||||
$a_server = &config_read_array('openvpn', 'openvpn-server');
|
||||
$a_server[] = $server;
|
||||
|
||||
write_config();
|
||||
|
||||
|
||||
@ -61,13 +61,7 @@ function webgui_configure_do($verbose = false)
|
||||
if ($config['system']['webgui']['protocol'] == "https") {
|
||||
$cert =& lookup_cert($config['system']['webgui']['ssl-certref']);
|
||||
if(!is_array($cert) && !$cert['crt'] && !$cert['prv']) {
|
||||
if (!is_array($config['ca'])) {
|
||||
$config['ca'] = array();
|
||||
}
|
||||
$a_ca = &config_read_array('ca');
|
||||
if (!is_array($config['cert'])) {
|
||||
$config['cert'] = array();
|
||||
}
|
||||
$a_cert = &config_read_array('cert');
|
||||
log_error("Creating SSL certificate for this host");
|
||||
$cert = array();
|
||||
|
||||
@ -104,9 +104,7 @@ function services_radvd_configure($blacklist = array())
|
||||
|
||||
killbypid('/var/run/radvd.pid', 'TERM', true);
|
||||
|
||||
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
|
||||
$config['dhcpdv6'] = array();
|
||||
}
|
||||
config_read_array('dhcpdv6');
|
||||
|
||||
$radvdconf = "# Automatically Generated, do not edit\n";
|
||||
|
||||
@ -1016,11 +1014,8 @@ function services_dhcpdv6_configure($blacklist = array(), $verbose = false)
|
||||
return;
|
||||
}
|
||||
|
||||
$syscfg = $config['system'];
|
||||
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
|
||||
$config['dhcpdv6'] = array();
|
||||
}
|
||||
$dhcpdv6cfg = $config['dhcpdv6'];
|
||||
$syscfg = config_read_array('system');
|
||||
$dhcpdv6cfg = config_read_array('dhcpdv6');
|
||||
$Iflist = get_configured_interface_list();
|
||||
|
||||
if ($verbose) {
|
||||
@ -1818,11 +1813,7 @@ function is_radvd_enabled()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
|
||||
$config['dhcpdv6'] = array();
|
||||
}
|
||||
|
||||
$dhcpdv6cfg = $config['dhcpdv6'];
|
||||
$dhcpdv6cfg = config_read_array('dhcpdv6');
|
||||
$Iflist = get_configured_interface_list();
|
||||
|
||||
/* handle manually configured DHCP6 server settings first */
|
||||
|
||||
@ -81,10 +81,8 @@ $admin_user = &getUserEntryByUID(0);
|
||||
if (!$admin_user) {
|
||||
$admin_user = array();
|
||||
$admin_user['uid'] = 0;
|
||||
if (!isset($config['system']['user'])) {
|
||||
$config['system']['user'] = array();
|
||||
}
|
||||
$config['system']['user'][] = $admin_user;
|
||||
$a_users = &config_read_array('system', 'user');
|
||||
$a_users[] = $admin_user;
|
||||
echo "\nRestored missing root user.\n";
|
||||
}
|
||||
|
||||
|
||||
@ -210,10 +210,6 @@ function add_gateway_to_config($interface, $gatewayip, $inet_type, $is_in_subnet
|
||||
|
||||
$label_IPvX = $inet_type == 'inet6' ? 'IPv6' : 'IPv4';
|
||||
|
||||
if (!isset($config['gateways']['gateway_item'])) {
|
||||
$config['gateways']['gateway_item'] = array();
|
||||
}
|
||||
|
||||
$a_gateways = &config_read_array('gateways', 'gateway_item');
|
||||
$is_default = true;
|
||||
$new_name = '';
|
||||
|
||||
@ -434,12 +434,8 @@
|
||||
}
|
||||
$type = $_POST['selectedtype'];
|
||||
|
||||
if (!is_array($config['ppps'])) {
|
||||
$config['ppps'] = array();
|
||||
}
|
||||
if (!is_array($config['ppps']['ppp'])) {
|
||||
$config['ppps']['ppp'] = array();
|
||||
}
|
||||
config_read_array('ppps', 'ppp');
|
||||
|
||||
foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
|
||||
if ($ppp['ptpid'] == "0") {
|
||||
if ((substr($config['interfaces']['wan']['if'],0,5) == "pppoe") || (substr($config['interfaces']['wan']['if'],0,4) == "pptp")) {
|
||||
@ -588,12 +584,7 @@
|
||||
$config['system']['hostname'] = $config['wizardtemp']['system']['hostname'];
|
||||
$config['system']['domain'] = $config['wizardtemp']['system']['domain'];
|
||||
if (!empty($config['wizardtemp']['wangateway'])) {
|
||||
if (!is_array($config['gateways'])) {
|
||||
$config['gateways'] = array();
|
||||
}
|
||||
if (!isset($config['gateways']['gateway_item'])) {
|
||||
$config['gateways']['gateway_item'] = array();
|
||||
}
|
||||
config_read_array('gateways', 'gateway_item');
|
||||
$found = false;
|
||||
$defaultgw_found = false;
|
||||
foreach ($config['gateways']['gateway_item'] as & $gw) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user