bind9/bin/tests/system/feature-test.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

271 lines
5.6 KiB
C
Raw Normal View History

/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* 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 https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <openssl/crypto.h>
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/provider.h>
#endif
#include <isc/crypto.h>
#include <isc/lib.h>
#include <isc/md.h>
2022-07-20 01:42:30 -04:00
#include <isc/mem.h>
2016-11-10 17:59:58 -05:00
#include <isc/net.h>
#include <isc/util.h>
#include <dns/edns.h>
#include <dns/lib.h>
2022-07-20 01:42:30 -04:00
#include <dst/dst.h>
static void
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 10:46:53 -04:00
usage(void) {
fprintf(stderr, "usage: feature-test <arg>\n");
fprintf(stderr, "args:\n");
2020-09-03 00:09:38 -04:00
fprintf(stderr, "\t--edns-version\n");
fprintf(stderr, "\t--enable-dnstap\n");
fprintf(stderr, "\t--enable-querytrace\n");
fprintf(stderr, "\t--fips-provider\n");
2020-09-03 00:09:38 -04:00
fprintf(stderr, "\t--gethostname\n");
fprintf(stderr, "\t--gssapi\n");
fprintf(stderr, "\t--have-fips-dh\n");
fprintf(stderr, "\t--have-fips-mode\n");
2020-09-03 00:09:38 -04:00
fprintf(stderr, "\t--have-geoip2\n");
fprintf(stderr, "\t--have-json-c\n");
2020-09-03 00:09:38 -04:00
fprintf(stderr, "\t--have-libxml2\n");
fprintf(stderr, "\t--ipv6only=no\n");
fprintf(stderr, "\t--md5\n");
2022-07-20 01:42:30 -04:00
fprintf(stderr, "\t--rsasha1\n");
fprintf(stderr, "\t--tsan\n");
2020-09-03 00:09:38 -04:00
fprintf(stderr, "\t--with-dlz-filesystem\n");
fprintf(stderr, "\t--with-libidn2\n");
2020-09-03 00:09:38 -04:00
fprintf(stderr, "\t--with-lmdb\n");
fprintf(stderr, "\t--with-libnghttp2\n");
fprintf(stderr, "\t--with-zlib\n");
}
int
main(int argc, char **argv) {
if (argc != 2) {
usage();
return 1;
}
if (strcmp(argv[1], "--edns-version") == 0) {
#ifdef DNS_EDNS_VERSION
printf("%d\n", DNS_EDNS_VERSION);
#else /* ifdef DNS_EDNS_VERSION */
printf("0\n");
#endif /* ifdef DNS_EDNS_VERSION */
return 0;
}
if (strcmp(argv[1], "--enable-dnstap") == 0) {
#ifdef HAVE_DNSTAP
return 0;
#else /* ifdef HAVE_DNSTAP */
return 1;
#endif /* ifdef HAVE_DNSTAP */
}
if (strcmp(argv[1], "--enable-querytrace") == 0) {
#ifdef WANT_QUERYTRACE
return 0;
#else /* ifdef WANT_QUERYTRACE */
return 1;
#endif /* ifdef WANT_QUERYTRACE */
}
if (strcasecmp(argv[1], "--fips-provider") == 0) {
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
OSSL_PROVIDER *fips = OSSL_PROVIDER_load(NULL, "fips");
if (fips != NULL) {
OSSL_PROVIDER_unload(fips);
}
return fips != NULL ? 0 : 1;
#else
return 1;
#endif
}
if (strcmp(argv[1], "--gethostname") == 0) {
char hostname[_POSIX_HOST_NAME_MAX + 1];
int n;
n = gethostname(hostname, sizeof(hostname));
if (n == -1) {
perror("gethostname");
return 1;
}
fprintf(stdout, "%s\n", hostname);
return 0;
}
if (strcmp(argv[1], "--gssapi") == 0) {
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 10:46:53 -04:00
#if HAVE_GSSAPI
return 0;
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 10:46:53 -04:00
#else /* HAVE_GSSAPI */
return 1;
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 10:46:53 -04:00
#endif /* HAVE_GSSAPI */
}
if (strcmp(argv[1], "--have-fips-dh") == 0) {
#if defined(ENABLE_FIPS_MODE)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
return 0;
#else
return 1;
#endif
#else
if (isc_crypto_fips_mode()) {
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
return 0;
#else
return 1;
#endif
}
return 0;
#endif
}
if (strcmp(argv[1], "--have-fips-mode") == 0) {
#if defined(ENABLE_FIPS_MODE)
return 0;
#else
return isc_crypto_fips_mode() ? 0 : 1;
#endif
}
if (strcmp(argv[1], "--have-geoip2") == 0) {
#ifdef HAVE_GEOIP2
return 0;
#else /* ifdef HAVE_GEOIP2 */
return 1;
#endif /* ifdef HAVE_GEOIP2 */
}
if (strcmp(argv[1], "--have-json-c") == 0) {
#ifdef HAVE_JSON_C
return 0;
#else /* ifdef HAVE_JSON_C */
return 1;
#endif /* ifdef HAVE_JSON_C */
}
if (strcmp(argv[1], "--have-libxml2") == 0) {
#ifdef HAVE_LIBXML2
return 0;
#else /* ifdef HAVE_LIBXML2 */
return 1;
#endif /* ifdef HAVE_LIBXML2 */
}
if (strcmp(argv[1], "--tsan") == 0) {
#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
return 0;
#endif
#endif
#if __SANITIZE_THREAD__
return 0;
#else
return 1;
#endif
}
if (strcmp(argv[1], "--md5") == 0) {
if (!dst_algorithm_supported(DST_ALG_HMACMD5)) {
return 1;
}
return 0;
}
2016-11-10 17:59:58 -05:00
if (strcmp(argv[1], "--ipv6only=no") == 0) {
#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
2016-11-10 17:59:58 -05:00
int s;
2016-11-15 00:51:36 -05:00
int n = -1;
2016-11-10 17:59:58 -05:00
int v6only = -1;
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 /* defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) */
2016-11-10 17:59:58 -05:00
return 1;
#endif /* defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) */
2016-11-10 17:59:58 -05:00
}
2022-07-20 01:42:30 -04:00
if (strcasecmp(argv[1], "--rsasha1") == 0) {
if (!dst_algorithm_supported(DST_ALG_RSASHA1)) {
return 1;
}
return 0;
2022-07-20 01:42:30 -04:00
}
2020-09-03 00:09:38 -04:00
if (strcmp(argv[1], "--with-dlz-filesystem") == 0) {
#ifdef DLZ_FILESYSTEM
return 0;
#else /* ifdef DLZ_FILESYSTEM */
return 1;
#endif /* ifdef DLZ_FILESYSTEM */
}
if (strcmp(argv[1], "--with-libidn2") == 0) {
2020-09-03 00:09:38 -04:00
#ifdef HAVE_LIBIDN2
return 0;
#else /* ifdef HAVE_LIBIDN2 */
return 1;
#endif /* ifdef HAVE_LIBIDN2 */
}
if (strcmp(argv[1], "--with-lmdb") == 0) {
#ifdef HAVE_LMDB
return 0;
#else /* ifdef HAVE_LMDB */
return 1;
#endif /* ifdef HAVE_LMDB */
}
if (strcmp(argv[1], "--with-libnghttp2") == 0) {
#ifdef HAVE_LIBNGHTTP2
return 0;
#else /* ifdef HAVE_LIBNGHTTP2 */
return 1;
#endif /* ifdef HAVE_LIBNGHTTP2 */
}
if (strcmp(argv[1], "--with-zlib") == 0) {
#ifdef HAVE_ZLIB
return 0;
#else /* ifdef HAVE_ZLIB */
return 1;
#endif /* ifdef HAVE_ZLIB */
}
fprintf(stderr, "unknown arg: %s\n", argv[1]);
usage();
return 1;
}