Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package nss_wrapper for openSUSE:Factory checked in at 2022-11-10 14:19:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nss_wrapper (Old) and /work/SRC/openSUSE:Factory/.nss_wrapper.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nss_wrapper" Thu Nov 10 14:19:12 2022 rev:15 rq:1034765 version:1.1.13 Changes: -------- --- /work/SRC/openSUSE:Factory/nss_wrapper/nss_wrapper.changes 2022-06-25 10:23:56.626646475 +0200 +++ /work/SRC/openSUSE:Factory/.nss_wrapper.new.1597/nss_wrapper.changes 2022-11-10 14:19:13.741320084 +0100 @@ -1,0 +2,6 @@ +Wed Nov 9 06:48:12 UTC 2022 - Andreas Schneider <[email protected]> + +- Update to version 1.1.13 + * Fixed possible mutex and threading issues + +------------------------------------------------------------------- Old: ---- nss_wrapper-1.1.12.tar.gz nss_wrapper-1.1.12.tar.gz.asc New: ---- nss_wrapper-1.1.13.tar.gz nss_wrapper-1.1.13.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nss_wrapper.spec ++++++ --- /var/tmp/diff_new_pack.fxy0zT/_old 2022-11-10 14:19:16.945337742 +0100 +++ /var/tmp/diff_new_pack.fxy0zT/_new 2022-11-10 14:19:16.949337764 +0100 @@ -23,7 +23,7 @@ # ############################# NOTE ################################## Name: nss_wrapper -Version: 1.1.12 +Version: 1.1.13 Release: 0 Summary: A wrapper for the user, group and hosts NSS API License: BSD-3-Clause ++++++ nss_wrapper-1.1.12.tar.gz -> nss_wrapper-1.1.13.tar.gz ++++++ Binary files old/nss_wrapper-1.1.12/.cache/clangd/index/nss_wrapper.c.496306141B70693D.idx and new/nss_wrapper-1.1.13/.cache/clangd/index/nss_wrapper.c.496306141B70693D.idx differ Binary files old/nss_wrapper-1.1.12/.cache/clangd/index/test_thread_getaddrinfo.c.17665B73698D65D5.idx and new/nss_wrapper-1.1.13/.cache/clangd/index/test_thread_getaddrinfo.c.17665B73698D65D5.idx differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/.editorconfig new/nss_wrapper-1.1.13/.editorconfig --- old/nss_wrapper-1.1.12/.editorconfig 1970-01-01 01:00:00.000000000 +0100 +++ new/nss_wrapper-1.1.13/.editorconfig 2022-11-09 07:45:15.000000000 +0100 @@ -0,0 +1,23 @@ +root = true + +[*] +charset = utf-8 +max_line_length = 80 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{c,h}] +indent_style = tab +indent_size = 8 +tab_width = 8 + +[*.cmake] +indent_style = space +indent_size = 4 +tab_width = 4 + +[CMake*] +indent_style = space +indent_size = 4 +tab_width = 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/.gitlab-ci.yml new/nss_wrapper-1.1.13/.gitlab-ci.yml --- old/nss_wrapper-1.1.12/.gitlab-ci.yml 2020-03-24 13:39:41.000000000 +0100 +++ new/nss_wrapper-1.1.13/.gitlab-ci.yml 2022-11-09 07:45:15.000000000 +0100 @@ -1,3 +1,4 @@ +--- variables: BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images FEDORA_BUILD: buildenv-fedora @@ -6,18 +7,24 @@ MINGW_BUILD: buildenv-mingw UBUNTU_BUILD: buildenv-ubuntu +stages: + - build + - test + - analysis + centos7/x86_64: + stage: test image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD script: - - mkdir -p obj && cd obj && cmake3 - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake3 + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -25,17 +32,18 @@ - obj/ fedora/x86_64: + stage: test image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -43,17 +51,18 @@ - obj/ fedora/address-sanitizer: + stage: build image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=AddressSanitizer - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=AddressSanitizer + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -61,16 +70,37 @@ - obj/ fedora/undefined-sanitizer: + stage: analysis + image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD + script: + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=UndefinedSanitizer + -DUNIT_TESTING=ON .. + && make -j$(nproc) && ctest --output-on-failure + tags: + - shared + except: + - tags + artifacts: + expire_in: 1 week + when: on_failure + paths: + - obj/ + +fedora/thread-sanitizer: + stage: analysis image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=UndefinedSanitizer - -DUNIT_TESTING=ON .. - && make -j$(nproc) && ctest --output-on-failure + - export TSAN_OPTIONS=second_deadlock_stack=1 + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=ThreadSanitizer + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -78,30 +108,31 @@ - obj/ fedora/csbuild: + stage: analysis image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD script: - - | - if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then + - | + if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20") - fi + fi - # Check if the commit exists in this branch - # This is not the case for a force push - git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20") + # Check if the commit exists in this branch + # This is not the case for a force push + git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20") - export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" - - csbuild - --build-dir=obj-csbuild - --prep-cmd="cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON @SRCDIR@" - --build-cmd "make clean && make -j$(nproc)" - --git-commit-range $CI_COMMIT_RANGE - --color - --print-current --print-fixed + - csbuild + --build-dir=obj-csbuild + --prep-cmd="cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON @SRCDIR@" + --build-cmd "make clean && make -j$(nproc)" + --git-commit-range $CI_COMMIT_RANGE + --color + --print-current --print-fixed tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -109,20 +140,21 @@ - obj-csbuild/ freebsd/x86_64: + stage: test image: script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make && ctest --output-on-failure tags: - - freebsd + - freebsd except: - - tags + - tags only: - - branches@cwrap/nss_wrapper - - branches@cryptomilk/nss_wrapper + - branches@cwrap/nss_wrapper + - branches@cryptomilk/nss_wrapper artifacts: expire_in: 1 week when: on_failure @@ -130,17 +162,18 @@ - obj/ tumbleweed/x86_64/gcc: + stage: test image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -148,18 +181,19 @@ - obj/ tumbleweed/x86_64/gcc7: + stage: test image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -167,18 +201,19 @@ - obj/ tumbleweed/x86_64/clang: + stage: test image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -186,20 +221,21 @@ - obj/ tumbleweed/static-analysis: + stage: analysis image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD script: - - export CCC_CC=clang - - export CCC_CXX=clang++ - - mkdir -p obj && cd obj && scan-build cmake - -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - scan-build --status-bugs -o scan make -j$(nproc) + - export CCC_CC=clang + - export CCC_CXX=clang++ + - mkdir -p obj && cd obj && scan-build cmake + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + scan-build --status-bugs -o scan make -j$(nproc) tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure @@ -207,17 +243,17 @@ - obj/scan ubuntu/x86_64: + stage: test image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$UBUNTU_BUILD script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && make -j$(nproc) && ctest --output-on-failure tags: - - shared + - shared except: - - tags + - tags artifacts: expire_in: 1 week when: on_failure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/CHANGELOG new/nss_wrapper-1.1.13/CHANGELOG --- old/nss_wrapper-1.1.12/CHANGELOG 2022-06-24 10:09:57.000000000 +0200 +++ new/nss_wrapper-1.1.13/CHANGELOG 2022-11-09 07:45:15.000000000 +0100 @@ -1,6 +1,9 @@ ChangeLog ========== +version 1.1.13 (released 2022-10-09) + * Fixed possible mutex and threading issues + version 1.1.12 (released 2022-06-24) * Added (de)contructor support on AIX with pragma init/finish * Fixed possible crash in getaddrinfo() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/CMakeLists.txt new/nss_wrapper-1.1.13/CMakeLists.txt --- old/nss_wrapper-1.1.12/CMakeLists.txt 2022-06-24 10:09:57.000000000 +0200 +++ new/nss_wrapper-1.1.13/CMakeLists.txt 2022-11-09 07:45:15.000000000 +0100 @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5.0) cmake_policy(SET CMP0048 NEW) -# Specify search path for CMake modules to be loaded by include() +# Specify search path for CMake modules to be loaded by include() # and find_package() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") @@ -11,7 +11,7 @@ include(DefineCMakeDefaults) include(DefineCompilerFlags) -project(nss_wrapper VERSION 1.1.12 LANGUAGES C) +project(nss_wrapper VERSION 1.1.13 LANGUAGES C) # global needed variables set(APPLICATION_NAME ${PROJECT_NAME}) @@ -25,7 +25,7 @@ # Increment PATCH. set(LIBRARY_VERSION_MAJOR 0) set(LIBRARY_VERSION_MINOR 3) -set(LIBRARY_VERSION_PATCH 2) +set(LIBRARY_VERSION_PATCH 3) set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/cmake/Modules/DefineCompilerFlags.cmake new/nss_wrapper-1.1.13/cmake/Modules/DefineCompilerFlags.cmake --- old/nss_wrapper-1.1.12/cmake/Modules/DefineCompilerFlags.cmake 2020-03-17 18:23:32.000000000 +0100 +++ new/nss_wrapper-1.1.13/cmake/Modules/DefineCompilerFlags.cmake 2022-11-09 07:45:15.000000000 +0100 @@ -34,4 +34,16 @@ CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.") set(CMAKE_EXEC_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined" CACHE STRING "Flags used by the linker during UNDEFINEDSANITIZER builds.") + + # Activate with: -DCMAKE_BUILD_TYPE=ThreadSanitizer + set(CMAKE_C_FLAGS_THREADSANITIZER "-g -O1 -fsanitize=thread" + CACHE STRING "Flags used by the C compiler during THREADSANITIZER builds.") + set(CMAKE_CXX_FLAGS_THREADSANITIZER "-g -O1 -fsanitize=thread" + CACHE STRING "Flags used by the CXX compiler during THREADSANITIZER builds.") + set(CMAKE_SHARED_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread" + CACHE STRING "Flags used by the linker during the creation of shared libraries during THREADSANITIZER builds.") + set(CMAKE_MODULE_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread" + CACHE STRING "Flags used by the linker during the creation of shared libraries during THREADSANITIZER builds.") + set(CMAKE_EXEC_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread" + CACHE STRING "Flags used by the linker during THREADSANITIZER builds.") endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/src/nss_wrapper.c new/nss_wrapper-1.1.13/src/nss_wrapper.c --- old/nss_wrapper-1.1.12/src/nss_wrapper.c 2022-06-24 10:09:57.000000000 +0200 +++ new/nss_wrapper-1.1.13/src/nss_wrapper.c 2022-11-09 07:45:15.000000000 +0100 @@ -177,17 +177,6 @@ #define NWRAP_INET_ADDRSTRLEN INET_ADDRSTRLEN #endif -#define NWRAP_LOCK(m) do { \ - pthread_mutex_lock(&( m ## _mutex)); \ -} while(0) - -#define NWRAP_UNLOCK(m) do { \ - pthread_mutex_unlock(&( m ## _mutex)); \ -} while(0) - -static pthread_mutex_t libc_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t nss_module_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER; - static bool nwrap_initialized = false; static pthread_mutex_t nwrap_initialized_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -198,50 +187,49 @@ static pthread_mutex_t nwrap_pw_global_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t nwrap_sp_global_mutex = PTHREAD_MUTEX_INITIALIZER; +#define nss_wrapper_init_mutex(m) \ + _nss_wrapper_init_mutex(m, #m) + /* Add new global locks here please */ /* Also don't forget to add locks to * nwrap_init() function. */ +# define NWRAP_REINIT_ALL do { \ + int ret; \ + ret = nss_wrapper_init_mutex(&nwrap_initialized_mutex); \ + if (ret != 0) exit(-1); \ + ret = nss_wrapper_init_mutex(&nwrap_global_mutex); \ + if (ret != 0) exit(-1); \ + ret = nss_wrapper_init_mutex(&nwrap_gr_global_mutex); \ + if (ret != 0) exit(-1); \ + ret = nss_wrapper_init_mutex(&nwrap_he_global_mutex); \ + if (ret != 0) exit(-1); \ + ret = nss_wrapper_init_mutex(&nwrap_pw_global_mutex); \ + if (ret != 0) exit(-1); \ + ret = nss_wrapper_init_mutex(&nwrap_sp_global_mutex); \ + if (ret != 0) exit(-1); \ +} while(0) + # define NWRAP_LOCK_ALL do { \ - NWRAP_LOCK(libc_symbol_binding); \ - NWRAP_LOCK(nss_module_symbol_binding); \ - NWRAP_LOCK(nwrap_initialized); \ - NWRAP_LOCK(nwrap_global); \ - NWRAP_LOCK(nwrap_gr_global); \ - NWRAP_LOCK(nwrap_he_global); \ - NWRAP_LOCK(nwrap_pw_global); \ - NWRAP_LOCK(nwrap_sp_global); \ + nwrap_mutex_lock(&nwrap_initialized_mutex); \ + nwrap_mutex_lock(&nwrap_global_mutex); \ + nwrap_mutex_lock(&nwrap_gr_global_mutex); \ + nwrap_mutex_lock(&nwrap_he_global_mutex); \ + nwrap_mutex_lock(&nwrap_pw_global_mutex); \ + nwrap_mutex_lock(&nwrap_sp_global_mutex); \ } while (0); # define NWRAP_UNLOCK_ALL do {\ - NWRAP_UNLOCK(nwrap_sp_global); \ - NWRAP_UNLOCK(nwrap_pw_global); \ - NWRAP_UNLOCK(nwrap_he_global); \ - NWRAP_UNLOCK(nwrap_gr_global); \ - NWRAP_UNLOCK(nwrap_global); \ - NWRAP_UNLOCK(nwrap_initialized); \ - NWRAP_UNLOCK(nss_module_symbol_binding); \ - NWRAP_UNLOCK(libc_symbol_binding); \ + nwrap_mutex_unlock(&nwrap_sp_global_mutex); \ + nwrap_mutex_unlock(&nwrap_pw_global_mutex); \ + nwrap_mutex_unlock(&nwrap_he_global_mutex); \ + nwrap_mutex_unlock(&nwrap_gr_global_mutex); \ + nwrap_mutex_unlock(&nwrap_global_mutex); \ + nwrap_mutex_unlock(&nwrap_initialized_mutex); \ } while (0); static void nwrap_init(void); -static void nwrap_thread_prepare(void) -{ - nwrap_init(); - NWRAP_LOCK_ALL; -} - -static void nwrap_thread_parent(void) -{ - NWRAP_UNLOCK_ALL; -} - -static void nwrap_thread_child(void) -{ - NWRAP_UNLOCK_ALL; -} - enum nwrap_dbglvl_e { NWRAP_LOG_ERROR = 0, NWRAP_LOG_WARN, @@ -1230,37 +1218,57 @@ return func; } +#define nwrap_mutex_lock(m) _nwrap_mutex_lock(m, #m, __func__, __LINE__) +static void _nwrap_mutex_lock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line) +{ + int ret; + + ret = pthread_mutex_lock(mutex); + if (ret != 0) { + NWRAP_LOG(NWRAP_LOG_ERROR, "PID(%d):PPID(%d): %s(%u): Couldn't lock pthread mutex(%s) - %s", + getpid(), getppid(), caller, line, name, strerror(ret)); + abort(); + } +} + +#define nwrap_mutex_unlock(m) _nwrap_mutex_unlock(m, #m, __func__, __LINE__) +static void _nwrap_mutex_unlock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line) +{ + int ret; + + ret = pthread_mutex_unlock(mutex); + if (ret != 0) { + NWRAP_LOG(NWRAP_LOG_ERROR, "PID(%d):PPID(%d): %s(%u): Couldn't unlock pthread mutex(%s) - %s", + getpid(), getppid(), caller, line, name, strerror(ret)); + abort(); + } +} + #define nwrap_bind_symbol_libc(sym_name) \ - NWRAP_LOCK(libc_symbol_binding); \ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \ _nwrap_bind_symbol(NWRAP_LIBC, #sym_name); \ } \ - NWRAP_UNLOCK(libc_symbol_binding) #define nwrap_bind_symbol_libc_posix(sym_name) \ - NWRAP_LOCK(libc_symbol_binding); \ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \ _nwrap_bind_symbol(NWRAP_LIBC, "__posix_" #sym_name); \ } \ - NWRAP_UNLOCK(libc_symbol_binding) #define nwrap_bind_symbol_libnsl(sym_name) \ - NWRAP_LOCK(libc_symbol_binding); \ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \ _nwrap_bind_symbol(NWRAP_LIBNSL, #sym_name); \ } \ - NWRAP_UNLOCK(libc_symbol_binding) #define nwrap_bind_symbol_libsocket(sym_name) \ - NWRAP_LOCK(libc_symbol_binding); \ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \ _nwrap_bind_symbol(NWRAP_LIBSOCKET, #sym_name); \ } \ - NWRAP_UNLOCK(libc_symbol_binding) + +static void nwrap_bind_symbol_all(void); /* INTERNAL HELPER FUNCTIONS */ static void nwrap_lines_unload(struct nwrap_cache *const nwrap) @@ -1285,7 +1293,7 @@ */ static struct passwd *libc_getpwnam(const char *name) { - nwrap_bind_symbol_libc(getpwnam); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwnam.f(name); } @@ -1297,11 +1305,7 @@ size_t buflen, struct passwd **result) { -#ifdef HAVE___POSIX_GETPWNAM_R - nwrap_bind_symbol_libc_posix(getpwnam_r); -#else - nwrap_bind_symbol_libc(getpwnam_r); -#endif + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwnam_r.f(name, pwd, @@ -1313,7 +1317,7 @@ static struct passwd *libc_getpwuid(uid_t uid) { - nwrap_bind_symbol_libc(getpwuid); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwuid.f(uid); } @@ -1325,11 +1329,7 @@ size_t buflen, struct passwd **result) { -#ifdef HAVE___POSIX_GETPWUID_R - nwrap_bind_symbol_libc_posix(getpwuid_r); -#else - nwrap_bind_symbol_libc(getpwuid_r); -#endif + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwuid_r.f(uid, pwd, @@ -1372,14 +1372,14 @@ static void libc_setpwent(void) { - nwrap_bind_symbol_libc(setpwent); + nwrap_bind_symbol_all(); nwrap_main_global->libc->symbols._libc_setpwent.f(); } static struct passwd *libc_getpwent(void) { - nwrap_bind_symbol_libc(getpwent); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwent.f(); } @@ -1390,7 +1390,7 @@ char *buf, int buflen) { - nwrap_bind_symbol_libc(getpwent_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwent_r.f(pwdst, buf, @@ -1402,7 +1402,7 @@ size_t buflen, struct passwd **pwdstp) { - nwrap_bind_symbol_libc(getpwent_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getpwent_r.f(pwdst, buf, @@ -1414,21 +1414,21 @@ static void libc_endpwent(void) { - nwrap_bind_symbol_libc(endpwent); + nwrap_bind_symbol_all(); nwrap_main_global->libc->symbols._libc_endpwent.f(); } static int libc_initgroups(const char *user, gid_t gid) { - nwrap_bind_symbol_libc(initgroups); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_initgroups.f(user, gid); } static struct group *libc_getgrnam(const char *name) { - nwrap_bind_symbol_libc(getgrnam); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrnam.f(name); } @@ -1440,11 +1440,7 @@ size_t buflen, struct group **result) { -#ifdef HAVE___POSIX_GETGRNAM_R - nwrap_bind_symbol_libc_posix(getgrnam_r); -#else - nwrap_bind_symbol_libc(getgrnam_r); -#endif + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrnam_r.f(name, grp, @@ -1456,7 +1452,7 @@ static struct group *libc_getgrgid(gid_t gid) { - nwrap_bind_symbol_libc(getgrgid); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrgid.f(gid); } @@ -1468,14 +1464,7 @@ size_t buflen, struct group **result) { -#ifdef HAVE___POSIX_GETGRGID_R - if (nwrap_main_global->libc->symbols._libc_getgrgid_r == NULL) { - *(void **) (&nwrap_main_global->libc->symbols._libc_getgrgid_r) = - _nwrap_bind_symbol_libc("__posix_getgrgid_r"); - } -#else - nwrap_bind_symbol_libc(getgrgid_r); -#endif + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrgid_r.f(gid, grp, @@ -1487,14 +1476,14 @@ static void libc_setgrent(void) { - nwrap_bind_symbol_libc(setgrent); + nwrap_bind_symbol_all(); nwrap_main_global->libc->symbols._libc_setgrent.f(); } static struct group *libc_getgrent(void) { - nwrap_bind_symbol_libc(getgrent); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrent.f(); } @@ -1505,7 +1494,7 @@ char *buf, size_t buflen) { - nwrap_bind_symbol_libc(getgrent_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrent_r.f(group, buf, @@ -1517,7 +1506,7 @@ size_t buflen, struct group **result) { - nwrap_bind_symbol_libc(getgrent_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrent_r.f(group, buf, @@ -1529,7 +1518,7 @@ static void libc_endgrent(void) { - nwrap_bind_symbol_libc(endgrent); + nwrap_bind_symbol_all(); nwrap_main_global->libc->symbols._libc_endgrent.f(); } @@ -1540,7 +1529,7 @@ gid_t *groups, int *ngroups) { - nwrap_bind_symbol_libc(getgrouplist); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getgrouplist.f(user, group, @@ -1551,28 +1540,28 @@ static void libc_sethostent(int stayopen) { - nwrap_bind_symbol_libnsl(sethostent); + nwrap_bind_symbol_all(); nwrap_main_global->libc->symbols._libc_sethostent.f(stayopen); } static struct hostent *libc_gethostent(void) { - nwrap_bind_symbol_libnsl(gethostent); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostent.f(); } static void libc_endhostent(void) { - nwrap_bind_symbol_libnsl(endhostent); + nwrap_bind_symbol_all(); nwrap_main_global->libc->symbols._libc_endhostent.f(); } static struct hostent *libc_gethostbyname(const char *name) { - nwrap_bind_symbol_libnsl(gethostbyname); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostbyname.f(name); } @@ -1580,7 +1569,7 @@ #ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */ static struct hostent *libc_gethostbyname2(const char *name, int af) { - nwrap_bind_symbol_libnsl(gethostbyname2); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostbyname2.f(name, af); } @@ -1595,7 +1584,7 @@ struct hostent **result, int *h_errnop) { - nwrap_bind_symbol_libnsl(gethostbyname2_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostbyname2_r.f(name, af, @@ -1611,7 +1600,7 @@ socklen_t len, int type) { - nwrap_bind_symbol_libnsl(gethostbyaddr); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostbyaddr.f(addr, len, @@ -1620,7 +1609,7 @@ static int libc_gethostname(char *name, size_t len) { - nwrap_bind_symbol_libnsl(gethostname); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostname.f(name, len); } @@ -1633,7 +1622,7 @@ struct hostent **result, int *h_errnop) { - nwrap_bind_symbol_libnsl(gethostbyname_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostbyname_r.f(name, ret, @@ -1654,7 +1643,7 @@ struct hostent **result, int *h_errnop) { - nwrap_bind_symbol_libnsl(gethostbyaddr_r); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_gethostbyaddr_r.f(addr, len, @@ -1672,7 +1661,7 @@ const struct addrinfo *hints, struct addrinfo **res) { - nwrap_bind_symbol_libsocket(getaddrinfo); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getaddrinfo.f(node, service, @@ -1688,7 +1677,7 @@ size_t servlen, int flags) { - nwrap_bind_symbol_libsocket(getnameinfo); + nwrap_bind_symbol_all(); return nwrap_main_global->libc->symbols._libc_getnameinfo.f(sa, salen, @@ -1699,6 +1688,81 @@ flags); } +static void __nwrap_bind_symbol_all_once(void) +{ + nwrap_bind_symbol_libc(getpwnam); +#ifdef HAVE_GETPWNAM_R +# ifdef HAVE___POSIX_GETPWNAM_R + nwrap_bind_symbol_libc_posix(getpwnam_r); +# else + nwrap_bind_symbol_libc(getpwnam_r); +# endif +#endif + nwrap_bind_symbol_libc(getpwuid); +#ifdef HAVE_GETPWUID_R +# ifdef HAVE___POSIX_GETPWUID_R + nwrap_bind_symbol_libc_posix(getpwuid_r); +# else + nwrap_bind_symbol_libc(getpwuid_r); +# endif +#endif + nwrap_bind_symbol_libc(setpwent); + nwrap_bind_symbol_libc(getpwent); +#ifdef HAVE_GETPWENT_R + nwrap_bind_symbol_libc(getpwent_r); +#endif + nwrap_bind_symbol_libc(endpwent); + nwrap_bind_symbol_libc(initgroups); + nwrap_bind_symbol_libc(getgrnam); +#ifdef HAVE_GETGRNAM_R +# ifdef HAVE___POSIX_GETGRNAM_R + nwrap_bind_symbol_libc_posix(getgrnam_r); +# else + nwrap_bind_symbol_libc(getgrnam_r); +# endif +#endif + nwrap_bind_symbol_libc(getgrgid); +#ifdef HAVE_GETGRGID_R +# ifdef HAVE___POSIX_GETGRGID_R + nwrap_bind_symbol_libc_posix(getgrgid_r); +# else + nwrap_bind_symbol_libc(getgrgid_r); +# endif +#endif + nwrap_bind_symbol_libc(setgrent); + nwrap_bind_symbol_libc(getgrent); + nwrap_bind_symbol_libc(getgrent_r); + nwrap_bind_symbol_libc(endgrent); + nwrap_bind_symbol_libc(getgrouplist); + nwrap_bind_symbol_libnsl(sethostent); + nwrap_bind_symbol_libnsl(gethostent); + nwrap_bind_symbol_libnsl(endhostent); + nwrap_bind_symbol_libnsl(gethostbyname); +#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */ + nwrap_bind_symbol_libnsl(gethostbyname2); +#endif +#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */ + nwrap_bind_symbol_libnsl(gethostbyname2_r); +#endif + nwrap_bind_symbol_libnsl(gethostbyaddr); + nwrap_bind_symbol_libnsl(gethostname); +#ifdef HAVE_GETHOSTBYNAME_R + nwrap_bind_symbol_libnsl(gethostbyname_r); +#endif +#ifdef HAVE_GETHOSTBYADDR_R + nwrap_bind_symbol_libnsl(gethostbyaddr_r); +#endif + nwrap_bind_symbol_libsocket(getaddrinfo); + nwrap_bind_symbol_libsocket(getnameinfo); +} + +static void nwrap_bind_symbol_all(void) +{ + static pthread_once_t all_symbol_binding_once = PTHREAD_ONCE_INIT; + + pthread_once(&all_symbol_binding_once, __nwrap_bind_symbol_all_once); +} + /********************************************************* * NWRAP NSS MODULE LOADER FUNCTIONS *********************************************************/ @@ -1732,20 +1796,16 @@ } #define nwrap_nss_module_bind_symbol(sym_name) \ - NWRAP_LOCK(nss_module_symbol_binding); \ if (symbols->_nss_##sym_name.obj == NULL) { \ symbols->_nss_##sym_name.obj = \ _nwrap_bind_nss_module_symbol(b, #sym_name); \ - } \ - NWRAP_UNLOCK(nss_module_symbol_binding) + } #define nwrap_nss_module_bind_symbol2(sym_name, alt_name) \ - NWRAP_LOCK(nss_module_symbol_binding); \ if (symbols->_nss_##sym_name.obj == NULL) { \ symbols->_nss_##sym_name.obj = \ _nwrap_bind_nss_module_symbol(b, #alt_name); \ - } \ - NWRAP_UNLOCK(nss_module_symbol_binding) + } static struct nwrap_nss_module_symbols * nwrap_bind_nss_module_symbols(struct nwrap_backend *b) @@ -1876,6 +1936,34 @@ } } +static int _nss_wrapper_init_mutex(pthread_mutex_t *m, const char *name) +{ + pthread_mutexattr_t ma; + bool need_destroy = false; + int ret = 0; + +#define __CHECK(cmd) do { \ + ret = cmd; \ + if (ret != 0) { \ + NWRAP_LOG(NWRAP_LOG_ERROR, \ + "%s: %s - failed %d", \ + name, #cmd, ret); \ + goto done; \ + } \ +} while(0) + + *m = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER; + __CHECK(pthread_mutexattr_init(&ma)); + need_destroy = true; + __CHECK(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK)); + __CHECK(pthread_mutex_init(m, &ma)); +done: + if (need_destroy) { + pthread_mutexattr_destroy(&ma); + } + return ret; +} + static void nwrap_init(void) { const char *env; @@ -1883,9 +1971,9 @@ size_t max_hostents_tmp; int ok; - NWRAP_LOCK(nwrap_initialized); + nwrap_mutex_lock(&nwrap_initialized_mutex); if (nwrap_initialized) { - NWRAP_UNLOCK(nwrap_initialized); + nwrap_mutex_unlock(&nwrap_initialized_mutex); return; } @@ -1894,11 +1982,11 @@ * We don't use NWRAP_(UN)LOCK_ALL macros here because we * want to avoid overhead when other threads do their job. */ - NWRAP_LOCK(nwrap_global); - NWRAP_LOCK(nwrap_gr_global); - NWRAP_LOCK(nwrap_he_global); - NWRAP_LOCK(nwrap_pw_global); - NWRAP_LOCK(nwrap_sp_global); + nwrap_mutex_lock(&nwrap_global_mutex); + nwrap_mutex_lock(&nwrap_gr_global_mutex); + nwrap_mutex_lock(&nwrap_he_global_mutex); + nwrap_mutex_lock(&nwrap_pw_global_mutex); + nwrap_mutex_lock(&nwrap_sp_global_mutex); nwrap_initialized = true; @@ -1977,7 +2065,12 @@ nwrap_he_global.cache->unload = nwrap_he_unload; /* We hold all locks here so we can use NWRAP_UNLOCK_ALL. */ - NWRAP_UNLOCK_ALL; + nwrap_mutex_unlock(&nwrap_sp_global_mutex); + nwrap_mutex_unlock(&nwrap_pw_global_mutex); + nwrap_mutex_unlock(&nwrap_he_global_mutex); + nwrap_mutex_unlock(&nwrap_gr_global_mutex); + nwrap_mutex_unlock(&nwrap_global_mutex); + nwrap_mutex_unlock(&nwrap_initialized_mutex); } bool nss_wrapper_enabled(void) @@ -6352,11 +6445,29 @@ return nwrap_gethostname(name, len); } +static void nwrap_thread_prepare(void) +{ + nwrap_init(); + NWRAP_LOCK_ALL; +} + +static void nwrap_thread_parent(void) +{ + NWRAP_UNLOCK_ALL; +} + +static void nwrap_thread_child(void) +{ + NWRAP_REINIT_ALL; +} + /**************************** * CONSTRUCTOR ***************************/ void nwrap_constructor(void) { + NWRAP_REINIT_ALL; + /* * If we hold a lock and the application forks, then the child * is not able to unlock the mutex and we are in a deadlock. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nss_wrapper-1.1.12/tests/CMakeLists.txt new/nss_wrapper-1.1.13/tests/CMakeLists.txt --- old/nss_wrapper-1.1.12/tests/CMakeLists.txt 2020-04-02 13:37:22.000000000 +0200 +++ new/nss_wrapper-1.1.13/tests/CMakeLists.txt 2022-11-09 07:45:15.000000000 +0100 @@ -66,6 +66,13 @@ list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/hosts) list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_MODULE_SO_PATH=${CMAKE_CURRENT_BINARY_DIR}/libnss_nwrap.so) list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_MODULE_FN_PREFIX=nwrap) + if (CMAKE_BUILD_TYPE) + string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) + + if (CMAKE_BUILD_TYPE_LOWER STREQUAL "threadsanitizer") + list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_DISABLE_DEEPBIND=1) + endif() + endif() set_property(TEST ${_TEST_NAME}
