The branch, master has been updated via af6bd05 rwrap: Update resolve_wrapper to version 1.1.4 from 3b5e3ef lib: tevent: Use struct sockaddr_storage to cope with IPv6.
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit af6bd055d463750625035a397b7d961e0503b620 Author: Andreas Schneider <a...@samba.org> Date: Tue May 31 08:36:01 2016 +0200 rwrap: Update resolve_wrapper to version 1.1.4 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Tue May 31 20:13:43 CEST 2016 on sn-devel-144 ----------------------------------------------------------------------- Summary of changes: lib/resolv_wrapper/resolv_wrapper.c | 75 ++++++++++++++++++++++++++++++++++--- lib/resolv_wrapper/wscript | 2 +- 2 files changed, 70 insertions(+), 7 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/resolv_wrapper/resolv_wrapper.c b/lib/resolv_wrapper/resolv_wrapper.c index d36d080..48018be 100644 --- a/lib/resolv_wrapper/resolv_wrapper.c +++ b/lib/resolv_wrapper/resolv_wrapper.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2014 Andreas Schneider <a...@samba.org> - * Copyright (c) 2014 Jakub Hrozek <jakub.hro...@gmail.com> + * Copyright (c) 2014 Jakub Hrozek <jakub.hro...@posteo.se> * * All rights reserved. * @@ -36,7 +36,11 @@ #include <errno.h> #include <arpa/inet.h> +#ifdef HAVE_ARPA_NAMESER_H +#include <arpa/nameser.h> +#endif /* HAVE_ARPA_NAMESER_H */ #include <netinet/in.h> +#include <sys/socket.h> #include <sys/types.h> #include <stdarg.h> #include <stdlib.h> @@ -227,6 +231,15 @@ static int rwrap_create_fake_aaaa_rr(const char *key, rr->type = ns_t_aaaa; return 0; } +static int rwrap_create_fake_ns_rr(const char *key, + const char *value, + struct rwrap_fake_rr *rr) +{ + memcpy(rr->rrdata.srv_rec.hostname, value, strlen(value) + 1); + memcpy(rr->key, key, strlen(key) + 1); + rr->type = ns_t_ns; + return 0; +} static int rwrap_create_fake_srv_rr(const char *key, const char *value, @@ -340,7 +353,7 @@ static ssize_t rwrap_fake_header(uint8_t **header_blob, size_t remaining, h->id = res_randomid(); /* random query ID */ h->qr = 1; /* response flag */ h->rd = 1; /* recursion desired */ - h->ra = 1; /* resursion available */ + h->ra = 1; /* recursion available */ h->qdcount = htons(1); /* no. of questions */ h->ancount = htons(ancount); /* no. of answers */ @@ -469,6 +482,47 @@ static ssize_t rwrap_fake_aaaa(struct rwrap_fake_rr *rr, return resp_size; } +static ssize_t rwrap_fake_ns(struct rwrap_fake_rr *rr, + uint8_t *answer, + size_t anslen) +{ + uint8_t *a = answer; + ssize_t resp_size = 0; + size_t rdata_size; + unsigned char hostname_compressed[MAXDNAME]; + ssize_t compressed_len; + + if (rr == NULL || rr->type != ns_t_ns) { + RWRAP_LOG(RWRAP_LOG_ERROR, + "Malformed record, no or wrong value!\n"); + return -1; + } + RWRAP_LOG(RWRAP_LOG_TRACE, "Adding NS RR"); + + /* Prepare the data to write */ + compressed_len = ns_name_compress(rr->rrdata.srv_rec.hostname, + hostname_compressed, + MAXDNAME, + NULL, + NULL); + if (compressed_len < 0) { + return -1; + } + + /* Is this enough? */ + rdata_size = compressed_len; + + resp_size = rwrap_fake_rdata_common(ns_t_ns, rdata_size, + rr->key, anslen, &a); + if (resp_size < 0) { + return -1; + } + + memcpy(a, hostname_compressed, compressed_len); + + return resp_size; +} + static ssize_t rwrap_fake_srv(struct rwrap_fake_rr *rr, uint8_t *answer, size_t anslen) @@ -662,7 +716,8 @@ static int rwrap_get_record(const char *hostfile, unsigned recursion, } RWRAP_LOG(RWRAP_LOG_TRACE, - "Searching in fake hosts file %s\n", hostfile); + "Searching in fake hosts file %s for %s:%d\n", hostfile, + query, type); fp = fopen(hostfile, "r"); if (fp == NULL) { @@ -702,6 +757,10 @@ static int rwrap_get_record(const char *hostfile, unsigned recursion, rec_type, "AAAA", key, query)) { rc = rwrap_create_fake_aaaa_rr(key, value, rr); break; + } else if (TYPE_MATCH(type, ns_t_ns, + rec_type, "NS", key, query)) { + rc = rwrap_create_fake_ns_rr(key, value, rr); + break; } else if (TYPE_MATCH(type, ns_t_srv, rec_type, "SRV", key, query)) { rc = rwrap_create_fake_srv_rr(key, value, rr); @@ -776,6 +835,7 @@ static inline bool rwrap_known_type(int type) switch (type) { case ns_t_a: case ns_t_aaaa: + case ns_t_ns: case ns_t_srv: case ns_t_soa: case ns_t_cname: @@ -835,6 +895,9 @@ static ssize_t rwrap_add_rr(struct rwrap_fake_rr *rr, case ns_t_aaaa: resp_data = rwrap_fake_aaaa(rr, answer, anslen); break; + case ns_t_ns: + resp_data = rwrap_fake_ns(rr, answer, anslen); + break; case ns_t_srv: resp_data = rwrap_fake_srv(rr, answer, anslen); break; @@ -911,7 +974,7 @@ static ssize_t rwrap_fake_answer(struct rwrap_fake_rr *rrs, /* Reads in a file in the following format: * TYPE RDATA * - * Malformed entried are silently skipped. + * Malformed entries are silently skipped. * Allocates answer buffer of size anslen that has to be freed after use. */ static int rwrap_res_fake_hosts(const char *hostfile, @@ -1421,8 +1484,8 @@ static int rwrap_res_ninit(struct __res_state *state) state->nscount = 0; memset(state->nsaddr_list, 0, sizeof(state->nsaddr_list)); - state->_u._ext.nscount = 0; #ifdef HAVE_RESOLV_IPV6_NSADDRS + state->_u._ext.nscount = 0; for (i = 0; i < state->_u._ext.nscount; i++) { SAFE_FREE(state->_u._ext.nsaddrs[i]); } @@ -1690,7 +1753,7 @@ int __res_nsearch(struct __res_state *state, } /**************************************************************************** - * RES_QUERY + * RES_SEARCH ***************************************************************************/ static int rwrap_res_search(const char *dname, diff --git a/lib/resolv_wrapper/wscript b/lib/resolv_wrapper/wscript index 34c00d2..5596ec9 100644 --- a/lib/resolv_wrapper/wscript +++ b/lib/resolv_wrapper/wscript @@ -2,7 +2,7 @@ import os -VERSION="1.1.3" +VERSION="1.1.4" def configure(conf): if conf.CHECK_BUNDLED_SYSTEM('resolv_wrapper', minversion=VERSION, set_target=False): -- Samba Shared Repository