Commit 797b0e64 authored by Franco Fichtner's avatar Franco Fichtner

src: migrate the version file to a new home

We now use /usr/local/opnsense/version/xxx as our version database.
Apart from the core package, opnsense-update(8) also puts its own
version information in there.  To stay somewhat consistent, the
version file should resemble the package name, even though that
looks strange in our case: /usr/local/opnsense/version/opnsense.
It's just that /usr/local/etc is too open and might clash with
other things in the future.
parent bd37d25d
...@@ -22,4 +22,5 @@ cat /etc/rc.bak >> /etc/rc ...@@ -22,4 +22,5 @@ cat /etc/rc.bak >> /etc/rc
rm -f /etc/rc.bak rm -f /etc/rc.bak
echo "Writing OPNsense version" echo "Writing OPNsense version"
echo "%%REPO_VERSION%%-%%REPO_COMMENT%%" > /usr/local/etc/version mkdir -p /usr/local/opnsense/version
echo "%%REPO_VERSION%%-%%REPO_COMMENT%%" > /usr/local/opnsense/version/opnsense
...@@ -15,4 +15,4 @@ echo "Enabling FreeBSD mirror" ...@@ -15,4 +15,4 @@ echo "Enabling FreeBSD mirror"
sed -i "" -e "s/^ enabled: no$/ enabled: yes/" /etc/pkg/FreeBSD.conf sed -i "" -e "s/^ enabled: no$/ enabled: yes/" /etc/pkg/FreeBSD.conf
echo "Removing OPNsense version" echo "Removing OPNsense version"
rm -f /usr/local/etc/version rm -f /usr/local/opnsense/version/opnsense
<?php <?php
/****h* pfSense/pfsense-utils
* NAME /*
* pfsense-utils.inc - Utilities specific to pfSense
* DESCRIPTION
* This include contains various pfSense specific functions.
* HISTORY
* $Id$
******
*
* Copyright (C) 2004-2007 Scott Ullrich (sullrich@gmail.com) * Copyright (C) 2004-2007 Scott Ullrich (sullrich@gmail.com)
* All rights reserved. * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
...@@ -33,13 +27,6 @@ ...@@ -33,13 +27,6 @@
* *
*/ */
/*
pfSense_BUILDER_BINARIES: /sbin/ifconfig /sbin/pfctl /usr/local/bin/php /usr/bin/netstat
pfSense_BUILDER_BINARIES: /bin/df /usr/bin/grep /usr/bin/awk /bin/rm /usr/sbin/pwd_mkdb /usr/bin/host
pfSense_BUILDER_BINARIES: /sbin/kldload
pfSense_MODULE: utils
*/
/****f* pfsense-utils/have_natpfruleint_access /****f* pfsense-utils/have_natpfruleint_access
* NAME * NAME
* have_natpfruleint_access * have_natpfruleint_access
...@@ -725,7 +712,7 @@ function check_firmware_version($tocheck = "all", $return_php = true) { ...@@ -725,7 +712,7 @@ function check_firmware_version($tocheck = "all", $return_php = true) {
return false; return false;
$version = php_uname('r'); $version = php_uname('r');
$version = explode('-', $version); $version = explode('-', $version);
$rawparams = array("firmware" => array("version" => trim(file_get_contents('/usr/local/etc/version'))), $rawparams = array("firmware" => array("version" => trim(file_get_contents('/usr/local/opnsense/version/opnsense'))),
"kernel" => array("version" => $version[0]), "kernel" => array("version" => $version[0]),
"base" => array("version" => $version[0]), "base" => array("version" => $version[0]),
"platform" => trim(file_get_contents('/usr/local/etc/platform')), "platform" => trim(file_get_contents('/usr/local/etc/platform')),
...@@ -763,7 +750,7 @@ function host_firmware_version($tocheck = "") { ...@@ -763,7 +750,7 @@ function host_firmware_version($tocheck = "") {
$os_version = trim(substr(php_uname("r"), 0, strpos(php_uname("r"), '-'))); $os_version = trim(substr(php_uname("r"), 0, strpos(php_uname("r"), '-')));
return array( return array(
"firmware" => array("version" => trim(file_get_contents('/usr/local/etc/version', " \n"))), "firmware" => array("version" => trim(file_get_contents('/usr/local/opnsense/version/opnsense', " \n"))),
"kernel" => array("version" => $os_version), "kernel" => array("version" => $os_version),
"base" => array("version" => $os_version), "base" => array("version" => $os_version),
"platform" => trim(file_get_contents('/usr/local/etc/platform', " \n")), "platform" => trim(file_get_contents('/usr/local/etc/platform', " \n")),
...@@ -1618,7 +1605,7 @@ function download_file($url, $destination, $verify_ssl = false, $connect_timeout ...@@ -1618,7 +1605,7 @@ function download_file($url, $destination, $verify_ssl = false, $connect_timeout
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/usr/local/etc/version"))); curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/usr/local/opnsense/version/opnsense")));
if (!empty($config['system']['proxyurl'])) { if (!empty($config['system']['proxyurl'])) {
curl_setopt($ch, CURLOPT_PROXY, $config['system']['proxyurl']); curl_setopt($ch, CURLOPT_PROXY, $config['system']['proxyurl']);
...@@ -1660,7 +1647,7 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody ...@@ -1660,7 +1647,7 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody
curl_setopt($ch, CURLOPT_NOPROGRESS, '1'); curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/usr/local/etc/version"))); curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/usr/local/opnsense/version/opnsense")));
if (!empty($config['system']['proxyurl'])) { if (!empty($config['system']['proxyurl'])) {
curl_setopt($ch, CURLOPT_PROXY, $config['system']['proxyurl']); curl_setopt($ch, CURLOPT_PROXY, $config['system']['proxyurl']);
......
<?php <?php
/****h* pfSense/pkg-utils
* NAME /*
* pkg-utils.inc - Package subsystem
* DESCRIPTION
* This file contains various functions used by the pfSense package system.
* HISTORY
* $Id$
******
*
* Copyright (C) 2010 Ermal Luci * Copyright (C) 2010 Ermal Luci
* Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com) * Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com)
* All rights reserved. * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
...@@ -34,12 +28,6 @@ ...@@ -34,12 +28,6 @@
* *
*/ */
/*
pfSense_BUILDER_BINARIES: /usr/bin/cd /usr/bin/tar /usr/sbin/fifolog_create /bin/chmod
pfSense_BUILDER_BINARIES: /usr/sbin/pkg_add /usr/sbin/pkg_info /usr/sbin/pkg_delete /bin/rm
pfSense_MODULE: pkg
*/
require_once("globals.inc"); require_once("globals.inc");
require_once("xmlrpc.inc"); require_once("xmlrpc.inc");
require_once("service-utils.inc"); require_once("service-utils.inc");
...@@ -620,7 +608,7 @@ function install_package($package, $pkg_info = "", $force_install = false) { ...@@ -620,7 +608,7 @@ function install_package($package, $pkg_info = "", $force_install = false) {
} }
if (!$force_install) { if (!$force_install) {
$compatible = true; $compatible = true;
$version = rtrim(file_get_contents("/usr/local/etc/version")); $version = rtrim(file_get_contents("/usr/local/opnsense/version/opnsense"));
if (isset($pkg_info['required_version'])) if (isset($pkg_info['required_version']))
$compatible = (pfs_version_compare("", $version, $pkg_info['required_version']) >= 0); $compatible = (pfs_version_compare("", $version, $pkg_info['required_version']) >= 0);
...@@ -1311,7 +1299,7 @@ function package_skip_tests($index,$requested_version){ ...@@ -1311,7 +1299,7 @@ function package_skip_tests($index,$requested_version){
global $config, $g; global $config, $g;
/* Get pfsense version*/ /* Get pfsense version*/
$version = rtrim(file_get_contents("/usr/local/etc/version")); $version = rtrim(file_get_contents("/usr/local/opnsense/version/opnsense"));
if($g['platform'] == "nanobsd") if($g['platform'] == "nanobsd")
if($index['noembedded']) if($index['noembedded'])
...@@ -1396,7 +1384,7 @@ function check_package_server_ssl() { ...@@ -1396,7 +1384,7 @@ function check_package_server_ssl() {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '30'); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '30');
curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/usr/local/etc/version"))); curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/usr/local/opnsense/version/opnsense")));
$result_page = curl_exec($ch); $result_page = curl_exec($ch);
$verifyfail = curl_getinfo($ch, CURLINFO_SSL_VERIFYRESULT); $verifyfail = curl_getinfo($ch, CURLINFO_SSL_VERIFYRESULT);
curl_close($ch); curl_close($ch);
......
...@@ -1906,7 +1906,7 @@ trap := "{$config['snmpd']['trapstring']}" ...@@ -1906,7 +1906,7 @@ trap := "{$config['snmpd']['trapstring']}"
EOD; EOD;
} }
$version = trim(file_get_contents('/usr/local/etc/version')); $version = trim(file_get_contents('/usr/local/opnsense/version/opnsense'));
$platform = trim(file_get_contents('/usr/local/etc/platform')); $platform = trim(file_get_contents('/usr/local/etc/platform'));
if (($platform == "pfSense") && ($g['product_name'] != "pfSense")) if (($platform == "pfSense") && ($g['product_name'] != "pfSense"))
$platform = $g['product_name']; $platform = $g['product_name'];
......
...@@ -33,7 +33,7 @@ require_once("config.inc"); ...@@ -33,7 +33,7 @@ require_once("config.inc");
require_once("gwlb.inc"); require_once("gwlb.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
$version = trim(file_get_contents("/usr/local/etc/version")); $version = trim(file_get_contents('/usr/local/opnsense/version/opnsense'));
$hostname = $config['system']['hostname']; $hostname = $config['system']['hostname'];
$product = $g['product_name']; $product = $g['product_name'];
$machine = trim(`uname -m`); $machine = trim(`uname -m`);
......
...@@ -63,7 +63,6 @@ timeout=30 # Wait for a maximum number of seconds to determine connection issues ...@@ -63,7 +63,6 @@ timeout=30 # Wait for a maximum number of seconds to determine connection issues
package_json_output="/tmp/pkg_status.json" package_json_output="/tmp/pkg_status.json"
tmp_pkg_output_file="/tmp/packages.output" tmp_pkg_output_file="/tmp/packages.output"
tmp_pkg_update_file="/tmp/pkg_updates.output" tmp_pkg_update_file="/tmp/pkg_updates.output"
version_file="/usr/local/etc/version"
# Check if pkg is already runnig # Check if pkg is already runnig
pkg_running=`ps -x | grep "pkg " | grep -v "grep"` pkg_running=`ps -x | grep "pkg " | grep -v "grep"`
......
<?php <?php
require_once("util.inc");
require_once("config.inc");
require_once("functions.inc");
require_once("shaper.inc");
$shortcut_section = "upnp"; require_once("util.inc");
require_once("config.inc");
require_once("functions.inc");
require_once("shaper.inc");
/* MiniUPnPd */ $shortcut_section = "upnp";
function upnp_notice ($msg) { log_error("miniupnpd: {$msg}"); } /* MiniUPnPd */
function upnp_warn ($msg) { log_error("miniupnpd: {$msg}"); }
function upnp_running () { function upnp_notice ($msg) { log_error("miniupnpd: {$msg}"); }
function upnp_warn ($msg) { log_error("miniupnpd: {$msg}"); }
function upnp_running () {
if((int)exec('/bin/pgrep -a miniupnpd | /usr/bin/wc -l') > 0) if((int)exec('/bin/pgrep -a miniupnpd | /usr/bin/wc -l') > 0)
return true; return true;
return false; return false;
} }
function upnp_write_config($file, $text) { function upnp_write_config($file, $text) {
$handle = fopen($file, 'w'); $handle = fopen($file, 'w');
if(!$handle) { if(!$handle) {
upnp_warn("Could not open {$file} for writing."); upnp_warn("Could not open {$file} for writing.");
...@@ -25,16 +26,16 @@ ...@@ -25,16 +26,16 @@
} }
fwrite($handle, $text); fwrite($handle, $text);
fclose($handle); fclose($handle);
} }
function upnp_uuid() { function upnp_uuid() {
/* md5 hash of wan mac */ /* md5 hash of wan mac */
$uuid = md5(get_interface_mac(get_real_interface("wan"))); $uuid = md5(get_interface_mac(get_real_interface("wan")));
/* put uuid in correct format 8-4-4-4-12 */ /* put uuid in correct format 8-4-4-4-12 */
return substr($uuid,0,8).'-'.substr($uuid,9,4).'-'.substr($uuid,13,4).'-'.substr($uuid,17,4).'-'.substr($uuid,21,12); return substr($uuid,0,8).'-'.substr($uuid,9,4).'-'.substr($uuid,13,4).'-'.substr($uuid,17,4).'-'.substr($uuid,21,12);
} }
function upnp_validate_queue($qname) { function upnp_validate_queue($qname) {
read_altq_config(); read_altq_config();
$qlist = get_altq_name_list(); $qlist = get_altq_name_list();
if (is_array($qlist)) { if (is_array($qlist)) {
...@@ -42,9 +43,9 @@ ...@@ -42,9 +43,9 @@
} else { } else {
return false; return false;
} }
} }
function upnp_validate_ip($ip, $check_cdir) { function upnp_validate_ip($ip, $check_cdir) {
/* validate cidr */ /* validate cidr */
$ip_array = array(); $ip_array = array();
if($check_cdir) { if($check_cdir) {
...@@ -62,21 +63,21 @@ ...@@ -62,21 +63,21 @@
if (!is_ipaddr($ip_array[0])) if (!is_ipaddr($ip_array[0]))
return false; return false;
return true; return true;
} }
function upnp_validate_port($port) { function upnp_validate_port($port) {
foreach(explode('-', $port) as $sub) foreach(explode('-', $port) as $sub)
if($sub < 0 || $sub > 65535) if($sub < 0 || $sub > 65535)
return false; return false;
return true; return true;
} }
function before_form_miniupnpd(&$pkg) { function before_form_miniupnpd(&$pkg) {
global $config; global $config;
} }
function validate_form_miniupnpd($post, &$input_errors) { function validate_form_miniupnpd($post, &$input_errors) {
if($post['enable'] && (!$post['enable_upnp'] && !$post['enable_natpmp'])) if($post['enable'] && (!$post['enable_upnp'] && !$post['enable_natpmp']))
$input_errors[] = 'At least one of \'UPnP\' or \'NAT-PMP\' must be allowed'; $input_errors[] = 'At least one of \'UPnP\' or \'NAT-PMP\' must be allowed';
if($post['iface_array']) if($post['iface_array'])
...@@ -118,9 +119,9 @@ ...@@ -118,9 +119,9 @@
} }
} }
} }
} }
function sync_package_miniupnpd() { function sync_package_miniupnpd() {
global $config; global $config;
global $input_errors; global $input_errors;
...@@ -206,7 +207,7 @@ ...@@ -206,7 +207,7 @@
$config_text .= "serial=".strtoupper(substr(upnp_uuid(),0,8))."\n"; $config_text .= "serial=".strtoupper(substr(upnp_uuid(),0,8))."\n";
/* set model number */ /* set model number */
$config_text .= "model_number=".file_get_contents("/usr/local/etc/version")."\n"; $config_text .= "model_number=".file_get_contents("/usr/local/opnsense/version/opnsense")."\n";
/* upnp access restrictions */ /* upnp access restrictions */
for($i=1; $i<=4; $i++) { for($i=1; $i<=4; $i++) {
...@@ -257,5 +258,4 @@ ...@@ -257,5 +258,4 @@
@unlink($config_file); @unlink($config_file);
} }
} }
} }
?>
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com> Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
...@@ -123,7 +124,7 @@ include("head.inc"); ...@@ -123,7 +124,7 @@ include("head.inc");
<?php <?php
$version = rtrim(file_get_contents("/usr/local/etc/version")); $version = rtrim(file_get_contents("/usr/local/opnsense/version/opnsense"));
$tab_array = array(); $tab_array = array();
$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php"); $tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
...@@ -136,7 +137,7 @@ include("head.inc"); ...@@ -136,7 +137,7 @@ include("head.inc");
<div class="container-fluid"> <div class="container-fluid">
<?php <?php
$version = rtrim(file_get_contents("/usr/local/etc/version")); $version = rtrim(file_get_contents("/usr/local/opnsense/version/opnsense"));
if($pkg_info) { if($pkg_info) {
$pkg_keys = array_keys($pkg_info); $pkg_keys = array_keys($pkg_info);
natcasesort($pkg_keys); natcasesort($pkg_keys);
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com> Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
...@@ -98,7 +99,7 @@ include("head.inc"); ...@@ -98,7 +99,7 @@ include("head.inc");
<?php <?php
$version = file_get_contents("/usr/local/etc/version"); $version = file_get_contents("/usr/local/opnsense/version/opnsense");
$tab_array = array(); $tab_array = array();
$tab_array[] = array(gettext("Available Packages"), false, "pkg_mgr.php"); $tab_array[] = array(gettext("Available Packages"), false, "pkg_mgr.php");
// $tab_array[] = array("{$version} " . gettext("packages"), false, "pkg_mgr.php"); // $tab_array[] = array("{$version} " . gettext("packages"), false, "pkg_mgr.php");
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2009 Jim Pingle <jimp@pfsense.org> Copyright (C) 2009 Jim Pingle <jimp@pfsense.org>
...@@ -83,7 +84,7 @@ function enable_altpkgrepourl(enable_over) { ...@@ -83,7 +84,7 @@ function enable_altpkgrepourl(enable_over) {
<tr> <tr>
<td> <td>
<?php <?php
$version = file_get_contents("/usr/local/etc/version"); $version = file_get_contents("/usr/local/opnsense/version/opnsense");
$tab_array = array(); $tab_array = array();
$tab_array[] = array(sprintf(gettext("%s packages"), $version), false, "pkg_mgr.php"); $tab_array[] = array(sprintf(gettext("%s packages"), $version), false, "pkg_mgr.php");
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php"); $tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com> Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
...@@ -143,7 +144,7 @@ if(!$latest_version) { ...@@ -143,7 +144,7 @@ if(!$latest_version) {
exit; exit;
} else { } else {
$current_installed_buildtime = ''; /* XXX zap */ $current_installed_buildtime = ''; /* XXX zap */
$current_installed_version = trim(file_get_contents("/usr/local/etc/version")); $current_installed_version = trim(file_get_contents('/usr/local/opnsense/version/opnsense'));
$latest_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); $latest_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
$latest_version_pfsense = strtotime($latest_version); $latest_version_pfsense = strtotime($latest_version);
if(!$latest_version) { if(!$latest_version) {
......
...@@ -105,7 +105,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -105,7 +105,7 @@ $filesystems = get_mounted_filesystems();
<tr> <tr>
<td width="25%" valign="top" class="vncellt"><?=gettext("Version");?></td> <td width="25%" valign="top" class="vncellt"><?=gettext("Version");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<strong><?php readfile("/usr/local/etc/version"); ?><span id="version"></span></strong> <strong><?php readfile('/usr/local/opnsense/version/opnsense'); ?><span id="version"></span></strong>
(<?php echo php_uname("m"); ?>) (<?php echo php_uname("m"); ?>)
<?php if(!$g['hideuname']): ?> <?php if(!$g['hideuname']): ?>
<br /> <br />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment