diff options
author | Renato Botelho <renato@netgate.com> | 2017-07-05 12:59:23 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-07-05 12:59:23 -0300 |
commit | 2f8793b72811d13a6b46244e17ae452d061e8a05 (patch) | |
tree | f9568cb7dd19f0cdee17660b991ab6b2587adf23 /src | |
parent | 38d110824c87ff60c6289c0432d55009586ceee4 (diff) | |
download | pfsense-2f8793b72811d13a6b46244e17ae452d061e8a05.zip pfsense-2f8793b72811d13a6b46244e17ae452d061e8a05.tar.gz |
Move uniqueid read to a function system_get_uniqueid()
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/system.inc | 18 | ||||
-rw-r--r-- | src/usr/local/www/widgets/widgets/system_information.widget.php | 6 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index c7c6be2..ed93d0f 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -2345,6 +2345,24 @@ function system_get_serial() { return get_single_sysctl('kern.hostuuid'); } +function system_get_uniqueid() { + global $g; + + $uniqueid_file="{$g['vardb_path']}/uniqueid"; + + if (empty($g['uniqueid'])) { + if (!file_exists($uniqueid_file)) { + mwexec("/usr/sbin/gnid > {$g['vardb_path']}/uniqueid " . + "2>/dev/null"); + } + if (file_exists($uniqueid_file)) { + $g['uniqueid'] = @file_get_contents($uniqueid_file); + } + } + + return ($g['uniqueid'] ?: ''); +} + /* * attempt to identify the specific platform (for embedded systems) * Returns an array with two elements: diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php index 838ee72..2109d3e 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -159,9 +159,9 @@ $rows_displayed = false; <?=gettext("Serial: ");?><strong><?=system_get_serial();?></strong> <?php // If the uniqueID is available, display it here - $idfile = "/var/db/uniqueid"; - if (file_exists($idfile)) { - print("<br />" . gettext("Netgate Device ID:") . " <strong>" . file_get_contents($idfile) . "</strong>"); + $uniqueid = system_get_uniqueid(); + if (!empty($uniqueid)) { + print("<br />" . gettext("Netgate Device ID:") . " <strong>{$uniqueid}</strong>"); } ?> </td> |