Bug#846847: debian-edu-config: sitesummary2ldapdhcp should be able to work with new ifconfig output
[Wolfgang Schweer
> The reason is the changed output of ifconfig. As there might be (older)
> systems with the previous ifconfig output on the network as well, both
> types of output should be considered.
Perhaps something like this might solve it, using the perl function provided by
the sitesummary package?
diff --git a/ldap-tools/sitesummary2ldapdhcp b/ldap-tools/sitesummary2ldapdhcp
index 4c6f02b..71a62b3 100644
--- a/ldap-tools/sitesummary2ldapdhcp
+++ b/ldap-tools/sitesummary2ldapdhcp
@@ -82,7 +82,7 @@ sub host_handler {
my $hostid = shift;
my $ipaddr = SiteSummary::get_primary_ip_address($hostid);
my $fqdn = scalar gethostbyaddr(inet_aton($ipaddr), AF_INET);
- my $macref = [(get_ether_hwaddr($hostid))];
+ my $macref = [(SiteSummary::get_macaddresses($hostid))];
# Update MAC and IP if name has been changed
if ($fqdn && $fqdn !~ m/^auto-mac-/) {
@@ -100,24 +100,6 @@ sub host_handler {
}
}
-sub get_ether_hwaddr {
- my $hostid = shift;
- my $path = get_filepath_current($hostid, "/system/ifconfig-a");
- if (open(FILE, "<", $path)) {
- my $sysinfo = 0;
- my @hwaddr = ();
- while (<FILE>) {
- chomp;
- if (m/Link encap:Ethernet HWaddr (.+\S)\s*$/) {
- push(@hwaddr, $1);
- }
- }
- close(FILE);
- return @hwaddr;
- } else {
- return undef;
- }
-}
sub get_primary_ether_hwaddr {
# FIXME How to handle several MAC addresses?
my $macref = shift;
Note, it will pick a different MAC address on a machine with many MAC addresses.
The get_macaddresses() function sort the MAC addresses, while the
get_ether_hwaddr() function do not. This is probably not a problem for
simple clients, and for the others the admin will need to change the MAC address
used.
--
Happy hacking
Petter Reinholdtsen
Reply to: