diff options
author | jim-p <jimp@pfsense.org> | 2012-05-01 14:24:22 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2012-05-01 14:25:28 -0400 |
commit | 3a1e12cfd9049100c0c97603ce049d067ea78e1b (patch) | |
tree | 0cd6ee16916e61940f44c38b0d9bd68d1acedf0d /usr/local/www | |
parent | eedd093a3813826b217c87f955f9d3303c5af2f2 (diff) | |
download | pfsense-3a1e12cfd9049100c0c97603ce049d067ea78e1b.zip pfsense-3a1e12cfd9049100c0c97603ce049d067ea78e1b.tar.gz |
Add some safety belt checks to status_queues.php to prevent exec blocking or infinite redirection loops. Better error display when things go wrong.
Diffstat (limited to 'usr/local/www')
-rwxr-xr-x | usr/local/www/status_queues.php | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/usr/local/www/status_queues.php b/usr/local/www/status_queues.php index 192cd6a..0772ce0 100755 --- a/usr/local/www/status_queues.php +++ b/usr/local/www/status_queues.php @@ -49,23 +49,26 @@ header("Pragma: no-cache"); // HTTP/1.0 require("guiconfig.inc"); -if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_path']}/qstats.pid")) - mwexec("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid"); +if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_path']}/qstats.pid")) { + /* Start in the background so we don't hang up the GUI */ + mwexec_bg("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid"); + /* Give it a moment to start up */ + sleep(1); +} $fd = @fsockopen("unix://{$g['varrun_path']}/qstats"); if (!$fd) { - log_error("Something wrong happened during comunication with stat gathering"); - header("Location: /status_queues.php"); - exit; + $error = "Something wrong happened during comunication with stat gathering"; +} else { + $stats = ""; + while(!feof($fd)) + $stats .= fread($fd, 4096); + fclose($fd); + @file_put_contents("{$g['tmp_path']}/qstats", $stats); + $altqstats = @parse_xml_config("{$g['tmp_path']}/qstats", array("altqstats")); + if ($altqstats == -1) + $error = "No queue statistics could be read."; } -$stats = ""; -while(!feof($fd)) - $stats .= fread($fd, 4096); -fclose($fd); - -@file_put_contents("{$g['tmp_path']}/qstats", $stats); -$altqstats = @parse_xml_config("{$g['tmp_path']}/qstats", array("altqstats")); - if ($_REQUEST['getactivity']) { /* calculate total packets being moved through all queues. */ $total_packets_s = 0; @@ -103,13 +106,13 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <?php -if(!is_array($config['shaper']['queue']) && count($config['shaper']['queue']) < 1) { +if(!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) { echo gettext("Traffic shaping is not configured."); include("fend.inc"); exit; } ?> - +<?php if (!$error): ?> <form action="status_queues.php" method="post"> <script type="text/javascript"> function getqueueactivity() { @@ -130,7 +133,11 @@ if(!is_array($config['shaper']['queue']) && count($config['shaper']['queue']) < setTimeout('getqueueactivity()', 150); }); </script> +<?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> +<?php if ($error): ?> + <tr><td><?php echo $error; ?></td></tr> +<?php else: ?> <tr> <td class="listhdr" colspan="1"><?=gettext("Queue"); ?></td> <td class="listhdr" colspan="6"><?=gettext("Statistics"); ?></td> @@ -167,6 +174,7 @@ if(!is_array($config['shaper']['queue']) && count($config['shaper']['queue']) < </tr> <tr><td class="vncell" bgcolor="#DDDDDD" colspan="7"> </td></tr> <?php $i++; endforeach; $total_queues = $i; ?> +<?php endif; ?> </table> <p> <strong><span class="red"><?=gettext("Note"); ?>:</span></strong><strong><br></strong> |