[SCM] Resolv Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Nov 27 09:50:35 MST 2014


The branch, master has been updated
       via  9d4dbed tests: Query A record via CNAME
       via  05e3046 rwrap: Support asking for A via CNAME
       via  c12b456 tests: test that CNAME and SRV records can recurse
       via  c3f3bfb rwrap: Recursively add additional data
       via  9578af3 rwrap: Make the rwrap_fake_* functions only fake RRs
       via  00274ff rwrap: CNAME record can recurse into A, AAAA or CNAME
       via  94c3456 rwrap: SRV record can recurse into A or AAAA
       via  dfb2f02 rwrap: Use the rwrap_fake_rr structure instead of raw uint8_t pointers
       via  1935ee8 Add data structures and functions to represent and manipulate RRs
       via  80151f6 tests: Add a test which talks to real nameservers.
       via  ba10259 rwrap: Correctly calculate the response size and return it.
       via  e88e4a5 rwrap: Handle trailing dot in dns names.
       via  2388096 rwrap: Compare dns names case insensitive.
       via  049962a torture: Increase time to wait for pid file.
      from  7f4d7eb cmake: Do not remove libresolv from required libraries.

https://git.samba.org/?p=resolv_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9d4dbed5eafdd4624a787c4e33ce3cd2610aed90
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Tue Nov 25 18:34:45 2014 +0100

    tests: Query A record via CNAME
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 05e3046112e84f71ea4ca56261de17c57123931d
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Tue Nov 25 18:34:28 2014 +0100

    rwrap: Support asking for A via CNAME
    
    Adds support for querying for an A record using a name that only expands
    into a CNAME.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit c12b4566a4ddcba8dd5f3f1369f1800130577f15
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Tue Nov 25 18:33:29 2014 +0100

    tests: test that CNAME and SRV records can recurse
    
    Add tests for recursing into a CNAME record.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit c3f3bfb7c91949f3ea5b41393d9afa9f168b82f4
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Tue Nov 25 18:33:21 2014 +0100

    rwrap: Recursively add additional data
    
    Change how we construct the fake answer such that the header and
    question are added first, then the answers and finally additional data.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 9578af3406df2f03f637fb55b47b4cbd8f7fb577
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Tue Nov 18 11:33:42 2014 +0100

    rwrap: Make the rwrap_fake_* functions only fake RRs
    
    The rwrap_fake_common() function did too much. Remove it and use
    separate functions to add fake header and question sections. The
    rwrap_fake_$RR functions will receive packet including the header and
    question and only add its RR data.
    
    This will allow recursive processing later.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 00274ffd8e29b42f202ebf7c1e1bce6cd34d9b0f
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Sun Nov 23 17:40:57 2014 +0100

    rwrap: CNAME record can recurse into A, AAAA or CNAME
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 94c3456970a0f0b851d1c5a99183697a2072790a
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Sun Nov 23 17:40:32 2014 +0100

    rwrap: SRV record can recurse into A or AAAA
    
    When querying for a SRV record, we'll need to include A or AAAA records
    in additional section. Therefore, keep querying the host file until we
    can either recurse the A/AAAA records or reach the recursion limit
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit dfb2f02f4134560292ee02dd0f0b3471a5876263
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Sun Nov 23 16:57:32 2014 +0100

    rwrap: Use the rwrap_fake_rr structure instead of raw uint8_t pointers
    
    Currently only one instance of the rwrap_fake_rr structure is used. Recursion
    will be implemented in a future patch.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 1935ee8184adb0c04bc11374d057421ae2c6b574
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Sun Nov 23 16:47:55 2014 +0100

    Add data structures and functions to represent and manipulate RRs
    
    Adds a structure that, using unions represents all supported RRs. Add a
    bunch of utility functions that can be used to create these structures.
    
    Currently the functions are unused.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 80151f6faa9c5caac8f23c9826e90eaac7003037
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Nov 5 13:48:49 2014 +0100

    tests: Add a test which talks to real nameservers.
    
    This is to inspect the answer buffer and be able to compare it.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit ba10259bba5f248cd4906b1b775eb42bce75c7ea
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Nov 4 17:14:22 2014 +0100

    rwrap: Correctly calculate the response size and return it.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit e88e4a55b2723aee7bd07f4182486eb4abee024d
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Nov 4 15:20:11 2014 +0100

    rwrap: Handle trailing dot in dns names.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 2388096ae7c0c7924a44cca94290ed7da06498d0
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Tue Nov 4 15:00:17 2014 +0100

    rwrap: Compare dns names case insensitive.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

commit 049962a9a4e735a46b555842a4cf6b3e721d05cb
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Nov 4 16:25:02 2014 +0100

    torture: Increase time to wait for pid file.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 src/resolv_wrapper.c        | 760 ++++++++++++++++++++++++++++++++------------
 tests/CMakeLists.txt        |   3 +
 tests/fake_hosts.in         |   5 +-
 tests/test_dns_fake.c       | 197 +++++++++++-
 tests/test_real_res_query.c | 196 ++++++++++++
 tests/torture.c             |   4 +-
 6 files changed, 940 insertions(+), 225 deletions(-)
 create mode 100644 tests/test_real_res_query.c


Changeset truncated at 500 lines:

diff --git a/src/resolv_wrapper.c b/src/resolv_wrapper.c
index 35f426d..a0b2821 100644
--- a/src/resolv_wrapper.c
+++ b/src/resolv_wrapper.c
@@ -141,17 +141,188 @@ static void rwrap_log(enum rwrap_dbglvl_e dbglvl,
 	}							\
 } while(0);
 
+#define RWRAP_MAX_RECURSION 5
+
+/* Priority and weight can be omitted from the hosts file, but need to be part
+ * of the output
+ */
+#define DFL_SRV_PRIO	1
+#define DFL_SRV_WEIGHT	100
+
+struct rwrap_srv_rrdata {
+	uint16_t port;
+	uint16_t prio;
+	uint16_t weight;
+	char hostname[MAXDNAME];
+};
+
+struct rwrap_soa_rrdata {
+	uint32_t serial;
+	uint32_t refresh;
+	uint32_t retry;
+	uint32_t expire;
+	uint32_t minimum;
+	char nameserver[MAXDNAME];
+	char mailbox[MAXDNAME];
+};
+
+struct rwrap_fake_rr {
+	union fake_rrdata {
+		struct in_addr a_rec;
+		struct in6_addr aaaa_rec;
+		struct rwrap_srv_rrdata srv_rec;
+		struct rwrap_soa_rrdata soa_rec;
+		char cname_rec[MAXDNAME];
+	} rrdata;
+
+	char key[MAXDNAME];
+	int type; /* ns_t_* */
+};
+
+static void rwrap_fake_rr_init(struct rwrap_fake_rr *rr, size_t len)
+{
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		rr[i].type = ns_t_invalid;
+	}
+}
+
+static int rwrap_create_fake_a_rr(const char *key,
+				  const char *value,
+				  struct rwrap_fake_rr *rr)
+{
+	int ok;
+
+	ok = inet_pton(AF_INET, value, &rr->rrdata.a_rec);
+	if (!ok) {
+		RWRAP_LOG(RWRAP_LOG_ERROR,
+			  "Failed to convert [%s] to binary\n", value);
+		return -1;
+	}
+
+	memcpy(rr->key, key, strlen(key) + 1);
+	rr->type = ns_t_a;
+	return 0;
+}
+
+static int rwrap_create_fake_aaaa_rr(const char *key,
+				     const char *value,
+				     struct rwrap_fake_rr *rr)
+{
+	int ok;
+
+	ok = inet_pton(AF_INET6, value, &rr->rrdata.aaaa_rec);
+	if (!ok) {
+		RWRAP_LOG(RWRAP_LOG_ERROR,
+			  "Failed to convert [%s] to binary\n", value);
+		return -1;
+	}
+
+	memcpy(rr->key, key, strlen(key) + 1);
+	rr->type = ns_t_aaaa;
+	return 0;
+}
+
+static int rwrap_create_fake_srv_rr(const char *key,
+				    const char *value,
+				    struct rwrap_fake_rr *rr)
+{
+	char *str_prio;
+	char *str_weight;
+	char *str_port;
+	const char *hostname;
+
+	/* parse the value into priority, weight, port and hostname
+	 * and check the validity */
+	hostname = value;
+	NEXT_KEY(hostname, str_port);
+	NEXT_KEY(str_port, str_prio);
+	NEXT_KEY(str_prio, str_weight);
+	if (str_port == NULL || hostname == NULL) {
+		RWRAP_LOG(RWRAP_LOG_ERROR,
+			  "Malformed SRV entry [%s]\n", value);
+		return -1;
+	}
+
+	if (str_prio) {
+		rr->rrdata.srv_rec.prio = atoi(str_prio);
+	} else {
+		rr->rrdata.srv_rec.prio = DFL_SRV_PRIO;
+	}
+	if (str_weight) {
+		rr->rrdata.srv_rec.weight = atoi(str_weight);
+	} else {
+		rr->rrdata.srv_rec.weight = DFL_SRV_WEIGHT;
+	}
+	rr->rrdata.srv_rec.port = atoi(str_port);
+	memcpy(rr->rrdata.srv_rec.hostname , hostname, strlen(hostname) + 1);
+
+	memcpy(rr->key, key, strlen(key) + 1);
+	rr->type = ns_t_srv;
+	return 0;
+}
+
+static int rwrap_create_fake_soa_rr(const char *key,
+				    const char *value,
+				    struct rwrap_fake_rr *rr)
+{
+	const char *nameserver;
+	char *mailbox;
+	char *str_serial;
+	char *str_refresh;
+	char *str_retry;
+	char *str_expire;
+	char *str_minimum;
+
+	/* parse the value into nameserver, mailbox, serial, refresh,
+	 * retry, expire, minimum and check the validity
+	 */
+	nameserver = value;
+	NEXT_KEY(nameserver, mailbox);
+	NEXT_KEY(mailbox, str_serial);
+	NEXT_KEY(str_serial, str_refresh);
+	NEXT_KEY(str_refresh, str_retry);
+	NEXT_KEY(str_retry, str_expire);
+	NEXT_KEY(str_expire, str_minimum);
+	if (nameserver == NULL || mailbox == NULL || str_serial == NULL ||
+	    str_refresh == NULL || str_retry == NULL || str_expire == NULL ||
+	    str_minimum == NULL) {
+		RWRAP_LOG(RWRAP_LOG_ERROR,
+			  "Malformed SOA entry [%s]\n", value);
+		return -1;
+	}
+
+	memcpy(rr->rrdata.soa_rec.nameserver, nameserver, strlen(nameserver)+1);
+	memcpy(rr->rrdata.soa_rec.mailbox, mailbox, strlen(mailbox)+1);
+
+	rr->rrdata.soa_rec.serial = atoi(str_serial);
+	rr->rrdata.soa_rec.refresh = atoi(str_refresh);
+	rr->rrdata.soa_rec.retry = atoi(str_retry);
+	rr->rrdata.soa_rec.expire = atoi(str_expire);
+	rr->rrdata.soa_rec.minimum = atoi(str_minimum);
+
+	memcpy(rr->key, key, strlen(key) + 1);
+	rr->type = ns_t_soa;
+	return 0;
+}
+
+static int rwrap_create_fake_cname_rr(const char *key,
+				      const char *value,
+				      struct rwrap_fake_rr *rr)
+{
+	memcpy(rr->rrdata.cname_rec , value, strlen(value) + 1);
+	memcpy(rr->key, key, strlen(key) + 1);
+	rr->type = ns_t_cname;
+	return 0;
+}
 
 /* Prepares a fake header with a single response. Advances header_blob */
 static ssize_t rwrap_fake_header(uint8_t **header_blob, size_t remaining,
-				 size_t rdata_size)
+			         size_t ancount, size_t arcount)
 {
 	uint8_t *hb;
 	HEADER *h;
-	int answers;
-
-	/* If rdata_size is zero, the answer is empty */
-	answers = rdata_size > 0 ? 1 : 0;
 
 	if (remaining < NS_HFIXEDSZ) {
 		RWRAP_LOG(RWRAP_LOG_ERROR, "Buffer too small!\n");
@@ -168,7 +339,8 @@ static ssize_t rwrap_fake_header(uint8_t **header_blob, size_t remaining,
 	h->ra = 1;			/* resursion available */
 
 	h->qdcount = htons(1);		/* no. of questions */
-	h->ancount = htons(answers);	/* no. of answers */
+	h->ancount = htons(ancount);	/* no. of answers */
+	h->arcount = htons(arcount);	/* no. of add'tl records */
 
 	hb += NS_HFIXEDSZ;		/* move past the header */
 	*header_blob = hb;
@@ -240,147 +412,79 @@ static ssize_t rwrap_fake_rdata_common(uint16_t type,
 	}
 
 	*rdata_ptr = rd;
-	return written + 3 * sizeof(uint16_t) + sizeof(uint32_t);
-}
-
-static ssize_t rwrap_fake_common(uint16_t type,
-				 const char *question,
-				 size_t rdata_size,
-				 uint8_t **answer_ptr,
-				 size_t anslen)
-{
-	uint8_t *a = *answer_ptr;
-	ssize_t written;
-	size_t remaining;
-
-	remaining = anslen;
-
-	written = rwrap_fake_header(&a, remaining, rdata_size);
-	if (written < 0) {
-		return -1;
-	}
-	remaining -= written;
-
-	written = rwrap_fake_question(question, type, &a, remaining);
-	if (written < 0) {
-		return -1;
-	}
-	remaining -= written;
-
-	/* rdata_size = 0 denotes an empty answer */
-	if (rdata_size > 0) {
-		written = rwrap_fake_rdata_common(type, rdata_size, question,
-						remaining, &a);
-		if (written < 0) {
-			return -1;
-		}
-	}
-
-	*answer_ptr = a;
-	return written;
+	return written + 3 * sizeof(uint16_t) + sizeof(uint32_t) + rdata_size;
 }
 
-static int rwrap_fake_a(const char *key,
-			const char *value,
-			uint8_t *answer_ptr,
-			size_t anslen)
+static ssize_t rwrap_fake_a(struct rwrap_fake_rr *rr,
+			    uint8_t *answer_ptr,
+			    size_t anslen)
 {
 	uint8_t *a = answer_ptr;
-	struct in_addr a_rec;
-	int rc;
-	int ok;
+	ssize_t resp_size;
 
-	if (value == NULL) {
-		RWRAP_LOG(RWRAP_LOG_ERROR, "Malformed record, no value!\n");
+	if (rr == NULL || rr->type != ns_t_a) {
+		RWRAP_LOG(RWRAP_LOG_ERROR,
+			  "Malformed record, no or wrong value!\n");
 		return -1;
 	}
+	RWRAP_LOG(RWRAP_LOG_TRACE, "Adding A RR");
 
-	rc = rwrap_fake_common(ns_t_a, key, sizeof(a_rec), &a, anslen);
-	if (rc < 0) {
+	resp_size = rwrap_fake_rdata_common(ns_t_a, sizeof(struct in_addr), rr->key,
+					    anslen, &a);
+	if (resp_size < 0) {
 		return -1;
 	}
 
-	ok = inet_pton(AF_INET, value, &a_rec);
-	if (!ok) {
-		RWRAP_LOG(RWRAP_LOG_ERROR,
-			  "Failed to convert [%s] to binary\n", value);
-		return -1;
-	}
-	memcpy(a, &a_rec, sizeof(struct in_addr));
+	memcpy(a, &rr->rrdata.a_rec, sizeof(struct in_addr));
 
-	return 0;
+	return resp_size;
 }
 
-static int rwrap_fake_aaaa(const char *key,
-			   const char *value,
-			   uint8_t *answer,
-			   size_t anslen)
+static ssize_t rwrap_fake_aaaa(struct rwrap_fake_rr *rr,
+			       uint8_t *answer,
+			       size_t anslen)
 {
 	uint8_t *a = answer;
-	struct in6_addr aaaa_rec;
-	int rc;
-	int ok;
+	ssize_t resp_size;
 
-	if (value == NULL) {
-		RWRAP_LOG(RWRAP_LOG_ERROR, "Malformed record, no value!\n");
+	if (rr == NULL || rr->type != ns_t_aaaa) {
+		RWRAP_LOG(RWRAP_LOG_ERROR,
+			  "Malformed record, no or wrong value!\n");
 		return -1;
 	}
+	RWRAP_LOG(RWRAP_LOG_TRACE, "Adding AAAA RR");
 
-	rc = rwrap_fake_common(ns_t_aaaa, key, sizeof(aaaa_rec), &a, anslen);
-	if (rc < 0) {
+	resp_size = rwrap_fake_rdata_common(ns_t_aaaa, sizeof(struct in6_addr),
+					    rr->key, anslen, &a);
+	if (resp_size < 0) {
 		return -1;
 	}
 
-	ok = inet_pton(AF_INET6, value, &aaaa_rec);
-	if (!ok) {
-		RWRAP_LOG(RWRAP_LOG_ERROR,
-			  "Failed to convert [%s] to binary\n", value);
-		return -1;
-	}
-	memcpy(a, &aaaa_rec, sizeof(struct in6_addr));
+	memcpy(a, &rr->rrdata.aaaa_rec, sizeof(struct in6_addr));
 
-	return 0;
+	return resp_size;
 }
 
-/*
- * Priority and weight can be omitted from the hosts file, but need to be part
- * of the output
- */
-#define DFL_SRV_PRIO	1
-#define DFL_SRV_WEIGHT	100
-
-static int rwrap_fake_srv(const char *key,
-			  const char *value,
-			  uint8_t *answer,
-			  size_t anslen)
+static ssize_t rwrap_fake_srv(struct rwrap_fake_rr *rr,
+			      uint8_t *answer,
+			      size_t anslen)
 {
 	uint8_t *a = answer;
-	int rv;
+	ssize_t resp_size;
 	size_t rdata_size;
-	char *str_prio;
-	char *str_weight;
-	char *str_port;
-	const char *hostname;
 	unsigned char hostname_compressed[MAXDNAME];
 	ssize_t compressed_len;
 
-	/*
-	 * Parse the value into priority, weight, port and hostname
-	 * and check the validity.
-	 */
-	hostname = value;
-	NEXT_KEY(hostname, str_port);
-	NEXT_KEY(str_port, str_prio);
-	NEXT_KEY(str_prio, str_weight);
-	if (str_port == NULL || hostname == NULL) {
+	if (rr == NULL || rr->type != ns_t_srv) {
 		RWRAP_LOG(RWRAP_LOG_ERROR,
-			  "Malformed SRV entry [%s]\n", value);
+			  "Malformed record, no or wrong value!\n");
 		return -1;
 	}
+	RWRAP_LOG(RWRAP_LOG_TRACE, "Adding SRV RR");
 	rdata_size = 3 * sizeof(uint16_t);
 
 	/* Prepare the data to write */
-	compressed_len = ns_name_compress(hostname,
+	compressed_len = ns_name_compress(rr->rrdata.srv_rec.hostname,
 					  hostname_compressed, MAXDNAME,
 					  NULL, NULL);
 	if (compressed_len < 0) {
@@ -388,84 +492,59 @@ static int rwrap_fake_srv(const char *key,
 	}
 	rdata_size += compressed_len;
 
-	rv = rwrap_fake_common(ns_t_srv, key, rdata_size, &a, anslen);
-	if (rv < 0) {
+	resp_size = rwrap_fake_rdata_common(ns_t_srv, rdata_size,
+					    rr->key, anslen, &a);
+	if (resp_size < 0) {
 		return -1;
 	}
 
-	if (str_prio) {
-		NS_PUT16(atoi(str_prio), a);
-	} else {
-		NS_PUT16(DFL_SRV_PRIO, a);
-	}
-	if (str_weight) {
-		NS_PUT16(atoi(str_weight), a);
-	} else {
-		NS_PUT16(DFL_SRV_WEIGHT, a);
-	}
-	NS_PUT16(atoi(str_port), a);
+	NS_PUT16(rr->rrdata.srv_rec.prio, a);
+	NS_PUT16(rr->rrdata.srv_rec.weight, a);
+	NS_PUT16(rr->rrdata.srv_rec.port, a);
 	memcpy(a, hostname_compressed, compressed_len);
 
-	return 0;
+	return resp_size;
 }
 
-static int rwrap_fake_soa(const char *key,
-			  const char *value,
-			  uint8_t *answer,
-			  size_t anslen)
+static ssize_t rwrap_fake_soa(struct rwrap_fake_rr *rr,
+			      uint8_t *answer,
+			      size_t anslen)
 {
 	uint8_t *a = answer;
-	int rv;
-	const char *nameserver;
-	char *mailbox;
-	char *str_serial;
-	char *str_refresh;
-	char *str_retry;
-	char *str_expire;
-	char *str_minimum;
+	ssize_t resp_size;
 	size_t rdata_size;
 	unsigned char nameser_compressed[MAXDNAME];
 	ssize_t compressed_ns_len;
 	unsigned char mailbox_compressed[MAXDNAME];
 	ssize_t compressed_mb_len;
 
-	/*
-	 * parse the value into nameserver, mailbox, serial, refresh,
-	 * retry, expire, minimum and check the validity
-	 */
-	nameserver = value;
-	NEXT_KEY(nameserver, mailbox);
-	NEXT_KEY(mailbox, str_serial);
-	NEXT_KEY(str_serial, str_refresh);
-	NEXT_KEY(str_refresh, str_retry);
-	NEXT_KEY(str_retry, str_expire);
-	NEXT_KEY(str_expire, str_minimum);
-	if (nameserver == NULL || mailbox == NULL || str_serial == NULL ||
-	    str_refresh == NULL || str_retry == NULL || str_expire == NULL ||
-	    str_minimum == NULL)
-	{
+	if (rr == NULL || rr->type != ns_t_soa) {
 		RWRAP_LOG(RWRAP_LOG_ERROR,
-			  "Malformed SOA entry [%s]\n", value);
+			  "Malformed record, no or wrong value!\n");
 		return -1;
 	}
+	RWRAP_LOG(RWRAP_LOG_TRACE, "Adding SOA RR");
 	rdata_size = 5 * sizeof(uint16_t);
 
-	compressed_ns_len = ns_name_compress(nameserver, nameser_compressed,
+	compressed_ns_len = ns_name_compress(rr->rrdata.soa_rec.nameserver,
+					     nameser_compressed,
 					     MAXDNAME, NULL, NULL);
 	if (compressed_ns_len < 0) {
 		return -1;
 	}
 	rdata_size += compressed_ns_len;
 
-	compressed_mb_len = ns_name_compress(mailbox, mailbox_compressed,
+	compressed_mb_len = ns_name_compress(rr->rrdata.soa_rec.mailbox,
+					     mailbox_compressed,
 					     MAXDNAME, NULL, NULL);
 	if (compressed_mb_len < 0) {
 		return -1;
 	}
 	rdata_size += compressed_mb_len;
 
-	rv = rwrap_fake_common(ns_t_soa, key, rdata_size, &a, anslen);
-	if (rv < 0) {
+	resp_size = rwrap_fake_rdata_common(ns_t_soa, rdata_size,
+					    rr->key, anslen, &a);
+	if (resp_size < 0) {
 		return -1;
 	}
 
@@ -473,61 +552,48 @@ static int rwrap_fake_soa(const char *key,
 	a += compressed_ns_len;
 	memcpy(a, mailbox_compressed, compressed_mb_len);


-- 
Resolv Wrapper Repository


More information about the samba-cvs mailing list