From 5517e23493aa44deb931c9b41d713c13c7fa5ab5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sep 23 2012 17:00:17 +0000 Subject: fix ifconfig output parser (#853982) --- diff --git a/ocsinventory-agent-ifconfig.patch b/ocsinventory-agent-ifconfig.patch new file mode 100644 index 0000000..708fa2c --- /dev/null +++ b/ocsinventory-agent-ifconfig.patch @@ -0,0 +1,108 @@ +=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm' +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm 2010-07-27 22:03:30 +0000 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm 2012-07-09 19:20:00 +0000 +@@ -11,7 +11,7 @@ + my $common = $params->{common}; + my @ip; + foreach (`ifconfig`){ +- if(/^\s*inet add?r\s*:\s*(\S+)/){ ++ if(/^\s*inet add?r\s*:\s*(\S+)/ || /^\s*inet\s+(\S+)/){ + ($1=~/127.+/)?next:push @ip, $1 + }; + } + +=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm' +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2011-02-21 21:55:28 +0000 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-07-09 19:20:00 +0000 +@@ -157,13 +157,12 @@ + $description = $driver = $ipaddress = $ipmask = $ipgateway = $macaddr = $pcislot = $status = $type = $virtualdev = undef; + + } else { # In a section +- +- $description = $1 if $line =~ /^(\S+)/; # Interface name +- $ipaddress = $1 if $line =~ /inet addr:(\S+)/i; +- $ipmask = $1 if $line =~ /\S*mask:(\S+)/i; +- $macaddr = $1 if $line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i; +- $status = 1 if $line =~ /^\s+UP\s/; +- $type = $1 if $line =~ /link encap:(\S+)/i; ++ $description = $1 if ($line =~ /^(\S+):/ || $line =~ /^(\S+)/); # Interface name ++ $ipaddress = $1 if ($line =~ /inet addr:(\S+)/i || $line =~ /^\s*inet\s+(\S+)/); ++ $ipmask = $1 if ($line =~ /\S*mask:(\S+)/i || $line =~ /\S*netmask\s+(\S+)/); ++ $macaddr = $1 if ($line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i || $line =~ /\s*ether\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i); ++ $status = 1 if ($line =~ /^\s+UP\s/ || $line =~ /^\S*UP,/); ++ $type = $1 if $line =~ /link encap:(\S+)/i; + } + + + +=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm' +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-07-09 19:20:00 +0000 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-09-10 21:01:30 +0000 +@@ -162,7 +162,7 @@ + $ipmask = $1 if ($line =~ /\S*mask:(\S+)/i || $line =~ /\S*netmask\s+(\S+)/); + $macaddr = $1 if ($line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i || $line =~ /\s*ether\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i); + $status = 1 if ($line =~ /^\s+UP\s/ || $line =~ /^\S*UP,/); +- $type = $1 if $line =~ /link encap:(\S+)/i; ++ $type = $1 if ($line =~ /link encap:(\S+)/i || $line =~ /^\s+(loop|ether).*\((\S+)\)/i); + } + + + +=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm' +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-09-10 21:01:30 +0000 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-09-20 22:03:51 +0000 +@@ -161,7 +161,7 @@ + $ipaddress = $1 if ($line =~ /inet addr:(\S+)/i || $line =~ /^\s*inet\s+(\S+)/); + $ipmask = $1 if ($line =~ /\S*mask:(\S+)/i || $line =~ /\S*netmask\s+(\S+)/); + $macaddr = $1 if ($line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i || $line =~ /\s*ether\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i); +- $status = 1 if ($line =~ /^\s+UP\s/ || $line =~ /^\S*UP,/); ++ $status = $1 if ($line =~ /^\s+UP\s/ || $line =~ /flags=.*(,|<)UP(,|>)/); + $type = $1 if ($line =~ /link encap:(\S+)/i || $line =~ /^\s+(loop|ether).*\((\S+)\)/i); + } + + +=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm' +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm 2012-07-09 19:20:00 +0000 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm 2012-09-23 15:42:02 +0000 +@@ -11,7 +11,8 @@ + my $common = $params->{common}; + my @ip; + foreach (`ifconfig`){ +- if(/^\s*inet add?r\s*:\s*(\S+)/ || /^\s*inet\s+(\S+)/){ ++ if(/^\s*inet\s*(\S+)\s*netmask/){ ++ #if(/^\s*inet add?r\s*:\s*(\S+)/ || /^\s*inet\s+(\S+)/){ + ($1=~/127.+/)?next:push @ip, $1 + }; + } + +=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm' +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-09-20 22:03:51 +0000 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-09-23 15:42:02 +0000 +@@ -158,10 +158,10 @@ + + } else { # In a section + $description = $1 if ($line =~ /^(\S+):/ || $line =~ /^(\S+)/); # Interface name +- $ipaddress = $1 if ($line =~ /inet addr:(\S+)/i || $line =~ /^\s*inet\s+(\S+)/); +- $ipmask = $1 if ($line =~ /\S*mask:(\S+)/i || $line =~ /\S*netmask\s+(\S+)/); +- $macaddr = $1 if ($line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i || $line =~ /\s*ether\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i); +- $status = $1 if ($line =~ /^\s+UP\s/ || $line =~ /flags=.*(,|<)UP(,|>)/); ++ $ipaddress = $1 if ($line =~ /inet addr:(\S+)/i || $line =~ /inet (\S+)\s+netmask/i); ++ $ipmask = $1 if ($line =~ /\S*mask:(\S+)/i || $line =~ /\S*netmask (\S+)\s/i); ++ $macaddr = $1 if ($line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i || $line =~ /ether\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i); ++ $status = 1 if ($line =~ /^\s+UP\s/ || $line =~ /flags=.*(,|<)UP(,|>)/); + $type = $1 if ($line =~ /link encap:(\S+)/i || $line =~ /^\s+(loop|ether).*\((\S+)\)/i); + } + + +--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm.old 2012-09-23 18:46:04.177526820 +0200 ++++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm 2012-09-23 18:52:24.019984283 +0200 +@@ -162,7 +162,8 @@ + $ipmask = $1 if ($line =~ /\S*mask:(\S+)/i || $line =~ /\S*netmask (\S+)\s/i); + $macaddr = $1 if ($line =~ /hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i || $line =~ /ether\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i); + $status = 1 if ($line =~ /^\s+UP\s/ || $line =~ /flags=.*(,|<)UP(,|>)/); +- $type = $1 if ($line =~ /link encap:(\S+)/i || $line =~ /^\s+(loop|ether).*\((\S+)\)/i); ++ $type = $1 if ($line =~ /link encap:(\S+)/i); ++ $type = $2 if ($line =~ /^\s+(loop|ether).*\((\S+)\)/i); + } + + diff --git a/ocsinventory-agent.spec b/ocsinventory-agent.spec index e4a3a46..fd07a92 100644 --- a/ocsinventory-agent.spec +++ b/ocsinventory-agent.spec @@ -6,7 +6,7 @@ Name: ocsinventory-agent Summary: Open Computer and Software Inventory Next Generation client Version: 2.0.5 -Release: 3%{?dist}%{?ocstag:.%{ocstag}} +Release: 4%{?dist}%{?ocstag:.%{ocstag}} Source0: http://launchpad.net/ocsinventory-unix-agent/stable-2.0/%{version}/+download/Ocsinventory-Unix-Agent-%{version}.tar.gz @@ -16,6 +16,14 @@ Source2: %{name}.cron Source11: %{name}.README Source12: %{name}.README.fr +# Fix ifconfig output parsing on fedora >= 17 #853982 +# https://bugs.launchpad.net/bugs/1045356 +# http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-unix-agent/trunk/revision/1112 +# http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-unix-agent/trunk/revision/1123 +# http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-unix-agent/trunk/revision/1133 +# http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-unix-agent/trunk/revision/1134 +Patch0: %{name}-ifconfig.patch + Group: Development/Libraries License: GPLv2+ URL: http://www.ocsinventory-ng.org/ @@ -23,9 +31,7 @@ URL: http://www.ocsinventory-ng.org/ BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -%if 0%{?rhel} != 3 BuildRequires: perl(Module::Install) -%endif BuildRequires: perl(XML::Simple) perl(LWP) perl(Net::IP) BuildRequires: perl(Digest::MD5) perl(File::Temp) @@ -35,16 +41,8 @@ Requires: %{_sysconfdir}/logrotate.d, %{_sysconfdir}/cron.hourly Requires: perl(HTTP::Request) Requires: perl(Net::SSLeay) perl(Crypt::SSLeay) perl(Net::IP) Requires: nmap monitor-edid which -%if 0%{?rhel} == 3 -Requires: perl(XML::Parser) -%else Requires: perl(Proc::Daemon) -%endif -%if 0%{?rhel}%{?fedora} <= 4 -Requires: kernel-utils -%else Requires: smartmontools -%endif # Optionnal : dmidecode on x86, /proc in ppc # Requires: %{_sbindir}/dmidecode # Optionnal : ipdiscover or nmap, monitor-edid @@ -52,10 +50,6 @@ Requires: smartmontools Obsoletes: ocsinventory-client <= 1.01 Provides: ocsinventory-client = %{version}-%{release} -%if 0%{?rhel} == 3 -%define perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib) -%endif - %{?perl_default_filter} @@ -85,6 +79,8 @@ de commandes ou de fichiers sur les clients Windows ou Linux. %prep %setup -q -n Ocsinventory-Unix-Agent-%{version} +%patch0 -p0 + # avoid rpmlint warning sed -i -e 's/\r//' lib/Ocsinventory/Agent/Modules/Download.pm @@ -219,6 +215,10 @@ rm -rf %{buildroot} %changelog +* Sun Sep 23 2012 Remi Collet - 2.0.5-4 +- fix ifconfig output parser (#853982) + https://bugs.launchpad.net/bugs/1045356 + * Fri Jul 20 2012 Fedora Release Engineering - 2.0.5-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild