aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
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 /SiteSummary.pm
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.
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r--SiteSummary.pm10
1 files changed, 5 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;
}