Commit cf3977b7 authored by Franco Fichtner's avatar Franco Fichtner

src: varlog_path softcoding removal

parent 71ff705e
......@@ -40,7 +40,6 @@ $g = array(
"varrun_path" => "/var/run",
"varetc_path" => "/var/etc",
"vardb_path" => "/var/db",
"varlog_path" => "/var/log",
"admin_group" => "admins",
"product_name" => "OPNsense",
"product_website" => "https://opnsense.org",
......
......@@ -637,84 +637,84 @@ function system_syslogd_start()
$facilitylist = implode(',', array_unique($separatelogfacilities));
$syslogconf .= "!radvd,routed,olsrd,zebra,ospfd,bgpd,miniupnpd\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/routing.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/routing.log\n";
$syslogconf .= "!ntp,ntpd,ntpdate\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/ntpd.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/ntpd.log\n";
$syslogconf .= "!ppp\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/ppp.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/ppp.log\n";
$syslogconf .= "!pptps\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/pptps.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/pptps.log\n";
$syslogconf .= "!poes\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/poes.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/poes.log\n";
$syslogconf .= "!l2tps\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/l2tps.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/l2tps.log\n";
$syslogconf .= "!charon\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/ipsec.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/ipsec.log\n";
if (isset($syslogcfg['vpn']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!openvpn\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/openvpn.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/openvpn.log\n";
if (isset($syslogcfg['vpn']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!apinger\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/gateways.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/gateways.log\n";
if (isset($syslogcfg['apinger']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!dnsmasq,filterdns,unbound\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/resolver.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/resolver.log\n";
$syslogconf .= "!dhcpd,dhcrelay,dhclient,dhcp6c\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/dhcpd.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/dhcpd.log\n";
if (isset($syslogcfg['dhcp']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!relayd\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/relayd.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/relayd.log\n";
if (isset($syslogcfg['relayd']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!hostapd\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/wireless.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/wireless.log\n";
if (isset($syslogcfg['hostapd']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!filterlog\n";
$syslogconf .= "*.* {$log_directive}{$g['varlog_path']}/filter.log\n";
$syslogconf .= "*.* {$log_directive}/var/log/filter.log\n";
if (isset($syslogcfg['filter']))
$syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*");
$syslogconf .= "!-{$facilitylist}\n";
if (!isset($syslogcfg['disablelocallogging']))
$syslogconf .= <<<EOD
local3.* {$log_directive}{$g['varlog_path']}/vpn.log
local4.* {$log_directive}{$g['varlog_path']}/portalauth.log
local7.* {$log_directive}{$g['varlog_path']}/dhcpd.log
*.notice;kern.debug;lpr.info;mail.crit;daemon.none; {$log_directive}{$g['varlog_path']}/system.log
news.err;local0.none;local3.none;local4.none; {$log_directive}{$g['varlog_path']}/system.log
local7.none {$log_directive}{$g['varlog_path']}/system.log
security.* {$log_directive}{$g['varlog_path']}/system.log
auth.info;authpriv.info;daemon.info {$log_directive}{$g['varlog_path']}/system.log
local3.* {$log_directive}/var/log/vpn.log
local4.* {$log_directive}/var/log/portalauth.log
local7.* {$log_directive}/var/log/dhcpd.log
*.notice;kern.debug;lpr.info;mail.crit;daemon.none; {$log_directive}/var/log/system.log
news.err;local0.none;local3.none;local4.none; {$log_directive}/var/log/system.log
local7.none {$log_directive}/var/log/system.log
security.* {$log_directive}/var/log/system.log
auth.info;authpriv.info;daemon.info {$log_directive}/var/log/system.log
auth.info;authpriv.info |exec /usr/local/sbin/sshlockout_pf 15
*.emerg *
......@@ -1173,7 +1173,7 @@ EOD;
$lighty_config .= "ssl.use-sslv2 = \"disable\"\n";
/* Hifn accelerators do NOT work with the BEAST mitigation code. Do not allow it to be enabled if a Hifn card has been detected. */
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
$fd = fopen('/var/log/dmesg.boot', 'r');
if ($fd) {
while (!feof($fd)) {
$dmesgl = fgets($fd);
......@@ -1329,14 +1329,15 @@ function system_ntp_configure($start_ntpd = true)
{
global $config, $g;
$driftfile = "/var/db/ntpd.drift";
$statsdir = "/var/log/ntp";
$driftfile = '/var/db/ntpd.drift';
$statsdir = '/var/log/ntp';
$gps_device = '/dev/gps0';
safe_mkdir($statsdir);
if (!is_array($config['ntpd']))
if (!is_array($config['ntpd'])) {
$config['ntpd'] = array();
}
$ntpcfg = "# \n";
$ntpcfg .= "# OPNsense ntp configuration file \n";
......@@ -1636,7 +1637,7 @@ function system_dmesg_save()
$lastcpline = $i;
}
$fd = fopen("{$g['varlog_path']}/dmesg.boot", "w");
$fd = fopen('/var/log/dmesg.boot', 'w');
if (!$fd) {
printf(gettext("Error: cannot open dmesg.boot in system_dmesg_save().%s"), "\n");
return 1;
......@@ -1702,20 +1703,21 @@ function system_disable_arp_wrong_if()
function system_enable_arp_wrong_if()
{
global $config;
set_sysctl(array(
"net.link.ether.inet.log_arp_wrong_iface" => "1",
"net.link.ether.inet.log_arp_movements" => "1"
));
}
function enable_watchdog() {
function enable_watchdog()
{
global $config;
return;
return; /* XXX delete or repair please */
$install_watchdog = false;
$supported_watchdogs = array("Geode");
$file = file_get_contents("/var/log/dmesg.boot");
$file = file_get_contents('/var/log/dmesg.boot');
foreach($supported_watchdogs as $sd) {
if(stristr($file, "Geode")) {
$install_watchdog = true;
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -29,11 +30,12 @@
require_once("guiconfig.inc");
$dhcpd_logfile = "{$g['varlog_path']}/dhcpd.log";
$dhcpd_logfile = '/var/log/dhcpd.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear']) {
clear_log_file($dhcpd_logfile);
......
......@@ -88,19 +88,22 @@ if ($filtersubmit) {
$filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null);
}
$filter_logfile = "{$g['varlog_path']}/filter.log";
$filter_logfile = '/var/log/filter.log';
$nentries = $config['syslog']['nentries'];
# Override Display Quantity
if ($filterlogentries_qty)
if ($filterlogentries_qty) {
$nentries = $filterlogentries_qty;
}
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($filter_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Firewall"));
$shortcut_section = "firewall";
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -30,7 +31,7 @@
require_once("guiconfig.inc");
require_once("filter_log.inc");
$filter_logfile = "{$g['varlog_path']}/filter.log";
$filter_logfile = '/var/log/filter.log';
/* Hardcode this. AJAX doesn't do so well with large numbers */
$nentries = 50;
......@@ -38,8 +39,9 @@ $nentries = 50;
/* AJAX related routines */
handle_ajax($nentries, $nentries + 20);
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($filter_logfile);
}
$filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100);
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2009 Jim Pingle (jpingle@gmail.com)
......@@ -31,7 +32,7 @@ $shortcut_section = "firewall";
require_once("guiconfig.inc");
include_once("filter_log.inc");
$filter_logfile = "{$g['varlog_path']}/filter.log";
$filter_logfile = '/var/log/filter.log';
$lines = 5000;
$entriesperblock = 5;
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -30,23 +31,28 @@
require_once("guiconfig.inc");
$system_logfile = "{$g['varlog_path']}/gateways.log";
$system_logfile = '/var/log/gateways.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($system_logfile);
}
if ($_GET['filtertext'])
if ($_GET['filtertext']) {
$filtertext = htmlspecialchars($_GET['filtertext']);
}
if ($_POST['filtertext'])
if ($_POST['filtertext']) {
$filtertext = htmlspecialchars($_POST['filtertext']);
}
if ($filtertext)
$filtertextmeta="?filtertext=$filtertext";
if ($filtertext) {
$filtertextmeta = "?filtertext={$filtertext}";
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Gateways"));
$shortcut_section = "gateways";
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -30,14 +31,16 @@
require_once("guiconfig.inc");
require_once("ipsec.inc");
$ipsec_logfile = "{$g['varlog_path']}/ipsec.log";
$ipsec_logfile = '/var/log/ipsec.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($ipsec_logfile);
}
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>.
......@@ -29,14 +30,16 @@
require_once("guiconfig.inc");
$ntpd_logfile = "{$g['varlog_path']}/ntpd.log";
$ntpd_logfile = '/var/log/ntpd.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($ntpd_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("NTP"));
$shortcut_section = "ntp";
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -33,14 +34,16 @@ $shortcut_section = "openvpn";
require_once("guiconfig.inc");
require_once("vpn.inc");
$openvpn_logfile = "{$g['varlog_path']}/openvpn.log";
$openvpn_logfile = '/var/log/openvpn.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($openvpn_logfile);
}
include("head.inc");
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -29,14 +30,16 @@
require_once("guiconfig.inc");
$ppp_logfile = "{$g['varlog_path']}/ppp.log";
$ppp_logfile = '/var/log/ppp.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($ppp_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("PPP"));
include("head.inc");
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2008 Bill Marquette <bill.marquette@gmail.com>.
......@@ -29,14 +30,16 @@
require_once("guiconfig.inc");
$relayd_logfile = "{$g['varlog_path']}/relayd.log";
$relayd_logfile = '/var/log/relayd.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($relayd_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Load Balancer"));
$shortcut_section = "relayd";
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
......@@ -30,23 +31,28 @@
require_once("guiconfig.inc");
$system_logfile = "{$g['varlog_path']}/resolver.log";
$system_logfile = '/var/log/resolver.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($system_logfile);
}
if ($_GET['filtertext'])
if ($_GET['filtertext']) {
$filtertext = htmlspecialchars($_GET['filtertext']);
}
if ($_POST['filtertext'])
if ($_POST['filtertext']) {
$filtertext = htmlspecialchars($_POST['filtertext']);
}
if ($filtertext)
$filtertextmeta="?filtertext=$filtertext";
if ($filtertext) {
$filtertextmeta = "?filtertext={$filtertext}";
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Resolver"));
$shortcut_section = "resolver";
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2012 Jim Pingle <jimp@pfsense.org>.
......@@ -28,14 +29,16 @@
require_once("guiconfig.inc");
$routing_logfile = "{$g['varlog_path']}/routing.log";
$routing_logfile = '/var/log/routing.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($routing_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Routing"));
$shortcut_section = "routing";
......
<?php
/*
Copyright (C) Deciso B.V.
Copyright (C) 2008 Bill Marquette <bill.marquette@gmail.com>.
......@@ -30,14 +31,16 @@
require_once("guiconfig.inc");
$wireless_logfile = "{$g['varlog_path']}/wireless.log";
$wireless_logfile = '/var/log/wireless.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
if ($_POST['clear'])
if ($_POST['clear']) {
clear_log_file($wireless_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Wireless"));
$shortcut_section = "wireless";
......
......@@ -523,19 +523,22 @@ function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = tru
system_syslogd_start();
}
function clear_all_log_files() {
global $g;
exec("/usr/bin/killall syslogd");
function clear_all_log_files()
{
killbyname('syslogd');
$log_files = array(
"system", "filter", "dhcpd", "vpn", "pptps", "poes", "l2tps", "openvpn", "portalauth",
"ipsec", "ppp", "relayd", "wireless", "lighttpd", "ntpd", "gateways", "resolver", "routing"
);
$log_files = array("system", "filter", "dhcpd", "vpn", "pptps", "poes", "l2tps", "openvpn", "portalauth", "ipsec", "ppp", "relayd", "wireless", "lighttpd", "ntpd", "gateways", "resolver", "routing");
foreach ($log_files as $lfile) {
clear_log_file("{$g['varlog_path']}/{$lfile}.log", false);
clear_log_file("/var/log/{$lfile}.log", false);
}
system_syslogd_start();
killbyname("dhcpd");
services_dhcpd_configure();
return;
}
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
......
......@@ -101,30 +101,32 @@ require_once('includes/functions.inc.php');
## Check to see if we have a swap space,
## if true, display, if false, hide it ...
if(file_exists("/usr/sbin/swapinfo")) {
if (file_exists('/usr/sbin/swapinfo')) {
$swapinfo = `/usr/sbin/swapinfo`;
if(stristr($swapinfo,'%') == true) $showswap=true;
if (stristr($swapinfo,'%')) {
$showswap = true;
}
}
## Find out whether there's hardware encryption or not
unset($hwcrypto);
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
if ($fd) {
while (!feof($fd)) {
$dmesgl = fgets($fd);
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
$hwcrypto = $matches[1];
break;
}
## Find out whether there's hardware encryption or not
unset($hwcrypto);
$fd = fopen('/var/log/dmesg.boot', 'r');
if ($fd) {
while (!feof($fd)) {
$dmesgl = fgets($fd);
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
$hwcrypto = $matches[1];
break;
}
fclose($fd);
}
fclose($fd);
}
##build widget saved list information
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
......
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
......@@ -32,16 +33,22 @@ require_once("filter.inc");
require_once("shaper.inc");
require_once("vslb.inc");
if (!is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
}
if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
}
$a_pool = &$config['load_balancer']['lbpool'];
$lb_logfile = "{$g['varlog_path']}/relayd.log";
$lb_logfile = '/var/log/relayd.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
$now = time();
$year = date("Y");
......
......@@ -249,7 +249,7 @@ if ($_POST) {
}
unset($hwcrypto);
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
$fd = fopen('/var/log/dmesg.boot', 'r');
if ($fd) {
while (!feof($fd)) {
$dmesgl = fgets($fd);
......
......@@ -41,6 +41,9 @@ require_once("vslb.inc");
$now = time();
$year = date("Y");
if (!is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
}
if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
}
......@@ -52,10 +55,11 @@ $a_pool = &$config['load_balancer']['lbpool'];
$rdr_a = get_lb_redirects();
$relay_hosts = get_lb_summary();
$lb_logfile = "{$g['varlog_path']}/relayd.log";
$lb_logfile = '/var/log/relayd.log';
$nentries = $config['syslog']['nentries'];
if (!$nentries)
if (!$nentries) {
$nentries = 50;
}
?>
......
......@@ -72,8 +72,8 @@ $filterfieldsarray = array(
"interface" => $nentriesinterfaces
);
$filter_logfile = "{$g['varlog_path']}/filter.log";
$filterlog = conv_log_filter($filter_logfile, $nentries, 50, $filterfieldsarray); //Get log entries
$filter_logfile = '/var/log/filter.log';
$filterlog = conv_log_filter($filter_logfile, $nentries, 50, $filterfieldsarray);
/* AJAX related routines */
handle_ajax($nentries, $nentries + 20);
......
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