summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2014-02-04 12:33:29 -0200
committerRenato Botelho <garga@FreeBSD.org>2014-02-04 12:47:20 -0200
commit1eb03024fe15fcd8cdd20f32a9ba7c7f1fb75821 (patch)
tree6c5186c0184447c633776c795c3f10553e3c3876 /usr/local/www
parent46b12609e51b9b3113abc9c22a1b0ad5a2b37d11 (diff)
downloadpfsense-1eb03024fe15fcd8cdd20f32a9ba7c7f1fb75821.zip
pfsense-1eb03024fe15fcd8cdd20f32a9ba7c7f1fb75821.tar.gz
Add escapeshellarg() calls on exec parameters. While I'm here, replace some exec() calls by php functions like symlink, copy, unlink, mkdir
Conflicts: usr/local/www/diag_logs_vpn.php usr/local/www/firewall_aliases_edit.php usr/local/www/guiconfig.inc
Diffstat (limited to 'usr/local/www')
-rwxr-xr-xusr/local/www/crash_reporter.php8
-rwxr-xr-xusr/local/www/diag_arp.php2
-rwxr-xr-xusr/local/www/diag_logs_vpn.php4
-rw-r--r--usr/local/www/diag_smart.php4
-rwxr-xr-xusr/local/www/firewall_aliases_edit.php6
-rwxr-xr-xusr/local/www/guiconfig.inc24
-rwxr-xr-xusr/local/www/interfaces.php2
-rwxr-xr-xusr/local/www/services_wol.php2
8 files changed, 26 insertions, 26 deletions
diff --git a/usr/local/www/crash_reporter.php b/usr/local/www/crash_reporter.php
index d3146b8..853be0a 100755
--- a/usr/local/www/crash_reporter.php
+++ b/usr/local/www/crash_reporter.php
@@ -102,10 +102,10 @@ exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors);
if (gettext($_POST['Submit']) == "Yes") {
echo gettext("Processing...");
if (!is_dir("/var/crash"))
- mwexec("/bin/mkdir -p /var/crash");
+ mkdir("/var/crash", 0750, true);
@file_put_contents("/var/crash/crashreport_header.txt", $crash_report_header);
if(file_exists("/tmp/PHP_errors.log"))
- exec("cp /tmp/PHP_errors.log /var/crash/");
+ copy("/tmp/PHP_errors.log", "/var/crash/");
exec("/usr/bin/gzip /var/crash/*");
$files_to_upload = glob("/var/crash/*");
echo "<p/>";
@@ -114,7 +114,7 @@ exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors);
flush();
if(is_array($files_to_upload)) {
$resp = upload_crash_report($files_to_upload);
- exec("rm /var/crash/*");
+ array_map('unlink', glob("/var/crash/*"));
// Erase the contents of the PHP error log
fclose(fopen("/tmp/PHP_errors.log", 'w'));
echo "<p/>";
@@ -124,7 +124,7 @@ exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors);
echo "Could not find any crash files.";
}
} else if(gettext($_POST['Submit']) == "No") {
- exec("rm /var/crash/*");
+ array_map('unlink', glob("rm /var/crash/*"));
// Erase the contents of the PHP error log
fclose(fopen("/tmp/PHP_errors.log", 'w'));
Header("Location: /");
diff --git a/usr/local/www/diag_arp.php b/usr/local/www/diag_arp.php
index c24ca62..19f74f0 100755
--- a/usr/local/www/diag_arp.php
+++ b/usr/local/www/diag_arp.php
@@ -249,7 +249,7 @@ function _getHostName($mac,$ip) {
else if ($dhcpip[$ip])
return $dhcpip[$ip];
else{
- exec("host -W 1 $ip", $output);
+ exec("host -W 1 " . escapeshellarg($ip), $output);
if (preg_match('/.*pointer ([A-Za-z0-9.-]+)\..*/',$output[0],$matches)) {
if ($matches[1] <> $ip)
return $matches[1];
diff --git a/usr/local/www/diag_logs_vpn.php b/usr/local/www/diag_logs_vpn.php
index db64753..116655e 100755
--- a/usr/local/www/diag_logs_vpn.php
+++ b/usr/local/www/diag_logs_vpn.php
@@ -90,9 +90,9 @@ function dump_clog_vpn($logfile, $tail) {
$logarr = "";
if(isset($config['system']['usefifolog']))
- exec("/usr/sbin/fifolog_reader " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+ exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
else
- exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+ exec("/usr/sbin/clog " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
foreach ($logarr as $logent) {
$logent = preg_split("/\s+/", $logent, 6);
diff --git a/usr/local/www/diag_smart.php b/usr/local/www/diag_smart.php
index d7e8072..73f3405 100644
--- a/usr/local/www/diag_smart.php
+++ b/usr/local/www/diag_smart.php
@@ -85,7 +85,7 @@ function update_email($email)
if(!empty($email))
{
// Put it in the smartd.conf file
- shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN -H -m " . $email . "/' /usr/local/etc/smartd.conf");
+ shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN -H -m " . escapeshellarg($email) . "/' /usr/local/etc/smartd.conf");
}
// Nope
else
@@ -98,7 +98,7 @@ function update_email($email)
function smartmonctl($action)
{
global $start_script;
- shell_exec($start_script . $action);
+ shell_exec($start_script . escapeshellarg($action));
}
// What page, aka. action is being wanted
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php
index 304cfd6..8813235 100755
--- a/usr/local/www/firewall_aliases_edit.php
+++ b/usr/local/www/firewall_aliases_edit.php
@@ -73,7 +73,7 @@ if($_POST)
// Debugging
if($debug)
- exec("rm -f {$g['tmp_path']}/alias_rename_log.txt");
+ unlink("{$g['tmp_path']}/alias_rename_log.txt");
function alias_same_type($name, $type) {
global $config;
@@ -205,7 +205,7 @@ if ($_POST) {
$temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
unlink($temp_filename);
mwexec("/bin/mkdir -p {$temp_filename}");
- mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
+ mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" " . escapeshellarg($_POST['address' . $x]));
/* if the item is tar gzipped then extract */
if(stristr($_POST['address' . $x], ".tgz"))
process_alias_tgz($temp_filename);
@@ -245,7 +245,7 @@ if ($_POST) {
/* nothing was found */
$input_errors[] = sprintf(gettext("You must provide a valid URL. Could not fetch usable data from '%s'."), $_POST['address' . $x]);
}
- mwexec("/bin/rm -rf {$temp_filename}");
+ mwexec("/bin/rm -rf " . escapeshellarg($temp_filename));
} else {
$input_errors[] = sprintf(gettext("URL '%s' is not valid."), $_POST['address' . $x]);
}
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index 454e02a..daf5173 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -551,9 +551,9 @@ function clear_log_file($logfile = "/var/log/system.log") {
touch($logfile);
} else {
if(isset($config['system']['usefifolog']))
- exec("/usr/sbin/fifolog_create -s 511488 {$logfile}");
+ exec("/usr/sbin/fifolog_create -s 511488 " . escapeshellarg($logfile));
else
- exec("/usr/sbin/clog -i -s 511488 {$logfile}");
+ exec("/usr/sbin/clog -i -s 511488 " . escapeshellarg($logfile));
}
system_syslogd_start();
}
@@ -565,20 +565,20 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert
$grepline = " ";
if(is_array($grepfor))
foreach($grepfor as $agrep)
- $grepline .= " | grep \"$agrep\"";
+ $grepline .= " | grep " . escapeshellarg($agrep);
if(is_array($grepinvert))
foreach($grepinvert as $agrep)
- $grepline .= " | grep -v \"$agrep\"";
+ $grepline .= " | grep -v " . escapeshellarg($agrep);
if(file_exists($logfile) && filesize($logfile) == 0) {
$logarr = array("Log file started.");
} else {
if($config['system']['disablesyslogclog']) {
- exec("cat {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
if(isset($config['system']['usefifolog']))
- exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
else
- exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ exec("/usr/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
}
foreach ($logarr as $logent) {
@@ -610,17 +610,17 @@ function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinve
$grepline = " ";
if(is_array($grepfor))
foreach($grepfor as $agrep)
- $grepline .= " | grep \"$agrep\"";
+ $grepline .= " | grep " . escapeshellarg($agrep);
if(is_array($grepinvert))
foreach($grepinvert as $agrep)
- $grepline .= " | grep -v \"$agrep\"";
+ $grepline .= " | grep -v " . escapeshellarg($agrep);
if($config['system']['disablesyslogclog']) {
- exec("cat {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
if(isset($config['system']['usefifolog'])) {
- exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
- exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ exec("/usr/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
}
return($logarr);
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index 548e859..7e2fc73 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -1151,7 +1151,7 @@ function check_wireless_mode() {
if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
$input_errors[] = sprintf(gettext("Unable to change mode to %s. You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$wancfg['wireless']['mode']]);
} else {
- mwexec("/sbin/ifconfig {$wlanif}_ destroy");
+ mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
}
$wancfg['wireless']['mode'] = $old_wireless_mode;
}
diff --git a/usr/local/www/services_wol.php b/usr/local/www/services_wol.php
index f60a792..6494a07 100755
--- a/usr/local/www/services_wol.php
+++ b/usr/local/www/services_wol.php
@@ -95,7 +95,7 @@ if ($_POST || $_GET['mac']) {
else {
$bcip = gen_subnet_max($ipaddr, get_interface_subnet($if));
/* Execute wol command and check return code. */
- if(!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}"))
+ if(!mwexec("/usr/local/bin/wol -i {$bcip} " . escapeshellarg($mac)))
$savemsg .= sprintf(gettext("Sent magic packet to %s."),$mac);
else
$savemsg .= sprintf(gettext('Please check the %1$ssystem log%2$s, the wol command for %3$s did not complete successfully%4$s'),'<a href="/diag_logs.php">', '</a>', $mac, ".<br>");
OpenPOWER on IntegriCloud