From 93d00ecd2050f7db5a4ae3abd4fcffa57c59e034 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 12 Mar 2015 08:15:47 +0100 Subject: [PATCH] inc/globals: far-reaching prune of global variables * Remove spurious debug output that was never enabled and make actual error messages the default behaviour. * Update links and remove a bit of softcoding that was going on around the GUI through global variables (we don't want to hide the help menu, nope). --- src/etc/inc/authgui.inc | 4 +-- src/etc/inc/config.gui.inc | 7 ---- src/etc/inc/config.inc | 7 ---- src/etc/inc/dyndns.class | 18 +++++----- src/etc/inc/filter.inc | 13 +------ src/etc/inc/filter_log.inc | 7 ++-- src/etc/inc/globals.inc | 24 ++++--------- src/etc/inc/interfaces.inc | 24 ------------- src/etc/inc/pfsense-utils.inc | 12 +------ src/etc/inc/services.inc | 3 -- src/etc/inc/util.inc | 13 ------- src/etc/rc.bootup | 6 ++-- src/www/fbegin.inc | 36 ++++++------------- src/www/foot.inc | 4 +-- src/www/license.php | 7 ++-- src/www/system_firmware.php | 4 +-- src/www/system_firmware_tabs.php | 60 ++++++++++++++++---------------- 17 files changed, 72 insertions(+), 177 deletions(-) diff --git a/src/etc/inc/authgui.inc b/src/etc/inc/authgui.inc index 62168b247..63e79a107 100644 --- a/src/etc/inc/authgui.inc +++ b/src/etc/inc/authgui.inc @@ -284,8 +284,8 @@ function display_login_form() diff --git a/src/etc/inc/config.gui.inc b/src/etc/inc/config.gui.inc index ce247c096..c3aa78834 100644 --- a/src/etc/inc/config.gui.inc +++ b/src/etc/inc/config.gui.inc @@ -50,13 +50,6 @@ if (file_exists("/usr/local/etc/platform")) { $g['platform'] = "unknown"; } -/* if /debugging exists, lets set $debugging - so we can output more information */ -if(file_exists("/debugging")) { - $debugging = true; - $g['debug'] = true; -} - $config = parse_config(); if($config_parsed == true) { diff --git a/src/etc/inc/config.inc b/src/etc/inc/config.inc index 753dfdc81..e96d19abe 100644 --- a/src/etc/inc/config.inc +++ b/src/etc/inc/config.inc @@ -55,13 +55,6 @@ if (file_exists("/usr/local/etc/platform")) { $g['platform'] = "unknown"; } -/* if /debugging exists, lets set $debugging - so we can output more information */ -if(file_exists("/debugging")) { - $debugging = true; - $g['debug'] = true; -} - if(file_exists("/var/run/booting") && file_exists("/conf/config.xml")) { $config_contents = file_get_contents("/conf/config.xml"); if(stristr($config_contents, "") == true) { diff --git a/src/etc/inc/dyndns.class b/src/etc/inc/dyndns.class index 13774d8dc..de350de6f 100644 --- a/src/etc/inc/dyndns.class +++ b/src/etc/inc/dyndns.class @@ -1375,16 +1375,16 @@ * - status is returned from a DynDNS service provider. */ function _debug($data) { - global $g; + global $debug; - if (!$g['debug']) - return; - $string = date('m-d-y h:i:s').' - ('.$this->_debugID.') - ['.$this->_dnsService.'] - '.$data."\n"; - conf_mount_rw(); - $file = fopen($this->_debugFile, 'a'); - fwrite($file, $string); - fclose($file); - conf_mount_ro(); + if ($debug) { + $string = date('m-d-y h:i:s').' - ('.$this->_debugID.') - ['.$this->_dnsService.'] - '.$data."\n"; + conf_mount_rw(); + $file = fopen($this->_debugFile, 'a'); + fwrite($file, $string); + fclose($file); + conf_mount_ro(); + } } function _checkIP() { global $debug; diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index 5e2edd305..99cd2d658 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -680,8 +680,6 @@ function filter_generate_gateways() { $int = $member['int']; $gatewayip = $member['gwip']; if (($int <> "") && is_ipaddr($gatewayip)) { - if ($g['debug']) - log_error(sprintf(gettext('Setting up route with %1$s on %2$s'), $gatewayip, $int)); if ($member['weight'] > 1) { $routeto .= str_repeat("( {$int} {$gatewayip} ) ", $member['weight']); } else @@ -2577,8 +2575,7 @@ function filter_generate_user_rule($rule) if(!isset($config['system']['schedule_states'])) mwexec("/sbin/pfctl -y {$sched['schedlabel']}"); return "# schedule finished - {$rule['descr']}"; - } else if($g['debug']) - log_error("[TDR DEBUG] status true -- rule type '$type'"); + } $aline['schedlabel'] = " schedule \"{$sched['schedlabel']}\" "; break; @@ -3351,8 +3348,6 @@ function filter_get_time_based_rule_status($schedule) { function filter_tdr_day($schedule) { global $g; - if($g['debug']) - log_error("[TDR DEBUG] filter_tdr_day($schedule)"); /* * Calculate day of month. @@ -3374,8 +3369,6 @@ function filter_tdr_hour($schedule) { $starting_time = strtotime($tmp[0]); $ending_time = strtotime($tmp[1]); $now = strtotime("now"); - if($g['debug']) - log_error("[TDR DEBUG] S: $starting_time E: $ending_time N: $now"); if($now >= $starting_time and $now < $ending_time) return true; return false; @@ -3392,8 +3385,6 @@ function filter_tdr_position($schedule) { * ... */ $weekday = date("w"); - if($g['debug']) - log_error("[TDR DEBUG] filter_tdr_position($schedule) $weekday"); if($weekday == 0) $weekday = 7; $schedule_days = explode(",", $schedule); @@ -3412,8 +3403,6 @@ function filter_tdr_month($schedule) { */ $todays_month = date("n"); $months = explode(",", $schedule); - if($g['debug']) - log_error("[TDR DEBUG] filter_tdr_month($schedule)"); foreach($months as $month) { if($month == $todays_month) return true; diff --git a/src/etc/inc/filter_log.inc b/src/etc/inc/filter_log.inc index ec7ae8b3b..d362b0112 100644 --- a/src/etc/inc/filter_log.inc +++ b/src/etc/inc/filter_log.inc @@ -242,8 +242,7 @@ function parse_filter_line($line) { $flent['advbase'] = $rule_data[$field++]; } } else { - if($g['debug']) - log_error(sprintf(gettext("There was a error parsing rule number: %s. Please report to mailing list or forum."), $flent['rulenum'])); + log_error(sprintf(gettext("There was a error parsing rule number: %s. Please report to mailing list or forum."), $flent['rulenum'])); return ""; } @@ -251,9 +250,7 @@ function parse_filter_line($line) { if (!((trim($flent['src']) == "") || (trim($flent['dst']) == "") || (trim($flent['time']) == ""))) { return $flent; } else { - if($g['debug']) { - log_error(sprintf(gettext("There was a error parsing rule: %s. Please report to mailing list or forum."), $errline)); - } + log_error(sprintf(gettext("There was a error parsing rule: %s. Please report to mailing list or forum."), $errline)); return ""; } } diff --git a/src/etc/inc/globals.inc b/src/etc/inc/globals.inc index 4aa56b933..767c04bdb 100644 --- a/src/etc/inc/globals.inc +++ b/src/etc/inc/globals.inc @@ -43,29 +43,22 @@ $g = array( "varetc_path" => "/var/etc", "vardb_path" => "/var/db", "varlog_path" => "/var/log", - "tmp_path" => "/tmp", "xml_rootobj" => "pfsense", "admin_group" => "admins", "product_name" => "OPNsense", - "product_copyright" => "Deciso B.V.", - "product_copyright_url" => "http://www.deciso.com", - "product_copyright_years" => "2014 - ".date("Y"), - "product_website" => "www.opnsense.org", - "product_website_footer" => "https://www.opnsense.org/?gui22", - "product_email" => "coreteam@opnsense.org", - "hidedownloadbackup" => false, - "hidebackupbeforeupgrade" => false, - "disablehelpmenu" => false, - "disablehelpicon" => false, + "product_website" => "https://opnsense.org", + "product_email" => "project@opnsense.org", + "product_copyright_owner" => "Deciso B.V.", + "product_copyright_years" => "2014 - 2015", + "product_copyright_url" => "https://www.deciso.com/", "crashreporterurl" => "https://crash.opnsense.org/", - "debug" => false, "latest_config" => "11.1", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "101", "minimum_ram_warning_text" => "128 MB", "wan_interface_name" => "wan", "nopccard_platforms" => array("wrap", "net48xx"), - "xmlrpcbaseurl" => "https://packages.pfsense.org", + "xmlrpcbaseurl" => "https://not.supported.opnsense.org", "captiveportal_path" => "/usr/local/captiveportal", "captiveportal_element_path" => "/var/db/cpelements", "captiveportal_element_sizelimit" => 1048576, @@ -94,11 +87,8 @@ if(file_exists("/usr/local/etc/platform")) { $g['platform'] = trim(file_get_contents("/usr/local/etc/platform")); if($g['platform'] == "nanobsd") { $g['firmware_update_text']="OPNsense-*.img.gz"; - $g['hidedownloadbackup'] = true; - $g['hidebackupbeforeupgrade'] = true; - } else { - $g['firmware_update_text']="pfSense-*.tgz"; + $g['firmware_update_text']="OPNsense-*.tgz"; } } diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index ebad97668..d1acca3fa 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -1055,8 +1055,6 @@ function interfaces_configure() if (file_exists("/var/run/booting")) printf(gettext("Configuring %s interface..."), $ifname); - if($g['debug']) - log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); if (file_exists("/var/run/booting")) echo gettext( "done.") . "\n"; @@ -1081,8 +1079,6 @@ function interfaces_configure() foreach ($track6_list as $if => $ifname) { if (file_exists("/var/run/booting")) printf(gettext("Configuring %s interface..."), $ifname); - if ($g['debug']) - log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); @@ -1102,8 +1098,6 @@ function interfaces_configure() foreach ($delayed_list as $if => $ifname) { if (file_exists("/var/run/booting")) printf(gettext("Configuring %s interface..."), $ifname); - if ($g['debug']) - log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); @@ -1117,8 +1111,6 @@ function interfaces_configure() foreach ($bridge_list as $if => $ifname) { if (file_exists("/var/run/booting")) printf(gettext("Configuring %s interface..."), $ifname); - if($g['debug']) - log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); @@ -1185,9 +1177,6 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg = if (!isset($config['interfaces'][$interface])) return; - if ($g['debug']) - log_error("Calling interface down for interface {$interface}, destroy is " . (($destroy) ? 'true' : 'false')); - /* * NOTE: The $realifv6 is needed when WANv4 is type PPP and v6 is DHCP and the option v6 from v4 is used. * In this case the real $realif of v4 is different from that of v6 for operation. @@ -2948,8 +2937,6 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven interface_virtual_create($interface_to_check); /* Disable Accepting router advertisements unless specifically requested */ - if ($g['debug']) - log_error("Deny router advertisements for interface {$interface}"); mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " inet6 -accept_rtadv"); /* wireless configuration? */ @@ -3210,13 +3197,9 @@ function interface_track6_configure($interface = "lan", $wancfg, $linkupevent = switch($trackcfg['ipaddrv6']) { case "6to4": - if ($g['debug']) - log_error("Interface {$interface} configured via {$wancfg['track6-interface']} type {$type}"); interface_track6_6to4_configure($interface, $wancfg); break; case "6rd": - if ($g['debug']) - log_error("Interface {$interface} configured via {$wancfg['track6-interface']} type {$type}"); interface_track6_6rd_configure($interface, $wancfg); break; case "dhcp6": @@ -3423,8 +3406,6 @@ function interface_6rd_configure($interface = "wan", $wancfg) { mwexec("/sbin/ifconfig {$stfiface} stfv4br " . escapeshellarg($wancfg['gateway-6rd'])); if ($wancfg['prefix-6rd-v4plen'] > 0 && $wancfg['prefix-6rd-v4plen'] < 32) mwexec("/sbin/ifconfig {$stfiface} stfv4net {$ip4address}/{$wancfg['prefix-6rd-v4plen']}"); - if ($g['debug']) - log_error("Created 6rd interface {$stfiface} {$rd6prefix}/{$rd6prefixlen}"); /* write out a default router file */ file_put_contents("/tmp/{$wanif}_routerv6", "{$rd6brgw}\n"); @@ -3521,9 +3502,6 @@ function interface_6to4_configure($interface = "wan", $wancfg){ pfSense_interface_flags($stfiface, IFF_LINK2); mwexec("/sbin/ifconfig {$stfiface} inet6 {$stflanpr} prefixlen 16"); - if ($g['debug']) - log_error("Set IPv6 address inet6 {$stflanpr} prefixlen 16 for {$stfiface}, route {$stfbrgw}"); - /* write out a default router file */ file_put_contents("/tmp/{$wanif}_routerv6", "{$stfbrgw}"); file_put_contents("/tmp/{$wanif}_defaultgwv6", "{$stfbrgw}"); @@ -3582,8 +3560,6 @@ function interface_dhcpv6_configure($interface = "wan", $wancfg) { $iflist = link_interface_to_track6($interface); foreach ($iflist as $friendly => $ifcfg) { if (is_numeric($ifcfg['track6-prefix-id'])) { - if ($g['debug']) - log_error("setting up $ifdescr - {$ifcfg['track6-prefix-id']}"); $realif = get_real_interface($friendly); $dhcp6cconf .= " prefix-interface {$realif} {\n"; $dhcp6cconf .= " sla-id {$ifcfg['track6-prefix-id']};\n"; diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index f683f27c0..f6dd04496 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -739,19 +739,11 @@ function strncpy(&$dst, $src, $length) { function reload_interfaces_sync() { global $config, $g; - if($g['debug']) - log_error(gettext("reload_interfaces_sync() is starting.")); - /* parse config.xml again */ $config = parse_config(true); /* enable routing */ system_routing_enable(); - if($g['debug']) - log_error(gettext("Enabling system routing")); - - if($g['debug']) - log_error(gettext("Cleaning up Interfaces")); /* set up interfaces */ interfaces_configure(); @@ -1473,9 +1465,7 @@ function compare_hostname_to_dnscache($hostname) { } if(trim($oldcontents) != trim($contents)) { - if($g['debug']) { - log_error(sprintf(gettext('DNSCACHE: Found old IP %1$s and new IP %2$s'), $oldcontents, $contents)); - } + log_error(sprintf(gettext('DNSCACHE: Found old IP %1$s and new IP %2$s'), $oldcontents, $contents)); return ($oldcontents); } else { return false; diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 70dbf2570..ed5186f61 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -217,9 +217,6 @@ function services_radvd_configure($blacklist = array()) $autotype = $config['interfaces'][$trackif]['ipaddrv6']; - if ($g['debug']) - log_error("configuring RA on {$if} for type {$autotype} radvd subnet {$subnetv6}/{$ifcfgsnv6}"); - $radvdconf .= "# Generated config for {$autotype} delegation from {$trackif} on {$if}\n"; $radvdconf .= "interface {$realif} {\n"; $radvdconf .= "\tAdvSendAdvert on;\n"; diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index aee40bf33..cddd582e8 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1053,10 +1053,6 @@ function log_error($error) } syslog(LOG_ERR, "$page: $error"); - - if ($g['debug']) { - syslog(LOG_WARNING, var_dump(debug_backtrace())); - } } /****f* util/exec_command @@ -1079,10 +1075,6 @@ function exec_command($command) { function mwexec($command, $mute = false, $clearsigmask = false) { global $g; - if ($g['debug']) { - if (!$_SERVER['REMOTE_ADDR']) - echo "mwexec(): $command\n"; - } $oarr = array(); $retval = 0; @@ -1108,11 +1100,6 @@ function mwexec($command, $mute = false, $clearsigmask = false) { function mwexec_bg($command, $clearsigmask = false) { global $g; - if ($g['debug']) { - if (!$_SERVER['REMOTE_ADDR']) - echo "mwexec(): $command\n"; - } - if ($clearsigmask) { $oldset = array(); pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 1eaa6afb4..8c0ba12b2 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -223,11 +223,9 @@ setup_microcode(); echo "done.\n"; /* set up interfaces */ -if(!$debugging) - mute_kernel_msgs(); +mute_kernel_msgs(); interfaces_configure(); -if(!$debugging) - unmute_kernel_msgs(); +unmute_kernel_msgs(); /* re-make hosts file after configuring interfaces */ system_hosts_generate(); diff --git a/src/www/fbegin.inc b/src/www/fbegin.inc index b97a11af7..18ed76bd1 100755 --- a/src/www/fbegin.inc +++ b/src/www/fbegin.inc @@ -297,24 +297,15 @@ if (isset($config['system']['developer'])) { } $diagnostics_menu = msort(array_merge($diagnostics_menu, return_ext_menu("Diagnostics")),0); -//$gold_menu = array(); -//$gold_menu[] = array(gettext("pfSense Gold"), "https://www.pfsense.org/gold"); -//$gold_menu = msort(array_merge($gold_menu, return_ext_menu("Gold")),0); - -if(! $g['disablehelpmenu']) { - $help_menu = array(); - $help_menu[] = array(gettext("About this Page"), $helpurl); - if($g['product_name'] == "pfSense") - $help_menu[] = array(gettext("Bug Database"), "https://github.com/opnsense/core/issues"); - $help_menu[] = array(gettext("User Forum"), "http://forum.opnsense.org/"); - $help_menu[] = array(gettext("Documentation"), "http://wiki.opnsense.org/"); - $help_menu[] = array(gettext("Developers Wiki"), "http://wiki.opnsense.org/index.php/developers"); - $help_menu[] = array(gettext("Paid Support"), "http://opnsense.org/support-overview/commercial-support/"); - //$help_menu[] = array(gettext("pfSense Book"), "https://www.pfsense.org/j.php?jumpto=book"); - //$help_menu[] = array(gettext("Search portal"), "https://www.pfsense.org/j.php?jumpto=searchportal"); - $help_menu[] = array(gettext("FreeBSD Handbook"), "https://www.pfsense.org/j.php?jumpto=fbsdhandbook"); - $help_menu = msort(array_merge($help_menu, return_ext_menu("Help")),0); -} +$help_menu = array(); +$help_menu[] = array(gettext("About this Page"), $helpurl); +$help_menu[] = array(gettext("Bug Database"), "https://github.com/opnsense/core/issues"); +$help_menu[] = array(gettext("User Forum"), "https://forum.opnsense.org/"); +$help_menu[] = array(gettext("Documentation"), "https://wiki.opnsense.org/"); +$help_menu[] = array(gettext("Developers Wiki"), "https://wiki.opnsense.org/index.php/Develop:Info"); +$help_menu[] = array(gettext("Paid Support"), "https://opnsense.org/support-overview/commercial-support/"); +$help_menu[] = array(gettext("FreeBSD Handbook"), "https://www.freebsd.org/doc/handbook/"); +$help_menu = msort(array_merge($help_menu, return_ext_menu("Help")),0); function add_to_menu($url, $name) { if (isAllowedPage($url)) @@ -377,13 +368,8 @@ if(is_subsystem_dirty('packagelock')) { echo '
  • '.get_shortcut_status_link($shortcut_section, false).'
  • '; echo '
  • '.get_shortcut_log_link($shortcut_section, false).'
  • '; - ?> - - - - + ?>
  • ">Help
  • -
  • Logout
  • @@ -465,7 +451,6 @@ if(is_subsystem_dirty('packagelock')) { ?> - @@ -474,7 +459,6 @@ if(is_subsystem_dirty('packagelock')) { output_menu($help_menu, "_blank"); ?> - diff --git a/src/www/foot.inc b/src/www/foot.inc index 0b678c87b..27dadcca1 100644 --- a/src/www/foot.inc +++ b/src/www/foot.inc @@ -1,8 +1,8 @@
    - is © - by All Rights Reserved. + is © + by All Rights Reserved. [view license]
    diff --git a/src/www/license.php b/src/www/license.php index 701f40dc0..b0d64248e 100644 --- a/src/www/license.php +++ b/src/www/license.php @@ -1,6 +1,8 @@ pfSense® (Copyright © 2004-2014 Electric Sheep Fencing, LLC. All rights reserved.) a fork from m0n0wall® (Copyright © 2002-2013 Manuel Kasper).

    OPNsense includes various freely availbale software packages and ports.
    - The current ports are listed here.
    + The current ports are listed here.

    The authors of OPNsense would like to thank all contributors for their efforts.

    diff --git a/src/www/system_firmware.php b/src/www/system_firmware.php index 7f93c764d..3a3d9a0f0 100644 --- a/src/www/system_firmware.php +++ b/src/www/system_firmware.php @@ -1,7 +1,7 @@ Copyright (C) 2003-2004 Manuel Kasper . All rights reserved. @@ -262,10 +262,8 @@ include("head.inc");
    -
    - " /> diff --git a/src/www/system_firmware_tabs.php b/src/www/system_firmware_tabs.php index 65bfa79c1..012e2e9e1 100644 --- a/src/www/system_firmware_tabs.php +++ b/src/www/system_firmware_tabs.php @@ -1,37 +1,37 @@ +*/ + +$active_tab = isset($active_tab) ? $active_tab : $_SERVER['PHP_SELF']; +$tab_array = array(); +//$tab_array[] = array(gettext("Manual Update"), $active_tab == "/system_firmware.php", "system_firmware.php"); +$tab_array[] = array(gettext("Auto Update"), $active_tab == "/system_firmware_check.php", "system_firmware_check.php"); +$tab_array[] = array(gettext("Updater Settings"), $active_tab == "/system_firmware_settings.php", "system_firmware_settings.php"); +//$tab_array[] = array(gettext("Restore Full Backup"), $active_tab == "/system_firmware_restorefullbackup.php", "system_firmware_restorefullbackup.php"); + +display_top_tabs($tab_array);