Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Sys-HostIP CPAN distribution.

Report information
The Basics
Id: 24002
Status: resolved
Priority: 0/
Queue: Sys-HostIP

People
Owner: Nobody in particular
Requestors: gmc [...] gmcx.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.3.1
Fixed in: (no value)



Subject: Interface detection regular expression is flawed
Download (untitled) / with headers
text/plain 832b
A few systems that I've worked on have multiple aliased interfaces (eth0:0, eth0:1, etc.) Some of these have double digit numbers after the colons, such as eth0:13. The regular expression (line 143 in HostIP.pm) will still find eth0:13, but since it only captures the first number after the colon, it will overwrite the entry in the hash previously stored for eth0:1. This happens successively for each entry that matches, so that if someone had the following interfaces: eth0:0 to eth0:19, the only ones that will show up are eth0:0 to eth0:9, with eth0:1 being overwritten in the end by eth0:19. The original regular expression is: /(^\w+(?:\d)?(?:\:\d)?)/. A simple modification: /(^\w+(?:\d)?(?:\:\d+)?)/ seems to fix this problem. Attached is a sample output before and after the change in my local copy of the module.
Subject: Sys_HostIP Sample Output.txt
Code used to test this: #!/usr/bin/perl use strict; use Data::Dumper; use Sys::HostIP; my $interfaces = Sys::HostIP->interfaces; print Dumper \$interfaces; Output before regular expression change: $VAR1 = \{ 'bond0:2' => '192.168.1.224', 'lo' => '127.0.0.1', 'bond0:5' => '192.168.1.100', 'bond0:3' => '192.168.1.33', 'bond0' => '192.168.1.30', 'eth1' => '192.168.1.30', 'bond0:1' => '192.168.1.219', 'eth0' => '192.168.1.30' }; Output after regular expression change: $VAR1 = \{ 'bond0:19' => '192.168.1.219', 'bond0:2' => '192.168.1.32', 'bond0' => '192.168.1.30', 'eth0' => '192.168.1.30', 'bond0:14' => '192.168.1.214', 'lo' => '127.0.0.1', 'bond0:23' => '192.168.1.223', 'bond0:17' => '192.168.1.217', 'bond0:5' => '192.168.1.100', 'bond0:11' => '192.168.1.211', 'bond0:24' => '192.168.1.224', 'bond0:12' => '192.168.1.212', 'bond0:10' => '192.168.1.210', 'bond0:13' => '192.168.1.213', 'bond0:16' => '192.168.1.216', 'bond0:22' => '192.168.1.222', 'bond0:3' => '192.168.1.33', 'bond0:15' => '192.168.1.215', 'bond0:21' => '192.168.1.221', 'bond0:18' => '192.168.1.218', 'bond0:20' => '192.168.1.220', 'eth1' => '192.168.1.30', 'bond0:1' => '192.168.1.31' };
Download (untitled) / with headers
text/plain 229b
It also looks like it doesn't let you have an interface named eth10 as this will overwrite the hash entry for eth1. Is this module dead? I am just going to regexp my addresses myself. Good reasons to use /mxs flags for regexp!
Subject: Re: [rt.cpan.org #24002] Interface detection regular expression is flawed
Date: Mon, 22 Dec 2008 11:40:58 -0800
To: bug-Sys-HostIP [...] rt.cpan.org
From: jon schatz <jon [...] divisionbyzero.com>
Download (untitled) / with headers
text/plain 257b
On Dec 21, 2008, at 5:48 PM, MARKLE via RT wrote: Show quoted text
> Is this module dead? I am just going to regexp my addresses myself.
module's not dead (although i can't seem to login to the bug system). i'll add your patch and update it on cpan. thanks, -jon
Download (untitled) / with headers
text/plain 543b
I've gotten around to needing this. Thanks. --- /usr/lib/perl5/site_perl/5.8.8/Sys/HostIP.pm.orig 2009-12-16 12:53:10.000000000 -0800 +++ /usr/lib/perl5/site_perl/5.8.8/Sys/HostIP.pm 2009-12-16 12:55:46.000000000 -0800 @@ -140,7 +140,7 @@ if ( ($line =~/^\s+/) && ($interface) ) { $if_info{$interface} .= $line; } - elsif (($interface) = ($line =~/(^\w+(?:\d)?(?:\:\d)?)/)) { + elsif (($interface) = ($line =~/(^\w+(?:\d+)?(?:\:\d+)?)/)) { $line =~s/\w+\d(\:)?\s+//; $if_info{$interface} = $line; }
Download Sys-HostIP.patch
text/x-diff 497b
--- /usr/lib/perl5/site_perl/5.8.8/Sys/HostIP.pm.orig 2009-12-16 12:53:10.000000000 -0800 +++ /usr/lib/perl5/site_perl/5.8.8/Sys/HostIP.pm 2009-12-16 12:55:46.000000000 -0800 @@ -140,7 +140,7 @@ if ( ($line =~/^\s+/) && ($interface) ) { $if_info{$interface} .= $line; } - elsif (($interface) = ($line =~/(^\w+(?:\d)?(?:\:\d)?)/)) { + elsif (($interface) = ($line =~/(^\w+(?:\d+)?(?:\:\d+)?)/)) { $line =~s/\w+\d(\:)?\s+//; $if_info{$interface} = $line; }
Download (untitled) / with headers
text/plain 212b
This has been resolved with version 1.4 recently uploaded to CPAN. However, the regular expression will probably be refactored and improved once more in the future. Thank you for your report and patch! Sawyer.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.