[SCM] UID Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Jan 17 13:35:16 UTC 2023


The branch, master has been updated
       via  2e0adc7 gitlab-ci: run .gitlab-ci.yml also on branches at metze/uid_wrapper
       via  465806a gitlab-ci: Add runner with ThreadSanitizer
       via  c2c4339 gitlab-ci: Introduce stages
       via  cacb76a gitlab-ci: Format yml correctly that ymllint is happy
       via  a86fe7e cmake: Disable deepbind if we run with sanitizers
       via  5541386 cmake: Add -DCMAKE_BUILD_TYPE=ThreadSanitizer
       via  6d309f8 tests: test socket_wrapper_syscall_{valid,va} interaction using uwrap_fake_socket_wrapper.so
       via  f9aeff7 src/uid_wrapper.c: make use of socket_wrapper_syscall_{valid,va}()
       via  da63f38 src/uid_wrapper.c: export uid_wrapper_syscall_{valid,va}()
       via  759f431 src/uid_wrapper.c: fix mutex fork handling
       via  681eb37 src/uid_wrapper.c: check for uid_wrapper related syscall numbers before uid_wrapper_enabled()
       via  1c7324b src/uid_wrapper.c: force RTLD_NEXT for pthread_create/exit() if available
       via  cf818b5 src/uid_wrapper.c: fix RTLD_NEXT handling for libpthread
       via  30bbcea src/uid_wrapper.c: Avoid dclose(RTLD_NEXT)
       via  15627c3 src/uid_wrapper.c: always go through uwrap_bind_symbol_all() protected by pthread_once()
       via  b2dff92 tests: fix data race in test_thread_sync_setreuid.c
       via  206542f tests: fix locking in test_thread_setuid.c
       via  9adb464 src/uid_wrapper.c: also log the process name
       via  1cc448d cmake: Check for getprogname()
       via  fb887e3 src/uid_wrapper.c: remove unused UWRAP_LIBSOCKET and UWRAP_LIBNSL
      from  6223b58 Add clang-format config file

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


- Log -----------------------------------------------------------------
commit 2e0adc7a0a6cdfe479a8225aa03d0286a1ef2b96
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 14 11:28:54 2023 +0100

    gitlab-ci: run .gitlab-ci.yml also on branches at metze/uid_wrapper
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 465806ac345a1599bb21202d6311b9fddb3f8096
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Sat Jan 14 09:39:44 2023 +0100

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

commit c2c4339d62ddcc64262681474dd9bc16d3b5dbce
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Sat Jan 14 09:36:26 2023 +0100

    gitlab-ci: Introduce stages
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit cacb76add5022583e0db16cb1cce0d2483157a35
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Sat Jan 14 09:33:45 2023 +0100

    gitlab-ci: Format yml correctly that ymllint is happy
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit a86fe7ebb737045cfb90a618a54e4429f6168a08
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Sat Jan 14 09:30:17 2023 +0100

    cmake: Disable deepbind if we run with sanitizers
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 5541386b1ffe7bd5561221c7f1931126fb6586b9
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Sat Jan 14 09:21:55 2023 +0100

    cmake: Add -DCMAKE_BUILD_TYPE=ThreadSanitizer
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 6d309f8b31493766f99d5f288550b1c33100bde8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 21:41:09 2023 +0100

    tests: test socket_wrapper_syscall_{valid,va} interaction using uwrap_fake_socket_wrapper.so
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit f9aeff77b2b2e7776f13239bab548bb5af717f8a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 11:22:02 2023 +0100

    src/uid_wrapper.c: make use of socket_wrapper_syscall_{valid,va}()
    
    If we find socket_wrapper_syscall_{valid,va}() symbols in the already
    loaded libraries, we'll try to hand over syscall() invocations to
    socket_wrapper.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit da63f387bf85da1ad95b112fb3ef513399b2254c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 11:42:05 2023 +0100

    src/uid_wrapper.c: export uid_wrapper_syscall_{valid,va}()
    
    We need to hook into syscall() from uid_wrapper as well as
    from socket_wrapper() (and maybe others in future).
    But the assumption is that only one wrapper will take care
    of a single syscall number.
    
    So we provide uid_wrapper_syscall_valid() in order to allow
    external consumers (e.g. socket_wrapper.so) to check if
    uid_wrapper wants to handle a specified syscall number.
    
    And we provide uid_wrapper_syscall_va() in order to allow
    calling into uwrap_syscall().
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 759f4317756b4c70cbf1943ff66a4c714a7e5030
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 8 20:31:35 2022 +0100

    src/uid_wrapper.c: fix mutex fork handling
    
    We need to use pthread_mutex_init in the child handler...
    See https://sourceware.org/bugzilla/show_bug.cgi?id=2745
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 681eb371ee03f2f85f50900842b04911fc75e103
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 11:27:32 2023 +0100

    src/uid_wrapper.c: check for uid_wrapper related syscall numbers before uid_wrapper_enabled()
    
    On FreeBSD syscall() is called after the pthread_atfork() 'prepare'
    hooks. So we need to avoid calling uid_wrapper_enabled() as it would
    deadlock.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 1c7324bd295b51cf06e0e8e1e61c494723ff8751
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 15:20:00 2023 +0100

    src/uid_wrapper.c: force RTLD_NEXT for pthread_create/exit() if available
    
    This is needed as thread sanatizer also overloads pthread_create and
    pthread_exit().
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit cf818b501be24bcfcad7157d2eb29f3404c85844
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jan 13 20:48:25 2023 +0100

    src/uid_wrapper.c: fix RTLD_NEXT handling for libpthread
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15228
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 30bbcea2b7a142c7e361806f5fdf0e145b915f7d
Author: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date:   Thu Nov 10 18:34:12 2022 +0000

    src/uid_wrapper.c: Avoid dclose(RTLD_NEXT)
    
    In case the libc was not found and RTLD_NEXT is used instead, we should not
    dlclose it, otherwise mayhem happens.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15228
    
    Signed-off-by: Samuel Thibault <samuel.thibault at ens-lyon.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 15627c333aa250a8a47414847bc6923d21d0a2b7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 8 20:08:40 2022 +0100

    src/uid_wrapper.c: always go through uwrap_bind_symbol_all() protected by pthread_once()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15227
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit b2dff923b6f804efcd95f1d6e88ea340a59f9ae3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 16:23:36 2023 +0100

    tests: fix data race in test_thread_sync_setreuid.c
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 206542fa9d393e851643a27c26fff638780d42f9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 16 15:43:21 2023 +0100

    tests: fix locking in test_thread_setuid.c
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 9adb464ed062225ea54e64db77d3c85e8b2e5700
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 8 21:30:18 2022 +0100

    src/uid_wrapper.c: also log the process name
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 1cc448d515b7a39e04edacbb02fc0dc01a3af493
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Sat Jan 14 09:57:13 2023 +0100

    cmake: Check for getprogname()
    
    Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit fb887e36a53f91fd53d3a61e721f8e5d1c03d9fd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 8 20:40:44 2022 +0100

    src/uid_wrapper.c: remove unused UWRAP_LIBSOCKET and UWRAP_LIBNSL
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 .gitlab-ci.yml                          | 231 +++++++------
 ConfigureChecks.cmake                   |   2 +
 cmake/Modules/DefineCompilerFlags.cmake |  12 +
 config.h.cmake                          |   3 +
 src/uid_wrapper.c                       | 552 +++++++++++++++++++++++++++-----
 tests/CMakeLists.txt                    |  20 ++
 tests/test_syscall_swrap.c              |  50 +++
 tests/test_thread_setuid.c              |  21 +-
 tests/test_thread_sync_setreuid.c       |  15 +-
 tests/uwrap_fake_socket_wrapper.c       |  44 +++
 tests/uwrap_fake_socket_wrapper.h       |   7 +
 11 files changed, 775 insertions(+), 182 deletions(-)
 create mode 100644 tests/test_syscall_swrap.c
 create mode 100644 tests/uwrap_fake_socket_wrapper.c
 create mode 100644 tests/uwrap_fake_socket_wrapper.h


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0cdb0ea..1a4a3b0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,4 @@
+---
 variables:
   GIT_DEPTH: 3
   BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images
@@ -7,18 +8,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
@@ -26,18 +33,19 @@ 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_INSTALL_PREFIX=/tmp/local
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure && make install
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_INSTALL_PREFIX=/tmp/local
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure && make install
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -45,17 +53,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
@@ -63,16 +72,36 @@ 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
+    - 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:$TUMBLEWEED_BUILD
+  script:
+    - 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
@@ -80,32 +109,33 @@ fedora/undefined-sanitizer:
       - obj/
 
 fedora/csbuild:
+  stage: analysis
   variables:
     GIT_DEPTH: 20
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
   script:
-  - |
-    if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
-        export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~15")
-    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}~15")
-
-    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
+    - |
+      if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
+          export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~15")
+      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}~15")
+
+      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
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -113,20 +143,22 @@ 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/uid_wrapper
-  - branches at cryptomilk/uid_wrapper
+    - branches at cwrap/uid_wrapper
+    - branches at cryptomilk/uid_wrapper
+    - branches at metze/uid_wrapper
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -134,17 +166,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
@@ -152,18 +185,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
@@ -171,18 +205,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
@@ -190,20 +225,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
@@ -211,17 +247,18 @@ 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/ConfigureChecks.cmake b/ConfigureChecks.cmake
index e299f6e..3201131 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -68,6 +68,8 @@ check_function_exists(getgroups HAVE_GETGROUPS)
 check_function_exists(__getgroups_chk HAVE___GETGROUPS_CHK)
 check_function_exists(setgroups HAVE_SETGROUPS)
 
+check_function_exists(getprogname HAVE_GETPROGNAME)
+
 if (HAVE_SETGROUPS)
     check_prototype_definition(setgroups
         "int setgroups(int size, const gid_t *list)"
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/config.h.cmake b/config.h.cmake
index 5b342e3..dde70ec 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -53,6 +53,9 @@
 #cmakedefine HAVE_SYSCALL 1
 #cmakedefine HAVE_SYSCALL_INT 1
 
+/* Define to 1 if you have the `getprogname' function. */
+#cmakedefine HAVE_GETPROGNAME 1
+
 /*************************** LIBRARIES ***************************/
 
 /**************************** OPTIONS ****************************/
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index f04642a..5b6a82b 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -44,25 +44,6 @@
 # define UWRAP_THREAD
 #endif
 
-# define UWRAP_LOCK(m) do { \
-	pthread_mutex_lock(&( m ## _mutex)); \
-} while(0)
-
-# define UWRAP_UNLOCK(m) do { \
-	pthread_mutex_unlock(&( m ## _mutex)); \
-} while(0)
-
-/* Add new global locks here please */
-# define UWRAP_LOCK_ALL \
-	UWRAP_LOCK(uwrap_id); \
-	UWRAP_LOCK(libc_symbol_binding); \
-	UWRAP_LOCK(libpthread_symbol_binding)
-
-# define UWRAP_UNLOCK_ALL \
-	UWRAP_UNLOCK(libpthread_symbol_binding); \
-	UWRAP_UNLOCK(libc_symbol_binding); \
-	UWRAP_UNLOCK(uwrap_id)
-
 #ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
 #define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
 #else
@@ -142,6 +123,19 @@ enum uwrap_dbglvl_e {
 	UWRAP_LOG_TRACE
 };
 
+#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 uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *function, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
 # define UWRAP_LOG(dbglvl, ...) uwrap_log((dbglvl), __func__, __VA_ARGS__)
 
@@ -152,6 +146,7 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *function, const ch
 	const char *d;
 	unsigned int lvl = 0;
 	const char *prefix = "UWRAP";
+	const char *progname = getprogname();
 
 	d = getenv("UID_WRAPPER_DEBUGLEVEL");
 	if (d != NULL) {
@@ -181,9 +176,14 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *function, const ch
 			break;
 	}
 
+	if (progname == NULL) {
+		progname = "<unknown>";
+	}
+
 	fprintf(stderr,
-		"%s(%d) - %s: %s\n",
+		"%s[%s (%u)] - %s: %s\n",
 		prefix,
+		progname,
 		(int)getpid(),
 		function,
 		buffer);
@@ -298,6 +298,28 @@ struct uwrap_libc_symbols {
 };
 #undef UWRAP_SYMBOL_ENTRY
 
+#define UWRAP_SYMBOL_ENTRY(i)         \
+	union {                       \
+		__rtld_default_##i f; \
+		void *obj;            \
+	} _rtld_default_##i
+
+#ifdef HAVE_SYSCALL
+typedef bool (*__rtld_default_socket_wrapper_syscall_valid)(long int sysno);
+typedef long int (*__rtld_default_socket_wrapper_syscall_va)(long int sysno,
+							     va_list va);


-- 
UID Wrapper Repository



More information about the samba-cvs mailing list