The branch, master has been updated via 80982e8 Bump version to 1.1.7 via 7c34da8 nwrap: Improve logging function via 8076f3d cmake: Check for getprogname() and getexecname() via 6c12eed nwrap: Always provide logging via f81e1e0 cmake: Fix path to nss_wrapper library from 2c754bf Update TODO
https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 80982e8bc36f36b13b010486810a01bb89ce9254 Author: Andreas Schneider <a...@samba.org> Date: Mon Nov 11 15:46:08 2019 +0100 Bump version to 1.1.7 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 7c34da8278adbc57b4f18c8290cdfb5d71629ef5 Author: Andreas Schneider <a...@samba.org> Date: Wed Nov 6 18:33:59 2019 +0100 nwrap: Improve logging function Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 8076f3d59b88d9a8d6649b1b98815089ad217b5f Author: Andreas Schneider <a...@samba.org> Date: Wed Nov 6 18:33:43 2019 +0100 cmake: Check for getprogname() and getexecname() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 6c12eeddb57cc43b970d4795ba5c7d0d752ed7a9 Author: Andreas Schneider <a...@samba.org> Date: Wed Nov 6 18:29:27 2019 +0100 nwrap: Always provide logging Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit f81e1e032c6828951b7a1ddc5bb4782923f0dbe9 Author: Andreas Schneider <a...@samba.org> Date: Wed Nov 6 18:43:29 2019 +0100 cmake: Fix path to nss_wrapper library Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 2 +- ChangeLog | 5 ++++ ConfigureChecks.cmake | 3 ++ config.h.cmake | 3 ++ nss_wrapper-config.cmake.in | 2 +- src/nss_wrapper.c | 71 +++++++++++++++++++++++++++------------------ 6 files changed, 55 insertions(+), 31 deletions(-) Changeset truncated at 500 lines: diff --git a/CMakeLists.txt b/CMakeLists.txt index e87842b..0939416 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") include(DefineCMakeDefaults) include(DefineCompilerFlags) -project(nss_wrapper VERSION 1.1.6 LANGUAGES C) +project(nss_wrapper VERSION 1.1.7 LANGUAGES C) # global needed variables set(APPLICATION_NAME ${PROJECT_NAME}) diff --git a/ChangeLog b/ChangeLog index 83a2380..3645f4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ ChangeLog ========== +version 1.1.7 (released 2019-11-11) + * Added NSS_WRAPPER_DISABLE_DEEPBIND env variable + * Improvded logging + * Fixed location in cmake config + version 1.1.6 (released 2019-05-19) * Fixed issues with memory alignment of getgrnam() * Fixed getpwnam() on FreeBSD diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index d0e1e0d..2947a8e 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -78,6 +78,9 @@ check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R) check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2) +check_function_exists(getprogname HAVE_GETPROGNAME) +check_function_exists(getexecname HAVE_GETEXECNAME) + if (WIN32) check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S) check_function_exists(_vsnprintf HAVE__VSNPRINTF) diff --git a/config.h.cmake b/config.h.cmake index 15f6afc..de0b5df 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -59,6 +59,9 @@ /* Define to 1 if you have the `gethostbyname2' function. */ #cmakedefine HAVE_GETHOSTBYNAME2 1 +#cmakedefine HAVE_GETPROGNAME 1 +#cmakedefine HAVE_GETEXECNAME 1 + #cmakedefine HAVE___POSIX_GETPWNAM_R 1 #cmakedefine HAVE___POSIX_GETPWUID_R 1 diff --git a/nss_wrapper-config.cmake.in b/nss_wrapper-config.cmake.in index 8f10f25..9375f5c 100644 --- a/nss_wrapper-config.cmake.in +++ b/nss_wrapper-config.cmake.in @@ -1 +1 @@ -set(NSS_WRAPPER_LIBRARY @CMAKE_INSTALL_LIBDIR@/@NSS_WRAPPER_LIB@) +set(NSS_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@NSS_WRAPPER_LIB@) diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c index 33b610b..1bcd3b1 100644 --- a/src/nss_wrapper.c +++ b/src/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) { -- NSS Wrapper Repository