From 9882cbef8e990c82498152d6831b91b27cfd0240 Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 4 Nov 2010 13:18:29 -0400 Subject: [PATCH 01/98] Use addslashes() here to prevent unescaped quotes from causing PHP errors. Fixes advanced/custom options in OpenVPN wizard. --- usr/local/www/wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/wizard.php b/usr/local/www/wizard.php index 9dc4d80059..965a2aa90e 100755 --- a/usr/local/www/wizard.php +++ b/usr/local/www/wizard.php @@ -155,7 +155,7 @@ function update_config_field($field, $updatetext, $unset, $arraynum, $field_type $text = "unset(\$config" . $field_conv . ");"; eval($text); } - $text = "\$config" . $field_conv . " = \"" . $updatetext . "\";"; + $text = "\$config" . $field_conv . " = \"" . addslashes($updatetext) . "\";"; eval($text); } From 428e66b61b7a511e059ad836f33367837288b71c Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 4 Nov 2010 14:30:50 -0400 Subject: [PATCH 02/98] Warn a user when entering the OpenVPN client/server screens that they need a CA/Cert if none exist. --- usr/local/www/vpn_openvpn_client.php | 34 +++++++++++++++++++++----- usr/local/www/vpn_openvpn_server.php | 36 ++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php index 4b23c950e7..93eb56c3b1 100644 --- a/usr/local/www/vpn_openvpn_client.php +++ b/usr/local/www/vpn_openvpn_client.php @@ -46,6 +46,21 @@ if (!is_array($config['openvpn']['openvpn-client'])) $a_client = &$config['openvpn']['openvpn-client']; +if (!is_array($config['ca'])) + $config['ca'] = array(); + +$a_ca =& $config['ca']; + +if (!is_array($config['cert'])) + $config['cert'] = array(); + +$a_cert =& $config['cert']; + +if (!is_array($config['crl'])) + $config['crl'] = array(); + +$a_crl =& $config['crl']; + $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; @@ -331,10 +346,17 @@ function autotls_change() { //--> Certificate Manager to make one."; +if (count($a_cert) == 0) + $savemsg .= "
You have no Certificates defined. You must visit the Certificate Manager to make one."; + +if ($input_errors) + print_input_errors($input_errors); +if ($savemsg) + print_info_box($savemsg); ?> @@ -610,7 +632,7 @@ function autotls_change() { + 1, or WAN with an if count of 1. + if (!isset($config['system']['webgui']['noantilockout']) && + (((count($config['interfaces']) > 1) && ($if == 'lan')) + || ((count($config['interfaces']) == 1) && ($if == 'wan')))): ?> + + + + + + + + + + + + + + + + + From c62d973d7d55db1ede92f93ceb61242dfe43b106 Mon Sep 17 00:00:00 2001 From: Warren Baker Date: Fri, 5 Nov 2010 20:33:01 +0200 Subject: [PATCH 04/98] Spelling fix. --- etc/inc/pkg-utils.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index adb2aa0ea4..cc27688174 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -953,7 +953,7 @@ function delete_package_xml($pkg) { update_output_window($static_output); } if($pkg_config['include_file'] <> "") { - $static_output = "\tRemoving pacakge instructions..."; + $static_output = "\tRemoving package instructions..."; update_output_window($static_output); fwrite($fd_log, "Remove '{$pkg_config['include_file']}'\n"); unlink_if_exists("/usr/local/pkg/" . $pkg_config['include_file']); From 50b2f6ab4c4bf786ea6921c16d7df569607b624a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Nov 2010 12:15:01 -0400 Subject: [PATCH 05/98] Ensure that we are working with a proper passed interface.. --- usr/local/www/status_graph.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php index ddcfd2d983..6397d753fb 100755 --- a/usr/local/www/status_graph.php +++ b/usr/local/www/status_graph.php @@ -54,10 +54,25 @@ if ($_POST['height']) else $height = "200"; -if ($_GET['if']) +$ifdescrs = array('wan' => gettext('WAN'), 'lan' => gettext('LAN')); + +for($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { + if(isset($config['interfaces']['opt' . $j]['enable'])) + $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; +} + +if ($_GET['if']) { $curif = $_GET['if']; -else + $found = false; + foreach($ifdescrs as $descr => $ifdescr) + if($descr == $curif) $found = true; + if(!$found) { + Header("Location: status_graph.php"); + exit; + } +} else { $curif = "wan"; +} $pgtitle = array(gettext("Status"),gettext("Traffic Graph")); @@ -72,7 +87,7 @@ include("head.inc"); ', $buffer); + } + if ($js = $GLOBALS['csrf']['rewrite-js']) { + $buffer = str_ireplace( + '', + ''. + '', + $buffer + ); + $script = ''; + $buffer = str_ireplace('', $script . '', $buffer, $count); + if (!$count) { + $buffer .= $script; + } + } + return $buffer; +} + +/** + * Checks if this is a post request, and if it is, checks if the nonce is valid. + * @param bool $fatal Whether or not to fatally error out if there is a problem. + * @return True if check passes or is not necessary, false if failure. + */ +function csrf_check($fatal = true) { + if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; + csrf_start(); + $name = $GLOBALS['csrf']['input-name']; + $ok = false; + $tokens = ''; + do { + if (!isset($_POST[$name])) break; + // we don't regenerate a token and check it because some token creation + // schemes are volatile. + $tokens = $_POST[$name]; + if (!csrf_check_tokens($tokens)) break; + $ok = true; + } while (false); + if ($fatal && !$ok) { + $callback = $GLOBALS['csrf']['callback']; + if (trim($tokens, 'A..Za..z0..9:;,') !== '') $tokens = 'hidden'; + $callback($tokens); + exit; + } + return $ok; +} + +/** + * Retrieves a valid token(s) for a particular context. Tokens are separated + * by semicolons. + */ +function csrf_get_tokens() { + $has_cookies = !empty($_COOKIE); + + // $ip implements a composite key, which is sent if the user hasn't sent + // any cookies. It may or may not be used, depending on whether or not + // the cookies "stick" + if (!$has_cookies && $secret) { + // :TODO: Harden this against proxy-spoofing attacks + $ip = ';ip:' . csrf_hash($_SERVER['IP_ADDRESS']); + } else { + $ip = ''; + } + csrf_start(); + + // These are "strong" algorithms that don't require per se a secret + if (session_id()) return 'sid:' . csrf_hash(session_id()) . $ip; + if ($GLOBALS['csrf']['cookie']) { + $val = csrf_generate_secret(); + setcookie($GLOBALS['csrf']['cookie'], $val); + return 'cookie:' . csrf_hash($val) . $ip; + } + if ($GLOBALS['csrf']['key']) return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip; + // These further algorithms require a server-side secret + if ($secret === '') return 'invalid'; + if ($GLOBALS['csrf']['user'] !== false) { + return 'user:' . csrf_hash($GLOBALS['csrf']['user']); + } + if ($GLOBALS['csrf']['allow-ip']) { + return ltrim($ip, ';'); + } + return 'invalid'; +} + +/** + * @param $tokens is safe for HTML consumption + */ +function csrf_callback($tokens) { + header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); + echo "CSRF check failedCSRF check failed. Please enable cookies.
Debug: ".$tokens." +"; +} + +/** + * Checks if a composite token is valid. Outward facing code should use this + * instead of csrf_check_token() + */ +function csrf_check_tokens($tokens) { + if (is_string($tokens)) $tokens = explode(';', $tokens); + foreach ($tokens as $token) { + if (csrf_check_token($token)) return true; + } + return false; +} + +/** + * Checks if a token is valid. + */ +function csrf_check_token($token) { + if (strpos($token, ':') === false) return false; + list($type, $value) = explode(':', $token, 2); + if (strpos($value, ',') === false) return false; + list($x, $time) = explode(',', $token, 2); + if ($GLOBALS['csrf']['expires']) { + if (time() > $time + $GLOBALS['csrf']['expires']) return false; + } + switch ($type) { + case 'sid': + return $value === csrf_hash(session_id(), $time); + case 'cookie': + $n = $GLOBALS['csrf']['cookie']; + if (!$n) return false; + if (!isset($_COOKIE[$n])) return false; + return $value === csrf_hash($_COOKIE[$n], $time); + case 'key': + if (!$GLOBALS['csrf']['key']) return false; + return $value === csrf_hash($GLOBALS['csrf']['key'], $time); + // We could disable these 'weaker' checks if 'key' was set, but + // that doesn't make me feel good then about the cookie-based + // implementation. + case 'user': + if ($GLOBALS['csrf']['secret'] === '') return false; + if ($GLOBALS['csrf']['user'] === false) return false; + return $value === csrf_hash($GLOBALS['csrf']['user'], $time); + case 'ip': + if (csrf_get_secret() === '') return false; + // do not allow IP-based checks if the username is set, or if + // the browser sent cookies + if ($GLOBALS['csrf']['user'] !== false) return false; + if (!empty($_COOKIE)) return false; + if (!$GLOBALS['csrf']['allow-ip']) return false; + return $value === csrf_hash($_SERVER['IP_ADDRESS'], $time); + } + return false; +} + +/** + * Sets a configuration value. + */ +function csrf_conf($key, $val) { + if (!isset($GLOBALS['csrf'][$key])) { + trigger_error('No such configuration ' . $key, E_USER_WARNING); + return; + } + $GLOBALS['csrf'][$key] = $val; +} + +/** + * Starts a session if we're allowed to. + */ +function csrf_start() { + if ($GLOBALS['csrf']['auto-session'] && !session_id()) { + session_start(); + } +} + +/** + * Retrieves the secret, and generates one if necessary. + */ +function csrf_get_secret() { + if ($GLOBALS['csrf']['secret']) return $GLOBALS['csrf']['secret']; + $dir = dirname(__FILE__); + $file = $dir . '/csrf-secret.php'; + $secret = ''; + if (file_exists($file)) { + include $file; + return $secret; + } + if (is_writable($dir)) { + $secret = csrf_generate_secret(); + $fh = fopen($file, 'w'); + fwrite($fh, ' Date: Tue, 9 Nov 2010 11:26:33 -0500 Subject: [PATCH 36/98] Revert --- etc/rc.php_ini_setup | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/rc.php_ini_setup b/etc/rc.php_ini_setup index b1565348b0..b2b6320bdc 100755 --- a/etc/rc.php_ini_setup +++ b/etc/rc.php_ini_setup @@ -162,7 +162,6 @@ zlib.output_compression = Off zlib.output_compression_level = 1 include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg" extension_dir=${EXTENSIONSDIR} -session.use_trans_sid = true ; Extensions From 034f08e7dd102c09e60184220927e6c5cba9f10c Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 9 Nov 2010 11:38:27 -0500 Subject: [PATCH 37/98] Fix Misc XSS issues --- usr/local/www/diag_dump_states.php | 8 ++++---- usr/local/www/fbegin.inc | 2 +- usr/local/www/status_rrd_graph.php | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/usr/local/www/diag_dump_states.php b/usr/local/www/diag_dump_states.php index a2009c9192..69d8dfd5d9 100755 --- a/usr/local/www/diag_dump_states.php +++ b/usr/local/www/diag_dump_states.php @@ -44,8 +44,8 @@ require_once("guiconfig.inc"); /* handle AJAX operations */ if($_GET['action']) { if($_GET['action'] == "remove") { - $srcip = $_GET['srcip']; - $dstip = $_GET['dstip']; + $srcip = escapeshellarg($_GET['srcip']); + $dstip = escapeshellarg($_GET['dstip']); if (is_ipaddr($srcip) and is_ipaddr($dstip)) { $retval = mwexec("/sbin/pfctl -k '{$srcip}' -k '{$dstip}'"); echo htmlentities("|{$srcip}|{$dstip}|{$retval}|"); @@ -58,7 +58,7 @@ if($_GET['action']) { /* get our states */ if($_GET['filter']) { - exec("/sbin/pfctl -s state | grep " . escapeshellarg($_GET['filter']), $states); + exec("/sbin/pfctl -s state | grep " . escapeshellarg(htmlspecialchars($_GET['filter'])), $states); } else { exec("/sbin/pfctl -s state", $states); @@ -135,7 +135,7 @@ include("head.inc");
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index eb1c0aac0c..12f8428085 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -221,7 +221,7 @@ if(! $g['disablehelpmenu']) { /* NOTICE ACKNOWLEDGE CODE by Erik Kristensen */ if ($_REQUEST['noticeaction'] == 'acknowledge') { - $notice_id = $_REQUEST['noticeid']; + $notice_id = htmlspecialchars($_REQUEST['noticeid']); close_notice($notice_id); } /**********************************************/ diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php index b4f6911fc2..48f57343eb 100755 --- a/usr/local/www/status_rrd_graph.php +++ b/usr/local/www/status_rrd_graph.php @@ -54,7 +54,7 @@ $databases = glob("*.rrd"); if ($_GET['cat']) { - $curcat = $_GET['cat']; + $curcat = htmlspecialchars($_GET['cat']); } else { if(! empty($config['rrd']['category'])) { $curcat = $config['rrd']['category']; @@ -281,7 +281,6 @@ function get_dates($curperiod, $graph) { return $dates; } - ?> From 506f6e90d401941ee7dc6d19b8dffe2281ed0a79 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 9 Nov 2010 13:07:55 -0500 Subject: [PATCH 38/98] Ensure csrf magic is loaded --- usr/local/www/guiconfig.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index 458488eeb3..4c68a32d30 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -34,6 +34,7 @@ /* Include authentication routines */ /* THIS MUST BE ABOVE ALL OTHER CODE */ +require_once("csrf/csrf-magic.php"); require_once("authgui.inc"); /* make sure nothing is cached */ From 12dfe8cad519114ec7dd2496766369884c43b719 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 9 Nov 2010 20:10:47 +0000 Subject: [PATCH 39/98] Fix display of queues on rules and layer7 containers. --- etc/inc/shaper.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index 201534cd57..aaf177bca7 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -3785,7 +3785,7 @@ function &get_unique_queue_list() { $qlist = array(); if (is_array($altq_list_queues)) { foreach ($altq_list_queues as $altq) { - if ($altq->GetEnabled()) + if ($altq->GetEnabled() == "") continue; $tmplist =& $altq->get_queue_list(); foreach ($tmplist as $qname => $link) { From 7673cdb5124ed1bcf355d120207fd3c908213050 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 9 Nov 2010 22:17:19 +0000 Subject: [PATCH 40/98] Use a shell script rather than bad hack to execute php code for pppoe periodic reset. --- etc/inc/interfaces.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 67bf69aa5a..273d7e93d5 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3438,7 +3438,13 @@ function setup_pppoe_reset_file($pppif, $iface="") { $cron_file = "{$g['varetc_path']}/pppoe_restart_{$pppif}"; if(!empty($iface) && !empty($pppif)){ - $cron_cmd = "#!/bin/sh\necho '' | /usr/local/bin/php -q"; + $cron_cmd = << Date: Tue, 9 Nov 2010 23:37:02 +0000 Subject: [PATCH 41/98] Correct this to make it actually work. This is also mentioned in Ticket #904 though it was already implemented. --- etc/inc/interfaces.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 273d7e93d5..37431bb956 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3235,7 +3235,7 @@ function interface_has_gateway($friendly) { global $config; if (!empty($config['interfaces'][$friendly])) { - if (substr($friendly, 0, 5) == "ovpnc") + if (substr($friendly, 0, 4) == "ovpnc") return true; $ifname = &$config['interfaces'][$friendly]; switch ($ifname['ipaddr']) { From 2545af0461093b7805bd467fcf9ae4d51a400fc3 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 00:28:14 -0700 Subject: [PATCH 42/98] Remove csrf-magic include from functions.inc -- it was causing problems with console PHP scripts. --- etc/inc/functions.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/inc/functions.inc b/etc/inc/functions.inc index de8e7ba24b..2eb2682b60 100644 --- a/etc/inc/functions.inc +++ b/etc/inc/functions.inc @@ -73,7 +73,6 @@ if(!function_exists("pfSenseHeader")) { /* END compatibility goo with HEAD */ /* include all configuration functions */ -require_once("csrf/csrf-magic.php"); require_once("interfaces.inc"); require_once("gwlb.inc"); require_once("services.inc"); From f0ce6758e81a036a6eee144549cbe9e4c72bbe8e Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 03:03:00 -0700 Subject: [PATCH 43/98] Add option to System: Firmware: Settings for running gitsync after installing an update, hidden/disabled if git has not been installed yet. --- etc/phpshellsessions/gitsync | 18 +++++++--- tmp/post_upgrade_command.php | 7 ++++ usr/local/www/system_firmware_settings.php | 38 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/etc/phpshellsessions/gitsync b/etc/phpshellsessions/gitsync index 6f7a53f267..9fa7079b7c 100644 --- a/etc/phpshellsessions/gitsync +++ b/etc/phpshellsessions/gitsync @@ -19,6 +19,10 @@ $CODIR = "/root/pfsense/"; global $argv; global $command_split; +// If this parameter is set, all interactive functions are disabled +// and neither PHP nor the web gui will be killed or restarted. +$upgrading = in_array("--upgrading", $argv); + unlink_if_exists("/tmp/config.cache"); if(!file_exists("/usr/local/bin/git")) { @@ -61,7 +65,7 @@ if(is_dir("$CODIR/pfSenseGITREPO/pfSenseGITREPO")) { if($command_split[2]) { $branch = $command_split[2]; } else { - if(!$argv[3]) { + if(!$argv[3] && !$upgrading) { echo "\nCurrent repository is $GIT_REPO\n"; echo "\nPlease select which branch you would like to sync against:\n\n"; foreach($branches as $branchname => $branchdesc) { @@ -98,7 +102,7 @@ foreach($branches as $branchname => $branchdesc) { $found = true; } if(!$found) { - if(isURL($branch)) { + if(isURL($branch) && !$upgrading) { echo "\n"; echo "NOTE: $branch was not found.\n\n"; $command = readline("Is this a custom GIT URL? [y]? "); @@ -142,7 +146,7 @@ if(file_exists("/root/.gitsync_merge")) { } } } -if(!$command_split[2] && !$argv[3]) { +if(!$command_split[2] && !$argv[3] && !$upgrading) { do { echo "\nAdd a custom RCS branch URL (HTTP) to merge in or press enter if done.\n\n"; $merge_repo = readline("> "); @@ -268,11 +272,15 @@ exec("mv $CODIR/pfSenseGITREPO/gitsync_temp.git $CODIR/pfSenseGITREPO/pfSenseGIT // Reset the repository to restore the deleted files exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard >/dev/null 2>/dev/null"); -post_cvssync_commands(); +if(!$upgrading) + post_cvssync_commands(); echo "===> Checkout complete.\n"; echo "\n"; -echo "Your system is now sync'd and PHP and Lighty will be restarted in 5 seconds.\n\n"; +if(!$upgrading) + echo "Your system is now sync'd and PHP and Lighty will be restarted in 5 seconds.\n\n"; +else + echo "Your system is now sync'd.\n\n"; function post_cvssync_commands() { echo "===> Removing FAST-CGI temporary files...\n"; diff --git a/tmp/post_upgrade_command.php b/tmp/post_upgrade_command.php index 907e3ab4aa..dfe9342d17 100755 --- a/tmp/post_upgrade_command.php +++ b/tmp/post_upgrade_command.php @@ -6,6 +6,13 @@ require_once("config.inc"); require_once("functions.inc"); + if(file_exists("/usr/local/bin/git") && isset($config['system']['gitsync']['synconupgrade'])) { + if(isset($config['system']['gitsync']['repositoryurl'])) + exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url " . escapeshellarg($config['system']['gitsync']['repositoryurl'])); + if(isset($config['system']['gitsync']['branch'])) + system("pfSsh.php playback gitsync " . escapeshellarg($config['system']['gitsync']['branch']) . " --upgrading"); + } + if($g['platform'] == "embedded") { $config['system']['enableserial'] = true; write_config(); diff --git a/usr/local/www/system_firmware_settings.php b/usr/local/www/system_firmware_settings.php index 216604a729..ea3c215cbe 100755 --- a/usr/local/www/system_firmware_settings.php +++ b/usr/local/www/system_firmware_settings.php @@ -57,11 +57,19 @@ if ($_POST) { else unset($config['system']['firmware']['allowinvalidsig']); + if($_POST['synconupgrade'] == "yes") + $config['system']['gitsync']['synconupgrade'] = true; + else + unset($config['system']['gitsync']['synconupgrade']); + $config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl']; + $config['system']['gitsync']['branch'] = $_POST['branch']; + write_config(); } } $curcfg = $config['system']['firmware']; +$gitcfg = $config['system']['gitsync']; $pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings")); include("head.inc"); @@ -156,6 +164,36 @@ function enable_altfirmwareurl(enable_over) { + + + + + + + + + + + + + + + + + + + + From daab67a170ddf38a76605e32a56874780e82b62d Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Nov 2010 09:49:21 -0500 Subject: [PATCH 44/98] Fix misc XSS issues from davey b --- usr/local/www/diag_logs.php | 4 ++-- usr/local/www/diag_logs_filter.php | 4 ++-- usr/local/www/diag_logs_vpn.php | 4 ++-- usr/local/www/firewall_shaper.php | 10 +++++----- usr/local/www/firewall_shaper_vinterface.php | 14 +++++++------- usr/local/www/status_dhcp_leases.php | 2 +- usr/local/www/status_services.php | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/usr/local/www/diag_logs.php b/usr/local/www/diag_logs.php index 145d4800ca..35b6231a84 100755 --- a/usr/local/www/diag_logs.php +++ b/usr/local/www/diag_logs.php @@ -54,10 +54,10 @@ if ($_POST['clear']) clear_log_file($system_logfile); if ($_GET['filtertext']) - $filtertext = $_GET['filtertext']; + $filtertext = htmlspecialchars($_GET['filtertext']); if ($_POST['filtertext']) - $filtertext = $_POST['filtertext']; + $filtertext = htmlspecialchars($_POST['filtertext']); if ($filtertext) $filtertextmeta="?filtertext=$filtertext"; diff --git a/usr/local/www/diag_logs_filter.php b/usr/local/www/diag_logs_filter.php index 02b2591517..025a7a39d7 100755 --- a/usr/local/www/diag_logs_filter.php +++ b/usr/local/www/diag_logs_filter.php @@ -73,9 +73,9 @@ if($_GET['dnsip'] or $_POST['dnsip']) { $filtertext = ""; if($_GET['filtertext'] or $_POST['filtertext']) { if($_GET['filtertext']) - $filtertext = $_GET['filtertext']; + $filtertext = htmlspecialchars($_GET['filtertext']); if($_POST['filtertext']) - $filtertext = $_POST['filtertext']; + $filtertext = htmlspecialchars($_POST['filtertext']); } $filter_logfile = "{$g['varlog_path']}/filter.log"; diff --git a/usr/local/www/diag_logs_vpn.php b/usr/local/www/diag_logs_vpn.php index 36bdb58407..adef3e1e9b 100755 --- a/usr/local/www/diag_logs_vpn.php +++ b/usr/local/www/diag_logs_vpn.php @@ -49,8 +49,8 @@ $nentries = $config['syslog']['nentries']; if (!$nentries) $nentries = 50; -$vpntype = ($_GET['vpntype']) ? $_GET['vpntype'] : "pptp"; -$mode = ($_GET['mode']) ? $_GET['mode'] : "login"; +$vpntype = (htmlspecialchars($_GET['vpntype'])) ? htmlspecialchars($_GET['vpntype']) : "pptp"; +$mode = (htmlspecialchars($_GET['mode'])) ? htmlspecialchars($_GET['mode']) : "login"; if ($_POST['clear']) clear_log_file("/var/log/vpn.log"); diff --git a/usr/local/www/firewall_shaper.php b/usr/local/www/firewall_shaper.php index 7de18d1e48..f3cdbab185 100755 --- a/usr/local/www/firewall_shaper.php +++ b/usr/local/www/firewall_shaper.php @@ -65,17 +65,17 @@ if ($_GET) { if ($_GET['queue']) $qname = trim($_GET['queue']); if ($_GET['interface']) - $interface = trim($_GET['interface']); + $interface = htmlspecialchars(trim($_GET['interface'])); if ($_GET['action']) - $action = $_GET['action']; + $action = htmlspecialchars($_GET['action']); } if ($_POST) { if ($_POST['name']) - $qname = trim($_POST['name']); + $qname = htmlspecialchars(trim($_POST['name'])); if ($_POST['interface']) - $interface = trim($_POST['interface']); + $interface = htmlspecialchars(trim($_POST['interface'])); if ($_POST['parentqueue']) - $parentqueue = trim($_POST['parentqueue']); + $parentqueue = htmlspecialchars(trim($_POST['parentqueue'])); } if ($interface) { diff --git a/usr/local/www/firewall_shaper_vinterface.php b/usr/local/www/firewall_shaper_vinterface.php index 52f86987c2..865f048cd9 100644 --- a/usr/local/www/firewall_shaper_vinterface.php +++ b/usr/local/www/firewall_shaper_vinterface.php @@ -62,21 +62,21 @@ read_dummynet_config(); if ($_GET) { if ($_GET['queue']) - $qname = trim($_GET['queue']); + $qname = htmlspecialchars(trim($_GET['queue'])); if ($_GET['pipe']) - $pipe = trim($_GET['pipe']); + $pipe = htmlspecialchars(trim($_GET['pipe'])); if ($_GET['action']) - $action = $_GET['action']; + $action = htmlspecialchars($_GET['action']); } if ($_POST) { if ($_POST['name']) - $qname = trim($_POST['name']); + $qname = htmlspecialchars(trim($_POST['name'])); if ($_POST['pipe']) - $pipe = trim($_POST['pipe']); + $pipe = htmlspecialchars(trim($_POST['pipe'])); else - $pipe = trim($_POST['name']); + $pipe = htmlspecialchars(trim($_POST['name'])); if ($_POST['parentqueue']) - $parentqueue = trim($_POST['parentqueue']); + $parentqueue = htmlspecialchars(trim($_POST['parentqueue'])); } if ($pipe) { diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php index f7981c8525..dd2a0db38b 100755 --- a/usr/local/www/status_dhcp_leases.php +++ b/usr/local/www/status_dhcp_leases.php @@ -393,7 +393,7 @@ foreach ($leases as $data) {
Certificate Manager to make one."; +if (count($a_cert) == 0) + $savemsg .= "
You have no Certificates defined. You must visit the Certificate Manager to make one."; + +if ($input_errors) + print_input_errors($input_errors); +if ($savemsg) + print_info_box_np($savemsg); ?> @@ -716,7 +738,7 @@ function netbios_change() {
Date: Fri, 5 Nov 2010 10:12:28 -0400 Subject: [PATCH 03/98] If the anti-lockout rule is active, show it in the rules list for the LAN interface (or WAN if the interface count is 1, same rules as in filter.inc for putting the rule in the ruleset) --- usr/local/www/firewall_rules.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index cdd417a9e5..26b9513daa 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -370,6 +370,38 @@ if($_REQUEST['undodrag']) {
 *** Address*** + + + + + + + + + +
">" width="17" height="17" border="0">
" width="17" height="17" border="0">
+
  - + " />
 
+ /> +
+ +
+ +
+ +
+ +
 

- + "> diff --git a/usr/local/www/status_services.php b/usr/local/www/status_services.php index 97aa1ce4ca..779e396243 100755 --- a/usr/local/www/status_services.php +++ b/usr/local/www/status_services.php @@ -104,7 +104,7 @@ if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) { restart_service($_GET['service']); break; } - $savemsg = sprintf(gettext("%s has been restarted."),$_GET['service']); + $savemsg = sprintf(gettext("%s has been restarted."),htmlspecialchars($_GET['service'])); sleep(5); } @@ -148,7 +148,7 @@ if($_GET['mode'] == "startservice" and !empty($_GET['service'])) { start_service($_GET['service']); break; } - $savemsg = sprintf(gettext("%s has been started."),$_GET['service']); + $savemsg = sprintf(gettext("%s has been started."),htmlspecialchars($_GET['service'])); sleep(5); } @@ -203,7 +203,7 @@ if($_GET['mode'] == "stopservice" && !empty($_GET['service'])) { stop_service($_GET['service']); break; } - $savemsg = sprintf(gettext("%s has been stopped."), $_GET['service']); + $savemsg = sprintf(gettext("%s has been stopped."), htmlspecialchars($_GET['service'])); sleep(5); } From 4fe9c2dcf1c90253b2b6a70e67b06c76ff251b35 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Nov 2010 11:56:23 -0500 Subject: [PATCH 45/98] * Adding function get_configured_ip_addresses() which returns all interfaces and their configured IP address * Add checkbox to System -> Advanced -> Admin for HTTP_REFERER checks * Add and enforce HTTP_REFERER check if checkbox is not checked. This will prevent HTML pages from crafting HTML GETs against the web interface and will prevent firewall admins from being "tricked" into clicking on links that may be harmful to their firewall. --- etc/inc/auth.inc | 26 +++++++++++++++++++++++++ etc/inc/authgui.inc | 2 +- etc/inc/util.inc | 15 ++++++++++++++ usr/local/www/system_advanced_admin.php | 20 ++++++++++++++++++- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 13ca678366..e7484c182b 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -86,6 +86,32 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][ } } +// If the HTTP_REFERER is something other than ourselves then disallow. +if(!$config['system']['nohttpreferercheck']) { + if($_SERVER['HTTP_REFERER']) { + $found_host = false; + $hostname_me = $config['system']['hostname'] . "." . $config['system']['domain']; + if(stristr($_SERVER['HTTP_REFERER'], $hostname_me)) + $found_host = true; + if(!empty($config['system']['webgui']['althostnames'])) { + $althosts = explode(" ", $config['system']['webgui']['althostnames']); + foreach ($althosts as $ah) + if(stristr($ah, $hostname_me)) + $found_host = true; + } + $interface_list_ips = get_configured_ip_addresses(); + foreach($interface_list_ips as $ilips) { + $hostname_me_ip = $config['webgui']['protocol'] . "://" . $ilips; + if(stristr($hostname_me_ip, $ilips)) + $found_host = true; + } + if($found_host == false) { + display_error_form("501", "An HTTP_REFERER was detected other than what is defined in System -> Advanced (" . $_SERVER['HTTP_REFERER'] . "). You can disable this check if needed in System -> Advanced -> Admin."); + exit; + } + } +} + $groupindex = index_groups(); $userindex = index_users(); diff --git a/etc/inc/authgui.inc b/etc/inc/authgui.inc index e0bea3dfd9..ee98f1c566 100644 --- a/etc/inc/authgui.inc +++ b/etc/inc/authgui.inc @@ -261,4 +261,4 @@ if($config['virtualip']) +?> \ No newline at end of file diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 0551d40060..4b74a7f611 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -624,6 +624,21 @@ function get_configured_interface_with_descr($only_opt = false, $withdisabled = return $iflist; } +/* + * get_configured_ip_addresses() - Return a list of all configured + * interfaces IP Addresses + * + */ +function get_configured_ip_addresses() { + require_once("interfaces.inc"); + $ip_array = array(); + $interfaces = get_configured_interface_list(); + foreach($interfaces as $int) { + $ipaddr = get_interface_ip($int); + $ip_array[$int] = $ipaddr; + } + return $ip_array; +} /* * get_interface_list() - Return a list of all physical interfaces diff --git a/usr/local/www/system_advanced_admin.php b/usr/local/www/system_advanced_admin.php index f34d1c7152..7875802eec 100644 --- a/usr/local/www/system_advanced_admin.php +++ b/usr/local/www/system_advanced_admin.php @@ -3,7 +3,7 @@ /* system_advanced_admin.php part of pfSense - Copyright (C) 2005-2007 Scott Ullrich + Copyright (C) 2005-2010 Scott Ullrich Copyright (C) 2008 Shrew Soft Inc @@ -56,6 +56,7 @@ $pconfig['disablehttpredirect'] = isset($config['system']['webgui']['disablehttp $pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']); $pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']); $pconfig['nodnsrebindcheck'] = isset($config['system']['webgui']['nodnsrebindcheck']); +$pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']); $pconfig['althostnames'] = $config['system']['webgui']['althostnames']; $pconfig['enableserial'] = $config['system']['enableserial']; $pconfig['enablesshd'] = $config['system']['enablesshd']; @@ -140,6 +141,11 @@ if ($_POST) { else unset($config['system']['webgui']['nodnsrebindcheck']); + if ($_POST['nohttpreferercheck'] == "yes") + $config['system']['webgui']['nohttpreferercheck'] = true; + else + unset($config['system']['webgui']['nohttpreferercheck']); + if ($_POST['althostnames']) $config['system']['webgui']['althostnames'] = $_POST['althostnames']; else @@ -359,6 +365,18 @@ function prot_change() { "bypass the DNS Rebinding Attack checks. Separate hostnames with spaces."); ?> + + + + /> + +
+ Wikipedia."); ?> + +   From 9734b0545e77614ec89f3848432212a809fb9a26 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Nov 2010 12:00:32 -0500 Subject: [PATCH 46/98] Remove trailing carriage return --- etc/inc/IPv6.inc | 2 +- etc/inc/PEAR.inc | 1 + etc/inc/auth.inc | 2 +- etc/inc/certs.inc | 2 +- etc/inc/config.lib.inc | 2 +- etc/inc/dyndns.class | 2 +- etc/inc/easyrule.inc | 3 ++- etc/inc/filter.inc | 3 ++- etc/inc/globals.inc | 3 ++- etc/inc/growl.class | 2 +- etc/inc/gwlb.inc | 2 +- etc/inc/interfaces.inc | 2 +- etc/inc/ipsec.inc | 2 +- etc/inc/itemid.inc | 2 +- etc/inc/led.inc | 1 + etc/inc/meta.inc | 2 +- etc/inc/notices.inc | 2 +- etc/inc/openvpn.auth-user.php | 2 +- etc/inc/openvpn.inc | 2 +- etc/inc/pfsense-utils.inc | 2 +- etc/inc/pkg-utils.inc | 2 +- etc/inc/priv.defs.inc | 2 +- etc/inc/priv.inc | 2 +- etc/inc/radius.inc | 2 +- etc/inc/rrd.inc | 2 +- etc/inc/service-utils.inc | 2 +- etc/inc/services.inc | 2 +- etc/inc/shaper.inc | 2 +- etc/inc/system.inc | 2 +- etc/inc/upgrade_config.inc | 3 ++- etc/inc/util.inc | 2 +- etc/inc/vpn.inc | 3 ++- etc/inc/wizardapp.inc | 2 +- etc/inc/xmlparse.inc | 2 +- etc/inc/xmlparse_attr.inc | 2 +- etc/inc/xmlreader.inc | 2 +- 36 files changed, 41 insertions(+), 34 deletions(-) diff --git a/etc/inc/IPv6.inc b/etc/inc/IPv6.inc index 8896ef6627..f7e85deaa4 100644 --- a/etc/inc/IPv6.inc +++ b/etc/inc/IPv6.inc @@ -919,4 +919,4 @@ class Net_IPv6 { * End: */ -?> +?> \ No newline at end of file diff --git a/etc/inc/PEAR.inc b/etc/inc/PEAR.inc index 26d11596bf..68d30fa136 100644 --- a/etc/inc/PEAR.inc +++ b/etc/inc/PEAR.inc @@ -1056,4 +1056,5 @@ class PEAR_Error * c-basic-offset: 4 * End: */ + ?> \ No newline at end of file diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index e7484c182b..d4e0875297 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -1270,4 +1270,4 @@ function session_auth() { return true; } -?> +?> \ No newline at end of file diff --git a/etc/inc/certs.inc b/etc/inc/certs.inc index f177c9e274..33aac66d18 100644 --- a/etc/inc/certs.inc +++ b/etc/inc/certs.inc @@ -556,4 +556,4 @@ function is_crl_internal($crl) { return !(!empty($crl['text']) && empty($crl['cert'])); } -?> +?> \ No newline at end of file diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index 7b27b7a81a..4feef0f615 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -803,4 +803,4 @@ function set_device_perms() { } } -?> +?> \ No newline at end of file diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index a07a7937b1..247fa680ab 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -921,4 +921,4 @@ } -?> +?> \ No newline at end of file diff --git a/etc/inc/easyrule.inc b/etc/inc/easyrule.inc index af3f270aaf..0679060b66 100644 --- a/etc/inc/easyrule.inc +++ b/etc/inc/easyrule.inc @@ -329,4 +329,5 @@ function easyrule_parse_pass($int, $proto, $src, $dst, $dstport = 0) { } return "Unknown pass error."; } -?> + +?> \ No newline at end of file diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 2e5360735e..d1bc9046d0 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -2722,4 +2722,5 @@ function discover_pkg_rules($ruletype) { } // vim: ts=4 sw=4 noexpandtab -?> + +?> \ No newline at end of file diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 5196dac7b6..b8593dca7c 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -165,4 +165,5 @@ $sysctls = array("net.inet.ip.portrange.first" => "1024", ); $config_inc_loaded = false; -?> + +?> \ No newline at end of file diff --git a/etc/inc/growl.class b/etc/inc/growl.class index 883ec8bf82..33650ca8d0 100644 --- a/etc/inc/growl.class +++ b/etc/inc/growl.class @@ -99,4 +99,4 @@ } } -?> +?> \ No newline at end of file diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 540a0a742c..7362c373ae 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -532,4 +532,4 @@ function get_interface_gateway($interface, &$dynamic = false) { return ($gw); } -?> +?> \ No newline at end of file diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 37431bb956..e0f29d2577 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3452,4 +3452,4 @@ EOD; unlink_if_exists($cron_file); } -?> +?> \ No newline at end of file diff --git a/etc/inc/ipsec.inc b/etc/inc/ipsec.inc index 0dd0fe0ad0..a46e596606 100644 --- a/etc/inc/ipsec.inc +++ b/etc/inc/ipsec.inc @@ -463,4 +463,4 @@ function ipsec_mobilekey_sort() { usort($config['ipsec']['mobilekey'], "mobilekeycmp"); } -?> +?> \ No newline at end of file diff --git a/etc/inc/itemid.inc b/etc/inc/itemid.inc index dde376260a..787760d728 100644 --- a/etc/inc/itemid.inc +++ b/etc/inc/itemid.inc @@ -103,4 +103,4 @@ function get_unique_id(){ return uniqid("nat_", true); } -?> +?> \ No newline at end of file diff --git a/etc/inc/led.inc b/etc/inc/led.inc index ed67db514c..3f615baad6 100644 --- a/etc/inc/led.inc +++ b/etc/inc/led.inc @@ -350,4 +350,5 @@ function char_to_morse($char) { break; } } + ?> \ No newline at end of file diff --git a/etc/inc/meta.inc b/etc/inc/meta.inc index 30903191ed..4091eac225 100644 --- a/etc/inc/meta.inc +++ b/etc/inc/meta.inc @@ -197,4 +197,4 @@ function read_file_metadata($fpath, & $metadata, $taglist = false) { $metadata[$fname] = $tags; } -?> +?> \ No newline at end of file diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc index fadd92bdba..34cbd82b2e 100644 --- a/etc/inc/notices.inc +++ b/etc/inc/notices.inc @@ -379,4 +379,4 @@ function register_via_growl() { } } -?> +?> \ No newline at end of file diff --git a/etc/inc/openvpn.auth-user.php b/etc/inc/openvpn.auth-user.php index 544e21f32a..460d681776 100755 --- a/etc/inc/openvpn.auth-user.php +++ b/etc/inc/openvpn.auth-user.php @@ -121,4 +121,4 @@ syslog(LOG_WARNING, "user {$username} authenticated\n"); exit(0); -?> +?> \ No newline at end of file diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 341044c374..2750d01ff7 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -935,4 +935,4 @@ function openvpn_refresh_crls() { } } -?> +?> \ No newline at end of file diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index ba774b76d4..d251ff262a 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2116,4 +2116,4 @@ function get_country_name($country_code) { return ""; } -?> +?> \ No newline at end of file diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index ec999ab0ac..49fd2c5d78 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -1078,4 +1078,4 @@ function squash_from_bytes($size, $round = "") { return; } -?> +?> \ No newline at end of file diff --git a/etc/inc/priv.defs.inc b/etc/inc/priv.defs.inc index 7025a95b0c..6ba46d4fef 100644 --- a/etc/inc/priv.defs.inc +++ b/etc/inc/priv.defs.inc @@ -1164,4 +1164,4 @@ $priv_list['page-firewall-schedules-edit']['match'][] = "firewall_schedule_edit. $priv_rmvd = array(); -?> +?> \ No newline at end of file diff --git a/etc/inc/priv.inc b/etc/inc/priv.inc index fa8092351c..f150aafced 100644 --- a/etc/inc/priv.inc +++ b/etc/inc/priv.inc @@ -285,4 +285,4 @@ function getAllowedPages($username) { return $allowed_pages; } -?> +?> \ No newline at end of file diff --git a/etc/inc/radius.inc b/etc/inc/radius.inc index dddacc30cd..459b0cfd25 100644 --- a/etc/inc/radius.inc +++ b/etc/inc/radius.inc @@ -1126,4 +1126,4 @@ class Auth_RADIUS_Acct_Update extends Auth_RADIUS_Acct var $status_type = RADIUS_UPDATE; } -?> +?> \ No newline at end of file diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index aaf4256aa5..f8f027b9aa 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -695,4 +695,4 @@ function kill_traffic_collector() { mwexec("/bin/pkill -f updaterrd.sh", true); } -?> +?> \ No newline at end of file diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 3f102b13e9..35889536cd 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -207,4 +207,4 @@ function is_service_running($service, $ps = "") { return false; } -?> +?> \ No newline at end of file diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 68a7128466..79c20d265d 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -1377,4 +1377,4 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont configure_cron(); } -?> +?> \ No newline at end of file diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index aaf177bca7..02a1cd79fc 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -4006,4 +4006,4 @@ $dn_default_shaper_msg .= ""; -?> +?> \ No newline at end of file diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 68e666cd34..80cabea30c 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -1488,4 +1488,4 @@ function system_get_dmesg_boot() { return file_get_contents("{$g['varlog_path']}/dmesg.boot"); } -?> +?> \ No newline at end of file diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index 2bffa83e59..7bf8f2e930 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -2272,4 +2272,5 @@ function upgrade_074_to_075() { if (is_array($config['crl'])) rename_field($config['crl'], 'name', 'descr'); } -?> + +?> \ No newline at end of file diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 4b74a7f611..63b76da4a0 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -1447,4 +1447,4 @@ function array_merge_recursive_unique($array0, $array1) return $result; } -?> +?> \ No newline at end of file diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc index 855756b093..7c045d20c1 100644 --- a/etc/inc/vpn.inc +++ b/etc/inc/vpn.inc @@ -1720,4 +1720,5 @@ function vpn_ipsec_configure_preferoldsa() { else mwexec("/sbin/sysctl net.key.preferred_oldsa=0"); } -?> + +?> \ No newline at end of file diff --git a/etc/inc/wizardapp.inc b/etc/inc/wizardapp.inc index bb9a6e4c47..2a2392ab45 100644 --- a/etc/inc/wizardapp.inc +++ b/etc/inc/wizardapp.inc @@ -345,4 +345,4 @@ $othersplist = array(); $othersplist['slingbox'][] = array('Slingbox2', 'udp', '5001', '5001', 'both'); -?> +?> \ No newline at end of file diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc index 118a97bb6b..582f9b4613 100644 --- a/etc/inc/xmlparse.inc +++ b/etc/inc/xmlparse.inc @@ -291,4 +291,4 @@ function dump_xml_config_raw($arr, $rootobj) { return $xmlconfig; } -?> +?> \ No newline at end of file diff --git a/etc/inc/xmlparse_attr.inc b/etc/inc/xmlparse_attr.inc index 06d02c48a3..802d335346 100644 --- a/etc/inc/xmlparse_attr.inc +++ b/etc/inc/xmlparse_attr.inc @@ -224,4 +224,4 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst return $parsedcfg[$rootobj]; } -?> +?> \ No newline at end of file diff --git a/etc/inc/xmlreader.inc b/etc/inc/xmlreader.inc index 3d21be1272..a228cd0199 100644 --- a/etc/inc/xmlreader.inc +++ b/etc/inc/xmlreader.inc @@ -211,4 +211,4 @@ function dump_xml_config_raw($arr, $rootobj) { return $xmlconfig; } -?> +?> \ No newline at end of file From 612fa5724a9eb132434a803d020f9e2d0b74a471 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Nov 2010 12:25:05 -0500 Subject: [PATCH 47/98] Note that this textbox controls HTTP_REFERER hostname checks as well --- usr/local/www/system_advanced_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/system_advanced_admin.php b/usr/local/www/system_advanced_admin.php index 7875802eec..8d00cd2289 100644 --- a/usr/local/www/system_advanced_admin.php +++ b/usr/local/www/system_advanced_admin.php @@ -359,7 +359,7 @@ function prot_change() {
- +
From 0bb2879551389e31286ee1a9b56071273a8a5e33 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Nov 2010 12:45:49 -0500 Subject: [PATCH 48/98] Correct HTTP_REFERER check when using an IP Address vs the Firewalls hostname --- etc/inc/auth.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index d4e0875297..443c9dc4cc 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -102,7 +102,7 @@ if(!$config['system']['nohttpreferercheck']) { $interface_list_ips = get_configured_ip_addresses(); foreach($interface_list_ips as $ilips) { $hostname_me_ip = $config['webgui']['protocol'] . "://" . $ilips; - if(stristr($hostname_me_ip, $ilips)) + if(stristr($_SERVER['HTTP_REFERER'],$hostname_me_ip)) $found_host = true; } if($found_host == false) { From c422a1699881a79dd96efbb40c19c930da0b7448 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 18:18:36 +0000 Subject: [PATCH 49/98] Actually was coorect before. 3rd parameter is length not index. Revert "Correct this to make it actually work. This is also mentioned in Ticket #904 though it was already implemented." This reverts commit 6f2cc3a680f984ccbb387301a26d022e6969e665. --- etc/inc/interfaces.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index e0f29d2577..f5848d6877 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3235,7 +3235,7 @@ function interface_has_gateway($friendly) { global $config; if (!empty($config['interfaces'][$friendly])) { - if (substr($friendly, 0, 4) == "ovpnc") + if (substr($friendly, 0, 5) == "ovpnc") return true; $ifname = &$config['interfaces'][$friendly]; switch ($ifname['ipaddr']) { From f6b30142f7f6cdc3d20ffd187be3dc528fd88cdc Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 18:25:38 +0000 Subject: [PATCH 50/98] Ticket #904. Actually correctly handle the assigned openvpn client as a dynamic gateway rather than breaking the behaviour of the system. Strange nobody has noticed broken gateway behaviour with openvpn assigned! --- etc/inc/interfaces.inc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index f5848d6877..aa1a3a05b8 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3208,9 +3208,6 @@ function get_interfaces_with_gateway() { /* loop interfaces, check config for outbound */ foreach($config['interfaces'] as $ifdescr => $ifname) { - if (substr($ifdescr, 0, 5) == "ovpnc") - return true; - switch ($ifname['ipaddr']) { case "dhcp": case "carpdev-dhcp": @@ -3222,7 +3219,8 @@ function get_interfaces_with_gateway() { $ints[$ifdescr] = $ifdescr; break; default: - if (!empty($ifname['gateway'])) + if (substr($ifname['if'], 0, 5) == "ovpnc" || + !empty($ifname['gateway'])) $ints[$ifdescr] = $ifdescr; break; } @@ -3452,4 +3450,4 @@ EOD; unlink_if_exists($cron_file); } -?> \ No newline at end of file +?> From e9d7afeb4ee833c506f7a9d73639de7367408623 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 18:27:51 +0000 Subject: [PATCH 51/98] Ticket #904. Hmm fix the interface_has_gateway() too. --- etc/inc/interfaces.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index aa1a3a05b8..bffb152761 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3233,8 +3233,6 @@ function interface_has_gateway($friendly) { global $config; if (!empty($config['interfaces'][$friendly])) { - if (substr($friendly, 0, 5) == "ovpnc") - return true; $ifname = &$config['interfaces'][$friendly]; switch ($ifname['ipaddr']) { case "dhcp": @@ -3246,6 +3244,8 @@ function interface_has_gateway($friendly) { return true; break; default: + if (substr($ifname['if'], 0, 5) == "ovpnc") + return true; if (!empty($ifname['gateway'])) return true; break; From 7f8d463f112558978a0c6f5ea57b071c7e4741a2 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 18:43:01 +0000 Subject: [PATCH 52/98] Bring interfaces up only if there is a mismatch to allow them to be reassigned. --- etc/rc | 3 --- etc/rc.bootup | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/etc/rc b/etc/rc index c4c1df3642..ab1b46092c 100755 --- a/etc/rc +++ b/etc/rc @@ -349,9 +349,6 @@ echo -n "Launching the init system..." /bin/rm -f /cf/conf/backup/backup.cache /bin/rm -f /root/lighttpd* /usr/bin/touch $varrunpath/booting -for iface in `/sbin/ifconfig -l`; do - /sbin/ifconfig $iface up -done /etc/rc.bootup # If a shell was selected from recovery diff --git a/etc/rc.bootup b/etc/rc.bootup index b61130a619..2d39df625f 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -157,9 +157,6 @@ echo "Loading configuration..."; parse_config_bootup(); echo "done.\n"; -$lan_if = $config['interfaces']['lan']['if']; -$wan_if = get_real_interface(); - /* * Determine if we need to throw a interface exception * and ask the user to reassign interfaces. This will @@ -168,6 +165,11 @@ $wan_if = get_real_interface(); while(is_interface_mismatch() == true) { led_assigninterfaces(); echo "\nNetwork interface mismatch -- Running interface assignment option.\n"; + $ifaces = get_interface_list(); + if (is_array($ifaces)) { + foreach($ifaces as $iface => $ifdata) + interfaces_bring_up($iface); + } set_networking_interfaces_ports(); led_kitt(); } From 35d26b25a179e02745e22875a31d0465f48a8b9e Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 19:16:06 +0000 Subject: [PATCH 53/98] Not sure why sometimes works sometimes does not work when bound to localhost the lighttpd instance of CP. Back to previous setup! Though security of it is debatble. --- etc/inc/system.inc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 80cabea30c..5934fecf80 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -1005,14 +1005,6 @@ url.access-deny = ( "~", ".inc" ) ######### Options that are good to be but not neccesary to be changed ####### ## bind to port (default: 80) - -EOD; - - if($captive_portal == true) - $lighty_config .= "server.bind = \"127.0.0.1\"\n"; - - $lighty_config .= << \ No newline at end of file +?> From b06d7ebb1d1d6468b180ddf24376c3f1063de625 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 19:34:24 +0000 Subject: [PATCH 54/98] Use exec and check return value of command to avoid priting messages of stderr to console. --- etc/inc/filter.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index d1bc9046d0..71030d6803 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -126,9 +126,9 @@ function filter_pflog_start() { echo "filter_pflog_start() being called $mt\n"; } mute_kernel_msgs(); - $pid = 0; - $pid = `/bin/pgrep -f "tcpdump -s 256 -v -l -n -e -ttt -i pflog0"`; - if(!$pid) + $output = 0; + exec("/bin/pgrep -f 'tcpdump -s 256 -v -l -n -e -ttt -i pflog0'", $output, $retval); + if($retval != 0) mwexec_bg("/usr/sbin/tcpdump -s 256 -v -l -n -e -ttt -i pflog0 | logger -t pf -p local0.info"); unmute_kernel_msgs(); } @@ -2723,4 +2723,4 @@ function discover_pkg_rules($ruletype) { // vim: ts=4 sw=4 noexpandtab -?> \ No newline at end of file +?> From fa11243673d97addd1af1c08117a03462253acce Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 19:40:56 +0000 Subject: [PATCH 55/98] Use php calls rather than forking to shell. --- etc/inc/pfsense-utils.inc | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index d251ff262a..6bd167135a 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -149,22 +149,13 @@ function get_tmp_file() { ******/ function get_dns_servers() { $dns_servers = array(); - $dns = `cat /etc/resolv.conf`; - $dns_s = split("\n", $dns); + $dns_s = file("/etc/resolv.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach($dns_s as $dns) { $matches = ""; if (preg_match("/nameserver (.*)/", $dns, $matches)) $dns_servers[] = $matches[1]; } - $dns_server_master = array(); - $lastseen = ""; - foreach($dns_servers as $t) { - if($t <> $lastseen) - if($t <> "") - $dns_server_master[] = $t; - $lastseen = $t; - } - return $dns_server_master; + return array_unique($dns_servers); } /****f* pfsense-utils/enable_hardware_offloading @@ -2116,4 +2107,4 @@ function get_country_name($country_code) { return ""; } -?> \ No newline at end of file +?> From e7d3fc15329347ef244123a20af5384e54ce46fd Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 20:09:13 +0000 Subject: [PATCH 56/98] Small improvement no functional change. --- etc/inc/services.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 79c20d265d..9cf128e8ed 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -1251,19 +1251,19 @@ EODAD; /* configure cron service */ function configure_cron() { global $g, $config; + conf_mount_rw(); /* preserve existing crontab entries */ - $crontab_contents = file_get_contents("/etc/crontab"); - $crontab_contents_a = split("\n", $crontab_contents); + $crontab_contents = file("/etc/crontab", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - for ($i = 0; $i < count($crontab_contents_a); $i++) { - $item =& $crontab_contents_a[$i]; - if (strpos($item, "# pfSense specific crontab entries") !== false) { - array_splice($crontab_contents_a, $i - 1); + for ($i = 0; $i < count($crontab_contents); $i++) { + $cron_item =& $crontab_contents[$i]; + if (strpos($cron_item, "# pfSense specific crontab entries") !== false) { + array_splice($crontab_contents, $i - 1); break; } } - $crontab_contents = implode("\n", $crontab_contents_a) . "\n"; + $crontab_contents = implode("\n", $crontab_contents) . "\n"; if (is_array($config['cron']['item'])) { @@ -1377,4 +1377,4 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont configure_cron(); } -?> \ No newline at end of file +?> From dd18038e5032e8a68a8af9bece9a828768615248 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 21:42:46 +0000 Subject: [PATCH 57/98] * Call get_configured_interface_* functions only once in the code * Optimize the test if the passed interface is a vaild one * Fix the apply settings to actually do something rather than do nothing at all * Some style and whitespace fixes --- etc/inc/services.inc | 1 + usr/local/www/interfaces.php | 89 +++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 9cf128e8ed..04651d0795 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -714,6 +714,7 @@ function services_snmpd_configure() { /* kill any running snmpd */ sigkillbypid("{$g['varrun_path']}/snmpd.pid", "TERM"); + sleep(2); if(is_process_running("bsnmpd")) mwexec("/usr/bin/killall bsnmpd", true); diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 0ff69dea78..7e016f90cb 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -4,7 +4,7 @@ interfaces.php Copyright (C) 2004-2008 Scott Ullrich Copyright (C) 2006 Daniel S. Haischt. - Copyright (C) 2008 Ermal Luçi + Copyright (C) 2008-2010 Ermal Luçi All rights reserved. originally part of m0n0wall (http://m0n0.ch/wall) @@ -55,20 +55,15 @@ require_once("vpn.inc"); require_once("xmlparse_attr.inc"); // Get configured interface list -$ifdescrs = get_configured_interface_list(false, true); +$ifdescrs = get_configured_interface_with_descr(false, true); -if ($_REQUEST['if']) { +$if = "wan"; +if ($_REQUEST['if']) $if = $_REQUEST['if']; - $found = false; - foreach($ifdescrs as $descr => $ifdescr) - if($descr == $if) - $found = true; - if(!$found) { - Header("Location: interfaces.php"); - exit; - } -} else { - $if = "wan"; + +if (empty($ifdescrs[$if])) { + Header("Location: interfaces.php"); + exit; } define("CRON_MONTHLY_PATTERN", "0 0 1 * *"); @@ -87,10 +82,15 @@ function remove_bad_chars($string) { if (!is_array($config['gateways']['gateway_item'])) $config['gateways']['gateway_item'] = array(); - $a_gateways = &$config['gateways']['gateway_item']; $wancfg = &$config['interfaces'][$if]; +// Populate page descr if it does not exist. +if ($if == "wan" && !$wancfg['descr']) + $wancfg['descr'] = "WAN"; +else if ($if == "lan" && !$wancfg['descr']) + $wancfg['descr'] = "LAN"; + foreach ($a_ppps as $pppid => $ppp) { if ($wancfg['if'] == $ppp['if']) @@ -175,15 +175,7 @@ if ($wancfg['if'] == $a_ppps[$pppid]['if']) { $pconfig['dhcphostname'] = $wancfg['dhcphostname']; $pconfig['alias-address'] = $wancfg['alias-address']; $pconfig['alias-subnet'] = $wancfg['alias-subnet']; - -// Populate page descr if it does not exist. -if($if == "wan" && !$wancfg['descr']) { - $wancfg['descr'] = "WAN"; -} else if ($if == "lan" && !$wancfg['descr']) { - $wancfg['descr'] = "LAN"; -} $pconfig['descr'] = remove_bad_chars($wancfg['descr']); - $pconfig['enable'] = isset($wancfg['enable']); if (is_array($config['aliases']['alias'])) { @@ -213,9 +205,8 @@ switch($wancfg['ipaddr']) { $pconfig['ipaddr'] = $wancfg['ipaddr']; $pconfig['subnet'] = $wancfg['subnet']; $pconfig['gateway'] = $wancfg['gateway']; - } else { + } else $pconfig['type'] = "none"; - } break; } @@ -312,15 +303,18 @@ if ($_POST['apply']) { else { unlink_if_exists("{$g['tmp_path']}/config.cache"); clear_subsystem_dirty('interfaces'); - if ($pconfig['enable']) - interface_configure($if, true); - else - interface_bring_down($if); + if (file_exists("{$g['tmp_path']}/.interfaces.apply")) { + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply")); + foreach ($toapplylist as $ifapply) { + if (isset($config['interfaces'][$ifapply]['enable'])) + interface_configure($ifapply, true); + else + interface_bring_down($ifapply); + } + } /* restart snmp so that it binds to correct address */ services_snmpd_configure(); - if ($if == "lan") - $savemsg = gettext("The changes have been applied. You may need to correct your web browser's IP address."); /* sync filter configuration */ setup_gateways_monitor(); @@ -331,22 +325,25 @@ if ($_POST['apply']) { enable_rrd_graphing(); } + @unlink("{$g['tmp_path']}/.interfaces.apply"); header("Location: interfaces.php?if={$if}"); exit; -} else - -if ($_POST && $_POST['enable'] != "yes") { +} else if ($_POST && $_POST['enable'] != "yes") { unset($wancfg['enable']); - if (isset($wancfg['wireless'])) { + if (isset($wancfg['wireless'])) interface_sync_wireless_clones($wancfg, false); - } write_config("Interface {$_POST['descr']}({$if}) is now disabled."); mark_subsystem_dirty('interfaces'); + if (file_exists("{$g['tmp_path']}/.interfaces.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply")); + else + $toapplylist = array(); + $toapplylist[$if] = $if; + file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist)); header("Location: interfaces.php?if={$if}"); exit; -} else +} else if ($_POST) { -if ($_POST) { unset($input_errors); $pconfig = $_POST; conf_mount_rw(); @@ -367,10 +364,8 @@ if ($_POST) { unset($_POST['pppoe_resetdate']); unset($_POST['pppoe_pr_preset_val']); } - /* optional interface if list */ - $iflist = get_configured_interface_with_descr(false, true); /* description unique? */ - foreach ($iflist as $ifent => $ifdescr) { + foreach ($ifdescrs as $ifent => $ifdescr) { if ($if != $ifent && $ifdescr == $_POST['descr']) { $input_errors[] = gettext("An interface with the specified description already exists."); break; @@ -697,17 +692,25 @@ if ($_POST) { handle_wireless_post(); } + conf_mount_ro(); write_config(); + + if (file_exists("{$g['tmp_path']}/.interfaces.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply")); + else + $toapplylist = array(); + $toapplylist[$if] = $if; + file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist)); + mark_subsystem_dirty('interfaces'); + /* regenerate cron settings/crontab file */ configure_cron(); - conf_mount_ro(); + header("Location: interfaces.php?if={$if}"); exit; } - - } // end if($_POST) function handle_wireless_post() { From 29f76490d8db635646472f9e38f8402f31bb0e33 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 10 Nov 2010 17:22:37 -0500 Subject: [PATCH 58/98] Only use escapeshellarg when passing the arguments to the shell. Fixes #1005 --- usr/local/www/diag_dump_states.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/usr/local/www/diag_dump_states.php b/usr/local/www/diag_dump_states.php index 69d8dfd5d9..a8671c1b80 100755 --- a/usr/local/www/diag_dump_states.php +++ b/usr/local/www/diag_dump_states.php @@ -44,11 +44,9 @@ require_once("guiconfig.inc"); /* handle AJAX operations */ if($_GET['action']) { if($_GET['action'] == "remove") { - $srcip = escapeshellarg($_GET['srcip']); - $dstip = escapeshellarg($_GET['dstip']); - if (is_ipaddr($srcip) and is_ipaddr($dstip)) { - $retval = mwexec("/sbin/pfctl -k '{$srcip}' -k '{$dstip}'"); - echo htmlentities("|{$srcip}|{$dstip}|{$retval}|"); + if (is_ipaddr($_GET['srcip']) and is_ipaddr($_GET['dstip'])) { + $retval = mwexec("/sbin/pfctl -k " . escapeshellarg($_GET['srcip']) . " -k " . escapeshellarg($_GET['dstip'])); + echo htmlentities("|{$_GET['srcip']}|{$_GET['dstip']}|{$retval}|"); } else { echo gettext("invalid input"); } From 30bd17f5508e5d668013f7e402c8d912a8493b62 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 10 Nov 2010 23:10:39 +0000 Subject: [PATCH 59/98] Make the antilockout rule match the webgui and ssh(if enabled) rather than any traffic destined to pfSense itself. --- etc/inc/filter.inc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 71030d6803..e23a104c4d 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -5,7 +5,7 @@ Copyright (C) 2004-2006 Scott Ullrich Copyright (C) 2005 Bill Marquette Copyright (C) 2006 Peter Allgeyer - Copyright (C) 2008 Ermal Luci + Copyright (C) 2008-2010 Ermal Luci All rights reserved. originally part of m0n0wall (http://m0n0.ch/wall) @@ -2148,6 +2148,15 @@ pass out on \$IPsec all keep state label "IPsec internal host to host" EOD; if(!isset($config['system']['webgui']['noantilockout'])) { + $portarg = 80; + if (isset($config['system']['webgui']['port']) && $config['system']['webgui']['port'] <> "") + $portarg = "{$config['system']['webgui']['port']}"; + $sshport = ""; + if (isset($config['system']['enablesshd'])) { + $sshport = 22; + if($config['system']['ssh']['port'] <> "") + $sshport = $config['system']['ssh']['port']; + } if(count($config['interfaces']) > 1 && !empty($FilterIflist['lan']['if'])) { /* if antilockout is enabled, LAN exists and has * an IP and subnet mask assigned @@ -2156,7 +2165,7 @@ EOD; $ipfrules .= << Date: Wed, 10 Nov 2010 23:12:41 +0000 Subject: [PATCH 60/98] Take into account if we have redirection active to allow even port 443. --- etc/inc/filter.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index e23a104c4d..cbe9013b2d 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -2151,6 +2151,8 @@ EOD; $portarg = 80; if (isset($config['system']['webgui']['port']) && $config['system']['webgui']['port'] <> "") $portarg = "{$config['system']['webgui']['port']}"; + if ($config['system']['webgui']['protocol'] == "https") + $portarg .= " 443 "; $sshport = ""; if (isset($config['system']['enablesshd'])) { $sshport = 22; From fa6c42d05be581f9515db720d0e8a142e916c050 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 18:22:22 -0700 Subject: [PATCH 61/98] Return this field to its old name to prevent a conflict of names and since the code that uses it still refers to it by that name. Issue reported at http://forum.pfsense.org/index.php/topic,29985.0.html This caused the full name field to be ignored when creating a user and prevented making a certificate at the creation of the user (either could still be changed afterward). --- usr/local/www/system_usermanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/system_usermanager.php b/usr/local/www/system_usermanager.php index 34fe611bcc..d4adf9e977 100644 --- a/usr/local/www/system_usermanager.php +++ b/usr/local/www/system_usermanager.php @@ -708,7 +708,7 @@ function sshkeyClicked(obj) { - + From 2b30323ef3ebbd11d84e913db3b33e514b0657a6 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 10 Nov 2010 21:56:12 -0500 Subject: [PATCH 62/98] Copy logic for when to show the cellular tab from status_rrd_graph.php. Fixes #714 --- usr/local/www/status_rrd_graph_settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/status_rrd_graph_settings.php b/usr/local/www/status_rrd_graph_settings.php index 7c01d8d043..6fb943a753 100755 --- a/usr/local/www/status_rrd_graph_settings.php +++ b/usr/local/www/status_rrd_graph_settings.php @@ -90,7 +90,7 @@ foreach($databases as $database) { if(stristr($database, "queues")) { $queues = true; } - if(stristr($database, "cellular")) { + if(stristr($database, "-cellular") && !empty($config['ppps'])) { $cellular = true; } if(stristr($database, "-vpnusers")) { From ce2078f7d0558b044474bb86697ee39763721c90 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Nov 2010 23:14:19 -0500 Subject: [PATCH 63/98] Unbreak graphs --- usr/local/www/graph.php | 1 + usr/local/www/status_graph.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/local/www/graph.php b/usr/local/www/graph.php index 6634ed323d..fb11d42460 100755 --- a/usr/local/www/graph.php +++ b/usr/local/www/graph.php @@ -51,6 +51,7 @@ header("Content-type: image/svg+xml"); /********** HTTP GET Based Conf ***********/ $ifnum=@$_GET["ifnum"]; // BSD / SNMP interface name / number +$ifnum = get_real_interface($ifnum); $ifname=@$_GET["ifname"]?$_GET["ifname"]:"Interface $ifnum"; //Interface name that will be showed on top right of graph /********* Other conf *******/ diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php index c674cbc660..a68b6bd68e 100755 --- a/usr/local/www/status_graph.php +++ b/usr/local/www/status_graph.php @@ -184,8 +184,8 @@ foreach ($ifdescrs as $ifn => $ifd) {

- - + + . From ea57ccb86b5c75246dabb8306c35b997cb4ede9d Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 21:25:03 -0700 Subject: [PATCH 64/98] Use this sort before saving, so the rule just added is sorted into the proper category like the rest. --- usr/local/www/firewall_rules_edit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php index ce7c1d297a..166bfa82f6 100755 --- a/usr/local/www/firewall_rules_edit.php +++ b/usr/local/www/firewall_rules_edit.php @@ -546,6 +546,7 @@ if ($_POST) { $a_filter[] = $filterent; } + filter_rules_sort(); write_config(); mark_subsystem_dirty('filter'); From 88bc276013552268ebef7058cd7b58c89de67125 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 22:03:07 -0700 Subject: [PATCH 65/98] Fix filter_rules_sort's compare function to know about floating rules so it won't change their order. --- etc/inc/util.inc | 16 ++++++++++++++++ usr/local/www/guiconfig.inc | 19 +++++++++++-------- usr/local/www/interfaces_assign.php | 17 +---------------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 63b76da4a0..2be567a872 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -566,6 +566,22 @@ function get_configured_ip_aliases_list() { } +/* comparison function for sorting by the order in which interfaces are normally created */ +function compare_interface_friendly_names($a, $b) { + if ($a == $b) + return 0; + else if ($a == 'wan') + return -1; + else if ($b == 'wan') + return 1; + else if ($a == 'lan') + return -1; + else if ($b == 'lan') + return 1; + + return strnatcmp($a, $b); +} + /* return the configured interfaces list. */ function get_configured_interface_list($only_opt = false, $withdisabled = false) { global $config; diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index 4c68a32d30..d1a92c752e 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -464,19 +464,22 @@ function filter_rules_sort() { for ($i = 0; isset($config['filter']['rule'][$i]); $i++) $config['filter']['rule'][$i]['seq'] = $i; - function filtercmp($a, $b) { - if ($a['interface'] == $b['interface']) - return $a['seq'] - $b['seq']; - else - return -strcmp($a['interface'], $b['interface']); - } - - usort($config['filter']['rule'], "filtercmp"); + usort($config['filter']['rule'], "filter_rules_compare"); /* strip the sequence numbers again */ for ($i = 0; isset($config['filter']['rule'][$i]); $i++) unset($config['filter']['rule'][$i]['seq']); } +function filter_rules_compare($a, $b) { + if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) + return $a['seq'] - $b['seq']; + else if (isset($a['floating'])) + return -1; + else if (isset($b['floating'])) + return 1; + else + return compare_interface_friendly_names($a['interface'], $b['interface']); +} function firewall_check_for_advanced_options(&$item) { $item_set = ""; diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index b4c85256a4..fbd6e7f3d6 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -320,7 +320,7 @@ if ($_GET['act'] == "add") { $config['interfaces'][$newifname]['descr'] = $descr; } - uksort($config['interfaces'], "compare_interface_names"); + uksort($config['interfaces'], "compare_interface_friendly_names"); /* Find an unused port for this interface */ foreach ($portlist as $portname => $portinfo) { @@ -350,21 +350,6 @@ if ($_GET['act'] == "add") { } -function compare_interface_names($a, $b) { - if ($a == $b) - return 0; - else if ($a == 'wan') - return -1; - else if ($b == 'wan') - return 1; - else if ($a == 'lan') - return -1; - else if ($b == 'lan') - return 1; - - return strnatcmp($a, $b); -} - include("head.inc"); if(file_exists("/var/run/interface_mismatch_reboot_needed")) From baaa8bb142f1f86dd7a7e60fe34fc07020fb482e Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 22:58:30 -0700 Subject: [PATCH 66/98] Move this function to allow removing it from easyrule. --- etc/inc/pfsense-utils.inc | 26 ++++++++++++++++++++++++++ usr/local/bin/easyrule | 22 ---------------------- usr/local/www/guiconfig.inc | 26 -------------------------- 3 files changed, 26 insertions(+), 48 deletions(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 6bd167135a..7c0bdc0245 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2107,4 +2107,30 @@ function get_country_name($country_code) { return ""; } +/* sort by interface only, retain the original order of rules that apply to + the same interface */ +function filter_rules_sort() { + global $config; + + /* mark each rule with the sequence number (to retain the order while sorting) */ + for ($i = 0; isset($config['filter']['rule'][$i]); $i++) + $config['filter']['rule'][$i]['seq'] = $i; + + usort($config['filter']['rule'], "filter_rules_compare"); + + /* strip the sequence numbers again */ + for ($i = 0; isset($config['filter']['rule'][$i]); $i++) + unset($config['filter']['rule'][$i]['seq']); +} +function filter_rules_compare($a, $b) { + if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) + return $a['seq'] - $b['seq']; + else if (isset($a['floating'])) + return -1; + else if (isset($b['floating'])) + return 1; + else + return compare_interface_friendly_names($a['interface'], $b['interface']); +} + ?> diff --git a/usr/local/bin/easyrule b/usr/local/bin/easyrule index 60f5fb1c97..f4c9dad90f 100755 --- a/usr/local/bin/easyrule +++ b/usr/local/bin/easyrule @@ -84,28 +84,6 @@ function is_specialnet($net) { return false; } -/* Another one we need from guiconfig.inc but can't include... */ -function filter_rules_sort() { - global $config; - - /* mark each rule with the sequence number (to retain the order while sorting) */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - $config['filter']['rule'][$i]['seq'] = $i; - - function filtercmp($a, $b) { - if ($a['interface'] == $b['interface']) - return $a['seq'] - $b['seq']; - else - return -strcmp($a['interface'], $b['interface']); - } - - usort($config['filter']['rule'], "filtercmp"); - - /* strip the sequence numbers again */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - unset($config['filter']['rule'][$i]['seq']); -} - if (($argc > 1) && !empty($argv[1])) { $message = ""; diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index d1a92c752e..ca038a5162 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -455,32 +455,6 @@ function pprint_port($port) { return $pport; } -/* sort by interface only, retain the original order of rules that apply to - the same interface */ -function filter_rules_sort() { - global $config; - - /* mark each rule with the sequence number (to retain the order while sorting) */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - $config['filter']['rule'][$i]['seq'] = $i; - - usort($config['filter']['rule'], "filter_rules_compare"); - - /* strip the sequence numbers again */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - unset($config['filter']['rule'][$i]['seq']); -} -function filter_rules_compare($a, $b) { - if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) - return $a['seq'] - $b['seq']; - else if (isset($a['floating'])) - return -1; - else if (isset($b['floating'])) - return 1; - else - return compare_interface_friendly_names($a['interface'], $b['interface']); -} - function firewall_check_for_advanced_options(&$item) { $item_set = ""; if($item['max']) From a5ebdeff9269034cee1291720718202526a1d43d Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Thu, 11 Nov 2010 00:43:41 -0700 Subject: [PATCH 67/98] Fix handling of floating rules in the drag and drop reordering code. Fix for part of ticket #878 --- usr/local/www/firewall_rules.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index 26b9513daa..b7f990d0a1 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -87,10 +87,17 @@ if($_REQUEST['dragdroporder']) { $drag_order = $_REQUEST['dragtable']; // Next traverse through rules building a new order for interface for ($i = 0; isset($a_filter[$i]); $i++) { - if($a_filter[$i]['interface'] <> $_REQUEST['if']) - $a_filter_unorder[] = $a_filter[$i]; - else - $a_filter_order_tmp[] = $a_filter[$i]; + if($_REQUEST['if'] == "FloatingRules") { + if(!isset($a_filter[$i]['floating'])) + $a_filter_unorder[] = $a_filter[$i]; + else + $a_filter_order_tmp[] = $a_filter[$i]; + } else { + if($a_filter[$i]['interface'] <> $_REQUEST['if'] || isset($a_filter[$i]['floating'])) + $a_filter_unorder[] = $a_filter[$i]; + else + $a_filter_order_tmp[] = $a_filter[$i]; + } } // Reorder rules with the posted order for ($i = 0; $i Date: Thu, 11 Nov 2010 02:03:40 -0700 Subject: [PATCH 68/98] Small rework of code for applying drag and drop reordering of rules and some extra checks added to fix some potential bugs. Ticket #878 Also minimizes the extent of the changes performed (useful when comparing config.xml files from before and after). --- usr/local/www/firewall_rules.php | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index b7f990d0a1..ccf1e58a5e 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -79,34 +79,33 @@ $ifdescs = get_configured_interface_with_descr(); // Drag and drop reordering if($_REQUEST['dragdroporder']) { // First create a new ruleset array and tmp arrays - $a_filter_unorder = array(); + $a_filter_before = array(); $a_filter_order = array(); $a_filter_order_tmp = array(); - // Pointer to id of item being reordered - $found = 0; + $a_filter_after = array(); + $found = false; $drag_order = $_REQUEST['dragtable']; // Next traverse through rules building a new order for interface for ($i = 0; isset($a_filter[$i]); $i++) { - if($_REQUEST['if'] == "FloatingRules") { - if(!isset($a_filter[$i]['floating'])) - $a_filter_unorder[] = $a_filter[$i]; - else - $a_filter_order_tmp[] = $a_filter[$i]; - } else { - if($a_filter[$i]['interface'] <> $_REQUEST['if'] || isset($a_filter[$i]['floating'])) - $a_filter_unorder[] = $a_filter[$i]; - else - $a_filter_order_tmp[] = $a_filter[$i]; - } + if(( $_REQUEST['if'] == "FloatingRules" && isset($a_filter[$i]['floating']) ) || ( $a_filter[$i]['interface'] == $_REQUEST['if'] && !isset($a_filter[$i]['floating']) )) { + $a_filter_order_tmp[] = $a_filter[$i]; + $found = true; + } else if (!$found) + $a_filter_before[] = $a_filter[$i]; + else + $a_filter_after[] = $a_filter[$i]; } // Reorder rules with the posted order - for ($i = 0; $i Date: Thu, 11 Nov 2010 02:53:35 -0700 Subject: [PATCH 69/98] Separate this into the original case with the floating rule cases above it to fix some scenarios where the order was still wrong. --- etc/inc/pfsense-utils.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 7c0bdc0245..3a6eb1afca 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2123,12 +2123,14 @@ function filter_rules_sort() { unset($config['filter']['rule'][$i]['seq']); } function filter_rules_compare($a, $b) { - if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) + if (isset($a['floating']) && isset($b['floating'])) return $a['seq'] - $b['seq']; else if (isset($a['floating'])) return -1; else if (isset($b['floating'])) return 1; + else if ($a['interface'] == $b['interface']) + return $a['seq'] - $b['seq']; else return compare_interface_friendly_names($a['interface'], $b['interface']); } From 6f567a593d77770cef8f4f2b66055a1a270166ca Mon Sep 17 00:00:00 2001 From: Warren Baker Date: Thu, 11 Nov 2010 12:51:56 +0200 Subject: [PATCH 70/98] NiftyCheck already included in bottom-loader.js otherwise div mainarea gets rounded twice. --- usr/local/www/pkg.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php index 5e4a65f789..32c9463514 100755 --- a/usr/local/www/pkg.php +++ b/usr/local/www/pkg.php @@ -414,11 +414,6 @@ if ($pkg['tabs'] <> "") { - - "; echo ""; From a2f38ac4d48fcd1560626873c51938bb24a5d841 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 11 Nov 2010 09:17:47 -0500 Subject: [PATCH 71/98] Handle AJAX --- usr/local/www/status_queues.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr/local/www/status_queues.php b/usr/local/www/status_queues.php index ad1c0665cc..82a069339b 100755 --- a/usr/local/www/status_queues.php +++ b/usr/local/www/status_queues.php @@ -41,6 +41,10 @@ ##|*MATCH=status_queues.php* ##|-PRIV +// Handle Javascript/AJAX +function csrf_startup() { + csrf_conf('rewrite-js', '/csrf/csrf-magic.js'); +} require("guiconfig.inc"); if ($_REQUEST['getactivity']) { From 19310a561a7ca59067b10e689fcff3d024c527bb Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Fri, 12 Nov 2010 02:17:29 -0700 Subject: [PATCH 72/98] Clarify these descriptions a bit more on 1:1 edit. --- usr/local/www/firewall_nat_1to1_edit.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php index 85327558de..9642663059 100755 --- a/usr/local/www/firewall_nat_1to1_edit.php +++ b/usr/local/www/firewall_nat_1to1_edit.php @@ -305,11 +305,11 @@ function typesel_change() { . - +
-
+
@@ -365,7 +365,7 @@ function typesel_change() {
- + From 9869cf3e25f9dc86d4a4da7b2a92ea6cc4660a44 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Nov 2010 11:49:27 +0000 Subject: [PATCH 73/98] Initialize rule keeping array to avoid possible caching effects on php. --- etc/inc/filter.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index cbe9013b2d..7c4c93f2e8 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -1610,6 +1610,8 @@ function filter_generate_user_rule($rule) { $pptpdcfg = $config['pptpd']; $pppoecfg = $config['pppoe']; $int = ""; + $aline = array(); + /* Check to see if the interface is in our list */ if(isset($rule['floating'])) { if(isset($rule['interface']) && $rule['interface'] <> "") { From f829d53248130b030a452cbccb9fd6e5c4d3d4da Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Nov 2010 11:51:09 +0000 Subject: [PATCH 74/98] Make sure there is a direction specified otherwise errors might occur. --- etc/inc/filter.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 7c4c93f2e8..b59b7ef743 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -1675,7 +1675,7 @@ function filter_generate_user_rule($rule) { update_filter_reload_status("Setting up pass/block rules {$rule['descr']}"); /* do not process reply-to for gateway'd rules */ - if($rule['gateway'] == "" && interface_has_gateway($rule['interface']) && !isset($rule['disablereplyto'])) { + if($rule['gateway'] == "" && $aline['direction'] <> "" && interface_has_gateway($rule['interface']) && !isset($rule['disablereplyto'])) { $rg = get_interface_gateway($rule['interface']); if(is_ipaddr($rg)) { $aline['reply'] = "reply-to ( {$ifcfg['if']} {$rg} ) "; From f27789bf9c0d0eb0a2b1f4b64f3edfe008a0dbf1 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Nov 2010 11:52:10 +0000 Subject: [PATCH 75/98] Whitespace fixes. --- etc/inc/filter.inc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index b59b7ef743..51fd235741 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -1614,20 +1614,19 @@ function filter_generate_user_rule($rule) { /* Check to see if the interface is in our list */ if(isset($rule['floating'])) { - if(isset($rule['interface']) && $rule['interface'] <> "") { - $interfaces = explode(",", $rule['interface']); - $ifliste = ""; - foreach ($interfaces as $iface) { - if(array_key_exists($iface, $FilterIflist)) - $ifliste .= " " . $FilterIflist[$iface]['if'] . " "; - } - if($ifliste <> "") - $aline['interface'] = " on { {$ifliste} }"; - else - $aline['interface'] = ""; + if(isset($rule['interface']) && $rule['interface'] <> "") { + $interfaces = explode(",", $rule['interface']); + $ifliste = ""; + foreach ($interfaces as $iface) { + if(array_key_exists($iface, $FilterIflist)) + $ifliste .= " " . $FilterIflist[$iface]['if'] . " "; } + if($ifliste <> "") + $aline['interface'] = " on { {$ifliste} }"; else $aline['interface'] = ""; + } else + $aline['interface'] = ""; } else if(!array_key_exists($rule['interface'], $FilterIflist)) { foreach($FilterIflist as $oc) $item .= $oc['descr']; return "# {$item} {$rule['interface']} array key does not exist for " . $rule['descr']; From 5812e717eb919e2d1eb94772f33275122415d76c Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Nov 2010 11:53:27 +0000 Subject: [PATCH 76/98] Add whitespace to avoid breaking the resulting rule. --- etc/inc/filter.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 51fd235741..d0295c03be 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -1622,7 +1622,7 @@ function filter_generate_user_rule($rule) { $ifliste .= " " . $FilterIflist[$iface]['if'] . " "; } if($ifliste <> "") - $aline['interface'] = " on { {$ifliste} }"; + $aline['interface'] = " on { {$ifliste} } "; else $aline['interface'] = ""; } else From 225a2f0b4696c497263d0926011a0f39ab08b0f3 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 12 Nov 2010 11:03:44 -0500 Subject: [PATCH 77/98] Bring in XSS id fixes from m0n0wall --- usr/local/www/exec.php | 6 +++--- usr/local/www/firewall_aliases_edit.php | 2 +- usr/local/www/firewall_nat_1to1_edit.php | 2 +- usr/local/www/firewall_nat_edit.php | 12 ++++++------ usr/local/www/firewall_nat_out_edit.php | 2 +- usr/local/www/firewall_rules_edit.php | 8 ++++---- usr/local/www/firewall_schedule_edit.php | 2 +- usr/local/www/firewall_virtual_ip_edit.php | 2 +- usr/local/www/interfaces_bridge_edit.php | 2 +- usr/local/www/interfaces_gif_edit.php | 2 +- usr/local/www/interfaces_gre_edit.php | 2 +- usr/local/www/interfaces_groups_edit.php | 2 +- usr/local/www/interfaces_lagg_edit.php | 2 +- usr/local/www/interfaces_ppps_edit.php | 2 +- usr/local/www/interfaces_qinq_edit.php | 2 +- usr/local/www/interfaces_vlan_edit.php | 2 +- usr/local/www/interfaces_wireless_edit.php | 2 +- usr/local/www/load_balancer_monitor_edit.php | 2 +- usr/local/www/load_balancer_pool_edit.php | 2 +- usr/local/www/load_balancer_relay_action_edit.php | 2 +- usr/local/www/load_balancer_relay_protocol_edit.php | 2 +- usr/local/www/load_balancer_virtual_server_edit.php | 2 +- usr/local/www/services_captiveportal_ip_edit.php | 2 +- usr/local/www/services_captiveportal_mac_edit.php | 2 +- .../www/services_captiveportal_vouchers_edit.php | 2 +- usr/local/www/services_dhcp_edit.php | 4 ++-- .../www/services_dnsmasq_domainoverride_edit.php | 2 +- usr/local/www/services_dnsmasq_edit.php | 2 +- usr/local/www/services_dyndns_edit.php | 2 +- usr/local/www/services_igmpproxy_edit.php | 2 +- usr/local/www/services_rfc2136_edit.php | 2 +- usr/local/www/services_wol_edit.php | 2 +- usr/local/www/status_dhcp_leases.php | 2 +- usr/local/www/system_gateway_groups_edit.php | 2 +- usr/local/www/system_gateways_edit.php | 2 +- usr/local/www/system_routes_edit.php | 2 +- usr/local/www/vpn_ipsec_keys_edit.php | 2 +- usr/local/www/vpn_l2tp_users_edit.php | 2 +- usr/local/www/vpn_pptp_users_edit.php | 2 +- 39 files changed, 50 insertions(+), 50 deletions(-) diff --git a/usr/local/www/exec.php b/usr/local/www/exec.php index 2d29a838be..e9b0259b85 100755 --- a/usr/local/www/exec.php +++ b/usr/local/www/exec.php @@ -104,8 +104,8 @@ if (isBlank( $_POST['txtRecallBuffer'] )) { } else { puts( " var arrRecallBuffer = new Array(" ); $arrBuffer = explode( "&", $_POST['txtRecallBuffer'] ); - for ($i=0; $i < (count( $arrBuffer ) - 1); $i++) puts( " '" . $arrBuffer[$i] . "'," ); - puts( " '" . $arrBuffer[count( $arrBuffer ) - 1] . "'" ); + for ($i=0; $i < (count( $arrBuffer ) - 1); $i++) puts( " '" . htmlspecialchars($arrBuffer[$i]) . "'," ); + puts( " '" . htmlspecialchars($arrBuffer[count( $arrBuffer ) - 1]) . "'" ); puts( " );" ); } @@ -259,7 +259,7 @@ if (!isBlank($_POST['txtPHPCommand'])) {     - + "> diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index 457198cf17..3ae4cc3361 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -558,7 +558,7 @@ EOD; - +
diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php index 9642663059..199adef094 100755 --- a/usr/local/www/firewall_nat_1to1_edit.php +++ b/usr/local/www/firewall_nat_1to1_edit.php @@ -447,7 +447,7 @@ function typesel_change() { "> " onclick="history.back()"> - + diff --git a/usr/local/www/firewall_nat_edit.php b/usr/local/www/firewall_nat_edit.php index c6c50a599a..e27053cde3 100755 --- a/usr/local/www/firewall_nat_edit.php +++ b/usr/local/www/firewall_nat_edit.php @@ -585,7 +585,7 @@ include("fbegin.inc"); ?> - + @@ -598,7 +598,7 @@ include("fbegin.inc"); ?> - + @@ -695,7 +695,7 @@ include("fbegin.inc"); ?> - + @@ -708,7 +708,7 @@ include("fbegin.inc"); ?> - + @@ -741,7 +741,7 @@ include("fbegin.inc"); ?> - +
"> " onclick="history.back()"> - + diff --git a/usr/local/www/firewall_nat_out_edit.php b/usr/local/www/firewall_nat_out_edit.php index fccb2e78ed..348475538c 100755 --- a/usr/local/www/firewall_nat_out_edit.php +++ b/usr/local/www/firewall_nat_out_edit.php @@ -532,7 +532,7 @@ any)");?> "> " onclick="history.back()"> - + diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php index 166bfa82f6..6d038a6874 100755 --- a/usr/local/www/firewall_rules_edit.php +++ b/usr/local/www/firewall_rules_edit.php @@ -977,9 +977,9 @@ include("head.inc");  
  "> " onclick="history.back()"> - + - + @@ -1372,9 +1372,9 @@ include("head.inc");  
  "> " onclick="history.back()"> - + - + diff --git a/usr/local/www/firewall_schedule_edit.php b/usr/local/www/firewall_schedule_edit.php index 74497c1de0..1023e52aa3 100644 --- a/usr/local/www/firewall_schedule_edit.php +++ b/usr/local/www/firewall_schedule_edit.php @@ -1156,7 +1156,7 @@ EOD; " /> " onclick="history.back()" /> - + diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index 79398bd076..e5e9072118 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -463,7 +463,7 @@ function typesel_change() { "> " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_bridge_edit.php b/usr/local/www/interfaces_bridge_edit.php index 6408fc0c88..0892445385 100644 --- a/usr/local/www/interfaces_bridge_edit.php +++ b/usr/local/www/interfaces_bridge_edit.php @@ -578,7 +578,7 @@ function show_source_port_range() { "> " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_gif_edit.php b/usr/local/www/interfaces_gif_edit.php index fdde8d4e72..e650149398 100644 --- a/usr/local/www/interfaces_gif_edit.php +++ b/usr/local/www/interfaces_gif_edit.php @@ -209,7 +209,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_gre_edit.php b/usr/local/www/interfaces_gre_edit.php index 609ccf941c..fe1962b331 100644 --- a/usr/local/www/interfaces_gre_edit.php +++ b/usr/local/www/interfaces_gre_edit.php @@ -221,7 +221,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_groups_edit.php b/usr/local/www/interfaces_groups_edit.php index 1906a69eec..194dfa091a 100755 --- a/usr/local/www/interfaces_groups_edit.php +++ b/usr/local/www/interfaces_groups_edit.php @@ -323,7 +323,7 @@ function removeRow(el) { " /> " /> - + diff --git a/usr/local/www/interfaces_lagg_edit.php b/usr/local/www/interfaces_lagg_edit.php index c7d1ef90f1..27610c8bde 100644 --- a/usr/local/www/interfaces_lagg_edit.php +++ b/usr/local/www/interfaces_lagg_edit.php @@ -208,7 +208,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_ppps_edit.php b/usr/local/www/interfaces_ppps_edit.php index 1f9e2bf2bf..46fb414fff 100644 --- a/usr/local/www/interfaces_ppps_edit.php +++ b/usr/local/www/interfaces_ppps_edit.php @@ -789,7 +789,7 @@ $types = array("select" => gettext("Select"), "ppp" => "PPP", "pppoe" => "PPPoE" " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_qinq_edit.php b/usr/local/www/interfaces_qinq_edit.php index a820e14558..7ab5a19d53 100755 --- a/usr/local/www/interfaces_qinq_edit.php +++ b/usr/local/www/interfaces_qinq_edit.php @@ -395,7 +395,7 @@ function removeRow(el) { " /> " /> - + diff --git a/usr/local/www/interfaces_vlan_edit.php b/usr/local/www/interfaces_vlan_edit.php index 3f26441a0f..6a84932af5 100755 --- a/usr/local/www/interfaces_vlan_edit.php +++ b/usr/local/www/interfaces_vlan_edit.php @@ -175,7 +175,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/interfaces_wireless_edit.php b/usr/local/www/interfaces_wireless_edit.php index c5c511a169..25251e3a50 100644 --- a/usr/local/www/interfaces_wireless_edit.php +++ b/usr/local/www/interfaces_wireless_edit.php @@ -194,7 +194,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/load_balancer_monitor_edit.php b/usr/local/www/load_balancer_monitor_edit.php index 7cc9ef3e7b..865148a8ed 100755 --- a/usr/local/www/load_balancer_monitor_edit.php +++ b/usr/local/www/load_balancer_monitor_edit.php @@ -355,7 +355,7 @@ function updateType(t){ ">" onclick="history.back()"> - + diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php index 0e15dc2c28..51b3bec524 100755 --- a/usr/local/www/load_balancer_pool_edit.php +++ b/usr/local/www/load_balancer_pool_edit.php @@ -297,7 +297,7 @@ echo ""; " onClick="AllServers('serversSelect', true); AllServers('serversDisabledSelect', true);"> " onclick="history.back()"> - + diff --git a/usr/local/www/load_balancer_relay_action_edit.php b/usr/local/www/load_balancer_relay_action_edit.php index 396cd9bb40..69bf0e396e 100755 --- a/usr/local/www/load_balancer_relay_action_edit.php +++ b/usr/local/www/load_balancer_relay_action_edit.php @@ -556,7 +556,7 @@ document.observe("dom:loaded", function() { ">" onclick="history.back()"> - + diff --git a/usr/local/www/load_balancer_relay_protocol_edit.php b/usr/local/www/load_balancer_relay_protocol_edit.php index 1c0daa832a..a885aa2aa7 100755 --- a/usr/local/www/load_balancer_relay_protocol_edit.php +++ b/usr/local/www/load_balancer_relay_protocol_edit.php @@ -279,7 +279,7 @@ echo ""; " onClick="AllOptions($('lbaction'), true); AllOptions($('available_action'), false);">" onclick="history.back()"> - + diff --git a/usr/local/www/load_balancer_virtual_server_edit.php b/usr/local/www/load_balancer_virtual_server_edit.php index e93f0d6b66..91183193f4 100755 --- a/usr/local/www/load_balancer_virtual_server_edit.php +++ b/usr/local/www/load_balancer_virtual_server_edit.php @@ -278,7 +278,7 @@ document.observe("dom:loaded", function() { "> " onclick="history.back()"> - + diff --git a/usr/local/www/services_captiveportal_ip_edit.php b/usr/local/www/services_captiveportal_ip_edit.php index b9b4efce6e..d6119ce87a 100755 --- a/usr/local/www/services_captiveportal_ip_edit.php +++ b/usr/local/www/services_captiveportal_ip_edit.php @@ -207,7 +207,7 @@ include("head.inc"); "> - + diff --git a/usr/local/www/services_captiveportal_mac_edit.php b/usr/local/www/services_captiveportal_mac_edit.php index f0d92c3798..aabf4b3bcb 100755 --- a/usr/local/www/services_captiveportal_mac_edit.php +++ b/usr/local/www/services_captiveportal_mac_edit.php @@ -184,7 +184,7 @@ include("head.inc"); "> - + diff --git a/usr/local/www/services_captiveportal_vouchers_edit.php b/usr/local/www/services_captiveportal_vouchers_edit.php index 96e563fcc2..94724a90ce 100644 --- a/usr/local/www/services_captiveportal_vouchers_edit.php +++ b/usr/local/www/services_captiveportal_vouchers_edit.php @@ -191,7 +191,7 @@ include("head.inc"); "> - + diff --git a/usr/local/www/services_dhcp_edit.php b/usr/local/www/services_dhcp_edit.php index 525a983bf6..cddc8e03d0 100755 --- a/usr/local/www/services_dhcp_edit.php +++ b/usr/local/www/services_dhcp_edit.php @@ -253,9 +253,9 @@ include("head.inc"); "> " onclick="history.back()"> - + - + diff --git a/usr/local/www/services_dnsmasq_domainoverride_edit.php b/usr/local/www/services_dnsmasq_domainoverride_edit.php index e55b6eebbc..948ecb0399 100755 --- a/usr/local/www/services_dnsmasq_domainoverride_edit.php +++ b/usr/local/www/services_dnsmasq_domainoverride_edit.php @@ -129,7 +129,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/services_dnsmasq_edit.php b/usr/local/www/services_dnsmasq_edit.php index a80ff00673..363805454d 100755 --- a/usr/local/www/services_dnsmasq_edit.php +++ b/usr/local/www/services_dnsmasq_edit.php @@ -170,7 +170,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/services_dyndns_edit.php b/usr/local/www/services_dyndns_edit.php index c221e97864..7d3072c13c 100644 --- a/usr/local/www/services_dyndns_edit.php +++ b/usr/local/www/services_dyndns_edit.php @@ -231,7 +231,7 @@ include("head.inc"); " onClick="enable_change(true)"> "> - + diff --git a/usr/local/www/services_igmpproxy_edit.php b/usr/local/www/services_igmpproxy_edit.php index 52bb636e2f..f4f74dfe5e 100755 --- a/usr/local/www/services_igmpproxy_edit.php +++ b/usr/local/www/services_igmpproxy_edit.php @@ -280,7 +280,7 @@ include("head.inc"); " /> " /> - + diff --git a/usr/local/www/services_rfc2136_edit.php b/usr/local/www/services_rfc2136_edit.php index d11278c0f3..7c5f1149e2 100644 --- a/usr/local/www/services_rfc2136_edit.php +++ b/usr/local/www/services_rfc2136_edit.php @@ -199,7 +199,7 @@ include("head.inc"); " onClick="enable_change(true)"> "> - + diff --git a/usr/local/www/services_wol_edit.php b/usr/local/www/services_wol_edit.php index f495abf04d..ca3104872f 100755 --- a/usr/local/www/services_wol_edit.php +++ b/usr/local/www/services_wol_edit.php @@ -156,7 +156,7 @@ include("head.inc"); "> " onclick="history.back()"> - + diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php index dd2a0db38b..896b1af24d 100755 --- a/usr/local/www/status_dhcp_leases.php +++ b/usr/local/www/status_dhcp_leases.php @@ -382,7 +382,7 @@ foreach ($leases as $data) { /* Only show the button for offline dynamic leases */ if (($data['type'] == "dynamic") && ($data['online'] != "online")) { - echo ""; + echo ""; echo "\n"; } echo "\n"; diff --git a/usr/local/www/system_gateway_groups_edit.php b/usr/local/www/system_gateway_groups_edit.php index f0e56198c9..10f001eaab 100755 --- a/usr/local/www/system_gateway_groups_edit.php +++ b/usr/local/www/system_gateway_groups_edit.php @@ -222,7 +222,7 @@ value=""> "> " class="formbtn" onclick="history.back()"> - + diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php index 4848bed5e5..21f37abce3 100755 --- a/usr/local/www/system_gateways_edit.php +++ b/usr/local/www/system_gateways_edit.php @@ -433,7 +433,7 @@ function show_advanced_gateway() { "> " class="formbtn" onclick="history.back()"> - + diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php index 96d24d5851..f2ca9931bf 100755 --- a/usr/local/www/system_routes_edit.php +++ b/usr/local/www/system_routes_edit.php @@ -255,7 +255,7 @@ include("head.inc"); "> " class="formbtn" onclick="history.back()"> - + diff --git a/usr/local/www/vpn_ipsec_keys_edit.php b/usr/local/www/vpn_ipsec_keys_edit.php index 020ca27db3..1534bf225a 100644 --- a/usr/local/www/vpn_ipsec_keys_edit.php +++ b/usr/local/www/vpn_ipsec_keys_edit.php @@ -143,7 +143,7 @@ include("head.inc"); "> - + diff --git a/usr/local/www/vpn_l2tp_users_edit.php b/usr/local/www/vpn_l2tp_users_edit.php index 31a33b70c0..5c4cdc3fb8 100644 --- a/usr/local/www/vpn_l2tp_users_edit.php +++ b/usr/local/www/vpn_l2tp_users_edit.php @@ -176,7 +176,7 @@ include("head.inc"); " onclick="history.back()" /> - + diff --git a/usr/local/www/vpn_pptp_users_edit.php b/usr/local/www/vpn_pptp_users_edit.php index f159931a63..73ba7cc782 100755 --- a/usr/local/www/vpn_pptp_users_edit.php +++ b/usr/local/www/vpn_pptp_users_edit.php @@ -167,7 +167,7 @@ include("head.inc"); "> - + From 190d5d5814add2cc1a85fa8f3db01f54243acb58 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 12 Nov 2010 11:28:40 -0500 Subject: [PATCH 78/98] Fix XSS in notices. --- usr/local/www/fbegin.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index 12f8428085..b720ca180f 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -271,9 +271,9 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') { $extraargs="&xml=" . $_POST['id']; $notice_msgs = 'Acknowledge All     .:.     '; if ($value['url']) { - $notice_msgs .= $date.' - ['.$value['id'].']'; + $notice_msgs .= $date.' - ['.$value['id'].']'; } else { - $notice_msgs .= $date.' - ['.$value['id'].']'.$noticemsg.''; + $notice_msgs .= $date.' - ['.$value['id'].']'.$noticemsg.''; } $notice_msgs .= "     .:.     "; } From 4656943e59eb19a534c06cc253e266da6c52e915 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 12 Nov 2010 11:35:02 -0500 Subject: [PATCH 79/98] Fix a theoretical/potential XSS in the http_referer check warning. --- etc/inc/auth.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 443c9dc4cc..362843646b 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -106,7 +106,7 @@ if(!$config['system']['nohttpreferercheck']) { $found_host = true; } if($found_host == false) { - display_error_form("501", "An HTTP_REFERER was detected other than what is defined in System -> Advanced (" . $_SERVER['HTTP_REFERER'] . "). You can disable this check if needed in System -> Advanced -> Admin."); + display_error_form("501", "An HTTP_REFERER was detected other than what is defined in System -> Advanced (" . htmlspecialchars($_SERVER['HTTP_REFERER']) . "). You can disable this check if needed in System -> Advanced -> Admin."); exit; } } From dd5bf424c155922b065b45e64733bdf8de620c0f Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 12 Nov 2010 11:36:13 -0500 Subject: [PATCH 80/98] Fix XSS issues --- usr/local/www/diag_authentication.php | 4 ++-- usr/local/www/diag_smart.php | 2 +- usr/local/www/firewall_aliases_edit.php | 2 +- usr/local/www/firewall_nat_edit.php | 2 +- usr/local/www/firewall_rules.php | 18 ++++++++--------- usr/local/www/firewall_rules_edit.php | 20 +++++++++---------- usr/local/www/firewall_shaper_layer7.php | 7 +++---- usr/local/www/firewall_shaper_queues.php | 6 +++--- usr/local/www/interfaces.php | 4 ++-- usr/local/www/interfaces_bridge_edit.php | 18 ++++++++--------- usr/local/www/interfaces_gif_edit.php | 8 ++++---- usr/local/www/interfaces_gre_edit.php | 8 ++++---- usr/local/www/interfaces_groups_edit.php | 4 ++-- usr/local/www/interfaces_lagg_edit.php | 2 +- usr/local/www/interfaces_qinq_edit.php | 4 ++-- usr/local/www/interfaces_vlan_edit.php | 2 +- usr/local/www/interfaces_wireless_edit.php | 2 +- .../www/load_balancer_relay_action_edit.php | 8 ++++---- .../www/load_balancer_virtual_server_edit.php | 8 ++++---- usr/local/www/services_dhcp.php | 18 ++++++++--------- usr/local/www/services_igmpproxy_edit.php | 2 +- usr/local/www/services_snmp.php | 4 ++-- usr/local/www/status_captiveportal.php | 14 ++++++------- .../www/status_captiveportal_vouchers.php | 10 +++++----- usr/local/www/system_authservers.php | 4 ++-- usr/local/www/system_camanager.php | 4 ++-- usr/local/www/system_certmanager.php | 8 ++++---- usr/local/www/system_crlmanager.php | 2 +- usr/local/www/system_groupmanager.php | 10 +++++----- usr/local/www/system_usermanager.php | 4 ++-- usr/local/www/vpn_ipsec_keys_edit.php | 2 +- usr/local/www/vpn_ipsec_mobile.php | 16 +++++++-------- usr/local/www/vpn_ipsec_phase1.php | 14 ++++++------- usr/local/www/vpn_ipsec_phase2.php | 20 +++++++++---------- usr/local/www/vpn_openvpn_client.php | 2 +- usr/local/www/vpn_openvpn_csc.php | 8 ++++---- usr/local/www/vpn_openvpn_server.php | 18 ++++++++--------- 37 files changed, 144 insertions(+), 145 deletions(-) diff --git a/usr/local/www/diag_authentication.php b/usr/local/www/diag_authentication.php index 19c0d6948c..a8f897c24c 100755 --- a/usr/local/www/diag_authentication.php +++ b/usr/local/www/diag_authentication.php @@ -105,13 +105,13 @@ include("head.inc"); - ' /> + ' /> - ' /> + ' /> diff --git a/usr/local/www/diag_smart.php b/usr/local/www/diag_smart.php index 11aae90310..05239fa92f 100644 --- a/usr/local/www/diag_smart.php +++ b/usr/local/www/diag_smart.php @@ -208,7 +208,7 @@ switch($action) - + diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index 3ae4cc3361..ab90a5a01d 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -569,7 +569,7 @@ EOD; - +
diff --git a/usr/local/www/firewall_nat_edit.php b/usr/local/www/firewall_nat_edit.php index e27053cde3..d216a9849e 100755 --- a/usr/local/www/firewall_nat_edit.php +++ b/usr/local/www/firewall_nat_edit.php @@ -834,7 +834,7 @@ include("fbegin.inc"); ?> diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php index 93eb56c3b1..04bbeb9985 100644 --- a/usr/local/www/vpn_openvpn_client.php +++ b/usr/local/www/vpn_openvpn_client.php @@ -809,7 +809,7 @@ if ($savemsg) diff --git a/usr/local/www/vpn_openvpn_csc.php b/usr/local/www/vpn_openvpn_csc.php index e23b202322..e980332d2f 100644 --- a/usr/local/www/vpn_openvpn_csc.php +++ b/usr/local/www/vpn_openvpn_csc.php @@ -476,7 +476,7 @@ function netbios_change() { #1:  - + @@ -484,7 +484,7 @@ function netbios_change() { #2:  - + @@ -492,7 +492,7 @@ function netbios_change() { #3:  - + @@ -500,7 +500,7 @@ function netbios_change() { #4:  - +
-
+

diff --git a/usr/local/www/vpn_openvpn_server.php b/usr/local/www/vpn_openvpn_server.php index 4f74fd48aa..7cb433236d 100644 --- a/usr/local/www/vpn_openvpn_server.php +++ b/usr/local/www/vpn_openvpn_server.php @@ -1099,7 +1099,7 @@ if ($savemsg) #1:  - + @@ -1107,7 +1107,7 @@ if ($savemsg) #2:  - + @@ -1115,7 +1115,7 @@ if ($savemsg) #3:  - + @@ -1123,7 +1123,7 @@ if ($savemsg) #4:  - + @@ -1151,7 +1151,7 @@ if ($savemsg) #1:  - + @@ -1159,7 +1159,7 @@ if ($savemsg) #2:  - + @@ -1247,7 +1247,7 @@ if ($savemsg) #1:  - + @@ -1255,7 +1255,7 @@ if ($savemsg) #2:  - + @@ -1276,7 +1276,7 @@ if ($savemsg) From 060d4c5ec0ab239a1535c014f48651996bb59f4b Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 12 Nov 2010 12:02:21 -0500 Subject: [PATCH 81/98] More notice XSS fixes. --- usr/local/www/fbegin.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index b720ca180f..0f8a795496 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -262,13 +262,13 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') { $noticemsg = str_replace("
", "", $noticemsg); $extra_args = ""; if($_GET['xml']) - $extraargs="&xml=" . $_GET['xml']; + $extraargs="&xml=" . htmlspecialchars($_GET['xml']); if($_POST['xml']) - $extraargs="&xml=" . $_POST['xml']; + $extraargs="&xml=" . htmlspecialchars($_POST['xml']); if($_GET['id']) - $extraargs="&xml=" . $_GET['id']; + $extraargs="&xml=" . htmlspecialchars($_GET['id']); if($_POST['id']) - $extraargs="&xml=" . $_POST['id']; + $extraargs="&xml=" . htmlspecialchars($_POST['id']); $notice_msgs = 'Acknowledge All     .:.     '; if ($value['url']) { $notice_msgs .= $date.' - ['.$value['id'].']'; From f01d8c4951c7319f0d06d43caa8b6ae35d2aa933 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 12 Nov 2010 12:15:14 -0500 Subject: [PATCH 82/98] One more potential XSS vector. Not sure how it would have text injected here, but better safe than sorry. --- usr/local/www/fbegin.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index 0f8a795496..92d90fb95a 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -273,7 +273,7 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') { if ($value['url']) { $notice_msgs .= $date.' - ['.$value['id'].']'; } else { - $notice_msgs .= $date.' - ['.$value['id'].']'.$noticemsg.''; + $notice_msgs .= $date.' - ['.$value['id'].']'.htmlspecialchars($noticemsg).''; } $notice_msgs .= "     .:.     "; } From 2bf0ada5ed126215de8f5cac33a75a1148744134 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 12 Nov 2010 12:29:53 -0500 Subject: [PATCH 83/98] Protect against XSS by someone broadcasting an HTML SSID... (better to be safe...) --- usr/local/www/status_wireless.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/status_wireless.php b/usr/local/www/status_wireless.php index 0aa56ba638..cc04bb352c 100755 --- a/usr/local/www/status_wireless.php +++ b/usr/local/www/status_wireless.php @@ -115,7 +115,7 @@ display_top_tabs($tab_array); /* Split by Mac address for the SSID Field */ $split = preg_split("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state); preg_match("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state, $bssid); - $ssid = $split[0]; + $ssid = htmlspecialchars($split[0]); $bssid = $bssid[0]; /* Split the rest by using spaces for this line using the 2nd part */ $split = preg_split("/[ ]+/i", $split[1]); From c895ab7b9da8c0d25136a022db558d0991e09c07 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 12 Nov 2010 16:05:40 -0500 Subject: [PATCH 84/98] Misc XSS fixes --- usr/local/www/installer.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/usr/local/www/installer.php b/usr/local/www/installer.php index 32124a4821..6a83ac67f1 100644 --- a/usr/local/www/installer.php +++ b/usr/local/www/installer.php @@ -289,7 +289,7 @@ function begin_install() { return; unlink_if_exists("/tmp/install_complete"); if($_REQUEST['disk']) - $disk = $_REQUEST['disk']; + $disk = htmlspecialchars($_REQUEST['disk']); else $disk = installer_find_first_disk(); if(!$disk) { @@ -302,7 +302,7 @@ function begin_install() { } // Handle other type of file systems if($_REQUEST['fstype']) - $fstype = strtoupper($_REQUEST['fstype']); + $fstype = htmlspecialchars(strtoupper($_REQUEST['fstype'])); else $fstype = "UFS+S"; write_out_pc_sysinstaller_config($disk, $fstype); @@ -422,15 +422,18 @@ function verify_before_install() { head_html(); body_html(); page_table_start(); - $disk = pcsysinstall_get_disk_info($_REQUEST['disk']); + $disk = pcsysinstall_get_disk_info(htmlspecialchars($_REQUEST['disk'])); $disksize = format_bytes($disk['size'] * 1048576); - $swapsize = $_REQUEST['swapsize']; + $swapsize = htmlspecialchars($_REQUEST['swapsize']); + $fstype_echo = htmlspecialchars($_REQUEST['fstype']); + $disk_echo = htmlspecialchars($_REQUEST['disk']); + $swapsize_echo = htmlspecialchars($_REQUEST['swapsize']); echo << - - + + - +
-
+

;
@@ -451,11 +454,11 @@ function verify_before_install() {

- + - - + +
Disk:{$_REQUEST['disk']}
Disk:{$disk_echo}
Description:{$disk['desc']}
Size:{$disksize}
SWAP Size:{$_REQUEST['swapsize']}
Filesystem:{$_REQUEST['fstype']}
SWAP Size:{$swapsize}
Filesystem:{$fstype_echo}
From fafd303ea918e40fe8267dd2e5bef0ebeb30986a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 12 Nov 2010 18:30:43 -0500 Subject: [PATCH 85/98] Unbreak AJAX --- usr/local/www/guiconfig.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index ca038a5162..0a7663ff4a 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -34,6 +34,9 @@ /* Include authentication routines */ /* THIS MUST BE ABOVE ALL OTHER CODE */ +function csrf_startup() { + csrf_conf('rewrite-js', '/csrf/csrf-magic.js'); +} require_once("csrf/csrf-magic.php"); require_once("authgui.inc"); From 83fcd140dd10ba7396b37693d83f304429a6e5ad Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 12 Nov 2010 18:34:51 -0500 Subject: [PATCH 86/98] CSRF startup code has been moved to guiconfig.inc --- usr/local/www/status_queues.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/usr/local/www/status_queues.php b/usr/local/www/status_queues.php index 82a069339b..ad1c0665cc 100755 --- a/usr/local/www/status_queues.php +++ b/usr/local/www/status_queues.php @@ -41,10 +41,6 @@ ##|*MATCH=status_queues.php* ##|-PRIV -// Handle Javascript/AJAX -function csrf_startup() { - csrf_conf('rewrite-js', '/csrf/csrf-magic.js'); -} require("guiconfig.inc"); if ($_REQUEST['getactivity']) { From 21699e76426d034ab44b6a8166e55024bee97dc8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Nov 2010 23:51:15 +0000 Subject: [PATCH 87/98] Fix test for altq on vlans and wlan. --- etc/inc/interfaces.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index bffb152761..34f2b4abbd 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3281,9 +3281,9 @@ function is_altq_capable($int) { if (in_array($int_family[0], $capable)) return true; - else if (stristr($int_family, "vlan")) /* VLANs are name $parent_$vlan now */ + else if (stristr($int, "vlan")) /* VLANs are name $parent_$vlan now */ return true; - else if (stristr($int_family, "_wlan")) /* WLANs are name $parent_$wlan now */ + else if (stristr($int, "_wlan")) /* WLANs are name $parent_$wlan now */ return true; else return false; From 6f7a997828287492588e8c35106d81d6929a5eb1 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Fri, 12 Nov 2010 20:02:02 -0700 Subject: [PATCH 88/98] Add style to rowhelper normal text fields in packages for consistency. --- usr/local/www/pkg_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php index 1f2b7d4e51..394187eca5 100755 --- a/usr/local/www/pkg_edit.php +++ b/usr/local/www/pkg_edit.php @@ -869,7 +869,7 @@ function display_row($trc, $value, $fieldname, $type, $rowhelper, $size) { global $text, $config; echo "\n"; if($type == "input") { - echo "\n"; + echo "\n"; } else if($type == "checkbox") { if($value) echo "\n"; From bddc88183aa575420b6c16f8c73c3df7dc251895 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Fri, 12 Nov 2010 22:44:11 -0700 Subject: [PATCH 89/98] Form image buttons are submit buttons and thus default buttons, causing unwanted behavior with the enter key. Use links instead, where possible. --- usr/local/www/firewall_schedule_edit.php | 8 ++++---- usr/local/www/firewall_shaper_layer7.php | 4 ++-- usr/local/www/interfaces_groups_edit.php | 4 ++-- usr/local/www/interfaces_qinq_edit.php | 4 ++-- usr/local/www/pkg_edit.php | 4 ++-- usr/local/www/services_dhcp.php | 2 +- usr/local/www/services_igmpproxy_edit.php | 2 +- usr/local/www/vpn_pppoe_edit.php | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/usr/local/www/firewall_schedule_edit.php b/usr/local/www/firewall_schedule_edit.php index 1023e52aa3..08b8b8c3eb 100644 --- a/usr/local/www/firewall_schedule_edit.php +++ b/usr/local/www/firewall_schedule_edit.php @@ -622,11 +622,11 @@ function insertElements(tempFriendlyTime, starttimehour, starttimemin, stoptimeh tr.appendChild(td); td = d.createElement("td"); - td.innerHTML = ""; + td.innerHTML = ""; tr.appendChild(td); td = d.createElement("td"); - td.innerHTML = ""; + td.innerHTML = ""; tr.appendChild(td); td = d.createElement("td"); @@ -1131,10 +1131,10 @@ EOD; - /images/icons/icon_e.gif' onclick='editRow("",this); return false;' value='Edit'> + /images/icons/icon_e.gif' /> - /images/icons/icon_x.gif' onclick='removeRow(this); return false;' value='Delete'> + /images/icons/icon_x.gif' /> diff --git a/usr/local/www/firewall_shaper_layer7.php b/usr/local/www/firewall_shaper_layer7.php index 56e36d0c7c..0a73a8454f 100755 --- a/usr/local/www/firewall_shaper_layer7.php +++ b/usr/local/www/firewall_shaper_layer7.php @@ -358,7 +358,7 @@ function addRow(table_id) { var tFielsNum = rows_count - initial_count[table_id]; if (rows_limit!=0 && tFielsNum >= rows_limit) return false; - var remove = ''; + var remove = ''; try { var newRow = tbl.insertRow(rows_count); @@ -539,7 +539,7 @@ include("fbegin.inc"); - " /> + diff --git a/usr/local/www/interfaces_groups_edit.php b/usr/local/www/interfaces_groups_edit.php index 4196ad87e9..adfb102d08 100755 --- a/usr/local/www/interfaces_groups_edit.php +++ b/usr/local/www/interfaces_groups_edit.php @@ -212,7 +212,7 @@ var addRowTo = (function() { td = d.createElement("td"); td.rowSpan = "1"; - td.innerHTML = ''; + td.innerHTML = ''; tr.appendChild(td); tbody.appendChild(tr); totalrows++; @@ -298,7 +298,7 @@ function removeRow(el) { - " /> + '; + td.innerHTML = ''; tr.appendChild(td); tbody.appendChild(tr); totalrows++; @@ -370,7 +370,7 @@ function removeRow(el) { - " /> + "") { $rowcounter++; echo ""; - echo ""; + echo ""; echo "\n"; echo "\n"; } @@ -768,7 +768,7 @@ if ($pkg['tabs'] <> "") { $rowcounter++; echo ""; - echo ""; + echo ""; echo "\n"; echo "\n"; } diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php index dae460ec94..e6c3f68306 100755 --- a/usr/local/www/services_dhcp.php +++ b/usr/local/www/services_dhcp.php @@ -839,7 +839,7 @@ include("head.inc"); - " /> + diff --git a/usr/local/www/services_igmpproxy_edit.php b/usr/local/www/services_igmpproxy_edit.php index 2336ea1c1d..63cb10ec31 100755 --- a/usr/local/www/services_igmpproxy_edit.php +++ b/usr/local/www/services_igmpproxy_edit.php @@ -255,7 +255,7 @@ include("head.inc"); - " /> + " type="text" class="formfld unknown" id="ip" size="10" value="" /> - " /> + Date: Sat, 13 Nov 2010 19:38:39 -0500 Subject: [PATCH 90/98] Open link in new tab/window --- usr/local/www/system_advanced_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/system_advanced_admin.php b/usr/local/www/system_advanced_admin.php index 8d00cd2289..2bdf7e2828 100644 --- a/usr/local/www/system_advanced_admin.php +++ b/usr/local/www/system_advanced_admin.php @@ -374,7 +374,7 @@ function prot_change() { Wikipedia."); ?> + "webConfigurator access in certain corner cases such as using 3rd party scripts to interact with pfSense. More information on HTTP_REFERER is available from Wikipedia."); ?> From 856d2bf957e10c98597a29135337b5bd35899893 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sat, 13 Nov 2010 23:00:43 -0700 Subject: [PATCH 91/98] Unset this reference before reusing the variable name to prevent corruption of groups. --- etc/inc/auth.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 362843646b..84b73dc02c 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -475,6 +475,7 @@ function local_user_set_groups($user, $new_groups = NULL ) { $group['member'][] = $user['uid']; $mod_groups[] = $group; } + unset($group); /* determine which memberships to remove */ foreach ($cur_groups as $groupname) { @@ -489,6 +490,7 @@ function local_user_set_groups($user, $new_groups = NULL ) { $mod_groups[] = $group; } } + unset($group); /* sync all modified groups */ foreach ($mod_groups as $group) From 0532e54d93b12be7da1bc68dea88f53f07bd0082 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Nov 2010 03:10:52 -0700 Subject: [PATCH 92/98] Rework handling of ports for reflection on port forwards to work properly with port aliases. Ticket #672 --- etc/inc/filter.inc | 163 +++++++++++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 63 deletions(-) diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index d0295c03be..f5b4cdf7b9 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -883,7 +883,7 @@ function filter_generate_reflection_nat($rule, $nat_ifs, $protocol, $target, $ta return $natrules; } -function filter_generate_reflection($rule, $nordr, $rdr_ifs, $srcaddr, $dstaddr_port, $dstport, &$starting_localhost_port, &$reflection_txt) { +function filter_generate_reflection($rule, $nordr, $rdr_ifs, $srcaddr, $dstaddr_port, &$starting_localhost_port, &$reflection_txt) { global $FilterIflist, $config; // Initialize natrules holder string @@ -904,16 +904,43 @@ function filter_generate_reflection($rule, $nordr, $rdr_ifs, $srcaddr, $dstaddr_ $natrules .= "\n# Reflection redirects\n"; - if($dstport[1]) - $range_end = ($dstport[1]); - else - $range_end = ($dstport[0]); + $localport = $rule['local-port']; + if(!empty($localport) && is_alias($localport)) { + $localport = filter_expand_alias($localport); + $localport = explode(" ", trim($localport)); + // The translation port for rdr, when specified, does not support more than one port or range. + // Emulating for behavior consistent with the original port forward. + $localport = $localport[0]; + } + + if(is_alias($rule['destination']['port'])) { + if(empty($localport) || $rule['destination']['port'] == $rule['local-port']) { + $dstport = filter_expand_alias($rule['destination']['port']); + $dstport = array_filter(explode(" ", trim($dstport))); + $localport = ""; + } else if(!empty($localport)) { + $dstport = array($localport); + } + } else { + $dstport = array(str_replace("-", ":", $rule['destination']['port'])); + $dstport_split = explode(":", $dstport[0]); + + if(!empty($localport) && $dstport_split[0] != $rule['local-port']) { + if(!is_alias($rule['local-port']) && $dstport_split[1] && $dstport_split[0] != $dstport_split[1]) { + $localendport = $localport + ($dstport_split[1] - $dstport_split[0]); + $localport .= ":$localendport"; + } + + $dstport = array($localport); + } else + $localport = ""; + } $dstaddr = explode(" ", $dstaddr_port); if($dstaddr[2]) $rflctintrange = $dstaddr[2]; else - $rflctintrange = ""; + return ""; $dstaddr = $dstaddr[0]; if(empty($dstaddr) || trim($dstaddr) == "0.0.0.0" || strtolower(trim($dstaddr)) == "port") return ""; @@ -964,67 +991,77 @@ function filter_generate_reflection($rule, $nordr, $rdr_ifs, $srcaddr, $dstaddr_ else return ""; - if($rule['local-port']) - $lrange_start = $rule['local-port']; - if(($range_end + 1) - $dstport[0] > 500) { - log_error("Not installing nat reflection rules for a port range > 500"); + $starting_localhost_port_tmp = $starting_localhost_port; + $toomanyports = false; /* only install reflection rules for < 19991 items */ - } else if($starting_localhost_port < 19991) { - $loc_pt = $lrange_start; - $rflctnorange = true; - if(is_alias($loc_pt)) { - $loc_pt_translated = filter_expand_alias($loc_pt); - if(empty($loc_pt_translated)) { - log_error("Reflection processing: {$loc_pt} is not a vaild port alias."); - continue; - } - $toadd_array = split(" ", $loc_pt_translated); - $rflctnorange = false; - } - - $inetdport = $starting_localhost_port; - if($range_end > $dstport[0]) { - $rflctrange = "{$starting_localhost_port}"; - $delta = $range_end - $dstport[0]; - if(($starting_localhost_port + $delta) > 19990) { - log_error("Installing partial nat reflection rules. Maximum 1,000 reached."); - $delta = 19990 - $starting_localhost_port; - $range_end = $dstport[0] + $delta; - $rflctintrange = ""; - } - $starting_localhost_port = $starting_localhost_port + $delta; - $rflctrange .= ":{$starting_localhost_port}"; - if(empty($rflctintrange)) - $rflctintrange = "{$dstport[0]}:{$range_end}"; - if($rflctnorange) - $toadd_array = range($loc_pt, $loc_pt + $delta); - $starting_localhost_port++; - } else { + foreach($dstport as $loc_pt) { + if($starting_localhost_port < 19991) { + $toadd_array = array(); + $inetdport = $starting_localhost_port; $rflctrange = $starting_localhost_port; - if(empty($rflctintrange)) - $rflctintrange = $dstport[0]; - if($rflctnorange) - $toadd_array = array($loc_pt); - $starting_localhost_port++; + + $loc_pt = explode(":", $loc_pt); + if($loc_pt[1] && $loc_pt[1] > $loc_pt[0]) + $delta = $loc_pt[1] - $loc_pt[0]; + else + $delta = 0; + + if(($inetdport + $delta + 1) - $starting_localhost_port_tmp > 500) { + log_error("Not installing nat reflection rules for a port range > 500"); + $inetdport = $starting_localhost_port; + $toadd_array = array(); + $toomanyports = true; + break; + } else if(($inetdport + $delta) > 19990) { + log_error("Installing partial nat reflection rules. Maximum 1,000 reached."); + $delta = 19990 - $inetdport; + $loc_pt[1] = $loc_pt[0] + $delta; + if($delta == 0) + unset($loc_pt[1]); + $toomanyports = true; + + if(!empty($localport)) { + if(is_alias($rule['destination']['port'])) { + $rflctintrange = alias_expand($rule['destination']['port']); + } else { + if($dstport_split[1]) + $dstport_split[1] = $dstport_split[0] + $inetdport + $delta - $starting_localhost_port; + $rflctintrange = implode(":", $dstport_split); + } + } + } + + if(empty($localport)) + $rflctintrange = implode(":", $loc_pt); + if($inetdport + $delta > $starting_localhost_port) + $rflctrange .= ":" . ($inetdport + $delta); + $starting_localhost_port = $inetdport + $delta + 1; + $toadd_array = array_merge($toadd_array, range($loc_pt[0], $loc_pt[0] + $delta)); + + if(!empty($toadd_array)) { + foreach($toadd_array as $tda) { + if (empty($tda)) + continue; + foreach($reflect_protos as $reflect_proto) { + if($reflect_proto == "udp") { + $socktype = "dgram"; + $dash_u = "-u "; + } else { + $socktype = "stream"; + $dash_u = ""; + } + $reflection_txt[] = "{$inetdport}\t{$socktype}\t{$reflect_proto}\tnowait/0\tnobody\t/usr/bin/nc\tnc {$dash_u}-w {$reflectiontimeout} {$target} {$tda}\n"; + } + $inetdport++; + } + $natrules .= "rdr on {$rdr_if_list} proto {$protocol} from {$srcaddr} to {$dstaddr} port {$rflctintrange} tag PFREFLECT -> 127.0.0.1 port {$rflctrange}\n"; + } } - foreach($toadd_array as $tda) { - if (empty($tda)) - continue; - foreach($reflect_protos as $reflect_proto) { - if($reflect_proto == "udp") { - $socktype = "dgram"; - $dash_u = "-u "; - } else { - $socktype = "stream"; - $dash_u = ""; - } - $reflection_txt[] = "{$inetdport}\t{$socktype}\t{$reflect_proto}\tnowait/0\tnobody\t/usr/bin/nc\tnc {$dash_u}-w {$reflectiontimeout} {$target} {$tda}\n"; - } - $inetdport++; - } - $natrules .= "rdr on {$rdr_if_list} proto {$protocol} from {$srcaddr} to {$dstaddr} port {$rflctintrange} tag PFREFLECT -> 127.0.0.1 port {$rflctrange}\n"; + if($toomanyports) + break; } + $reflection_txt = array_unique($reflection_txt); } @@ -1443,7 +1480,7 @@ function filter_nat_rules_generate() { $natrules .= "no nat on {$natif} proto tcp from ({$natif}) to {$rule_subnet}/{$rule_interface_subnet}\n"; $natrules .= "nat on {$natif} proto tcp from {$rule_subnet}/{$rule_interface_subnet} to {$target} port {$dstport[0]} -> ({$natif})\n"; } - $natrules .= filter_generate_reflection($rule, $nordr, $nat_if_list, $srcaddr, $dstaddr, $dstport, $starting_localhost_port, $reflection_rules); + $natrules .= filter_generate_reflection($rule, $nordr, $nat_if_list, $srcaddr, $dstaddr, $starting_localhost_port, $reflection_rules); $natrules .= "\n"; foreach ($reflection_rules as $txtline) From 0aa72c108dd7d15f9bac62bf22eef0924c717b0d Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Nov 2010 04:05:40 -0700 Subject: [PATCH 93/98] Don't perform referer check if display_error_form is not defined (captive portal), just like as is done for the DNS rebind check. Ticket #1007 --- etc/inc/auth.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 84b73dc02c..dbd8a3e790 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -87,7 +87,7 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][ } // If the HTTP_REFERER is something other than ourselves then disallow. -if(!$config['system']['nohttpreferercheck']) { +if(function_exists("display_error_form") && !$config['system']['nohttpreferercheck']) { if($_SERVER['HTTP_REFERER']) { $found_host = false; $hostname_me = $config['system']['hostname'] . "." . $config['system']['domain']; From ba8e08709a2c4bbb35e1640d7ac744da7e58b6e5 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Nov 2010 05:36:28 -0700 Subject: [PATCH 94/98] Copy /boot/loader.conf.local to the newly imaged slice. Ticket #892 --- etc/rc.firmware | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/rc.firmware b/etc/rc.firmware index a7cbfafa13..b10737e02a 100755 --- a/etc/rc.firmware +++ b/etc/rc.firmware @@ -287,6 +287,12 @@ pfSenseNanoBSDupgrade) mkdir /tmp/$GLABEL_SLICE mount /dev/ufs/$GLABEL_SLICE /tmp/$GLABEL_SLICE + # If /boot/loader.conf.local exists + # copy to the other slice. + if [ -f /boot/loader.conf.local ]; then + cp /boot/loader.conf.local /tmp/$GLABEL_SLICE/boot/loader.conf.local + fi + # If /tmp/$GLABEL_SLICE/tmp/post_upgrade_command exists # after update then execute the command. if [ -f /tmp/$GLABEL_SLICE/tmp/post_upgrade_command ]; then From bd32ac6cf1cfe6812f06aa30cf6a2f3cf7a3d6dd Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Nov 2010 06:59:41 -0700 Subject: [PATCH 95/98] Fix case of variable name for swap usage. Ticket #477 --- usr/local/www/widgets/widgets/system_information.widget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index aadd78e813..b808fdeef2 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -224,7 +224,7 @@ $curcfg = $config['system']['firmware']; SWAP usage - left barred bargray barright bar + left barred bargray barright bar   From fbd96b06f5145d0eb1f8d397ffb02bbdd651093d Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Nov 2010 07:55:31 -0700 Subject: [PATCH 96/98] Fix variable names. Ticket #954 --- usr/local/www/firewall_nat_out.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr/local/www/firewall_nat_out.php b/usr/local/www/firewall_nat_out.php index fb59a6027a..bf72f2c885 100755 --- a/usr/local/www/firewall_nat_out.php +++ b/usr/local/www/firewall_nat_out.php @@ -132,7 +132,7 @@ if (isset($_POST['save']) && $_POST['save'] == "Save") { $ossubnet = $config['pptpd']['pptp_subnet']; else $ossubnet = "32"; - $osn = gen_subnet($config['pptpd']['localip'], $osn); + $osn = gen_subnet($config['pptpd']['localip'], $ossubnet); $natent = array(); $natent['source']['network'] = "{$osn}/{$ossubnet}"; $natent['sourceport'] = ""; @@ -148,10 +148,10 @@ if (isset($_POST['save']) && $_POST['save'] == "Save") { if($config['pppoe']['mode'] == "server") { if (is_ipaddr($config['pppoe']['localip'])) { if($config['pppoe']['pppoe_subnet'] <> "") - $ossubnet = $config['pppoe']['pptp_subnet']; + $ossubnet = $config['pppoe']['pppoe_subnet']; else $ossubnet = "32"; - $osn = gen_subnet($config['pppoe']['localip'], $osn); + $osn = gen_subnet($config['pppoe']['localip'], $ossubnet); $natent = array(); $natent['source']['network'] = "{$osn}/{$ossubnet}"; $natent['sourceport'] = ""; @@ -167,10 +167,10 @@ if (isset($_POST['save']) && $_POST['save'] == "Save") { if($config['l2tp']['mode'] == "server") { if (is_ipaddr($config['l2tp']['localip'])) { if($config['l2tp']['l2tp_subnet'] <> "") - $ossubnet = $config['l2tp']['pptp_subnet']; + $ossubnet = $config['l2tp']['l2tp_subnet']; else $ossubnet = "32"; - $osn = gen_subnet($config['l2tp']['localip'], $osn); + $osn = gen_subnet($config['l2tp']['localip'], $ossubnet); $natent = array(); $natent['source']['network'] = "{$osn}/{$ossubnet}"; $natent['sourceport'] = ""; From 364ecdd1baa20f4809ff5699d557971d4960768a Mon Sep 17 00:00:00 2001 From: jim-p Date: Sun, 14 Nov 2010 14:29:26 -0500 Subject: [PATCH 97/98] Fix misnamed form field on CRL import. --- usr/local/www/system_crlmanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/system_crlmanager.php b/usr/local/www/system_crlmanager.php index d7f7108d60..9a78cb6f9a 100644 --- a/usr/local/www/system_crlmanager.php +++ b/usr/local/www/system_crlmanager.php @@ -344,7 +344,7 @@ function method_change() { - +
From 64ec1ddf3503679cdf866e37ca9e99ec9974dc6b Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 14 Nov 2010 14:46:35 -0500 Subject: [PATCH 98/98] Add nocsrf flag --- usr/local/www/guiconfig.inc | 8 +++++--- usr/local/www/installer.php | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index 0a7663ff4a..bafb8fa482 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -34,10 +34,12 @@ /* Include authentication routines */ /* THIS MUST BE ABOVE ALL OTHER CODE */ -function csrf_startup() { - csrf_conf('rewrite-js', '/csrf/csrf-magic.js'); +if(!$nocsrf) { + function csrf_startup() { + csrf_conf('rewrite-js', '/csrf/csrf-magic.js'); + } + require_once("csrf/csrf-magic.php"); } -require_once("csrf/csrf-magic.php"); require_once("authgui.inc"); /* make sure nothing is cached */ diff --git a/usr/local/www/installer.php b/usr/local/www/installer.php index 6a83ac67f1..aa3b9c0603 100644 --- a/usr/local/www/installer.php +++ b/usr/local/www/installer.php @@ -27,6 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +$nocsrf = true; + require("globals.inc"); require("guiconfig.inc");