]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
convert geoip to geoip2 in win32utils/Configure
authorThomas Jach <th.jach@gmail.com>
Tue, 2 Jul 2019 23:27:42 +0000 (16:27 -0700)
committerEvan Hunt <each@isc.org>
Thu, 4 Jul 2019 15:58:26 +0000 (08:58 -0700)
bin/named/config.c
bin/named/geoip.c
bin/named/server.c
config.h.win32
doc/arm/Bv9ARM-book.xml
lib/dns/win32/libdns.vcxproj.filters.in
lib/dns/win32/libdns.vcxproj.in
lib/isc/win32/libisc.vcxproj.in
win32utils/Configure

index 6f6da2facd7f46cc2907553cef75fbf1a899e1ae..cc74012e7fa649dc3701f54406f8680d6fbe3471 100644 (file)
@@ -64,8 +64,10 @@ options {\n\
 #ifndef WIN32
 "      files unlimited;\n"
 #endif
-#ifdef HAVE_GEOIP2
+#if defined(HAVE_GEOIP2) && !defined(WIN32)
 "      geoip-directory \"" MAXMINDDB_PREFIX "/share/GeoIP2\";\n"
+#elif defined(HAVE_GEOIP2)
+"      geoip-directory \".\";\n"
 #endif
 "\
 #      has-old-clients <obsolete>;\n\
index f72895ee173307135e94bd41edb46b5b47d36abb..83fbd96e67ec83bb5e4d4035b055ef36d3e04d3a 100644 (file)
@@ -40,7 +40,7 @@ open_geoip2(const char *dir, const char *dbfile, MMDB_s *mmdb) {
                isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
                              NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
                              "GeoIP2 database '%s/%s': path too long",
-                             (dir != NULL) ? dir : ".", dbfile);
+                             dir, dbfile);
                return (NULL);
        }
 
@@ -78,6 +78,10 @@ named_geoip_load(char *dir) {
 #if defined(HAVE_GEOIP2)
        REQUIRE(dir != NULL);
 
+       isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+                     NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
+                     "looking for GeoIP2 databases in '%s'", dir);
+
        named_g_geoip->country = open_geoip2(dir, "GeoIP2-Country.mmdb",
                                             &geoip_country);
        if (named_g_geoip->country == NULL) {
index a8f0872992ef462cc97fe82a914ed2a54d8a87e7..d1ca372a4a292c7e5a7deea2f7a122b1f2b783c8 100644 (file)
@@ -8270,12 +8270,11 @@ load_configuration(const char *filename, named_server_t *server,
         */
        obj = NULL;
        result = named_config_get(maps, "geoip-directory", &obj);
-       if (result == ISC_R_SUCCESS && cfg_obj_isstring(obj)) {
+       INSIST(result == ISC_R_SUCCESS);
+       if (cfg_obj_isstring(obj)) {
                char *dir;
                DE_CONST(cfg_obj_asstring(obj), dir);
                named_geoip_load(dir);
-       } else {
-               named_geoip_load(NULL);
        }
        named_g_aclconfctx->geoip = named_g_geoip;
 #endif /* HAVE_GEOIP2 */
index 0fe66c5f191aa1389da6e47ed134c6f3ac3b7e7f..fda2009e518bbfb4d5e71603500ccbe891713ca5 100644 (file)
@@ -310,9 +310,6 @@ typedef __int64 off_t;
 /* Define to 1 if you have the `readline' function. */
 @HAVE_READLINE@
 
-/* Build with GeoIP support */
-@HAVE_GEOIP@
-
 /* Build with GeoIP2 support */
 @HAVE_GEOIP2@
 
index 37ba6fcd8a13f8af4c076f1ff7eabcbb5e06cf19..fbd5e939e681f4e52b24fd6e7c9e8179fb37d352 100644 (file)
@@ -4562,8 +4562,9 @@ badresp:1,adberr:0,findfail:0,valfail:0]
                module: for example, if the library is installed in
                <filename>/usr/local/lib</filename>, then the default
                <command>geoip-directory</command> will be
-               <filename>/usr/local/share/GeoIP</filename>.
-               See <xref linkend="acl"/> for details about
+               <filename>/usr/local/share/GeoIP</filename>. On Windows,
+               the default is the <command>named</command> working
+               directory.  See <xref linkend="acl"/> for details about
                <command>geoip</command> ACLs.
              </para>
            </listitem>
index 4f2a2e8463e127e8c7ccdeeaf870135a24e28c93..56f12aeba2bce094d8c58adb12f1149e72a514a0 100644 (file)
       <Filter>Library Source Files</Filter>
     </ClCompile>
 @IF GEOIP
-    <ClCompile Include="..\geoip.c">
+    <ClCompile Include="..\geoip2.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
 @END GEOIP
index bb5ef0dd606fe02b477948d150335fb880d1ee6b..2317624d091fe684df9874e50f9cd2a8ed13ba0a 100644 (file)
     <ClCompile Include="..\fixedname.c" />
     <ClCompile Include="..\forward.c" />
 @IF GEOIP
-    <ClCompile Include="..\geoip.c" />
+    <ClCompile Include="..\geoip2.c" />
 @END GEOIP
     <ClCompile Include="..\gssapictx.c" />
     <ClCompile Include="..\gssapi_link.c" />
index 0d5aa96709757c90b7656d9b1974b3b771dcb55f..9e8133c63790036497d81ae41d0a56b557907553 100644 (file)
@@ -109,12 +109,6 @@ copy @K5SPRT_DLL@ ..\Build\Debug\
 copy @WSHELP_DLL@ ..\Build\Debug\
 @END GSSAPI
 
-@IF GEOIP
-echo Copying the GeoIP DLL.
-
-copy @GEOIP_DLL@ ..\Build\Debug\
-@END GEOIP
-
 @IF IDNKIT
 echo Copying the IDN kit DLL.
 
@@ -258,12 +252,6 @@ copy @K5SPRT_DLL@ ..\Build\Release\
 copy @WSHELP_DLL@ ..\Build\Release\
 @END GSSAPI
 
-@IF GEOIP
-echo Copying the GeoIP DLL.
-
-copy @GEOIP_DLL@ ..\Build\Release\
-@END GEOIP
-
 @IF IDNKIT
 echo Copying the IDN kit DLL.
 
index a378f44847a588d57581dbaf95ac4037520585ab..aee6ee7f0b8ac244e0208747cc74d53c6e27a751 100644 (file)
@@ -195,9 +195,7 @@ my %configdefh;
 my @substdefh = ("AES_CC",
                  "CONFIGARGS",
                  "DNS_RDATASET_FIXED",
-                 "HAVE_GEOIP",
-                 "HAVE_GEOIP_CITY_V6",
-                 "HAVE_GEOIP_V6",
+                 "HAVE_GEOIP2",
                  "HAVE_LIBXML2",
                  "HAVE_OPENSSL_ED25519",
                  "HAVE_OPENSSL_ED448",
@@ -283,7 +281,6 @@ my %configdll;
 
 my @substdll = ("COMERR_DLL",
                 "GSSAPI_DLL",
-                "GEOIP_DLL",
                 "ICONV_DLL",
                 "IDN_DLL",
                 "KRB5_DLL",
@@ -369,7 +366,7 @@ my @withlist = ("aes",
                 "eddsa",
                 "extra-tests",
                 "gssapi",
-                "geoip",
+                "geoip2",
                 "iconv",
                 "idn",
                 "openssl",
@@ -426,7 +423,7 @@ my @help = (
 "  with-cc-alg           choose the algorithm for cookies aes|sha1|sha256\n",
 "  with-gssapi[=PATH]    build with MIT KfW GSSAPI yes|no|path\n",
 "  with-libxml2[=PATH]   build with libxml2 library yes|no|path\n",
-"  with-geoip[=PATH]     build with GeoIP support yes|no|path\n",
+"  with-geoip2[=PATH]    build with GeoIP2 support yes|no|path\n",
 "  with-pssuspend[=COMMAND] specify pssuspend command\n",
 "  with-python[=COMMAND] specify python interpreter python|command\n",
 "  with-readline[=PATH]  build with readline library support yes|no|path\n",
@@ -472,8 +469,8 @@ my $cookie_algorithm = "aes";
 my $use_gssapi = "no";
 my $validation_default = "auto";
 my $gssapi_path = "C:\\Program\ Files\\MIT\\Kerberos\\";
-my $use_geoip = "no";
-my $geoip_path = "";
+my $use_geoip2 = "no";
+my $geoip2_path = "";
 my $use_libxml2 = "auto";
 my $libxml2_path = "..\\..\\";
 my $with_pssuspend = "no";
@@ -776,11 +773,13 @@ sub mywith {
             $use_libxml2 = "yes";
             $libxml2_path = $val;
         }
-    } elsif ($key =~ /^geoip$/i) {
+    } elsif ($key =~ /^geoip2$/i) {
         if ($val !~ /^no$/i) {
-            $use_geoip = "yes";
+            $use_geoip2 = "yes";
             if ($val !~ /^yes$/i) {
-                $geoip_path = $val;
+                $geoip2_path = $val;
+            } else {
+                $geoip2_path = "..\\..\\GeoIP2";
             }
         }
     } elsif ($key =~ /^readline$/i) {
@@ -978,10 +977,10 @@ if ($verbose) {
     } else {
         print "libxml2-path: $libxml2_path\n";
     }
-    if ($use_geoip eq "no") {
-        print "geoip: disabled\n";
+    if ($use_geoip2 eq "no") {
+        print "geoip2: disabled\n";
     } else {
-        print "geoip-path: $geoip_path\n";
+        print "geoip2-path: $geoip2_path\n";
     }
     if ($use_readline eq "no") {
         print "readline: disabled\n";
@@ -1479,6 +1478,7 @@ EOF
             $configdefh{"HAVE_DH_GET0_KEY"} = 1;
             $configdefh{"HAVE_ECDSA_SIG_GET0"} = 1;
             $configdefh{"HAVE_RSA_SET0_KEY"} = 1;
+            $configdefh{"HAVE_CRYPTO_ZALLOC"} = 1;
             $configdefh{"HAVE_EVP_CIPHER_CTX_FREE"} = 1;
             $configdefh{"HAVE_EVP_CIPHER_CTX_NEW"} = 1;
             $configdefh{"HAVE_EVP_MD_CTX_FREE"} = 1;
@@ -1730,118 +1730,53 @@ if ($use_gssapi ne "yes") {
 # disable-auto-validation
 $configdefh{"VALIDATION_DEFAULT"} = "\"$validation_default\"";
 
-# with-geoip
-if ($use_geoip eq "no") {
+# with-geoip2
+if ($use_geoip2 eq "no") {
     if ($verbose) {
-        print "geoip library is disabled\n";
+        print "geoip2 library is disabled\n";
     }
 } else {
     $configcond{"GEOIP"} = 1;
-    $geoip_path = File::Spec->rel2abs($geoip_path);
+    $geoip2_path = File::Spec->rel2abs($geoip2_path);
     if ($verbose) {
-        print "checking for geoip directory at \"$geoip_path\"\n";
-    }
-    if (!-f File::Spec->catfile($geoip_path, "GeoIP.h")) {
-        die "can't find GeoIP.h include\n";
-    }
-    if (!-f File::Spec->catfile($geoip_path, "GeoIP.lib")) {
-        die "can't find Geoip.lib library\n";
-    }
-    if (!-f File::Spec->catfile($geoip_path, "GeoIP.dll")) {
-        die "can't find Geoip.dll DLL\n";
-    }
-    $configinc{"GEOIP_INC"} = "$geoip_path";
-    my $geoip_lib = File::Spec->catfile($geoip_path, "GeoIP.lib");
-    $configlib{"GEOIP_LIB"} = "$geoip_lib";
-    my $geoip_dll = File::Spec->catfile($geoip_path, "GeoIP.dll");
-    $configdll{"GEOIP_DLL"} = "$geoip_dll";
-
-    if ($verbose) {
-        print "checking for GeoIP support\n";
-    }
-    my $ret = `copy "$geoip_dll" .`;
-    if ($? != 0) {
-        die "Can't copy GeoIP DLL to working directory: $ret\n";
+        print "checking for geoip2 directory at \"$geoip2_path\"\n";
     }
-    open F, ">testgeoip.c" || die $!;
-    print F << 'EOF';
-extern void *GeoIP_open();
-
-int main() {
-        return GeoIP_open != 0;
-}
-EOF
-    close F;
-    $compret = `cl /nologo /MD testgeoip.c "$geoip_lib"`;
-    if (grep { -f and -x } ".\\testgeoip.exe") {
-        `.\\testgeoip.exe`;
-        if ($? == 0) {
-            die "GeoIP test failed\n";
-        }
-    } else {
-        die "can't compile GeoIP test: $compret\n";
+    if (!-f File::Spec->catfile($geoip2_path, "maxminddb.h")) {
+        die "can't find maxminddb.h include\n";
     }
-    $configdefh{"HAVE_GEOIP"} = 1;
-
-    if ($verbose) {
-        print "checking for GeoIP Country IPv6 support\n";
+    if (!-f File::Spec->catfile($geoip2_path, "maxminddb_config.h")) {
+        die "can't find maxminddb_config.h include\n";
     }
-    my $geoip_inc = qq(/I "$geoip_path");
-    my $geoip_libs = qq("$geoip_lib" ws2_32.lib);
-    open F, ">testgeoip1.c" || die $!;
-    print F << 'EOF';
-#include <GeoIP.h>
-
-struct in6_addr in6;
-int flag = 1;
-
-int main() {
-        if (flag)
-                return 1;
-        return GeoIP_country_name_by_ipnum_v6(NULL, in6) != NULL;
-}
-EOF
-    close F;
-    $compret = `cl /nologo $geoip_inc /MD testgeoip1.c $geoip_libs`;
-    if (grep { -f and -x } ".\\testgeoip1.exe") {
-        `.\\testgeoip1.exe`;
-        if ($? == 0) {
-            die "GeoIP Country IPv6 test failed\n";
-        }
-    } else {
-        die "can't compile GeoIP Country IPv6 test: $compret\n";
+    if (!-f File::Spec->catfile($geoip2_path, "libmaxminddb.lib")) {
+        die "can't find libmaxminddb.lib library\n";
     }
-    $configdefh{"HAVE_GEOIP_V6"} = 1;
+    $configinc{"GEOIP_INC"} = "$geoip2_path";
+    my $geoip2_lib = File::Spec->catfile($geoip2_path, "libmaxminddb.lib");
+    $configlib{"GEOIP_LIB"} = "$geoip2_lib";
+    my $geoip_inc = qq(/I "$geoip2_path");
+    my $geoip2_libs = qq("$geoip2_lib" Ws2_32.Lib);
 
     if ($verbose) {
-        print "checking for GeoIP City IPv6 support\n";
+        print "checking for GeoIP2 support\n";
     }
     open F, ">testgeoip2.c" || die $!;
     print F << 'EOF';
-#include <GeoIP.h>
-#include <GeoIPCity.h>
-
-struct in6_addr in6;
-int i = GEOIP_CITY_EDITION_REV0_V6;
-int flag = 1;
-
-int main() {
-        if (flag)
-                return 1;
-        return GeoIP_record_by_ipnum_v6(NULL, in6) != NULL;
+#include <maxminddb.h>
+int main(void) {
+       return MMDB_lib_version() != 0;
 }
 EOF
     close F;
-    $compret = `cl /nologo $geoip_inc /MD testgeoip2.c $geoip_libs`;
+    $compret = `cl /nologo $geoip_inc /MD testgeoip2.c $geoip2_libs`;
     if (grep { -f and -x } ".\\testgeoip2.exe") {
         `.\\testgeoip2.exe`;
         if ($? == 0) {
-            die "GeoIP City IPv6 test failed\n";
+            die "GeoIP2 test failed\n";
         }
     } else {
-        die "can't compile GeoIP City IPv6 test: $compret\n";
+        die "can't compile GeoIP2 test: $compret\n";
     }
-    $configdefh{"HAVE_GEOIP_CITY_V6"} = 1;
+    $configdefh{"HAVE_GEOIP2"} = 1;
 }
 
 # with-readline
@@ -2746,9 +2681,6 @@ sub makeinstallfile {
             print LOUT "krb5_32.dll-BCFT\n";
         }
     }
-    if ($use_geoip eq "yes") {
-        print LOUT "libgeoip.dll-BCFT\n";
-    }
     if ($use_idn eq "yes") {
         print LOUT "idnkit.dll-BCFT\n";
         print LOUT "iconv.dll-BCFT\n";
@@ -2950,7 +2882,7 @@ exit 0;
 #  --with-aes supported
 #  --with-cc-alg supported
 #  --with-randomdev not supported on WIN32 (makes no sense)
-#  --with-geoip supported
+#  --with-geoip2 supported
 #  --with-gssapi supported with MIT (K)erberos (f)or (W)indows
 #  --with-lmdb no supported on WIN32 (port is not reliable)
 #  --with-libxml2 supported