From fed4818c2739dea98f9110b3998679cd12331704 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 14 Jul 2016 11:03:33 +0200 Subject: [PATCH 01/25] Fix idle_timeout without keepalive for TLS --- src/stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stub.c b/src/stub.c index 94627d24..30e80125 100644 --- a/src/stub.c +++ b/src/stub.c @@ -330,7 +330,7 @@ process_keepalive( /* For TCP if no keepalive sent back, then we must use 0 idle timeout as server does not support it. TLS allows idle connections without keepalive, according to RFC7858. */ -#if !defined(KEEP_CONNECTIONS_OPEN_DEBUG) && !KEEP_CONNECTIONS_OPEN_DEBUG +#if !defined(KEEP_CONNECTIONS_OPEN_DEBUG) || !KEEP_CONNECTIONS_OPEN_DEBUG if (upstream->transport != GETDNS_TRANSPORT_TLS) upstream->keepalive_timeout = 0; else From 470fb7a5fbeb2f8a1eba68c11fddeb1494fceaaa Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 14 Jul 2016 11:42:21 +0200 Subject: [PATCH 02/25] !0 is not necessarily 1 --- src/stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stub.c b/src/stub.c index 30e80125..2b6f9c36 100644 --- a/src/stub.c +++ b/src/stub.c @@ -1597,7 +1597,7 @@ upstream_valid_and_open(getdns_upstream *upstream, return 1; /* Connection is complete, we know the auth status so check*/ if (upstream->conn_state == GETDNS_CONN_OPEN && - !upstream_auth_status_ok(upstream, netreq) == 1) + !upstream_auth_status_ok(upstream, netreq)) return 0; /* We must have a TLS connection still setting up so schedule and the write code will check again once the connection is complete*/ From 74b57d4679abe9d1d7deaad175229f3036c61b25 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 14 Jul 2016 13:33:11 +0200 Subject: [PATCH 03/25] Resync utils with unbound source --- src/util/import.sh | 4 ++ src/util/val_secalgo.c | 96 +++++++++++++++++++++++++----------------- src/util/val_secalgo.h | 12 +++++- 3 files changed, 72 insertions(+), 40 deletions(-) diff --git a/src/util/import.sh b/src/util/import.sh index ee903681..82f03921 100755 --- a/src/util/import.sh +++ b/src/util/import.sh @@ -44,6 +44,10 @@ do -e 's/secalgo_ds_digest/_getdns_secalgo_ds_digest/g' \ -e 's/dnskey_algo_id_is_supported/_getdns_dnskey_algo_id_is_supported/g' \ -e 's/verify_canonrrset/_getdns_verify_canonrrset/g' \ + -e 's/nsec3_hash_algo_size_supported/_getdns_nsec3_hash_algo_size_supported/g' \ + -e 's/secalgo_nsec3_hash/_getdns_secalgo_nsec3_hash/g' \ + -e 's/secalgo_hash_sha256/_getdns_secalgo_hash_sha256/g' \ + -e 's/ecdsa_evp_workaround_init/_getdns_ecdsa_evp_workaround_init/g' \ -e 's/LDNS_/GLDNS_/g' \ -e 's/enum sec_status/int/g' \ -e 's/sec_status_bogus/0/g' \ diff --git a/src/util/val_secalgo.c b/src/util/val_secalgo.c index b04400cc..edbf538b 100644 --- a/src/util/val_secalgo.c +++ b/src/util/val_secalgo.c @@ -72,7 +72,7 @@ /* return size of digest if supported, or 0 otherwise */ size_t -nsec3_hash_algo_size_supported(int id) +_getdns_nsec3_hash_algo_size_supported(int id) { switch(id) { case NSEC3_HASH_SHA1: @@ -84,7 +84,7 @@ nsec3_hash_algo_size_supported(int id) /* perform nsec3 hash. return false on failure */ int -secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, +_getdns_secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, unsigned char* res) { switch(algo) { @@ -96,6 +96,12 @@ secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, } } +void +_getdns_secalgo_hash_sha256(unsigned char* buf, size_t len, unsigned char* res) +{ + (void)SHA256(buf, len, res); +} + /** * Return size of DS digest according to its hash algorithm. * @param algo: DS digest algo. @@ -342,6 +348,23 @@ i * the '44' is the total remaining length. } #endif /* USE_ECDSA */ +#ifdef USE_ECDSA_EVP_WORKAROUND +static EVP_MD ecdsa_evp_256_md; +static EVP_MD ecdsa_evp_384_md; +void _getdns_ecdsa_evp_workaround_init(void) +{ + /* openssl before 1.0.0 fixes RSA with the SHA256 + * hash in EVP. We create one for ecdsa_sha256 */ + ecdsa_evp_256_md = *EVP_sha256(); + ecdsa_evp_256_md.required_pkey_type[0] = EVP_PKEY_EC; + ecdsa_evp_256_md.verify = (void*)ECDSA_verify; + + ecdsa_evp_384_md = *EVP_sha384(); + ecdsa_evp_384_md.required_pkey_type[0] = EVP_PKEY_EC; + ecdsa_evp_384_md.verify = (void*)ECDSA_verify; +} +#endif /* USE_ECDSA_EVP_WORKAROUND */ + /** * Setup key and digest for verification. Adjust sig if necessary. * @@ -470,20 +493,7 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type, return 0; } #ifdef USE_ECDSA_EVP_WORKAROUND - /* openssl before 1.0.0 fixes RSA with the SHA256 - * hash in EVP. We create one for ecdsa_sha256 */ - { - static int md_ecdsa_256_done = 0; - static EVP_MD md; - if(!md_ecdsa_256_done) { - EVP_MD m = *EVP_sha256(); - md_ecdsa_256_done = 1; - m.required_pkey_type[0] = (*evp_key)->type; - m.verify = (void*)ECDSA_verify; - md = m; - } - *digest_type = &md; - } + *digest_type = &ecdsa_evp_256_md; #else *digest_type = EVP_sha256(); #endif @@ -497,20 +507,7 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type, return 0; } #ifdef USE_ECDSA_EVP_WORKAROUND - /* openssl before 1.0.0 fixes RSA with the SHA384 - * hash in EVP. We create one for ecdsa_sha384 */ - { - static int md_ecdsa_384_done = 0; - static EVP_MD md; - if(!md_ecdsa_384_done) { - EVP_MD m = *EVP_sha384(); - md_ecdsa_384_done = 1; - m.required_pkey_type[0] = (*evp_key)->type; - m.verify = (void*)ECDSA_verify; - md = m; - } - *digest_type = &md; - } + *digest_type = &ecdsa_evp_384_md; #else *digest_type = EVP_sha384(); #endif @@ -544,7 +541,7 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, { const EVP_MD *digest_type; EVP_MD_CTX* ctx; - int res, dofree = 0; + int res, dofree = 0, docrypto_free = 0; EVP_PKEY *evp_key = NULL; if(!setup_key_digest(algo, &evp_key, &digest_type, key, keylen)) { @@ -563,7 +560,7 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, EVP_PKEY_free(evp_key); return 0; } - dofree = 1; + docrypto_free = 1; } #endif #if defined(USE_ECDSA) && defined(USE_DSA) @@ -593,6 +590,7 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, log_err("EVP_MD_CTX_new: malloc failure"); EVP_PKEY_free(evp_key); if(dofree) free(sigblock); + else if(docrypto_free) CRYPTO_free(sigblock); return 0; } if(EVP_VerifyInit(ctx, digest_type) == 0) { @@ -600,6 +598,7 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, EVP_MD_CTX_destroy(ctx); EVP_PKEY_free(evp_key); if(dofree) free(sigblock); + else if(docrypto_free) CRYPTO_free(sigblock); return 0; } if(EVP_VerifyUpdate(ctx, (unsigned char*)gldns_buffer_begin(buf), @@ -608,15 +607,21 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, EVP_MD_CTX_destroy(ctx); EVP_PKEY_free(evp_key); if(dofree) free(sigblock); + else if(docrypto_free) CRYPTO_free(sigblock); return 0; } res = EVP_VerifyFinal(ctx, sigblock, sigblock_len, evp_key); +#ifdef HAVE_EVP_MD_CTX_NEW EVP_MD_CTX_destroy(ctx); +#else + EVP_MD_CTX_cleanup(ctx); + free(ctx); +#endif EVP_PKEY_free(evp_key); - if(dofree) - free(sigblock); + if(dofree) free(sigblock); + else if(docrypto_free) CRYPTO_free(sigblock); if(res == 1) { return 1; @@ -644,7 +649,7 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, /* return size of digest if supported, or 0 otherwise */ size_t -nsec3_hash_algo_size_supported(int id) +_getdns_nsec3_hash_algo_size_supported(int id) { switch(id) { case NSEC3_HASH_SHA1: @@ -656,7 +661,7 @@ nsec3_hash_algo_size_supported(int id) /* perform nsec3 hash. return false on failure */ int -secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, +_getdns_secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, unsigned char* res) { switch(algo) { @@ -668,6 +673,12 @@ secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, } } +void +_getdns_secalgo_hash_sha256(unsigned char* buf, size_t len, unsigned char* res) +{ + (void)HASH_HashBuf(HASH_AlgSHA256, res, buf, (unsigned long)len); +} + size_t _getdns_ds_digest_size_supported(int algo) { @@ -1185,6 +1196,9 @@ _getdns_verify_canonrrset(gldns_buffer* buf, int algo, unsigned char* sigblock, #include "macros.h" #include "rsa.h" #include "dsa.h" +#ifdef HAVE_NETTLE_DSA_COMPAT_H +#include "dsa-compat.h" +#endif #include "asn1.h" #ifdef USE_ECDSA #include "ecdsa.h" @@ -1236,7 +1250,7 @@ _digest_nettle(int algo, uint8_t* buf, size_t len, /* return size of digest if supported, or 0 otherwise */ size_t -nsec3_hash_algo_size_supported(int id) +_getdns_nsec3_hash_algo_size_supported(int id) { switch(id) { case NSEC3_HASH_SHA1: @@ -1248,7 +1262,7 @@ nsec3_hash_algo_size_supported(int id) /* perform nsec3 hash. return false on failure */ int -secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, +_getdns_secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, unsigned char* res) { switch(algo) { @@ -1260,6 +1274,12 @@ secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, } } +void +_getdns_secalgo_hash_sha256(unsigned char* buf, size_t len, unsigned char* res) +{ + _digest_nettle(SHA256_DIGEST_SIZE, (uint8_t*)buf, len, res); +} + /** * Return size of DS digest according to its hash algorithm. * @param algo: DS digest algo. diff --git a/src/util/val_secalgo.h b/src/util/val_secalgo.h index 917ebc00..704449ec 100644 --- a/src/util/val_secalgo.h +++ b/src/util/val_secalgo.h @@ -45,7 +45,7 @@ struct gldns_buffer; /** Return size of nsec3 hash algorithm, 0 if not supported */ -size_t nsec3_hash_algo_size_supported(int id); +size_t _getdns_nsec3_hash_algo_size_supported(int id); /** * Hash a single hash call of an NSEC3 hash algorithm. @@ -56,9 +56,17 @@ size_t nsec3_hash_algo_size_supported(int id); * @param res: result stored here (must have sufficient space). * @return false on failure. */ -int secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, +int _getdns_secalgo_nsec3_hash(int algo, unsigned char* buf, size_t len, unsigned char* res); +/** + * Calculate the sha256 hash for the data buffer into the result. + * @param buf: buffer to digest. + * @param len: length of the buffer to digest. + * @param res: result is stored here (space 256/8 bytes). + */ +void _getdns_secalgo_hash_sha256(unsigned char* buf, size_t len, unsigned char* res); + /** * Return size of DS digest according to its hash algorithm. * @param algo: DS digest algo. From b4e7a82e11d644e7309d9de1fa9989feaf81635b Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 14 Jul 2016 13:40:49 +0200 Subject: [PATCH 04/25] EDNS0 padding is RFC --- src/gldns/rrdef.h | 3 ++- src/gldns/wire2str.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gldns/rrdef.h b/src/gldns/rrdef.h index 703ee31e..b13580ea 100644 --- a/src/gldns/rrdef.h +++ b/src/gldns/rrdef.h @@ -421,7 +421,8 @@ enum gldns_enum_edns_option GLDNS_EDNS_DHU = 6, /* RFC6975 */ GLDNS_EDNS_N3U = 7, /* RFC6975 */ GLDNS_EDNS_CLIENT_SUBNET = 8, /* draft-vandergaast-edns-client-subnet */ - GLDNS_EDNS_KEEPALIVE = 11 /* draft-ietf-dnsop-edns-tcp-keepalive*/ + GLDNS_EDNS_KEEPALIVE = 11, /* draft-ietf-dnsop-edns-tcp-keepalive*/ + GLDNS_EDNS_PADDING = 12 /* RFC7830 */ }; typedef enum gldns_enum_edns_option gldns_edns_option; diff --git a/src/gldns/wire2str.c b/src/gldns/wire2str.c index b9a979eb..abc055d7 100644 --- a/src/gldns/wire2str.c +++ b/src/gldns/wire2str.c @@ -166,6 +166,7 @@ static gldns_lookup_table gldns_edns_options_data[] = { { 7, "N3U" }, { 8, "edns-client-subnet" }, { 11, "edns-tcp-keepalive"}, + { 12, "Padding" }, { 0, NULL} }; gldns_lookup_table* gldns_edns_options = gldns_edns_options_data; @@ -1886,7 +1887,10 @@ int gldns_wire2str_edns_option_print(char** s, size_t* sl, break; case GLDNS_EDNS_KEEPALIVE: w += gldns_wire2str_edns_keepalive_print(s, sl, optdata, optlen); - break; + break; + case GLDNS_EDNS_PADDING: + w += print_hex_buf(s, sl, optdata, optlen); + break; default: /* unknown option code */ w += print_hex_buf(s, sl, optdata, optlen); From af706716412503707267b3fa8eacf2155fe15126 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 14 Jul 2016 13:46:12 +0200 Subject: [PATCH 05/25] =?UTF-8?q?parentheses=20around=20comparison=20in=20?= =?UTF-8?q?operand=20of=20=E2=80=98&=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/context.c b/src/context.c index b0c9a198..edea6aef 100644 --- a/src/context.c +++ b/src/context.c @@ -1297,7 +1297,7 @@ getdns_context_create_with_extended_memory_functions( /* Unbound needs SSL to be init'ed this early when TLS is used. However we * don't know that till later so we will have to do this every time. */ - if (set_from_os & 2 == 0) + if ((set_from_os & 2) == 0) SSL_library_init(); #ifdef HAVE_LIBUNBOUND From ea69d31dba214399ea386b3b5af31731bce72e3a Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 14 Jul 2016 13:54:58 +0200 Subject: [PATCH 06/25] move getdns_query to src/tools --- .gitignore | 2 +- Makefile.in | 11 +- configure.ac | 8 +- src/Makefile.in | 31 +- src/test/Makefile.in | 16 +- src/test/getdns_query.c | 1614 ----------------- src/test/tpkg/110-link.tpkg/110-link.test | 2 +- .../210-stub-only-link.test | 2 +- 8 files changed, 25 insertions(+), 1661 deletions(-) delete mode 100644 src/test/getdns_query.c diff --git a/.gitignore b/.gitignore index fce9d682..0f4482ef 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,9 @@ src/test/check_getdns src/test/check_getdns_event src/test/check_getdns_uv src/test/check_getdns_ev -src/test/getdns_query src/test/scratchpad src/test/scratchpad.c +src/tools/getdns_query doc/*.3 src/getdns/getdns.h *.log diff --git a/Makefile.in b/Makefile.in index 331c889e..8364c14e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -111,10 +111,10 @@ pad: scratchpad src/test/scratchpad || ./libtool exec gdb src/test/scratchpad install-getdns_query: - cd src/test && $(MAKE) install + cd src/tools && $(MAKE) install uninstall-getdns_query: - cd src/test && $(MAKE) uninstall + cd src/tools && $(MAKE) uninstall clean: cd src && $(MAKE) $@ @@ -182,6 +182,8 @@ $(distdir): mkdir -p $(distdir)/src/compat mkdir -p $(distdir)/src/util mkdir -p $(distdir)/src/gldns + mkdir -p $(distdir)/src/tools + mkdir -p $(distdir)/src/jsmn mkdir -p $(distdir)/doc mkdir -p $(distdir)/spec mkdir -p $(distdir)/spec/example @@ -224,6 +226,11 @@ $(distdir): cp $(srcdir)/spec/*.tgz $(distdir)/spec || true cp $(srcdir)/spec/example/Makefile.in $(distdir)/spec/example cp $(srcdir)/spec/example/*.[ch] $(distdir)/spec/example + cp $(srcdir)/src/tools/Makefile.in $(distdir)/src/tools + cp $(srcdir)/src/tools/*.[ch] $(distdir)/src/tools + cp $(srcdir)/src/jsmn/*.[ch] $(distdir)/src/jsmn + cp $(srcdir)/src/jsmn/LICENSE $(distdir)/src/jsmn + cp $(srcdir)/src/jsmn/README.md $(distdir)/src/jsmn rm -f $(distdir)/Makefile $(distdir)/src/Makefile $(distdir)/src/getdns/getdns.h $(distdir)/spec/example/Makefile $(distdir)/src/test/Makefile $(distdir)/doc/Makefile $(distdir)/src/config.h distcheck: $(distdir).tar.gz diff --git a/configure.ac b/configure.ac index 468178ce..2651ec1a 100644 --- a/configure.ac +++ b/configure.ac @@ -889,9 +889,9 @@ AC_DEFINE_UNQUOTED([TRUST_ANCHOR_FILE], ["$TRUST_ANCHOR_FILE"], [Default trust a AC_SUBST(TRUST_ANCHOR_FILE) AC_MSG_NOTICE([Default trust anchor: $TRUST_ANCHOR_FILE]) -AC_ARG_WITH(getdns_query, AS_HELP_STRING([--with-getdns_query], - [Also compile and install the getdns_query tool]), - [], [withval="no"]) +AC_ARG_WITH(getdns_query, AS_HELP_STRING([--without-getdns_query], + [Do not compile and install the getdns_query tool]), + [], [withval="yes"]) if test x_$withval = x_no; then GETDNS_QUERY="" INSTALL_GETDNS_QUERY="" @@ -917,7 +917,7 @@ AC_SUBST(GETDNS_QUERY) AC_SUBST(INSTALL_GETDNS_QUERY) AC_SUBST(UNINSTALL_GETDNS_QUERY) -AC_CONFIG_FILES([Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile doc/Makefile getdns.pc getdns_ext_event.pc]) +AC_CONFIG_FILES([Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile src/tools/Makefile doc/Makefile getdns.pc getdns_ext_event.pc]) if [ test -n "$DOXYGEN" ] then AC_CONFIG_FILES([src/Doxyfile]) fi diff --git a/src/Makefile.in b/src/Makefile.in index c9ff78db..212b7180 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -157,7 +157,7 @@ test: all cd test && $(MAKE) $@ getdns_query: all - cd test && $(MAKE) $@ + cd tools && $(MAKE) $@ scratchpad: all cd test && $(MAKE) $@ @@ -165,11 +165,13 @@ scratchpad: all pad: scratchpad clean: + cd tools && $(MAKE) $@ cd test && $(MAKE) $@ rm -f *.o *.lo extension/*.lo extension/*.o $(PROGRAMS) libgetdns.la libgetdns_ext_*.la rm -rf .libs extension/.libs distclean : clean + cd tools && $(MAKE) $@ cd test && $(MAKE) $@ rmdir test 2>/dev/null || true rm -f Makefile config.status config.log Doxyfile config.h version.c getdns/Makefile getdns/getdns.h getdns/getdns_extra.h @@ -177,35 +179,9 @@ distclean : clean rmdir extension 2>/dev/null || true rm -Rf autom4te.cache -$(distdir): FORCE - mkdir -p $(distdir)/src - cp configure.ac $(distdir) - cp configure $(distdir) - cp Makefile.in $(distdir) - cp src/Makefile.in $(distdir)/src - -distcheck: $(distdir).tar.gz - gzip -cd $(distdir).tar.gz | tar xvf - - cd $(distdir) && ./configure - cd $(distdir) && $(MAKE) all - cd $(distdir) && $(MAKE) check - cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install - cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall - @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \ - if test "$${remaining}" -ne 0; then - echo "@@@ $${remaining} file(s) remaining in stage directory!"; \ - exit 1; \ - fi - cd $(distdir) && $(MAKE) clean - rm -rf $(distdir) - @echo "*** Package $(distdir).tar.gz is ready for distribution" - Makefile: $(srcdir)/Makefile.in ../config.status cd .. && ./config.status src/Makefile -configure.status: configure - cd .. && ./config.status --recheck - depend: (cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new ) (blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I"$$blddir" *.c gldns/*.c compat/*.c util/*.c jsmn/*.c extension/*.c| \ @@ -225,6 +201,7 @@ depend: -e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in.new ) (cd $(srcdir) ; diff Makefile.in.new Makefile.in && rm Makefile.in.new \ || mv Makefile.in.new Makefile.in ) + cd tools && $(MAKE) $@ cd test && $(MAKE) $@ .PHONY: clean test diff --git a/src/test/Makefile.in b/src/test/Makefile.in index a33ec15f..83e9e9c6 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -67,13 +67,13 @@ CHECK_OBJS=check_getdns_common.lo check_getdns_context_set_timeout.lo \ check_getdns.lo check_getdns_transport.lo ALL_OBJS=$(CHECK_OBJS) check_getdns_libevent.lo check_getdns_libev.lo \ - check_getdns_selectloop.lo getdns_query.lo scratchpad.lo \ + check_getdns_selectloop.lo scratchpad.lo \ testmessages.lo tests_dict.lo tests_list.lo tests_namespaces.lo \ tests_stub_async.lo tests_stub_sync.lo NON_C99_OBJS=check_getdns_libuv.lo -PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync getdns_query $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) +PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) .SUFFIXES: .c .o .a .lo .h @@ -124,9 +124,6 @@ check_getdns_uv: check_getdns.lo check_getdns_common.lo check_getdns_context_set check_getdns_ev: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo ../libgetdns_ext_ev.la $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -getdns_query: getdns_query.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(LDFLAGS) $(LDLIBS) - scratchpad: scratchpad.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS) @@ -135,12 +132,11 @@ scratchpad.lo: scratchpad.c $(srcdir)/scratchpad.c: scratchpad.template.c [ ! -f $(srcdir)/scratchpad.c ] && cp -p $(srcdir)/scratchpad.template.c $(srcdir)/scratchpad.c || true -install: getdns_query - $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) - $(LIBTOOL) --mode=install cp getdns_query $(DESTDIR)$(bindir) +install: + echo nothing to install uninstall: - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/getdns_query + echo nothing to uninstall nolibcheck: @echo "***" @@ -263,8 +259,6 @@ check_getdns_selectloop.lo check_getdns_selectloop.o: $(srcdir)/check_getdns_sel check_getdns_transport.lo check_getdns_transport.o: $(srcdir)/check_getdns_transport.c \ $(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h ../getdns/getdns.h \ ../getdns/getdns_extra.h -getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c ../config.h $(srcdir)/../debug.h ../config.h \ - ../getdns/getdns.h ../getdns/getdns_extra.h scratchpad.template.lo scratchpad.template.o: scratchpad.template.c ../getdns/getdns.h \ ../getdns/getdns_extra.h testmessages.lo testmessages.o: $(srcdir)/testmessages.c $(srcdir)/testmessages.h diff --git a/src/test/getdns_query.c b/src/test/getdns_query.c deleted file mode 100644 index 81ebd79d..00000000 --- a/src/test/getdns_query.c +++ /dev/null @@ -1,1614 +0,0 @@ -/* - * Copyright (c) 2013, NLNet Labs, Verisign, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of the copyright holders nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "debug.h" -#include -#include -#include -#include -#include -#include -#include -#ifndef USE_WINSOCK -#include -#include -#include -#else -#include -#include -typedef unsigned short in_port_t; -#include -#include -#endif - -#define EXAMPLE_PIN "pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\"" - -static int quiet = 0; -static int batch_mode = 0; -static char *query_file = NULL; -static int json = 0; -static char *the_root = "."; -static char *name; -static getdns_context *context; -static getdns_dict *extensions; -static getdns_dict *query_extensions_spc = NULL; -static getdns_list *pubkey_pinset = NULL; -static getdns_list *listen_list = NULL; -int touched_listen_list; -static getdns_dict *listen_dict = NULL; -static size_t pincount = 0; -static size_t listen_count = 0; -static uint16_t request_type = GETDNS_RRTYPE_NS; -static int timeout, edns0_size, padding_blocksize; -static int async = 0, interactive = 0; -static enum { GENERAL, ADDRESS, HOSTNAME, SERVICE } calltype = GENERAL; - -static int get_rrtype(const char *t) -{ - char buf[1024] = "GETDNS_RRTYPE_"; - uint32_t rrtype; - long int l; - size_t i; - char *endptr; - - if (strlen(t) > sizeof(buf) - 15) - return -1; - for (i = 14; *t && i < sizeof(buf) - 1; i++, t++) - buf[i] = toupper(*t); - buf[i] = '\0'; - - if (!getdns_str2int(buf, &rrtype)) - return (int)rrtype; - - if (strncasecmp(buf + 14, "TYPE", 4) == 0) { - l = strtol(buf + 18, &endptr, 10); - if (!*endptr && l >= 0 && l < 65536) - return l; - } - return -1; -} - -static int get_rrclass(const char *t) -{ - char buf[1024] = "GETDNS_RRCLASS_"; - uint32_t rrclass; - long int l; - size_t i; - char *endptr; - - if (strlen(t) > sizeof(buf) - 16) - return -1; - for (i = 15; *t && i < sizeof(buf) - 1; i++, t++) - buf[i] = toupper(*t); - buf[i] = '\0'; - - if (!getdns_str2int(buf, &rrclass)) - return (int)rrclass; - - if (strncasecmp(buf + 15, "CLASS", 5) == 0) { - l = strtol(buf + 20, &endptr, 10); - if (!*endptr && l >= 0 && l < 65536) - return l; - } - return -1; -} - -static getdns_return_t -fill_transport_list(getdns_context *context, char *transport_list_str, - getdns_transport_list_t *transports, size_t *transport_count) -{ - size_t max_transports = *transport_count; - *transport_count = 0; - for ( size_t i = 0 - ; i < max_transports && i < strlen(transport_list_str) - ; i++, (*transport_count)++) { - switch(*(transport_list_str + i)) { - case 'U': - transports[i] = GETDNS_TRANSPORT_UDP; - break; - case 'T': - transports[i] = GETDNS_TRANSPORT_TCP; - break; - case 'L': - transports[i] = GETDNS_TRANSPORT_TLS; - break; - default: - fprintf(stderr, "Unrecognised transport '%c' in string %s\n", - *(transport_list_str + i), transport_list_str); - return GETDNS_RETURN_GENERIC_ERROR; - } - } - return GETDNS_RETURN_GOOD; -} - -void -print_usage(FILE *out, const char *progname) -{ - fprintf(out, "usage: %s [