2016-10-27 21:05:19 -04:00
|
|
|
/*
|
2018-02-23 03:53:12 -05:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2016-10-27 21:05:19 -04:00
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2018-02-23 03:53:12 -05:00
|
|
|
*
|
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
|
* information regarding copyright ownership.
|
2016-10-27 21:05:19 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <isc/print.h>
|
|
|
|
|
#include <isc/util.h>
|
2016-11-10 17:59:58 -05:00
|
|
|
#include <isc/net.h>
|
2016-10-31 19:53:37 -04:00
|
|
|
#include <dns/edns.h>
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#include <Winsock2.h>
|
|
|
|
|
#endif
|
2016-10-27 21:05:19 -04:00
|
|
|
|
|
|
|
|
#ifndef MAXHOSTNAMELEN
|
|
|
|
|
#ifdef HOST_NAME_MAX
|
|
|
|
|
#define MAXHOSTNAMELEN HOST_NAME_MAX
|
|
|
|
|
#else
|
|
|
|
|
#define MAXHOSTNAMELEN 256
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
usage() {
|
|
|
|
|
fprintf(stderr, "usage: feature-test <arg>\n");
|
|
|
|
|
fprintf(stderr, "args:\n");
|
|
|
|
|
fprintf(stderr, " --edns-version\n");
|
2017-09-11 14:53:42 -04:00
|
|
|
fprintf(stderr, " --enable-dnsrps\n");
|
2016-10-27 21:05:19 -04:00
|
|
|
fprintf(stderr, " --gethostname\n");
|
|
|
|
|
fprintf(stderr, " --gssapi\n");
|
|
|
|
|
fprintf(stderr, " --have-dlopen\n");
|
2019-06-28 00:08:20 -04:00
|
|
|
fprintf(stderr, " --have-geoip2\n");
|
2016-10-27 21:05:19 -04:00
|
|
|
fprintf(stderr, " --have-libxml2\n");
|
2016-11-10 17:59:58 -05:00
|
|
|
fprintf(stderr, " --ipv6only=no\n");
|
2016-10-27 21:05:19 -04:00
|
|
|
fprintf(stderr, " --with-idn\n");
|
2017-12-20 01:13:58 -05:00
|
|
|
fprintf(stderr, " --with-lmdb\n");
|
2019-01-30 09:12:54 -05:00
|
|
|
fprintf(stderr, " --with-dlz-filesystem\n");
|
2016-10-27 21:05:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char **argv) {
|
|
|
|
|
if (argc != 2) {
|
|
|
|
|
usage();
|
|
|
|
|
return (1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 14:53:42 -04:00
|
|
|
if (strcmp(argv[1], "--enable-dnsrps") == 0) {
|
|
|
|
|
#ifdef USE_DNSRPS
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 21:05:19 -04:00
|
|
|
if (strcmp(argv[1], "--edns-version") == 0) {
|
|
|
|
|
#ifdef DNS_EDNS_VERSION
|
|
|
|
|
printf("%d\n", DNS_EDNS_VERSION);
|
|
|
|
|
#else
|
|
|
|
|
printf("0\n");
|
|
|
|
|
#endif
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "--gethostname") == 0) {
|
|
|
|
|
char hostname[MAXHOSTNAMELEN];
|
|
|
|
|
int n;
|
2016-10-31 19:53:37 -04:00
|
|
|
#ifdef WIN32
|
2017-09-08 16:39:09 -04:00
|
|
|
/* From InitSocket() */
|
2016-10-31 19:53:37 -04:00
|
|
|
WORD wVersionRequested;
|
|
|
|
|
WSADATA wsaData;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
wVersionRequested = MAKEWORD(2, 0);
|
|
|
|
|
err = WSAStartup( wVersionRequested, &wsaData );
|
|
|
|
|
if (err != 0) {
|
|
|
|
|
fprintf(stderr, "WSAStartup() failed: %d\n", err);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-27 21:05:19 -04:00
|
|
|
n = gethostname(hostname, sizeof(hostname));
|
|
|
|
|
if (n == -1) {
|
|
|
|
|
perror("gethostname");
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
fprintf(stdout, "%s\n", hostname);
|
2016-10-31 19:53:37 -04:00
|
|
|
#ifdef WIN32
|
|
|
|
|
WSACleanup();
|
|
|
|
|
#endif
|
2016-10-27 21:05:19 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "--gssapi") == 0) {
|
|
|
|
|
#if defined(GSSAPI)
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 19:45:58 -04:00
|
|
|
if (strcmp(argv[1], "--have-dlopen") == 0) {
|
2016-10-27 21:05:19 -04:00
|
|
|
#if defined(HAVE_DLOPEN) && defined(ISC_DLZ_DLOPEN)
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 21:36:52 -04:00
|
|
|
if (strcmp(argv[1], "--have-geoip2") == 0) {
|
|
|
|
|
#ifdef HAVE_GEOIP2
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 19:45:58 -04:00
|
|
|
if (strcmp(argv[1], "--have-libxml2") == 0) {
|
2016-10-27 21:05:19 -04:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "--with-idn") == 0) {
|
Rework libidn2 detection
Clean up the parts of configure.in responsible for handling libidn2
detection and adjust other pieces of the build system to match these
cleanups:
- use pkg-config when --with-libidn2 is used without an explicit path,
- look for idn2_to_ascii_lz() rather than idn2_to_ascii_8z() as the
former is used in BIND while the latter is not,
- do not look for idn2_to_unicode_8zlz() as it is present in all
libidn2 versions which have idn2_to_ascii_lz(),
- check whether the <idn2.h> header is usable,
- set LDFLAGS in the Makefile for dig so that, if specified, the
requested libidn2 path is used when linking with libidn2,
- override CPPFLAGS when looking for libidn2 components so that the
configure script does not produce warnings when libidn2 is not
installed system-wide,
- merge the AS_CASE() call into the AS_IF() call below it to simplify
code,
- indicate the default value of --with-libidn2 in "./configure --help"
output,
- use $with_libidn2 rather than $use_libidn2 to better match the name
of the configure script argument,
- stop differentiating between IDN "in" and "out" support, i.e. make
dig either support libidn2 or not; remove WITH_* Autoconf macros and
use a new one, HAVE_LIBIDN2, to determine whether libidn2 support
should be enabled.
2018-07-10 08:34:35 -04:00
|
|
|
#ifdef HAVE_LIBIDN2
|
2016-10-27 21:05:19 -04:00
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 01:13:58 -05:00
|
|
|
if (strcmp(argv[1], "--with-lmdb") == 0) {
|
|
|
|
|
#ifdef HAVE_LMDB
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-30 09:12:54 -05:00
|
|
|
if (strcmp(argv[1], "--with-dlz-filesystem") == 0) {
|
|
|
|
|
#ifdef DLZ_FILESYSTEM
|
|
|
|
|
return (0);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-10 17:59:58 -05:00
|
|
|
if (strcmp(argv[1], "--ipv6only=no") == 0) {
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return (0);
|
|
|
|
|
#elif defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
|
|
|
|
|
int s;
|
2016-11-15 00:51:36 -05:00
|
|
|
int n = -1;
|
2016-11-10 17:59:58 -05:00
|
|
|
int v6only = -1;
|
2018-09-05 08:03:10 -04:00
|
|
|
socklen_t len = sizeof(v6only);
|
2016-11-10 17:59:58 -05:00
|
|
|
|
|
|
|
|
s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
2016-11-15 00:51:36 -05:00
|
|
|
if (s >= 0) {
|
|
|
|
|
n = getsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
|
|
|
|
|
(void *)&v6only, &len);
|
|
|
|
|
close(s);
|
|
|
|
|
}
|
2016-11-10 17:59:58 -05:00
|
|
|
return ((n == 0 && v6only == 0) ? 0 : 1);
|
|
|
|
|
#else
|
|
|
|
|
return (1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 21:05:19 -04:00
|
|
|
fprintf(stderr, "unknown arg: %s\n", argv[1]);
|
|
|
|
|
usage();
|
|
|
|
|
return (1);
|
|
|
|
|
}
|