summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-28 09:20:58 +0100
committerAndreas Schneider <asn@samba.org>2019-02-12 16:54:18 +0100
commite7c9380faf0f0557c202119f960026f8700667ee (patch)
tree92bb44566c67d98056f8437a24608ec6d0d5da48
parentcf436b6d3e1d2c85d47e76e19519e36672ac93b8 (diff)
downloadsocket_wrapper-e7c9380faf0f0557c202119f960026f8700667ee.tar.gz
socket_wrapper-e7c9380faf0f0557c202119f960026f8700667ee.tar.xz
socket_wrapper-e7c9380faf0f0557c202119f960026f8700667ee.zip
swrap: Add env variable to disable deep binding
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--doc/socket_wrapper.19
-rw-r--r--doc/socket_wrapper.1.txt7
-rw-r--r--src/socket_wrapper.c20
3 files changed, 28 insertions, 8 deletions
diff --git a/doc/socket_wrapper.1 b/doc/socket_wrapper.1
index 7e10224..a064eed 100644
--- a/doc/socket_wrapper.1
+++ b/doc/socket_wrapper.1
@@ -2,12 +2,12 @@
.\" Title: socket_wrapper
.\" Author: Samba Team
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\" Date: 2018-06-26
+.\" Date: 2018-11-28
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "SOCKET_WRAPPER" "1" "2018\-06\-26" "\ \&" "\ \&"
+.TH "SOCKET_WRAPPER" "1" "2018\-11\-28" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -147,6 +147,11 @@ If you need to see what is going on in socket_wrapper itself or try to find a bu
3 = TRACE
.RE
.RE
+.PP
+\fBSOCKET_WRAPPER_DISABLE_DEEPBIND\fR
+.RS 4
+This allows you to disable deep binding in socket_wrapper\&. This is useful for running valgrind tools or sanitizers like (address, undefined, thread)\&.
+.RE
.SH "EXAMPLE"
.sp
.if n \{\
diff --git a/doc/socket_wrapper.1.txt b/doc/socket_wrapper.1.txt
index 583b50a..da16c6d 100644
--- a/doc/socket_wrapper.1.txt
+++ b/doc/socket_wrapper.1.txt
@@ -1,6 +1,6 @@
socket_wrapper(1)
=================
-:revdate: 2018-06-26
+:revdate: 2018-11-28
:author: Samba Team
NAME
@@ -78,6 +78,11 @@ debug symbols.
- 2 = DEBUG
- 3 = TRACE
+*SOCKET_WRAPPER_DISABLE_DEEPBIND*::
+
+This allows you to disable deep binding in socket_wrapper. This is useful for
+running valgrind tools or sanitizers like (address, undefined, thread).
+
EXAMPLE
-------
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index ca0a833..f9993a2 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -587,15 +587,25 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
int i;
#ifdef RTLD_DEEPBIND
- const char *env = getenv("LD_PRELOAD");
+ const char *env_preload = getenv("LD_PRELOAD");
+ const char *env_deepbind = getenv("SOCKET_WRAPPER_DISABLE_DEEPBIND");
+ bool enable_deepbind = true;
/* Don't do a deepbind if we run with libasan */
- if (env != NULL && strlen(env) < 1024) {
- const char *p = strstr(env, "libasan.so");
- if (p == NULL) {
- flags |= RTLD_DEEPBIND;
+ if (env_preload != NULL && strlen(env_preload) < 1024) {
+ const char *p = strstr(env_preload, "libasan.so");
+ if (p != NULL) {
+ enable_deepbind = false;
}
}
+
+ if (env_deepbind != NULL && strlen(env_deepbind) >= 1) {
+ enable_deepbind = false;
+ }
+
+ if (enable_deepbind) {
+ flags |= RTLD_DEEPBIND;
+ }
#endif
switch (lib) {