diff options
author | Andreas Schneider <asn@samba.org> | 2019-11-13 15:41:47 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-11-14 23:50:06 +0000 |
commit | 8e8313b2b57f3e760876feb5b732d1d2774baa18 (patch) | |
tree | a9859019c8bc64c4d907d77e8d5b717290ff1b26 /third_party | |
parent | 4320196977012e02765f4804070438149d858e22 (diff) | |
download | samba-8e8313b2b57f3e760876feb5b732d1d2774baa18.tar.gz |
third_party: Update nss_wrapper to version 1.1.7
This adds missing support for Address Sanitzer.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Nov 14 23:50:06 UTC 2019 on sn-devel-184
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/nss_wrapper/nss_wrapper.c | 91 | ||||
-rw-r--r-- | third_party/nss_wrapper/wscript | 2 |
2 files changed, 58 insertions, 35 deletions
diff --git a/third_party/nss_wrapper/nss_wrapper.c b/third_party/nss_wrapper/nss_wrapper.c index 62c7af16774..1bcd3b1b72d 100644 --- a/third_party/nss_wrapper/nss_wrapper.c +++ b/third_party/nss_wrapper/nss_wrapper.c @@ -243,9 +243,18 @@ enum nwrap_dbglvl_e { NWRAP_LOG_TRACE }; -#ifdef NDEBUG -# define NWRAP_LOG(...) +#ifndef HAVE_GETPROGNAME +static const char *getprogname(void) +{ +#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME) + return program_invocation_short_name; +#elif defined(HAVE_GETEXECNAME) + return getexecname(); #else + return NULL; +#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */ +} +#endif /* HAVE_GETPROGNAME */ static void nwrap_log(enum nwrap_dbglvl_e dbglvl, const char *func, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); # define NWRAP_LOG(dbglvl, ...) nwrap_log((dbglvl), __func__, __VA_ARGS__) @@ -258,43 +267,49 @@ static void nwrap_log(enum nwrap_dbglvl_e dbglvl, va_list va; const char *d; unsigned int lvl = 0; - int pid = getpid(); + const char *prefix = "NWRAP"; + const char *progname = getprogname(); d = getenv("NSS_WRAPPER_DEBUGLEVEL"); if (d != NULL) { lvl = atoi(d); } + if (lvl < dbglvl) { + return; + } + va_start(va, format); vsnprintf(buffer, sizeof(buffer), format, va); va_end(va); - if (lvl >= dbglvl) { - switch (dbglvl) { - case NWRAP_LOG_ERROR: - fprintf(stderr, - "NWRAP_ERROR(%d) - %s: %s\n", - pid, func, buffer); - break; - case NWRAP_LOG_WARN: - fprintf(stderr, - "NWRAP_WARN(%d) - %s: %s\n", - pid, func, buffer); - break; - case NWRAP_LOG_DEBUG: - fprintf(stderr, - "NWRAP_DEBUG(%d) - %s: %s\n", - pid, func, buffer); - break; - case NWRAP_LOG_TRACE: - fprintf(stderr, - "NWRAP_TRACE(%d) - %s: %s\n", - pid, func, buffer); - break; - } + switch (dbglvl) { + case NWRAP_LOG_ERROR: + prefix = "NWRAP_ERROR"; + break; + case NWRAP_LOG_WARN: + prefix = "NWRAP_WARN"; + break; + case NWRAP_LOG_DEBUG: + prefix = "NWRAP_DEBUG"; + break; + case NWRAP_LOG_TRACE: + prefix = "NWRAP_TRACE"; + break; } + + if (progname == NULL) { + progname = "<unknown>"; + } + + fprintf(stderr, + "%s[%s (%u)] - %s: %s\n", + prefix, + progname, + (unsigned int)getpid(), + func, + buffer); } -#endif /* NDEBUG NWRAP_LOG */ struct nwrap_libc_fns { struct passwd *(*_libc_getpwnam)(const char *name); @@ -824,7 +839,6 @@ enum nwrap_lib { NWRAP_LIBSOCKET, }; -#ifndef NDEBUG static const char *nwrap_str_lib(enum nwrap_lib lib) { switch (lib) { @@ -839,7 +853,6 @@ static const char *nwrap_str_lib(enum nwrap_lib lib) /* Compiler would warn us about unhandled enum value if we get here */ return "unknown"; } -#endif static void *nwrap_load_lib_handle(enum nwrap_lib lib) { @@ -848,15 +861,25 @@ static void *nwrap_load_lib_handle(enum nwrap_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("NSS_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) { diff --git a/third_party/nss_wrapper/wscript b/third_party/nss_wrapper/wscript index 7a2f53ad299..dd83083b2e7 100644 --- a/third_party/nss_wrapper/wscript +++ b/third_party/nss_wrapper/wscript @@ -2,7 +2,7 @@ import os -VERSION="1.1.6" +VERSION="1.1.7" def configure(conf): if conf.CHECK_NSS_WRAPPER(): |