.PHONY: check-perl
check-perl: testdata.db
- cd $(builddir)/src/perl && $(MAKE) LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" test database="../../$<"
+ cd $(builddir)/src/perl && $(MAKE) LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" test \
+ database="../../$<" keyfile="$(abs_srcdir)/examples/public-key.pem"
.PHONY: install-perl
install-perl:
MODULE = Location PACKAGE = Location
struct loc_database *
-init(file)
+init(file, keyfile)
char* file;
+ char* keyfile;
CODE:
struct loc_ctx* ctx = NULL;
croak("Could not read database: %s\n", file);
}
+ // Try to open the keyfile
+ f = fopen(keyfile, "r");
+ if (!f) {
+ loc_database_unref(db);
+ loc_unref(ctx);
+
+ croak("Could not open keyfile %s: %s\n",
+ keyfile, strerror(errno));
+ }
+
+ // Verify the database
+ int status = loc_database_verify(db, f);
+ if (status) {
+ loc_database_unref(db);
+ loc_unref(ctx);
+ fclose(f);
+
+ croak("Could not verify the database signature\n");
+ }
+
+ // Close the keyfile
+ fclose(f);
+
// Cleanup
loc_unref(ctx);
# Where to find the test database.
my $testdb = $ENV{'database'};
+my $keyfile = $ENV{'keyfile'};
use Test::More tests => 6;
BEGIN { use_ok('Location') };
my $address = "2a07:1c44:5800::1";
# Connect to the database.
-my $db = &Location::init("$testdb");
+my $db = &Location::init("$testdb", "$keyfile");
my $vendor = &Location::get_vendor($db);
ok($vendor eq "IPFire Project", "Test 1 - Get Database Vendor");