Project

General

Profile

« Previous | Next » 

Revision d8af270c

Added by Jim Pingle over 9 years ago

Address some security issues in diag_logs.php. While I'm here, fixup page names and shortcuts.

View differences:

src/usr/local/www/diag_logs.php
69 69

  
70 70
require("guiconfig.inc");
71 71

  
72
/*
73
Build a list of allowed log files so we can reject others to prevent the page
74
from acting on unauthorized files.
75
*/
76
$allowed_logs = array(
77
	"system" => array("name" => "General",
78
		    "shortcut" => ""),
79
	"dhcpd" => array("name" => "DHCP",
80
		    "shortcut" => "dhcp"),
81
	"portalauth" => array("name" => "Captive Portal Authentication",
82
		    "shortcut" => "captiveportal"),
83
	"ipsec" => array("name" => "IPsec",
84
		    "shortcut" => "ipsec"),
85
	"ppp" => array("name" => "PPP",
86
		    "shortcut" => ""),
87
	"relayd" => array("name" => "Load Balancer",
88
		    "shortcut" => "relayd"),
89
	"openvpn" => array("name" => "OpenVPN",
90
		    "shortcut" => "openvpn"),
91
	"ntpd" => array("name" => "NTPd",
92
		    "shortcut" => "ntp"),
93
	"gateways" => array("name" => "Gateways",
94
		    "shortcut" => "gateways"),
95
	"routing" => array("name" => "Routing",
96
		    "shortcut" => "routing"),
97
	"resolver" => array("name" => "DNS Resolver",
98
		    "shortcut" => "resolver"),
99
	"wireless" => array("name" => "Wireless",
100
		    "shortcut" => "wireless"),
101
);
102

  
72 103
// The logs to display are specified in a GET argument. Default to 'system' logs
73
if (!$_GET['logfile'])
104
if (!$_GET['logfile']) {
74 105
	$logfile = 'system';
75
else
106
} else {
76 107
	$logfile = $_GET['logfile'];
108
	if (!array_key_exists($logfile, $allowed_logs)) {
109
		/* Do not let someone attempt to load an unauthorized log. */
110
		$logfile = 'system';
111
	}
112
}
77 113

  
78
$system_logfile = "{$g['varlog_path']}/{$logfile}.log";
114
$system_logfile = "{$g['varlog_path']}/" . basename($logfile) . ".log";
79 115

  
80 116
$nentries = $config['syslog']['nentries'];
81 117
if (!$nentries) {
......
98 134
	$filtertextmeta="?filtertext=$filtertext";
99 135
}
100 136

  
101
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("General"));
137
/* Setup shortcuts if they exist */
138

  
139
if (!empty($allowed_logs[$logfile]["shortcut"])) {
140
	$shortcut_section = $allowed_logs[$logfile]["shortcut"];
141
}
142

  
143
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"]));
102 144
include("head.inc");
103 145

  
104 146
$tab_array = array();

Also available in: Unified diff