From 5779ade6707ba530517da239d9ec3fc751d17d83 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Fri, 31 Jul 2015 10:03:34 -0300 Subject: Introduce a new item to $g global, 'product_version' and stop reading /etc/version all around --- etc/inc/globals.inc | 4 ++-- etc/inc/pfsense-utils.inc | 12 ++++++------ etc/inc/services.inc | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'etc/inc') diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 504f67c..b40a862 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -58,6 +58,7 @@ $g = array( "xml_rootobj" => "pfsense", "admin_group" => "admins", "product_name" => "pfSense", + "product_version" => trim(file_get_contents("{$g['etc_path']}/version"), " \n"), "product_copyright" => "Electric Sheep Fencing LLC", "product_copyright_url" => "http://www.electricsheepfencing.com", "product_copyright_years" => "2004 - ".date("Y"), @@ -98,9 +99,8 @@ $tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr"); if (file_exists("/etc/platform")) { $arch = php_uname("m"); - $current_version = trim(file_get_contents("{$g['etc_path']}/version")); - if (strstr($current_version, "-RELEASE")) { + if (strstr($g['product_version'], "-RELEASE")) { /* This is only necessary for RELEASE */ $arch = ($arch == "i386") ? "" : '/' . $arch; /* Full installs and NanoBSD use the same update directory and manifest in 2.x */ diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 22b0be0..93719ad 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -802,7 +802,7 @@ function check_firmware_version($tocheck = "all", $return_php = true) { } $version = php_uname('r'); $version = explode('-', $version); - $rawparams = array("firmware" => array("version" => trim(file_get_contents('/etc/version'))), + $rawparams = array("firmware" => array("version" => $g['product_version']), "kernel" => array("version" => $version[0]), "base" => array("version" => $version[0]), "platform" => trim(file_get_contents('/etc/platform')), @@ -841,7 +841,7 @@ function host_firmware_version($tocheck = "") { $os_version = trim(substr(php_uname("r"), 0, strpos(php_uname("r"), '-'))); return array( - "firmware" => array("version" => trim(file_get_contents('/etc/version', " \n"))), + "firmware" => array("version" => $g['product_version']), "kernel" => array("version" => $os_version), "base" => array("version" => $os_version), "platform" => trim(file_get_contents('/etc/platform', " \n")), @@ -1773,9 +1773,9 @@ function download_file($url, $destination, $verify_ssl = true, $connect_timeout curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if (!isset($config['system']['host_uuid'])) { - curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version") . ' : ' . get_single_sysctl('kern.hostuuid'))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version'] . ' : ' . get_single_sysctl('kern.hostuuid')); } else { - curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version"))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version']); } if (!empty($config['system']['proxyurl'])) { @@ -1819,9 +1819,9 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); if (!isset($config['system']['host_uuid'])) { - curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version") . ' : ' . get_single_sysctl('kern.hostuuid'))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version'] . ' : ' . get_single_sysctl('kern.hostuuid')); } else { - curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version"))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version']); } if (!empty($config['system']['proxyurl'])) { diff --git a/etc/inc/services.inc b/etc/inc/services.inc index e3bf092..1412f7e 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -2084,13 +2084,12 @@ trap := "{$config['snmpd']['trapstring']}" EOD; } - $version = trim(file_get_contents('/etc/version')); $platform = trim(file_get_contents('/etc/platform')); if (($platform == "pfSense") && ($g['product_name'] != "pfSense")) { $platform = $g['product_name']; } $sysDescr = "{$g['product_name']} " . php_uname("n") . - " {$version} {$platform} " . php_uname("s") . + " {$g['product_version']} {$platform} " . php_uname("s") . " " . php_uname("r") . " " . php_uname("m"); $snmpdconf .= <<