Commit 7773bb31 authored by Franco Fichtner's avatar Franco Fichtner

src: varetc_path gone; now we're getting somewhere...

parent fffc9000
...@@ -212,7 +212,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut ...@@ -212,7 +212,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut
else else
$message = 0; $message = 0;
include("{$g['varetc_path']}/captiveportal-{$cpzone}-logout.html"); include("/var/etc/captiveportal-{$cpzone}-logout.html");
} else { } else {
// TODO: remove? should be handled by login page // TODO: remove? should be handled by login page
...@@ -422,7 +422,7 @@ function captiveportal_configure_zone($cpcfg) { ...@@ -422,7 +422,7 @@ function captiveportal_configure_zone($cpcfg) {
$htmltext = get_default_captive_portal_html(); $htmltext = get_default_captive_portal_html();
} }
$fd = @fopen("{$g['varetc_path']}/captiveportal_{$cpzone}.html", "w"); $fd = @fopen("/var/etc/captiveportal_{$cpzone}.html", "w");
if ($fd) { if ($fd) {
// Special case handling. Convert so that we can pass this page // Special case handling. Convert so that we can pass this page
// through the PHP interpreter later without clobbering the vars. // through the PHP interpreter later without clobbering the vars.
...@@ -450,7 +450,7 @@ function captiveportal_configure_zone($cpcfg) { ...@@ -450,7 +450,7 @@ function captiveportal_configure_zone($cpcfg) {
$errtext = get_default_captive_portal_html(); $errtext = get_default_captive_portal_html();
} }
$fd = @fopen("{$g['varetc_path']}/captiveportal-{$cpzone}-error.html", "w"); $fd = @fopen("/var/etc/captiveportal-{$cpzone}-error.html", "w");
if ($fd) { if ($fd) {
// Special case handling. Convert so that we can pass this page // Special case handling. Convert so that we can pass this page
// through the PHP interpreter later without clobbering the vars. // through the PHP interpreter later without clobbering the vars.
...@@ -510,7 +510,7 @@ document.location.href="<?=\$my_redirurl;?>"; ...@@ -510,7 +510,7 @@ document.location.href="<?=\$my_redirurl;?>";
EOD; EOD;
} }
$fd = @fopen("{$g['varetc_path']}/captiveportal-{$cpzone}-logout.html", "w"); $fd = @fopen("/var/etc/captiveportal-{$cpzone}-logout.html", "w");
if ($fd) { if ($fd) {
fwrite($fd, $logouttext); fwrite($fd, $logouttext);
fclose($fd); fclose($fd);
...@@ -553,9 +553,9 @@ EOD; ...@@ -553,9 +553,9 @@ EOD;
killbypid("/var/run/lighty-{$cpzone}-CaptivePortal.pid"); killbypid("/var/run/lighty-{$cpzone}-CaptivePortal.pid");
killbypid("/var/run/lighty-{$cpzone}-CaptivePortal-SSL.pid"); killbypid("/var/run/lighty-{$cpzone}-CaptivePortal-SSL.pid");
killbypid("/var/run/cp_prunedb_{$cpzone}.pid"); killbypid("/var/run/cp_prunedb_{$cpzone}.pid");
@unlink("{$g['varetc_path']}/captiveportal_{$cpzone}.html"); @unlink("/var/etc/captiveportal_{$cpzone}.html");
@unlink("{$g['varetc_path']}/captiveportal-{$cpzone}-error.html"); @unlink("/var/etc/captiveportal-{$cpzone}-error.html");
@unlink("{$g['varetc_path']}/captiveportal-{$cpzone}-logout.html"); @unlink("/var/etc/captiveportal-{$cpzone}-logout.html");
captiveportal_radius_stop_all(); captiveportal_radius_stop_all();
...@@ -637,7 +637,7 @@ function captiveportal_init_webgui_zone($cpcfg) ...@@ -637,7 +637,7 @@ function captiveportal_init_webgui_zone($cpcfg)
} }
system_generate_lighty_config( system_generate_lighty_config(
"{$g['varetc_path']}/lighty-{$cpzone}-CaptivePortal-SSL.conf", "/var/etc/lighty-{$cpzone}-CaptivePortal-SSL.conf",
$crt, $crt,
$key, $key,
$ca, $ca,
...@@ -658,7 +658,7 @@ function captiveportal_init_webgui_zone($cpcfg) ...@@ -658,7 +658,7 @@ function captiveportal_init_webgui_zone($cpcfg)
} }
system_generate_lighty_config( system_generate_lighty_config(
"{$g['varetc_path']}/lighty-{$cpzone}-CaptivePortal.conf", "/var/etc/lighty-{$cpzone}-CaptivePortal.conf",
"", "",
"", "",
"", "",
...@@ -672,12 +672,12 @@ function captiveportal_init_webgui_zone($cpcfg) ...@@ -672,12 +672,12 @@ function captiveportal_init_webgui_zone($cpcfg)
@unlink("{$g['varrun']}/lighty-{$cpzone}-CaptivePortal.pid"); @unlink("{$g['varrun']}/lighty-{$cpzone}-CaptivePortal.pid");
/* attempt to start lighttpd */ /* attempt to start lighttpd */
$res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-{$cpzone}-CaptivePortal.conf"); $res = mwexec("/usr/local/sbin/lighttpd -f /var/etc/lighty-{$cpzone}-CaptivePortal.conf");
/* fire up https instance */ /* fire up https instance */
if (isset($cpcfg['httpslogin'])) { if (isset($cpcfg['httpslogin'])) {
@unlink("{$g['varrun']}/lighty-{$cpzone}-CaptivePortal-SSL.pid"); @unlink("{$g['varrun']}/lighty-{$cpzone}-CaptivePortal-SSL.pid");
$res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-{$cpzone}-CaptivePortal-SSL.conf"); $res = mwexec("/usr/local/sbin/lighttpd -f /var/etc/lighty-{$cpzone}-CaptivePortal-SSL.conf");
} }
} }
...@@ -1318,9 +1318,9 @@ function portal_reply_page($redirurl, $type = null, $message = null, $clientmac ...@@ -1318,9 +1318,9 @@ function portal_reply_page($redirurl, $type = null, $message = null, $clientmac
header("Location: {$redirurl}"); header("Location: {$redirurl}");
return; return;
} else if ($type == "login") } else if ($type == "login")
$htmltext = get_include_contents("{$g['varetc_path']}/captiveportal_{$cpzone}.html"); $htmltext = get_include_contents("/var/etc/captiveportal_{$cpzone}.html");
else else
$htmltext = get_include_contents("{$g['varetc_path']}/captiveportal-{$cpzone}-error.html"); $htmltext = get_include_contents("/var/etc/captiveportal-{$cpzone}-error.html");
$cpcfg = $config['captiveportal'][$cpzone]; $cpcfg = $config['captiveportal'][$cpzone];
......
...@@ -37,7 +37,6 @@ $g = array( ...@@ -37,7 +37,6 @@ $g = array(
"factory_shipped_password" => "opnsense", "factory_shipped_password" => "opnsense",
"dhcpd_chroot_path" => "/var/dhcpd", "dhcpd_chroot_path" => "/var/dhcpd",
"unbound_chroot_path" => "/var/unbound", "unbound_chroot_path" => "/var/unbound",
"varetc_path" => "/var/etc",
"admin_group" => "admins", "admin_group" => "admins",
"product_name" => "OPNsense", "product_name" => "OPNsense",
"product_website" => "https://opnsense.org", "product_website" => "https://opnsense.org",
......
...@@ -98,8 +98,8 @@ if (!$username || !$password) { ...@@ -98,8 +98,8 @@ if (!$username || !$password) {
/* Replaced by a sed with propper variables used below(ldap parameters). */ /* Replaced by a sed with propper variables used below(ldap parameters). */
//<template> //<template>
if (file_exists("{$g['varetc_path']}/openvpn/{$modeid}.ca")) { if (file_exists("/var/etc/openvpn/{$modeid}.ca")) {
putenv("LDAPTLS_CACERT={$g['varetc_path']}/openvpn/{$modeid}.ca"); putenv("LDAPTLS_CACERT=/var/etc/openvpn/{$modeid}.ca");
putenv("LDAPTLS_REQCERT=never"); putenv("LDAPTLS_REQCERT=never");
} }
......
...@@ -367,10 +367,9 @@ function openvpn_add_custom(& $settings, & $conf) { ...@@ -367,10 +367,9 @@ function openvpn_add_custom(& $settings, & $conf) {
} }
} }
function openvpn_add_keyfile(& $data, & $conf, $mode_id, $directive, $opt = "") { function openvpn_add_keyfile(&$data, &$conf, $mode_id, $directive, $opt = '')
global $g; {
$fpath = "/var/etc/openvpn/{$mode_id}.{$directive}";
$fpath = $g['varetc_path']."/openvpn/{$mode_id}.{$directive}";
openvpn_create_dirs(); openvpn_create_dirs();
file_put_contents($fpath, base64_decode($data)); file_put_contents($fpath, base64_decode($data));
//chown($fpath, 'nobody'); //chown($fpath, 'nobody');
...@@ -530,7 +529,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -530,7 +529,7 @@ function openvpn_reconfigure($mode, $settings)
// See ticket #1417 // See ticket #1417
if (!empty($ip) && !empty($mask) && ($cidr < 30)) { if (!empty($ip) && !empty($mask) && ($cidr < 30)) {
$conf .= "server {$ip} {$mask}\n"; $conf .= "server {$ip} {$mask}\n";
$conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; $conf .= "client-config-dir /var/etc/openvpn-csc\n";
if(is_ipaddr($ipv6)) if(is_ipaddr($ipv6))
$conf .= "server-ipv6 {$ipv6}/{$prefix}\n"; $conf .= "server-ipv6 {$ipv6}/{$prefix}\n";
} }
...@@ -557,7 +556,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -557,7 +556,7 @@ function openvpn_reconfigure($mode, $settings)
$conf .= "server {$ip} {$mask}\n"; $conf .= "server {$ip} {$mask}\n";
if(is_ipaddr($ipv6)) if(is_ipaddr($ipv6))
$conf .= "server-ipv6 {$ipv6}/{$prefix}\n"; $conf .= "server-ipv6 {$ipv6}/{$prefix}\n";
$conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; $conf .= "client-config-dir /var/etc/openvpn-csc\n";
} else { } else {
if ($settings['serverbridge_dhcp']) { if ($settings['serverbridge_dhcp']) {
if ((!empty($settings['serverbridge_interface'])) && (strcmp($settings['serverbridge_interface'], "none"))) { if ((!empty($settings['serverbridge_interface'])) && (strcmp($settings['serverbridge_interface'], "none"))) {
...@@ -565,7 +564,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -565,7 +564,7 @@ function openvpn_reconfigure($mode, $settings)
$biface_sm=gen_subnet_mask(get_interface_subnet($settings['serverbridge_interface'])); $biface_sm=gen_subnet_mask(get_interface_subnet($settings['serverbridge_interface']));
if (is_ipaddrv4($biface_ip) && is_ipaddrv4($settings['serverbridge_dhcp_start']) && is_ipaddrv4($settings['serverbridge_dhcp_end'])) { if (is_ipaddrv4($biface_ip) && is_ipaddrv4($settings['serverbridge_dhcp_start']) && is_ipaddrv4($settings['serverbridge_dhcp_end'])) {
$conf .= "server-bridge {$biface_ip} {$biface_sm} {$settings['serverbridge_dhcp_start']} {$settings['serverbridge_dhcp_end']}\n"; $conf .= "server-bridge {$biface_ip} {$biface_sm} {$settings['serverbridge_dhcp_start']} {$settings['serverbridge_dhcp_end']}\n";
$conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; $conf .= "client-config-dir /var/etc/openvpn-csc\n";
} else { } else {
$conf .= "mode server\n"; $conf .= "mode server\n";
} }
...@@ -611,7 +610,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -611,7 +610,7 @@ function openvpn_reconfigure($mode, $settings)
// The management port to listen on // The management port to listen on
// Use unix socket to overcome the problem on any type of server // Use unix socket to overcome the problem on any type of server
$conf .= "management {$g['varetc_path']}/openvpn/{$mode_id}.sock unix\n"; $conf .= "management /var/etc/openvpn/{$mode_id}.sock unix\n";
//$conf .= "management 127.0.0.1 {$settings['local_port']}\n"; //$conf .= "management 127.0.0.1 {$settings['local_port']}\n";
if ($settings['maxclients']) if ($settings['maxclients'])
...@@ -663,7 +662,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -663,7 +662,7 @@ function openvpn_reconfigure($mode, $settings)
$conf .= "lport 0\n"; $conf .= "lport 0\n";
// Use unix socket to overcome the problem on any type of server // Use unix socket to overcome the problem on any type of server
$conf .= "management {$g['varetc_path']}/openvpn/{$mode_id}.sock unix\n"; $conf .= "management /var/etc/openvpn/{$mode_id}.sock unix\n";
// The remote server // The remote server
$conf .= "remote {$settings['server_addr']} {$settings['server_port']}\n"; $conf .= "remote {$settings['server_addr']} {$settings['server_port']}\n";
...@@ -691,7 +690,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -691,7 +690,7 @@ function openvpn_reconfigure($mode, $settings)
} }
if ($settings['auth_user'] && $settings['auth_pass']) { if ($settings['auth_user'] && $settings['auth_pass']) {
$up_file = "{$g['varetc_path']}/openvpn/{$mode_id}.up"; $up_file = "/var/etc/openvpn/{$mode_id}.up";
$conf .= "auth-user-pass {$up_file}\n"; $conf .= "auth-user-pass {$up_file}\n";
$userpass = "{$settings['auth_user']}\n"; $userpass = "{$settings['auth_user']}\n";
$userpass .= "{$settings['auth_pass']}\n"; $userpass .= "{$settings['auth_pass']}\n";
...@@ -701,10 +700,10 @@ function openvpn_reconfigure($mode, $settings) ...@@ -701,10 +700,10 @@ function openvpn_reconfigure($mode, $settings)
if ($settings['proxy_addr']) { if ($settings['proxy_addr']) {
$conf .= "http-proxy {$settings['proxy_addr']} {$settings['proxy_port']}"; $conf .= "http-proxy {$settings['proxy_addr']} {$settings['proxy_port']}";
if ($settings['proxy_authtype'] != "none") { if ($settings['proxy_authtype'] != "none") {
$conf .= " {$g['varetc_path']}/openvpn/{$mode_id}.pas {$settings['proxy_authtype']}"; $conf .= " /var/etc/openvpn/{$mode_id}.pas {$settings['proxy_authtype']}";
$proxypas = "{$settings['proxy_user']}\n"; $proxypas = "{$settings['proxy_user']}\n";
$proxypas .= "{$settings['proxy_passwd']}\n"; $proxypas .= "{$settings['proxy_passwd']}\n";
file_put_contents("{$g['varetc_path']}/openvpn/{$mode_id}.pas", $proxypas); file_put_contents("/var/etc/openvpn/{$mode_id}.pas", $proxypas);
} }
$conf .= " \n"; $conf .= " \n";
} }
...@@ -787,18 +786,18 @@ function openvpn_reconfigure($mode, $settings) ...@@ -787,18 +786,18 @@ function openvpn_reconfigure($mode, $settings)
openvpn_add_custom($settings, $conf); openvpn_add_custom($settings, $conf);
openvpn_create_dirs(); openvpn_create_dirs();
$fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.conf"; $fpath = "/var/etc/openvpn/{$mode_id}.conf";
file_put_contents($fpath, $conf); file_put_contents($fpath, $conf);
unset($conf); unset($conf);
$fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface"; $fpath = "/var/etc/openvpn/{$mode_id}.interface";
file_put_contents($fpath, $interface); file_put_contents($fpath, $interface);
//chown($fpath, 'nobody'); //chown($fpath, 'nobody');
//chgrp($fpath, 'nobody'); //chgrp($fpath, 'nobody');
@chmod("{$g['varetc_path']}/openvpn/{$mode_id}.conf", 0600); @chmod("/var/etc/openvpn/{$mode_id}.conf", 0600);
@chmod("{$g['varetc_path']}/openvpn/{$mode_id}.interface", 0600); @chmod("/var/etc/openvpn/{$mode_id}.interface", 0600);
@chmod("{$g['varetc_path']}/openvpn/{$mode_id}.key", 0600); @chmod("/var/etc/openvpn/{$mode_id}.key", 0600);
@chmod("{$g['varetc_path']}/openvpn/{$mode_id}.tls-auth", 0600); @chmod("/var/etc/openvpn/{$mode_id}.tls-auth", 0600);
@chmod("{$g['varetc_path']}/openvpn/{$mode_id}.conf", 0600); @chmod("/var/etc/openvpn/{$mode_id}.conf", 0600);
} }
function openvpn_restart($mode, $settings) function openvpn_restart($mode, $settings)
...@@ -833,7 +832,7 @@ function openvpn_restart($mode, $settings) ...@@ -833,7 +832,7 @@ function openvpn_restart($mode, $settings)
} }
/* start the new process */ /* start the new process */
$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf"; $fpath = "/var/etc/openvpn/{$mode_id}.conf";
openvpn_clear_route($mode, $settings); openvpn_clear_route($mode, $settings);
mwexec_bg("/usr/local/sbin/openvpn --config " . escapeshellarg($fpath)); mwexec_bg("/usr/local/sbin/openvpn --config " . escapeshellarg($fpath));
...@@ -870,7 +869,7 @@ function openvpn_delete($mode, & $settings) ...@@ -870,7 +869,7 @@ function openvpn_delete($mode, & $settings)
mwexec("/sbin/ifconfig " . escapeshellarg($devname) . " name " . escapeshellarg($tunname)); mwexec("/sbin/ifconfig " . escapeshellarg($devname) . " name " . escapeshellarg($tunname));
/* remove the configuration files */ /* remove the configuration files */
@array_map('unlink', glob("{$g['varetc_path']}/openvpn/{$mode_id}.*")); @array_map('unlink', glob("/var/etc/openvpn/{$mode_id}.*"));
} }
function openvpn_cleanup_csc($common_name) function openvpn_cleanup_csc($common_name)
...@@ -878,10 +877,11 @@ function openvpn_cleanup_csc($common_name) ...@@ -878,10 +877,11 @@ function openvpn_cleanup_csc($common_name)
@unlink('/var/etc/openvpn-csc/' . basename($common_name)); @unlink('/var/etc/openvpn-csc/' . basename($common_name));
} }
function openvpn_resync_csc(& $settings) { function openvpn_resync_csc(&$settings)
{
global $g, $config; global $g, $config;
$fpath = $g['varetc_path']."/openvpn-csc/".$settings['common_name']; $fpath = "/var/etc/openvpn-csc/{$settings['common_name']}";
if (isset($settings['disable'])) { if (isset($settings['disable'])) {
@unlink($fpath); @unlink($fpath);
...@@ -1034,7 +1034,7 @@ function openvpn_get_active_servers($type="multipoint") { ...@@ -1034,7 +1034,7 @@ function openvpn_get_active_servers($type="multipoint") {
$server['conns'] = array(); $server['conns'] = array();
$server['vpnid'] = $settings['vpnid']; $server['vpnid'] = $settings['vpnid'];
$server['mgmt'] = "server{$server['vpnid']}"; $server['mgmt'] = "server{$server['vpnid']}";
$socket = "unix://{$g['varetc_path']}/openvpn/{$server['mgmt']}.sock"; $socket = "unix:///var/etc/openvpn/{$server['mgmt']}.sock";
list($tn, $sm) = explode('/', $settings['tunnel_network']); list($tn, $sm) = explode('/', $settings['tunnel_network']);
if ((($server['mode'] == "p2p_shared_key") || ($sm >= 30) ) && ($type == "p2p")) if ((($server['mode'] == "p2p_shared_key") || ($sm >= 30) ) && ($type == "p2p"))
...@@ -1136,7 +1136,7 @@ function openvpn_get_active_clients() { ...@@ -1136,7 +1136,7 @@ function openvpn_get_active_clients() {
$client['vpnid'] = $settings['vpnid']; $client['vpnid'] = $settings['vpnid'];
$client['mgmt'] = "client{$client['vpnid']}"; $client['mgmt'] = "client{$client['vpnid']}";
$socket = "unix://{$g['varetc_path']}/openvpn/{$client['mgmt']}.sock"; $socket = "unix:///var/etc/openvpn/{$client['mgmt']}.sock";
$client['status']="down"; $client['status']="down";
$clients[] = openvpn_get_client_status($client, $socket); $clients[] = openvpn_get_client_status($client, $socket);
...@@ -1255,7 +1255,7 @@ function openvpn_refresh_crls() { ...@@ -1255,7 +1255,7 @@ function openvpn_refresh_crls() {
if (!empty($settings['crlref'])) { if (!empty($settings['crlref'])) {
$crl = lookup_crl($settings['crlref']); $crl = lookup_crl($settings['crlref']);
crl_update($crl); crl_update($crl);
$fpath = $g['varetc_path']."/openvpn/server{$settings['vpnid']}.crl-verify"; $fpath = "/var/etc/openvpn/server{$settings['vpnid']}.crl-verify";
file_put_contents($fpath, base64_decode($crl['text'])); file_put_contents($fpath, base64_decode($crl['text']));
@chmod($fpath, 0644); @chmod($fpath, 0644);
} }
......
...@@ -34,7 +34,6 @@ require_once("vpn.inc"); ...@@ -34,7 +34,6 @@ require_once("vpn.inc");
require_once("vslb.inc"); require_once("vslb.inc");
require_once("gwlb.inc"); require_once("gwlb.inc");
if (!function_exists('get_services')) { if (!function_exists('get_services')) {
function get_services() { function get_services() {
...@@ -386,7 +385,7 @@ if (!function_exists('service_control_start')) { ...@@ -386,7 +385,7 @@ if (!function_exists('service_control_start')) {
$vpnmode = isset($extras['vpnmode']) ? htmlspecialchars($extras['vpnmode']) : htmlspecialchars($extras['mode']); $vpnmode = isset($extras['vpnmode']) ? htmlspecialchars($extras['vpnmode']) : htmlspecialchars($extras['mode']);
if (($vpnmode == "server") || ($vpnmode == "client")) { if (($vpnmode == "server") || ($vpnmode == "client")) {
$id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']); $id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']);
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf"; $configfile = "/var/etc/openvpn/{$vpnmode}{$id}.conf";
if (file_exists($configfile)) if (file_exists($configfile))
openvpn_restart_by_vpnid($vpnmode, $id); openvpn_restart_by_vpnid($vpnmode, $id);
} }
...@@ -530,7 +529,7 @@ if (!function_exists('service_control_restart')) { ...@@ -530,7 +529,7 @@ if (!function_exists('service_control_restart')) {
$vpnmode = htmlspecialchars($extras['vpnmode']); $vpnmode = htmlspecialchars($extras['vpnmode']);
if ($vpnmode == "server" || $vpnmode == "client") { if ($vpnmode == "server" || $vpnmode == "client") {
$id = htmlspecialchars($extras['id']); $id = htmlspecialchars($extras['id']);
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf"; $configfile = "/var/etc/openvpn/{$vpnmode}{$id}.conf";
if (file_exists($configfile)) if (file_exists($configfile))
openvpn_restart_by_vpnid($vpnmode, $id); openvpn_restart_by_vpnid($vpnmode, $id);
} }
......
...@@ -304,7 +304,7 @@ function services_radvd_configure($blacklist = array()) ...@@ -304,7 +304,7 @@ function services_radvd_configure($blacklist = array())
} }
/* write radvd.conf */ /* write radvd.conf */
if (!@file_put_contents("{$g['varetc_path']}/radvd.conf", $radvdconf)) { if (!@file_put_contents("/var/etc/radvd.conf", $radvdconf)) {
log_error("Error: cannot open radvd.conf in services_radvd_configure().\n"); log_error("Error: cannot open radvd.conf in services_radvd_configure().\n");
if (file_exists("/var/run/booting")) if (file_exists("/var/run/booting"))
printf("Error: cannot open radvd.conf in services_radvd_configure().\n"); printf("Error: cannot open radvd.conf in services_radvd_configure().\n");
...@@ -1919,7 +1919,7 @@ function services_snmpd_configure() ...@@ -1919,7 +1919,7 @@ function services_snmpd_configure()
echo gettext("Starting SNMP daemon... "); echo gettext("Starting SNMP daemon... ");
/* generate snmpd.conf */ /* generate snmpd.conf */
$fd = fopen("{$g['varetc_path']}/snmpd.conf", "w"); $fd = fopen("/var/etc/snmpd.conf", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open snmpd.conf in services_snmpd_configure().%s"),"\n"); printf(gettext("Error: cannot open snmpd.conf in services_snmpd_configure().%s"),"\n");
return 1; return 1;
...@@ -2092,7 +2092,7 @@ EOD; ...@@ -2092,7 +2092,7 @@ EOD;
} }
/* run bsnmpd */ /* run bsnmpd */
mwexec("/usr/sbin/bsnmpd -c {$g['varetc_path']}/snmpd.conf" . mwexec("/usr/sbin/bsnmpd -c /var/etc/snmpd.conf" .
"{$bindlan} -p /var/run/snmpd.pid"); "{$bindlan} -p /var/run/snmpd.pid");
if (file_exists("/var/run/booting")) if (file_exists("/var/run/booting"))
...@@ -2143,7 +2143,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false ...@@ -2143,7 +2143,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
/* write private key file /* write private key file
this is dumb - public and private keys are the same for HMAC-MD5, this is dumb - public and private keys are the same for HMAC-MD5,
but nsupdate insists on having both */ but nsupdate insists on having both */
$fd = fopen("{$g['varetc_path']}/K{$i}{$keyname}+157+00000.private", "w"); $fd = fopen("/var/etc/K{$i}{$keyname}+157+00000.private", "w");
$privkey = <<<EOD $privkey = <<<EOD
Private-key-format: v1.2 Private-key-format: v1.2
Algorithm: 157 (HMAC) Algorithm: 157 (HMAC)
...@@ -2165,7 +2165,7 @@ EOD; ...@@ -2165,7 +2165,7 @@ EOD;
$proto = 2; $proto = 2;
} }
$fd = fopen("{$g['varetc_path']}/K{$i}{$keyname}+157+00000.key", "w"); $fd = fopen("/var/etc/K{$i}{$keyname}+157+00000.key", "w");
fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$dnsupdate['keydata']}\n"); fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$dnsupdate['keydata']}\n");
fclose($fd); fclose($fd);
...@@ -2218,13 +2218,13 @@ EOD; ...@@ -2218,13 +2218,13 @@ EOD;
$upinst .= "\n"; /* mind that trailing newline! */ $upinst .= "\n"; /* mind that trailing newline! */
if ($need_update) { if ($need_update) {
@file_put_contents("{$g['varetc_path']}/nsupdatecmds{$i}", $upinst); @file_put_contents("/var/etc/nsupdatecmds{$i}", $upinst);
unset($upinst); unset($upinst);
/* invoke nsupdate */ /* invoke nsupdate */
$cmd = "/usr/local/bin/nsupdate -k {$g['varetc_path']}/K{$i}{$keyname}+157+00000.key"; $cmd = "/usr/local/bin/nsupdate -k /var/etc/K{$i}{$keyname}+157+00000.key";
if (isset($dnsupdate['usetcp'])) if (isset($dnsupdate['usetcp']))
$cmd .= " -v"; $cmd .= " -v";
$cmd .= " {$g['varetc_path']}/nsupdatecmds{$i}"; $cmd .= " /var/etc/nsupdatecmds{$i}";
mwexec_bg($cmd); mwexec_bg($cmd);
unset($cmd); unset($cmd);
} }
...@@ -2380,5 +2380,3 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont ...@@ -2380,5 +2380,3 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
} }
configure_cron(); configure_cron();
} }
?>
...@@ -549,13 +549,13 @@ function system_staticroutes_configure($interface = "", $update_dns = false) { ...@@ -549,13 +549,13 @@ function system_staticroutes_configure($interface = "", $update_dns = false) {
array_unique($filterdns_list); array_unique($filterdns_list);
foreach ($filterdns_list as $hostname) foreach ($filterdns_list as $hostname)
$hostnames .= "cmd {$hostname} '/usr/local/opnsense/service/configd_ctl.py \"routedns reload\"'\n"; $hostnames .= "cmd {$hostname} '/usr/local/opnsense/service/configd_ctl.py \"routedns reload\"'\n";
file_put_contents("{$g['varetc_path']}/filterdns-route.hosts", $hostnames); file_put_contents("/var/etc/filterdns-route.hosts", $hostnames);
unset($hostnames); unset($hostnames);
if (isvalidpid('/var/run/filterdns-route.pid')) { if (isvalidpid('/var/run/filterdns-route.pid')) {
killbypid('/var/run/filterdns-route.pid', 'HUP'); killbypid('/var/run/filterdns-route.pid', 'HUP');
} else { } else {
mwexec("/usr/local/sbin/filterdns -p /var/run/filterdns-route.pid -i {$interval} -c {$g['varetc_path']}/filterdns-route.hosts -d 1"); mwexec("/usr/local/sbin/filterdns -p /var/run/filterdns-route.pid -i {$interval} -c /var/etc/filterdns-route.hosts -d 1");
} }
} else { } else {
killbypid('/var/run/filterdns-route.pid'); killbypid('/var/run/filterdns-route.pid');
...@@ -744,7 +744,7 @@ EOD; ...@@ -744,7 +744,7 @@ EOD;
EOD; EOD;
} }
/* write syslog.conf */ /* write syslog.conf */
if (!@file_put_contents("{$g['varetc_path']}/syslog.conf", $syslogconf)) { if (!@file_put_contents("/var/etc/syslog.conf", $syslogconf)) {
printf(gettext("Error: cannot open syslog.conf in system_syslogd_start().%s"), "\n"); printf(gettext("Error: cannot open syslog.conf in system_syslogd_start().%s"), "\n");
unset($syslogconf); unset($syslogconf);
return 1; return 1;
...@@ -771,7 +771,7 @@ EOD; ...@@ -771,7 +771,7 @@ EOD;
} }
} }
$syslogd_extra = "-f {$g['varetc_path']}/syslog.conf {$sourceip}"; $syslogd_extra = "-f /var/etc/syslog.conf {$sourceip}";
} }
if (isvalidpid('/var/run/syslog.pid')) { if (isvalidpid('/var/run/syslog.pid')) {
...@@ -845,7 +845,7 @@ function system_webgui_start() ...@@ -845,7 +845,7 @@ function system_webgui_start()
} }
/* generate lighttpd configuration */ /* generate lighttpd configuration */
system_generate_lighty_config("{$g['varetc_path']}/lighty-webConfigurator.conf", system_generate_lighty_config("/var/etc/lighty-webConfigurator.conf",
$crt, $key, $ca, "lighty-webConfigurator.pid", $portarg, "/usr/local/www/", $crt, $key, $ca, "lighty-webConfigurator.pid", $portarg, "/usr/local/www/",
"cert.pem", "ca.pem"); "cert.pem", "ca.pem");
...@@ -858,7 +858,7 @@ function system_webgui_start() ...@@ -858,7 +858,7 @@ function system_webgui_start()
mwexec('/usr/local/etc/rc.php_ini_setup'); mwexec('/usr/local/etc/rc.php_ini_setup');
/* attempt to start lighthttpd and return true if ok */ /* attempt to start lighthttpd and return true if ok */
return !mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-webConfigurator.conf"); return !mwexec("/usr/local/sbin/lighttpd -f /var/etc/lighty-webConfigurator.conf");
} }
function system_generate_lighty_config( function system_generate_lighty_config(
...@@ -1088,9 +1088,9 @@ EOD; ...@@ -1088,9 +1088,9 @@ EOD;
$lighty_config .= "\n"; $lighty_config .= "\n";
$lighty_config .= "## ssl configuration\n"; $lighty_config .= "## ssl configuration\n";
$lighty_config .= "ssl.engine = \"enable\"\n"; $lighty_config .= "ssl.engine = \"enable\"\n";
$lighty_config .= "ssl.pemfile = \"{$g['varetc_path']}/{$cert_location}\"\n\n"; $lighty_config .= "ssl.pemfile = \"/var/etc/{$cert_location}\"\n\n";
if($ca <> "") if($ca <> "")
$lighty_config .= "ssl.ca-file = \"{$g['varetc_path']}/{$ca_location}\"\n\n"; $lighty_config .= "ssl.ca-file = \"/var/etc/{$ca_location}\"\n\n";
} }
$lighty_config .= " }\n"; $lighty_config .= " }\n";
...@@ -1142,30 +1142,30 @@ EOD; ...@@ -1142,30 +1142,30 @@ EOD;
$ca = str_replace("\n\n", "\n", $ca); $ca = str_replace("\n\n", "\n", $ca);
if($cert <> "" and $key <> "") { if($cert <> "" and $key <> "") {
$fd = fopen("{$g['varetc_path']}/{$cert_location}", "w"); $fd = fopen("/var/etc/{$cert_location}", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open cert.pem in system_webgui_start().%s"), "\n"); printf(gettext("Error: cannot open cert.pem in system_webgui_start().%s"), "\n");
return 1; return 1;
} }
chmod("{$g['varetc_path']}/{$cert_location}", 0600); chmod("/var/etc/{$cert_location}", 0600);
fwrite($fd, $cert); fwrite($fd, $cert);
fwrite($fd, "\n"); fwrite($fd, "\n");
fwrite($fd, $key); fwrite($fd, $key);
fclose($fd); fclose($fd);
if(!(empty($ca) || (strlen(trim($ca)) == 0))) { if(!(empty($ca) || (strlen(trim($ca)) == 0))) {
$fd = fopen("{$g['varetc_path']}/{$ca_location}", "w"); $fd = fopen("/var/etc/{$ca_location}", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open ca.pem in system_webgui_start().%s"), "\n"); printf(gettext("Error: cannot open ca.pem in system_webgui_start().%s"), "\n");
return 1; return 1;
} }
chmod("{$g['varetc_path']}/{$ca_location}", 0600); chmod("/var/etc/{$ca_location}", 0600);
fwrite($fd, $ca); fwrite($fd, $ca);
fclose($fd); fclose($fd);
} }
$lighty_config .= "\n"; $lighty_config .= "\n";
$lighty_config .= "## " . gettext("ssl configuration") . "\n"; $lighty_config .= "## " . gettext("ssl configuration") . "\n";
$lighty_config .= "ssl.engine = \"enable\"\n"; $lighty_config .= "ssl.engine = \"enable\"\n";
$lighty_config .= "ssl.pemfile = \"{$g['varetc_path']}/{$cert_location}\"\n\n"; $lighty_config .= "ssl.pemfile = \"/var/etc/{$cert_location}\"\n\n";
// Harden SSL a bit for PCI conformance testing // Harden SSL a bit for PCI conformance testing
$lighty_config .= "ssl.use-sslv2 = \"disable\"\n"; $lighty_config .= "ssl.use-sslv2 = \"disable\"\n";
...@@ -1192,7 +1192,7 @@ EOD; ...@@ -1192,7 +1192,7 @@ EOD;
} }
if(!(empty($ca) || (strlen(trim($ca)) == 0))) if(!(empty($ca) || (strlen(trim($ca)) == 0)))
$lighty_config .= "ssl.ca-file = \"{$g['varetc_path']}/{$ca_location}\"\n\n"; $lighty_config .= "ssl.ca-file = \"/var/etc/{$ca_location}\"\n\n";
} }
// Add HTTP to HTTPS redirect // Add HTTP to HTTPS redirect
......
...@@ -60,7 +60,7 @@ function voucher_expire($voucher_received) { ...@@ -60,7 +60,7 @@ function voucher_expire($voucher_received) {
continue; // seems too short to be a voucher! continue; // seems too short to be a voucher!
unset($output); unset($output);
$_gb = exec("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -k {$g['varetc_path']}/voucher_{$cpzone}.public -- $v", $output); $_gb = exec("/usr/local/bin/voucher -c /var/etc/voucher_{$cpzone}.cfg -k /var/etc/voucher_{$cpzone}.public -- $v", $output);
list($status, $roll, $nr) = explode(" ", $output[0]); list($status, $roll, $nr) = explode(" ", $output[0]);
if ($status == "OK") { if ($status == "OK") {
// check if we have this ticket on a registered roll for this ticket // check if we have this ticket on a registered roll for this ticket
...@@ -165,7 +165,7 @@ function voucher_auth($voucher_received, $test = 0) { ...@@ -165,7 +165,7 @@ function voucher_auth($voucher_received, $test = 0) {
if (strlen($voucher) < 3) if (strlen($voucher) < 3)
continue; // seems too short to be a voucher! continue; // seems too short to be a voucher!
$result = exec("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -k {$g['varetc_path']}/voucher_{$cpzone}.public -- $v"); $result = exec("/usr/local/bin/voucher -c /var/etc/voucher_{$cpzone}.cfg -k /var/etc/voucher_{$cpzone}.public -- $v");
list($status, $roll, $nr) = explode(" ", $result); list($status, $roll, $nr) = explode(" ", $result);
if ($status == "OK") { if ($status == "OK") {
if (!$first_voucher) { if (!$first_voucher) {
...@@ -303,7 +303,7 @@ function voucher_configure_zone($sync = false) ...@@ -303,7 +303,7 @@ function voucher_configure_zone($sync = false)
/* write public key used to verify vouchers */ /* write public key used to verify vouchers */
$pubkey = base64_decode($config['voucher'][$cpzone]['publickey']); $pubkey = base64_decode($config['voucher'][$cpzone]['publickey']);
$fd = fopen("{$g['varetc_path']}/voucher_{$cpzone}.public", "w"); $fd = fopen("/var/etc/voucher_{$cpzone}.public", "w");
if (!$fd) { if (!$fd) {
captiveportal_syslog("Voucher error: cannot write voucher.public\n"); captiveportal_syslog("Voucher error: cannot write voucher.public\n");
unlock($voucherlck); unlock($voucherlck);
...@@ -311,10 +311,10 @@ function voucher_configure_zone($sync = false) ...@@ -311,10 +311,10 @@ function voucher_configure_zone($sync = false)
} }
fwrite($fd, $pubkey); fwrite($fd, $pubkey);
fclose($fd); fclose($fd);
@chmod("{$g['varetc_path']}/voucher_{$cpzone}.public", 0600); @chmod("/var/etc/voucher_{$cpzone}.public", 0600);
/* write config file used by voucher binary to decode vouchers */ /* write config file used by voucher binary to decode vouchers */
$fd = fopen("{$g['varetc_path']}/voucher_{$cpzone}.cfg", "w"); $fd = fopen("/var/etc/voucher_{$cpzone}.cfg", "w");
if (!$fd) { if (!$fd) {
captiveportal_syslog(gettext("Error: cannot write voucher.cfg") . "\n"); captiveportal_syslog(gettext("Error: cannot write voucher.cfg") . "\n");
unlock($voucherlck); unlock($voucherlck);
...@@ -322,7 +322,7 @@ function voucher_configure_zone($sync = false) ...@@ -322,7 +322,7 @@ function voucher_configure_zone($sync = false)
} }
fwrite($fd, "{$config['voucher'][$cpzone]['rollbits']},{$config['voucher'][$cpzone]['ticketbits']},{$config['voucher'][$cpzone]['checksumbits']},{$config['voucher'][$cpzone]['magic']},{$config['voucher'][$cpzone]['charset']}\n"); fwrite($fd, "{$config['voucher'][$cpzone]['rollbits']},{$config['voucher'][$cpzone]['ticketbits']},{$config['voucher'][$cpzone]['checksumbits']},{$config['voucher'][$cpzone]['magic']},{$config['voucher'][$cpzone]['charset']}\n");
fclose($fd); fclose($fd);
@chmod("{$g['varetc_path']}/voucher_{$cpzone}.cfg", 0600); @chmod("/var/etc/voucher_{$cpzone}.cfg", 0600);
unlock($voucherlck); unlock($voucherlck);
if (!$sync) { if (!$sync) {
......
...@@ -183,8 +183,7 @@ function relayd_configure($kill_first=false) { ...@@ -183,8 +183,7 @@ function relayd_configure($kill_first=false) {
} }
} }
$fd = fopen('/var/etc/relayd.conf', 'w');
$fd = fopen("{$g['varetc_path']}/relayd.conf", "w");
$conf .= "log updates \n"; $conf .= "log updates \n";
/* Global timeout, interval and prefork settings /* Global timeout, interval and prefork settings
...@@ -355,13 +354,13 @@ function relayd_configure($kill_first=false) { ...@@ -355,13 +354,13 @@ function relayd_configure($kill_first=false) {
if (is_process_running('relayd')) { if (is_process_running('relayd')) {
if (! empty($vs_a)) { if (! empty($vs_a)) {
if ($kill_first) { if ($kill_first) {
mwexec('pkill relayd'); killbyname('relayd');
/* Remove all active relayd anchors now that relayd is no longer running. */ /* Remove all active relayd anchors now that relayd is no longer running. */
cleanup_lb_anchor("*"); cleanup_lb_anchor('*');
mwexec("/usr/local/sbin/relayd -f {$g['varetc_path']}/relayd.conf"); mwexec('/usr/local/sbin/relayd -f /var/etc/relayd.conf');
} else { } else {
// it's running and there is a config, just reload // it's running and there is a config, just reload
mwexec("/usr/local/sbin/relayctl reload"); mwexec('/usr/local/sbin/relayctl reload');
} }
} else { } else {
/* /*
...@@ -371,7 +370,7 @@ function relayd_configure($kill_first=false) { ...@@ -371,7 +370,7 @@ function relayd_configure($kill_first=false) {
* mwexec('/usr/local/sbin/relayctl stop'); * mwexec('/usr/local/sbin/relayctl stop');
* returns "command failed" * returns "command failed"
*/ */
mwexec('pkill relayd'); killbyname('relayd');
/* Remove all active relayd anchors now that relayd is no longer running. */ /* Remove all active relayd anchors now that relayd is no longer running. */
cleanup_lb_anchor("*"); cleanup_lb_anchor("*");
} }
...@@ -379,8 +378,8 @@ function relayd_configure($kill_first=false) { ...@@ -379,8 +378,8 @@ function relayd_configure($kill_first=false) {
if (! empty($vs_a)) { if (! empty($vs_a)) {
// not running and there is a config, start it // not running and there is a config, start it
/* Remove all active relayd anchors so it can start fresh. */ /* Remove all active relayd anchors so it can start fresh. */
cleanup_lb_anchor("*"); cleanup_lb_anchor('*');
mwexec("/usr/local/sbin/relayd -f {$g['varetc_path']}/relayd.conf"); mwexec('/usr/local/sbin/relayd -f /var/etc/relayd.conf');
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment