[SCM] NSS Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Mon Nov 7 10:05:56 UTC 2022


The branch, master has been updated
       via  ff54c5b gitlab-ci: Add runner for ThreadSanitizer
       via  84a24c2 gitlab-ci: Format yaml file
       via  a5687c3 gitlab-ci: Add stages
       via  8a495a5 nwrap: Add NWRAP_REINIT_ALL to initialize mutexes
       via  92f0f6a nwrap: Remove unneeded nss_module_symbol_binding_mutex
       via  8c35ff4 nwrap: Bind symbols only once
       via  5461b4e nwrap: Introduce nwrap_mutex_(un)lock() for better debugging
       via  5187e32 nwrap: Move nwrap_thread_*() to the end
       via  da2f3f5 nwrap: Fix mutex unlocking in nwrap_init()
       via  71e56b8 tests: Disable deep binding with ThreadSanitizer
       via  4dab609 cmake: Add support for ThreadSanitizer
       via  b698b7e Add editorconfig
      from  ea36a64 Bump version to 1.1.12

https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ff54c5b94eed33ae86cd2cea6e70300d828259c9
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Fri Nov 4 09:46:06 2022 +0100

    gitlab-ci: Add runner for ThreadSanitizer
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 84a24c27ab3f935e06783c3aefad33f1d349c128
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Fri Nov 4 09:48:31 2022 +0100

    gitlab-ci: Format yaml file
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit a5687c30077ae177c49d8e18a8a7b2ec0c4bb5ce
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Fri Nov 4 09:44:44 2022 +0100

    gitlab-ci: Add stages
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 8a495a5e9a4977f7226dce8da334f5fb4a724225
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 4 14:47:16 2022 +0100

    nwrap: Add NWRAP_REINIT_ALL to initialize mutexes
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 92f0f6a93037685fdb7fffbacc32efdc13a2980a
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 4 14:35:50 2022 +0100

    nwrap: Remove unneeded nss_module_symbol_binding_mutex
    
    This loading of nss symbols already is protected by the mutex of nwrap_init().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 8c35ff4bd5bfdcc61a57dc81cbc165901d81f02b
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 4 14:24:54 2022 +0100

    nwrap: Bind symbols only once
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5461b4e9403f1a39ed3de1f63368ce180529e68a
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 4 13:57:23 2022 +0100

    nwrap: Introduce nwrap_mutex_(un)lock() for better debugging
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5187e32fcc89271c02480221c896eb6ed70ecc78
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 4 13:52:05 2022 +0100

    nwrap: Move nwrap_thread_*() to the end
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit da2f3f5ce3828f572415c168555274cf51fd9d9c
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Fri Nov 4 13:19:55 2022 +0100

    nwrap: Fix mutex unlocking in nwrap_init()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 71e56b8abea3cbbc6f461f4fb426faf46c5a09c9
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 4 14:41:19 2022 +0100

    tests: Disable deep binding with ThreadSanitizer
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 4dab609787bf58db4a652694a9c05067bc9be1a0
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Fri Nov 4 09:42:06 2022 +0100

    cmake: Add support for ThreadSanitizer
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit b698b7e17615c8434f0c0e2f815cc314fbcf0f36
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Fri Nov 4 13:26:19 2022 +0100

    Add editorconfig
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 .editorconfig                           |  23 +++
 .gitlab-ci.yml                          | 220 +++++++++++---------
 cmake/Modules/DefineCompilerFlags.cmake |  12 ++
 src/nss_wrapper.c                       | 343 +++++++++++++++++++++-----------
 tests/CMakeLists.txt                    |   7 +
 5 files changed, 397 insertions(+), 208 deletions(-)
 create mode 100644 .editorconfig


Changeset truncated at 500 lines:

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..bbe1bd5
--- /dev/null
+++ b/.editorconfig
@@ -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 --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dbf5351..f35b1f3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,4 @@
+---
 variables:
   BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images
   FEDORA_BUILD: buildenv-fedora
@@ -6,18 +7,24 @@ variables:
   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 @@ centos7/x86_64:
       - 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 @@ fedora/x86_64:
       - 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 @@ fedora/address-sanitizer:
       - 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 @@ fedora/undefined-sanitizer:
       - 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 @@ fedora/csbuild:
       - 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 at cwrap/nss_wrapper
-  - branches at cryptomilk/nss_wrapper
+    - branches at cwrap/nss_wrapper
+    - branches at cryptomilk/nss_wrapper
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -130,17 +162,18 @@ freebsd/x86_64:
       - 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 @@ tumbleweed/x86_64/gcc:
       - 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 @@ tumbleweed/x86_64/gcc7:
       - 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 @@ tumbleweed/x86_64/clang:
       - 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 @@ tumbleweed/static-analysis:
       - 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 --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index 3277b99..c92182d 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -34,4 +34,16 @@ if (UNIX AND NOT WIN32)
         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 --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 88e81d9..07c9757 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -177,17 +177,6 @@ typedef nss_status_t NSS_STATUS;
 #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_he_global_mutex = PTHREAD_MUTEX_INITIALIZER;
 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;
-}


-- 
NSS Wrapper Repository



More information about the samba-cvs mailing list