aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2008-07-25 17:22:47 +0000
committerPetter Reinholdtsen <pere@hungry.com>2008-07-25 17:22:47 +0000
commit7475f92516def93743800968da3baf8ddc475b2f (patch)
treef849ce2e3b42f79f81fa2fb251aab2375364e4db
parentee6735e8293f56b1c2296d84a807eb1437b2edba (diff)
downloadsitesummary-7475f92516def93743800968da3baf8ddc475b2f.tar.gz
sitesummary-7475f92516def93743800968da3baf8ddc475b2f.tar.bz2
sitesummary-7475f92516def93743800968da3baf8ddc475b2f.tar.xz
* Rewrite get_primary_macaddress() to return the same MAC address
independently from the interface ordering returned by ifconfig -a.
-rw-r--r--SiteSummary.pm10
-rw-r--r--debian/changelog2
2 files changed, 7 insertions, 5 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm
index 033956b..591463c 100644
--- a/SiteSummary.pm
+++ b/SiteSummary.pm
@@ -106,18 +106,18 @@ sub get_primary_ip_address {
sub get_primary_macaddress {
my $hostid = shift;
my $path = get_filepath_current($hostid, "/system/ifconfig-a");
- # XXX Not properly implemented, just pick the first interface
- my $macaddress;
+ # XXX Not properly implemented, just pick the first MAC after
+ # sorting alphabetically.
if (open (FILE, $path)) {
+ my @macs;
while(<FILE>) {
chomp;
if (m/Link encap:Ethernet\s+HWaddr (\S+)\s+/) {
- $macaddress = $1;
- last;
+ push(@macs, $1);
}
}
close(FILE);
- return $macaddress;
+ return (sort @macs)[0];
} else {
return undef;
}
diff --git a/debian/changelog b/debian/changelog
index 7a7716c..b46cb4a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ sitesummary (0.0.45) UNRELEASED; urgency=low
* Add new statistics script hardware-models to list the different
hardware vendor and models.
* Report the hardware models in the default web page.
+ * Rewrite get_primary_macaddress() to return the same MAC address
+ independently from the interface ordering returned by ifconfig -a.
-- Petter Reinholdtsen <pere@debian.org> Fri, 25 Jul 2008 00:50:51 +0200