From: Aki Tuomi Date: Thu, 28 Dec 2017 09:30:00 +0000 (+0200) Subject: lib-http: test-http-client - Make DNS client optional X-Git-Tag: 2.3.9~2589 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=488a0d56bfee4e051e0241c8d085424a2268beb0;p=thirdparty%2Fdovecot%2Fcore.git lib-http: test-http-client - Make DNS client optional Only use DNS client if present. Allows running the test-http-client standalone. --- diff --git a/src/lib-http/test-http-client.c b/src/lib-http/test-http-client.c index 2d3fdca819..1a8048cd09 100644 --- a/src/lib-http/test-http-client.c +++ b/src/lib-http/test-http-client.c @@ -13,6 +13,9 @@ #include "iostream-openssl.h" #endif +#include +#include + struct http_test_request { struct io *io; struct istream *payload; @@ -364,11 +367,16 @@ int main(int argc, char *argv[]) dns_set.dns_client_socket_path = "/var/run/dovecot/dns-client"; dns_set.timeout_msecs = 30*1000; dns_set.idle_timeout_msecs = UINT_MAX; - dns_client = dns_client_init(&dns_set); - if (dns_client_connect(dns_client, &error) < 0) - i_fatal("Couldn't initialize DNS client: %s", error); + /* check if there is a DNS client */ + if (access("/var/run/dovecot/dns-client", R_OK|W_OK) == 0) { + dns_client = dns_client_init(&dns_set); + if (dns_client_connect(dns_client, &error) < 0) + i_fatal("Couldn't initialize DNS client: %s", error); + } else { + dns_client = NULL; + } i_zero(&ssl_set); ssl_set.allow_invalid_cert = TRUE; ssl_set.ca_dir = "/etc/ssl/certs"; /* debian */ @@ -443,7 +451,8 @@ int main(int argc, char *argv[]) http_client_context_unref(&http_cctx); - dns_client_deinit(&dns_client); + if (dns_client != NULL) + dns_client_deinit(&dns_client); io_loop_destroy(&ioloop); #ifdef HAVE_OPENSSL