Bug #1326

Scripts stops executing if GeoIP:PurePerl is not installed but .dat is present

Added by Broseph over 1 year ago. Updated 4 days ago.

Status:Rejected Start date:11/03/2010
Priority:Normal Due date:
Assignee:Packhead % Done:

0%

Category:Daemon
Target version:-
Affected Version:1.6.11 Blocking Target Version:No

Description

The log that results:

<pre>
2010-11-03 18:30:01: - MYSQL: Connecting to MySQL database 'maradmin_hlxce' on 'localhost' as user 'maradmin_marstat' ... connected ok
2010-11-03 18:30:01: - CONFIG: Reading database config...
2010-11-03 18:30:01: - CONFIG: I have found the following server configs in database:
2010-11-03 18:30:01: - S_CONFIG: 174.34.131.44:27015
2010-11-03 18:30:01: - S_CONFIG: 174.34.131.34:27050
2010-11-03 18:30:01: - S_CONFIG: 174.34.133.109:27015
Can't locate object method "open" via package "Geo::IP::PurePerl" at ./hlstats.pl line 1676.
</pre>

And nothing more until you remove the GeoLiteCity.dat file.

History

#1 Updated by psychonic over 1 year ago

  • Status changed from New to Assigned
  • Assignee set to psychonic

This isn't necessarily a bug. If you have the geo lookup option set to use the binary file, both the file and the Geo::IP::PurePerl module are required to run.

#2 Updated by Broseph over 1 year ago

Agreed but if for example you don't have the file, you get a descriptive error message. If you don't have the module installed you get a silent fail instead,

#3 Updated by Packhead 3 months ago

  • Assignee changed from psychonic to Packhead
  • Target version set to 1.6.16

Will resolve in next release. Just need better error handling.

#4 Updated by Packhead about 1 month ago

  • Status changed from Assigned to Rejected

So I've reviewed this, and I'm not sure how you've managed to get into this situation, to be honest. Here's the chunk of code that handles this:

hlstats.pl line 1709 as of hlx-16 r773:
@ my $geotell = ((!defined($g_gi)) ? -1 : tell $g_gi{fh});

if ($g_geoip_binary > 0 && $geotell == -1) {
my $geoipfile = "$opt_libdir/GeoLiteCity/GeoLiteCity.dat";
if (-r $geoipfile) {
eval "use Geo::IP::PurePerl"; my $hasGeoIP = $ ? 0 : 1;
if ($hasGeoIP) {
$g_gi = Geo::IP::PurePerl->open($geoipfile, "GEOIP_STANDARD");
} else {
&printEvent("ERROR", "GeoIP method set to binary file lookup but Geo::IP::PurePerl module NOT FOUND", 1);
$g_gi = undef;
}
} else {
&printEvent("ERROR", "GeoIP method set to binary file lookup but $geoipfile NOT FOUND", 1);
$g_gi = undef;
}
} elsif ($g_geoip_binary == 0 && $geotell > -1) {
close($g_gi{fh});
$g_gi = undef;
}

We first check to see if the setting to use the binary file is enabled -- we should pass that check. Then we set a var to the DAT file path and then check if we can open it. If so, we immediately check if we have Geo::IP::PurePerl installed -- if perl can load this, it returns 1. If not, it returns 0. We then immediately check if we received a 1 (yes we have Geo::IP) or 0 (we don't). In your particular case, you have the file, so pass the first check. Then you don't have PurePerl loaded, so you should fail the check., which will set $g_gi to undefined, and then geolookup won't work anywhere else. However you're hitting $g_gi = Geo::IP::... Why, I'm not sure. Perhaps a really old Geo::IP::PurePerl module?

Anyways, something else I noticed is that if your .DAT file is corrupt you get weird errors like this. Check that your .DAT file isn't corrupted (just redownload it).

Since the logic appears to work according to all my testing, I'm rejecting this report.

#5 Updated by Packhead 4 days ago

  • Target version deleted (1.6.16)

Also available in: Atom PDF