Wrong version comparaison

Bug #586321 reported by Guillaume Rousse
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OCS Inventory: Unified Unix Agent
Fix Released
Medium
mortheres

Bug Description

Vmsystem.pm use the following code to check dmidecode version:
if ( `dmidecode -V 2>/dev/null` >= 2.7 )

However, this result in a numeric comparaison version, which is wrong, as illustrated by the following one-liner:
perl -e 'print "foo" if 2.10 >= 2.7'

The check has to be done through version module, and forcing a double-dotted version comparison. The attached patch fix this issue.

Revision history for this message
Guillaume Rousse (guillaume-rousse) wrote :
Revision history for this message
mortheres (mortheres) wrote :

Hi,

Thank you for the patch and the report. The problem is that your patch only works under perl 5.10 and not on perl 5.8 because the 'version' module is not integrated in Perl 5.8 :( :( :( . OCS Unix agent have to stay with perl 5.8 for the moment because of compatibility with older systems and so we will have to take a look to find a sexy solution for version numbers comparison in Perl 5.8...

Kind regards,

--
Guillaume

mortheres (mortheres)
Changed in ocsinventory-unix-agent:
importance: Undecided → Medium
assignee: nobody → mortheres (mortheres)
Revision history for this message
Stonedge (redshadow69) wrote :

I've modify my client to use grep and wc for the -t parameter validation

`dmidecode -t 0| grep Vendor | wc -l 2>/dev/null` >= 1

Since it require grep and wc not sure if its the best solution bu at less it work on older system...

Stonedge

Revision history for this message
Stonedge (redshadow69) wrote :

Ok here a better solution since it only use perl Split function to parse the dmidecode version

my @SplitVersion = split(/\./, `dmidecode -V`);
if (@SplitVersion[0] >= 3){
      return 1;}
elsif ((@SplitVersion[0] == 2) && ( @SplitVersion[1] >= 7)){
      return 1;}

As far as I know this one should work with almost any perl version... but i'm not a perl expert at all

Stonedge

Revision history for this message
mortheres (mortheres) wrote :

Hi,

Thanks a lot for your patch. This could be a workaround for this problem. I create a patch for Vmsystem.pm using your proposal of code. Can you test it to see if its works for you ? If it is ok, I add this this patch in repository code.

Kind regards,

Guillaume

Revision history for this message
Guillaume Rousse (guillaume-rousse) wrote :

A much better solution would be the one implemented in fusioninventory: don't bother with the dmidecode version just to be able to filter the result, but run it once without option, so as to catch the full output, and cache the result.

If you're insterested, the parsing code is available there (getInfosFromDmidecode):
https://github.com/guillomovitch/fusioninventory-agent/blob/master/lib/FusionInventory/Agent/Tools.pm

Revision history for this message
mortheres (mortheres) wrote :

Hi,

Thank you for this proposal but we are actually in release candidate process and your solution should make modify too much code for the moment. The workaround that Stonedge has proposed is easier to integrate. We will take a look to your proposal for a next OCS Unix Agent release.

The Stonedge's workaround has been integrated in revision 1045 of the stable-2.0 branch of the OCS Unix agent: http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-unix-agent/stable-2.0/revision/1045. It will be released in the final OCS 2.0 release.

Kind regards,

Guillaume

Changed in ocsinventory-unix-agent:
milestone: none → 2.0
status: New → Fix Committed
mortheres (mortheres)
Changed in ocsinventory-unix-agent:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.