[SCM] Resolv Wrapper Repository - branch master updated
Andreas Schneider
asn at samba.org
Thu Nov 11 14:28:53 UTC 2021
The branch, master has been updated
via c75587f cmake: Fix detection of a fully seperate libresolv
via c741eab doc: Update documentation for glibc 2.34 changes
via fd4b5a4 doc: Rename resolv_wrapper.1.txt to resolv_wrapper.1.adoc
via 7909e0a rwrap: Use our own rwrap_randomid()
via 9172ea4 tests: Add test_res_fake_uri_nsearch()
from fce9dec Bump version to 1.1.7
https://git.samba.org/?p=resolv_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c75587f858eb49e6b13ab610e63289df0485ddac
Author: Andreas Schneider <asn at samba.org>
Date: Wed Nov 3 15:12:22 2021 +0100
cmake: Fix detection of a fully seperate libresolv
With glibc 2.24 all res_* symbols moved from libresolv to libc. This means
that socket_wrapper is not able to do the traffic to the DNS server. This
leaves us only with DNS faking.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit c741eabfaad7a611bdb6cb6bac5bbe53ca4582cc
Author: Andreas Schneider <asn at samba.org>
Date: Wed Nov 3 15:22:44 2021 +0100
doc: Update documentation for glibc 2.34 changes
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fd4b5a4719d6e13d883d7e1fc9c9e944dfa2715e
Author: Andreas Schneider <asn at samba.org>
Date: Wed Nov 3 15:24:42 2021 +0100
doc: Rename resolv_wrapper.1.txt to resolv_wrapper.1.adoc
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 7909e0a3dcd23a4d5e340de9410d628e223ea524
Author: Andreas Schneider <asn at samba.org>
Date: Wed Nov 3 15:09:56 2021 +0100
rwrap: Use our own rwrap_randomid()
This is what glibc does, but the function is marked as deprecated now.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 9172ea46b69655603e8db97fc6f1cdffdde03da0
Author: Andreas Schneider <asn at samba.org>
Date: Thu Aug 19 12:47:30 2021 +0200
tests: Add test_res_fake_uri_nsearch()
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
-----------------------------------------------------------------------
Summary of changes:
ConfigureChecks.cmake | 21 ++-
doc/README | 6 +-
doc/resolv_wrapper.1 | 166 +++++++++++----------
...{resolv_wrapper.1.txt => resolv_wrapper.1.adoc} | 4 +
src/resolv_wrapper.c | 4 +-
tests/test_dns_fake.c | 60 ++++++++
6 files changed, 175 insertions(+), 86 deletions(-)
rename doc/{resolv_wrapper.1.txt => resolv_wrapper.1.adoc} (92%)
Changeset truncated at 500 lines:
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 8444232..6eb00da 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -57,12 +57,23 @@ check_function_exists(getexecname HAVE_GETEXECNAME)
find_library(RESOLV_LIRBRARY resolv)
if (RESOLV_LIRBRARY)
- set(HAVE_LIBRESOLV TRUE)
+ check_function_exists(res_nquery HAVE_LIBC_RES_INIT)
+ check_function_exists(__res_query HAVE_LIBC__RES_INIT)
+
+ if (NOT HAVE_LIBC_RES_INIT AND NOT HAVE_LIBC__RES_INIT)
+ set(CMAKE_REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
+ check_function_exists(res_query HAVE_RES_QUERY)
+ check_function_exists(__res_query HAVE___RES_QUERY)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+
+ if (HAVE_RES_QUERY OR HAVE___RES_QUERY)
+ set(HAVE_LIBRESOLV 1)
+
+ endif()
+ endif()
# If we have a libresolv, we need to check functions linking the library
list(APPEND _REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
-else()
- message(STATUS "libresolv not found on ${CMAKE_SYSTEM_NAME}: Only dns faking will be available")
endif()
set(CMAKE_REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
@@ -205,4 +216,8 @@ int main(void) {
# ENDIAN
test_big_endian(WORDS_BIGENDIAN)
+if (NOT HAVE_LIBRESOLV)
+ message(STATUS "Limited features: Only dns faking will be available")
+endif()
+
set(RWRAP_REQUIRED_LIBRARIES ${_REQUIRED_LIBRARIES} CACHE INTERNAL "resolv_wrapper required system libraries")
diff --git a/doc/README b/doc/README
index 8798ec5..94e5d47 100644
--- a/doc/README
+++ b/doc/README
@@ -1,3 +1,7 @@
The manpage is written with asciidoc. To generate the manpage use:
-a2x --doctype manpage --format manpage doc/resolv_wrapper.1.txt
+ asciidoctor -b manpage doc/resolv_wrapper.1.adoc
+
+or
+
+ a2x --doctype manpage --format manpage doc/resolv_wrapper.1.txt
diff --git a/doc/resolv_wrapper.1 b/doc/resolv_wrapper.1
index 1def7e8..ccbf282 100644
--- a/doc/resolv_wrapper.1
+++ b/doc/resolv_wrapper.1
@@ -1,50 +1,54 @@
'\" t
.\" Title: resolv_wrapper
.\" Author: The Samba Team
-.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\" Date: 2020-01-31
+.\" Generator: Asciidoctor 2.0.15
+.\" Date: 2021-11-03
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "RESOLV_WRAPPER" "1" "2020\-01\-31" "\ \&" "\ \&"
-.\" -----------------------------------------------------------------
-.\" * Define some portability stuff
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" http://bugs.debian.org/507673
-.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.TH "RESOLV_WRAPPER" "1" "2021-11-03" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
-.\" disable hyphenation
+.ss \n[.ss] 0
.nh
-.\" disable justification (adjust text to left margin only)
.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
+.de URL
+\fI\\$2\fP <\\$1>\\$3
+..
+.als MTO URL
+.if \n[.g] \{\
+. mso www.tmac
+. am URL
+. ad l
+. .
+. am MTO
+. ad l
+. .
+. LINKSTYLE blue R < >
+.\}
.SH "NAME"
-resolv_wrapper \- A wrapper for dns name resolving or dns faking\&.
+resolv_wrapper \- A wrapper for dns name resolving or dns faking.
.SH "SYNOPSIS"
.sp
-LD_PRELOAD=libresolv_wrapper\&.so RESOLV_WRAPPER_CONF="/path/to/resolv\&.conf" \fB\&./myapplication\fR
+LD_PRELOAD=libresolv_wrapper.so RESOLV_WRAPPER_CONF="/path/to/resolv.conf" \fB./myapplication\fP
.SH "DESCRIPTION"
.sp
-resolv_wrapper makes it possible on most UNIX platforms to contact your own DNS implementation in your test environment\&. It requires socket_wrapper to be able to contact it\&. If it doesn\(cqt work on a special platform the wrapper is able to fake DNS queries and return valid responses to your application\&.
+resolv_wrapper makes it possible on most UNIX platforms to contact your own DNS
+implementation in your test environment. It requires socket_wrapper to be able
+to contact it.
+If it doesn\(cqt work on a special platform the wrapper is able to fake DNS queries
+and return valid responses to your application.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
-.sp -1
-.IP \(bu 2.3
+. sp -1
+. IP \(bu 2.3
.\}
-Redirects name queries to the nameservers specified in your resolv\&.conf
+Redirects name queries to the nameservers specified in your resolv.conf
.RE
.sp
.RS 4
@@ -52,64 +56,67 @@ Redirects name queries to the nameservers specified in your resolv\&.conf
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
-.sp -1
-.IP \(bu 2.3
+. sp -1
+. IP \(bu 2.3
.\}
-Can fake DNS queries using a simple formatted DNS hosts file\&.
+Can fake DNS queries using a simple formatted DNS hosts file.
.RE
.SH "ENVIRONMENT VARIABLES"
-.PP
-\fBRESOLV_WRAPPER_CONF\fR
+.sp
+\fBRESOLV_WRAPPER_CONF\fP
.RS 4
-This is used to specify the resolv\&.conf to use\&. The format of the resolv\&.conf file is defined in the manpage
-\fIresolv\&.conf(5)\fR\&. Currently only the
-\fBnamserver\fR
-directive is supported\&.
+This is used to specify the resolv.conf to use. The format of the resolv.conf
+file is defined in the manpage \fIresolv.conf(5)\fP. Currently only the \fBnamserver\fP
+directive is supported.
.RE
-.PP
-\fBRESOLV_WRAPPER_HOSTS\fR
-.RS 4
-This environment variable is used for faking DNS queries\&. It must point to a hosts\-like text file that specifies fake records for custom queries\&. The format of the file looks like this:
.sp
-.if n \{\
+In order that this works with socket_wrapper. The res_* symbols need to be in
+a separate libresolv library. If they are part of libc this wont work. This is
+the case with glibc >= 2.34.
+.sp
+\fBRESOLV_WRAPPER_HOSTS\fP
.RS 4
-.\}
+This environment variable is used for faking DNS queries. It must point to a
+hosts\-like text file that specifies fake records for custom queries. The
+format of the file looks like this:
+.sp
+.if n .RS 4
.nf
+.fam C
TYPE RECORD_NAME RECORD_VALUE
+.fam
.fi
-.if n \{\
-.RE
-.\}
+.if n .RE
.RE
.sp
For example:
.sp
-.if n \{\
-.RS 4
-.\}
+.if n .RS 4
.nf
-A dc\&.cwrap\&.org 127\&.0\&.0\&.10
-AAAA dc\&.cwrap\&.org fd00::5357:5f0a
-CNAME kerberos\&.cwrap\&.org dc\&.cwrap\&.org
-SRV _kerberos\&._tcp\&.cwrap\&.org kerberos\&.cwrap\&.org 88
-URI _vpn\&.cwrap\&.org https://vpn\&.cwrap\&.org/VPN
-TXT cwrap\&.org v=spf1 mx
+.fam C
+A dc.cwrap.org 127.0.0.10
+AAAA dc.cwrap.org fd00::5357:5f0a
+CNAME kerberos.cwrap.org dc.cwrap.org
+SRV _kerberos._tcp.cwrap.org kerberos.cwrap.org 88
+URI _vpn.cwrap.org https://vpn.cwrap.org/VPN
+TXT cwrap.org v=spf1 mx
+.fam
.fi
-.if n \{\
-.RE
-.\}
-.PP
-\fBRESOLV_WRAPPER_DEBUGLEVEL\fR
+.if n .RE
+.sp
+\fBRESOLV_WRAPPER_DEBUGLEVEL\fP
.RS 4
-If you need to see what is going on in resolv_wrapper itself or try to find a bug, you can enable logging support in resolv_wrapper if you built it with debug symbols\&.
+If you need to see what is going on in resolv_wrapper itself or try to find a
+bug, you can enable logging support in resolv_wrapper if you built it with
+debug symbols.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
-.sp -1
-.IP \(bu 2.3
+. sp -1
+. IP \(bu 2.3
.\}
0 = ERROR
.RE
@@ -119,8 +126,8 @@ If you need to see what is going on in resolv_wrapper itself or try to find a bu
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
-.sp -1
-.IP \(bu 2.3
+. sp -1
+. IP \(bu 2.3
.\}
1 = WARNING
.RE
@@ -130,8 +137,8 @@ If you need to see what is going on in resolv_wrapper itself or try to find a bu
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
-.sp -1
-.IP \(bu 2.3
+. sp -1
+. IP \(bu 2.3
.\}
2 = DEBUG
.RE
@@ -141,33 +148,30 @@ If you need to see what is going on in resolv_wrapper itself or try to find a bu
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
-.sp -1
-.IP \(bu 2.3
+. sp -1
+. IP \(bu 2.3
.\}
3 = TRACE
.RE
.RE
-.PP
-\fBRESOLV_WRAPPER_DISABLE_DEEPBIND\fR
+.sp
+\fBRESOLV_WRAPPER_DISABLE_DEEPBIND\fP
.RS 4
-This allows you to disable deep binding in resolv_wrapper\&. This is useful for running valgrind tools or sanitizers like (address, undefined, thread)\&.
+This allows you to disable deep binding in resolv_wrapper. This is useful for
+running valgrind tools or sanitizers like (address, undefined, thread).
.RE
.SH "EXAMPLE"
.sp
-The following command would trick \fIkinit(1)\fR into using DNS servers from "\&./resolv\&.conf" for Kerberos service resolution:
+The following command would trick \fIkinit(1)\fP into using DNS servers from "./resolv.conf"
+for Kerberos service resolution:
.sp
-.if n \{\
-.RS 4
-.\}
+.if n .RS 4
.nf
-$ LD_PRELOAD=libresolv_wrapper\&.so RESOLV_WRAPPER_CONF="\&./resolv\&.conf" kinit user at EXAMPLE\&.COM
+.fam C
+$ LD_PRELOAD=libresolv_wrapper.so RESOLV_WRAPPER_CONF="./resolv.conf" kinit user at EXAMPLE.COM
+.fam
.fi
-.if n \{\
-.RE
-.\}
+.if n .RE
.SH "AUTHOR"
-.PP
-\fBThe Samba Team\fR
-.RS 4
-Author.
-.RE
+.sp
+The Samba Team
\ No newline at end of file
diff --git a/doc/resolv_wrapper.1.txt b/doc/resolv_wrapper.1.adoc
similarity index 92%
rename from doc/resolv_wrapper.1.txt
rename to doc/resolv_wrapper.1.adoc
index 5b23dac..2387909 100644
--- a/doc/resolv_wrapper.1.txt
+++ b/doc/resolv_wrapper.1.adoc
@@ -34,6 +34,10 @@ This is used to specify the resolv.conf to use. The format of the resolv.conf
file is defined in the manpage 'resolv.conf(5)'. Currently only the *namserver*
directive is supported.
+In order that this works with socket_wrapper. The res_* symbols need to be in
+a separate libresolv library. If they are part of libc this wont work. This is
+the case with glibc >= 2.34.
+
*RESOLV_WRAPPER_HOSTS*::
This environment variable is used for faking DNS queries. It must point to a
diff --git a/src/resolv_wrapper.c b/src/resolv_wrapper.c
index b69a55a..899f4cc 100644
--- a/src/resolv_wrapper.c
+++ b/src/resolv_wrapper.c
@@ -434,6 +434,8 @@ static int rwrap_create_fake_ptr_rr(const char *key,
return 0;
}
+#define rwrap_randomid() 0xffff & getpid()
+
/* 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 ancount, size_t arcount)
@@ -451,7 +453,7 @@ static ssize_t rwrap_fake_header(uint8_t **header_blob, size_t remaining,
h.blob = *header_blob;
memset(h.blob, 0, NS_HFIXEDSZ);
- h.header->id = res_randomid(); /* random query ID */
+ h.header->id = rwrap_randomid(); /* random query ID */
h.header->qr = 1; /* response flag */
h.header->rd = 1; /* recursion desired */
h.header->ra = 1; /* recursion available */
diff --git a/tests/test_dns_fake.c b/tests/test_dns_fake.c
index 121ccbc..c057ebe 100644
--- a/tests/test_dns_fake.c
+++ b/tests/test_dns_fake.c
@@ -749,6 +749,65 @@ static void test_res_fake_txt_query(void **state)
assert_string_equal(rrdata, "v=spf1 mx");
}
+static void test_res_fake_uri_nsearch(void **state)
+{
+ int rv;
+ struct __res_state dnsstate;
+ unsigned char answer[ANSIZE] = {0};
+ ns_msg handle;
+ ns_rr rr; /* expanded resource record */
+ const uint8_t *rrdata;
+ int prio;
+ int weight;
+
+ (void) state; /* unused */
+
+ memset(&dnsstate, 0, sizeof(struct __res_state));
+ rv = res_ninit(&dnsstate);
+ assert_int_equal(rv, 0);
+
+ rv = res_nsearch(&dnsstate,
+ "_vpn.cwrap.org",
+ 1,
+ 256,
+ answer,
+ sizeof(answer));
+ assert_int_equal(rv, 208);
+
+ ns_initparse(answer, sizeof(answer), &handle);
+
+ assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror);
+ assert_int_equal(ns_msg_count(handle, ns_s_an), 3);
+
+ assert_int_equal(ns_parserr(&handle, ns_s_an, 0, &rr), 0);
+ assert_int_equal(ns_rr_type(rr), ns_t_uri);
+ assert_string_equal(ns_rr_name(rr), "_vpn.cwrap.org");
+ rrdata = ns_rr_rdata(rr);
+ NS_GET16(prio, rrdata);
+ NS_GET16(weight, rrdata);
+ assert_int_equal(prio, 2);
+ assert_int_equal(weight, 5);
+ assert_string_equal(rrdata, "https://vpn.cwrap.org/VPN");
+
+ assert_int_equal(ns_parserr(&handle, ns_s_an, 1, &rr), 0);
+ assert_int_equal(ns_rr_type(rr), ns_t_uri);
+ rrdata = ns_rr_rdata(rr);
+ NS_GET16(prio, rrdata);
+ NS_GET16(weight, rrdata);
+ assert_int_equal(prio, 2);
+ assert_int_equal(weight, 10);
+ assert_string_equal(rrdata, "https://vpn2.cwrap.org/VPN");
+
+ assert_int_equal(ns_parserr(&handle, ns_s_an, 2, &rr), 0);
+ assert_int_equal(ns_rr_type(rr), ns_t_uri);
+ rrdata = ns_rr_rdata(rr);
+ NS_GET16(prio, rrdata);
+ NS_GET16(weight, rrdata);
+ assert_int_equal(prio, 2);
+ assert_int_equal(weight, 20);
+ assert_string_equal(rrdata, "https://vpn3.cwrap.org/VPN");
+}
+
int main(void)
{
int rc;
@@ -769,6 +828,7 @@ int main(void)
cmocka_unit_test(test_res_fake_a_via_cname),
cmocka_unit_test(test_res_fake_ptr_query),
cmocka_unit_test(test_res_fake_txt_query),
+ cmocka_unit_test(test_res_fake_uri_nsearch),
};
rc = cmocka_run_group_tests(fake_tests, NULL, NULL);
--
Resolv Wrapper Repository
More information about the samba-cvs
mailing list