[SCM] UID Wrapper Repository - branch master updated

2023-08-08 Thread Andreas Schneider
The branch, master has been updated
   via  c8bf3ae tests: Fix fake socket_wrapper_syscall_valid()
  from  850f24c cmake: Fix cmocka >= 1.1.6 find_package() in CONFIG mode

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


- Log -
commit c8bf3ae675b47726d65e83e3abf62cafa93b12e6
Author: Andreas Schneider 
Date:   Mon Aug 7 14:22:54 2023 +0200

tests: Fix fake socket_wrapper_syscall_valid()

We want to return errno = ENOSYS in socket_wrapper_syscall_va(). However if 
we
do not handle __FAKE_SOCKET_WRAPPER_SYSCALL_NO+1 then we will call
libc_syscall() for __FAKE_SOCKET_WRAPPER_SYSCALL_NO+1.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15445
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15448

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 tests/uwrap_fake_socket_wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/tests/uwrap_fake_socket_wrapper.c 
b/tests/uwrap_fake_socket_wrapper.c
index 657873a..0472b45 100644
--- a/tests/uwrap_fake_socket_wrapper.c
+++ b/tests/uwrap_fake_socket_wrapper.c
@@ -23,7 +23,7 @@
 /* simulate socket_wrapper hooks */
 bool socket_wrapper_syscall_valid(long int sysno)
 {
-   if (sysno == __FAKE_SOCKET_WRAPPER_SYSCALL_NO) {
+   if (sysno >= __FAKE_SOCKET_WRAPPER_SYSCALL_NO) {
return true;
}
 


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2023-02-27 Thread Andreas Schneider
The branch, master has been updated
   via  850f24c cmake: Fix cmocka >= 1.1.6 find_package() in CONFIG mode
  from  9db9f48 cmake: Print a message that uid_wrapper was found with 
find_package()

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


- Log -
commit 850f24c6366abda30bfd77734b90330b8809d306
Author: Andreas Schneider 
Date:   Fri Feb 17 17:51:27 2023 +0100

cmake: Fix cmocka >= 1.1.6 find_package() in CONFIG mode

Signed-off-by: Andreas Schneider 
Reviewed-by: Pavel Filipenský 

---

Summary of changes:
 tests/CMakeLists.txt | 4 
 1 file changed, 4 insertions(+)


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 635e86e..68e050e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,5 +1,9 @@
 project(tests C)
 
+if (TARGET cmocka::cmocka)
+set(CMOCKA_LIBRARY cmocka::cmocka)
+endif()
+
 add_library(uwrap_fake_socket_wrapper SHARED uwrap_fake_socket_wrapper.c)
 target_compile_options(uwrap_fake_socket_wrapper
PRIVATE


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2023-01-25 Thread Andreas Schneider
The branch, master has been updated
   via  9db9f48 cmake: Print a message that uid_wrapper was found with 
find_package()
   via  bcda60d cmake: Improve version detection to support ranges
  from  0e0 Bump version to 1.3.0

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


- Log -
commit 9db9f48cfff026f11c6882811d205c2a16589517
Author: Andreas Schneider 
Date:   Tue Jan 24 11:03:43 2023 +0100

cmake: Print a message that uid_wrapper was found with find_package()

Signed-off-by: Andreas Schneider 
Reviewed-by: Pavel Filipenský 

commit bcda60d404ab0c9fc7a5bf8f5e5fd81cef8d6862
Author: Andreas Schneider 
Date:   Tue Jan 24 11:03:18 2023 +0100

cmake: Improve version detection to support ranges

Signed-off-by: Andreas Schneider 
Reviewed-by: Pavel Filipenský 

---

Summary of changes:
 CMakeLists.txt  |  2 ++
 uid_wrapper-config-version.cmake.in | 41 +++--
 uid_wrapper-config.cmake.in | 15 +-
 3 files changed, 51 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c11220a..1523bd7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,8 @@ install(
 )
 
 # cmake config files
+set(PACKAGE_NAME "uid_wrapper")
+set(PACKAGE_NAME_UPPER "UID_WRAPPER")
 configure_file(uid_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake @ONLY)
 configure_file(uid_wrapper-config.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config.cmake @ONLY)
 install(
diff --git a/uid_wrapper-config-version.cmake.in 
b/uid_wrapper-config-version.cmake.in
index 4bff45e..c59f6c8 100644
--- a/uid_wrapper-config-version.cmake.in
+++ b/uid_wrapper-config-version.cmake.in
@@ -1,11 +1,40 @@
 set(PACKAGE_VERSION @PROJECT_VERSION@)
 
-# Check whether the requested PACKAGE_FIND_VERSION is compatible
-if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
-set(PACKAGE_VERSION_COMPATIBLE FALSE)
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
 else()
-set(PACKAGE_VERSION_COMPATIBLE TRUE)
-if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
-set(PACKAGE_VERSION_EXACT TRUE)
+  if(${PACKAGE_VERSION} MATCHES "^([0-9]+)\\.")
+set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
+  string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
 endif()
+  else()
+set(CVF_VERSION_MAJOR ${PACKAGE_VERSION})
+  endif()
+
+  if(PACKAGE_FIND_VERSION_RANGE)
+# both endpoints of the range must have the expected major version
+math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
+if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT 
PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
+  OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT 
PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND 
PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
+OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND 
PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+endif()
+  else()
+if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+endif()
+
+if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+  set(PACKAGE_VERSION_EXACT TRUE)
+endif()
+  endif()
 endif()
diff --git a/uid_wrapper-config.cmake.in b/uid_wrapper-config.cmake.in
index 43ab1fa..4e77dd6 100644
--- a/uid_wrapper-config.cmake.in
+++ b/uid_wrapper-config.cmake.in
@@ -1 +1,14 @@
-set(UID_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@UID_WRAPPER_LIB@)
+set(@PACKAGE_NAME_UPPER@_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@UID_WRAPPER_LIB@)
+
+# Load information for each installed configuration.
+file(GLOB _cmake_config_files 
"${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-config-*.cmake")
+foreach(_cmake_config_file IN LISTS _cmake_config_files)
+include("${_cmake_config_file}")
+endforeach()
+unset(_cmake_config_files)
+unset(_cmake_config_file)
+
+include(FindPackageMessage)
+find_package_message(@PACKAGE_NAME@
+ "Found @PACKAGE_NAME@: ${@PACKAGE_NAME_UPPER@_LIBRARY} 
(version \"${PACKAGE_VERSION}\")"
+ "[${@PACKAGE_NAME_UPPER@_LIBRARY}][${PACKAGE_VERSION}]")


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2023-01-17 Thread Andreas Schneider
The branch, master has been updated
   via  0e0 Bump version to 1.3.0
   via  e6abc78 Rename to CHANGELOG
  from  2e0adc7 gitlab-ci: run .gitlab-ci.yml also on 
branches@metze/uid_wrapper

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


- Log -
commit 0e0e6eff6488f3bb6a1c55ad8f92b2ea6ee3
Author: Andreas Schneider 
Date:   Tue Jan 17 14:39:42 2023 +0100

Bump version to 1.3.0

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit e6abc78dbd28d554e2c07e0d9ef93dd3e97199b2
Author: Andreas Schneider 
Date:   Tue Jan 17 14:36:14 2023 +0100

Rename to CHANGELOG

Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 ChangeLog => CHANGELOG | 9 +++--
 CMakeLists.txt | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)
 rename ChangeLog => CHANGELOG (91%)


Changeset truncated at 500 lines:

diff --git a/ChangeLog b/CHANGELOG
similarity index 91%
rename from ChangeLog
rename to CHANGELOG
index 3b5f1e8..92542f5 100644
--- a/ChangeLog
+++ b/CHANGELOG
@@ -1,5 +1,10 @@
-ChangeLog
-==
+CHANGELOG
+=
+
+version 1.3.0 (released 2023-01-17)
+  * Added support to interact with socket_wrapper syscall()
+  * Fixed deadlocks with threads
+  * Improved log output
 
 version 1.2.9 (released 2021-12-02)
   * Add support for getgroups_chk()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 457dd72..c11220a 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(uid_wrapper VERSION 1.2.9 LANGUAGES C)
+project(uid_wrapper VERSION 1.3.0 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -23,7 +23,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.1.0")
+set(LIBRARY_VERSION "0.2.0")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2023-01-17 Thread Andreas Schneider
The branch, master has been updated
   via  2e0adc7 gitlab-ci: run .gitlab-ci.yml also on 
branches@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 
Date:   Sat Jan 14 11:28:54 2023 +0100

gitlab-ci: run .gitlab-ci.yml also on branches@metze/uid_wrapper

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Andreas Schneider 

commit 465806ac345a1599bb21202d6311b9fddb3f8096
Author: Andreas Schneider 
Date:   Sat Jan 14 09:39:44 2023 +0100

gitlab-ci: Add runner with ThreadSanitizer

Signed-off-by: Andreas Schneider 
Reviewed-by: Andreas Schneider 

commit c2c4339d62ddcc64262681474dd9bc16d3b5dbce
Author: Andreas Schneider 
Date:   Sat Jan 14 09:36:26 2023 +0100

gitlab-ci: Introduce stages

Signed-off-by: Andreas Schneider 
Reviewed-by: Andreas Schneider 

commit cacb76add5022583e0db16cb1cce0d2483157a35
Author: Andreas Schneider 
Date:   Sat Jan 14 09:33:45 2023 +0100

gitlab-ci: Format yml correctly that ymllint is happy

Signed-off-by: Andreas Schneider 
Reviewed-by: Andreas Schneider 

commit a86fe7ebb737045cfb90a618a54e4429f6168a08
Author: Andreas Schneider 
Date:   Sat Jan 14 09:30:17 2023 +0100

cmake: Disable deepbind if we run with sanitizers

Signed-off-by: Andreas Schneider 
Reviewed-by: Andreas Schneider 

commit 5541386b1ffe7bd5561221c7f1931126fb6586b9
Author: Andreas Schneider 
Date:   Sat Jan 14 09:21:55 2023 +0100

cmake: Add -DCMAKE_BUILD_TYPE=ThreadSanitizer

Signed-off-by: Andreas Schneider 
Reviewed-by: Andreas Schneider 

commit 6d309f8b31493766f99d5f288550b1c33100bde8
Author: Stefan Metzmacher 
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 
Reviewed-by: Andreas Schneider 

commit f9aeff77b2b2e7776f13239bab548bb5af717f8a
Author: Stefan Metzmacher 
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 
Reviewed-by: Andreas Schneider 

commit da63f387bf85da1ad95b112fb3ef513399b2254c
Author: Stefan Metzmacher 
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 
Reviewed-by: Andreas Schneider 

commit 759f4317756b4c70cbf1943ff66a4c714a7e5030
Author: Stefan Metzmacher 
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 

[SCM] UID Wrapper Repository - branch master updated

2023-01-17 Thread Andreas Schneider
The branch, master has been updated
   via  6223b58 Add clang-format config file
   via  4681e51 Add editorconfig
  from  a9189e2 Bump version to 1.2.9

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


- Log -
commit 6223b58f5942d6d245ba696871c193e8f5c4313c
Author: Andreas Schneider 
Date:   Tue Jan 17 11:11:04 2023 +0100

Add clang-format config file

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 4681e51bc0285b6ad77ecdf95cf6c1e6bb53a6ee
Author: Andreas Schneider 
Date:   Tue Jan 17 11:10:28 2023 +0100

Add editorconfig

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 .clang-format | 26 ++
 .editorconfig | 23 +++
 2 files changed, 49 insertions(+)
 create mode 100644 .clang-format
 create mode 100644 .editorconfig


Changeset truncated at 500 lines:

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000..5385807
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,26 @@
+# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+BasedOnStyle: LLVM
+IndentWidth: 8
+ContinuationIndentWidth: 8
+UseTab: true
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterEnum: false
+AfterFunction: true
+AfterStruct: false
+AfterUnion: false
+AfterExternBlock: true
+BeforeElse: false
+BeforeWhile: false
+AllowShortIfStatementsOnASingleLine: false
+ColumnLimit: 80
+IndentCaseLabels: false
+AlignAfterOpenBracket: Align
+BinPackParameters: false
+BinPackArguments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowAllArgumentsOnNextLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AlwaysBreakAfterReturnType: None
+AlignEscapedNewlines: Left
+SortIncludes: false
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000..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


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2021-12-02 Thread Andreas Schneider
The branch, master has been updated
   via  a9189e2 Bump version to 1.2.9
  from  207ecf8 uwrap: Add support for getgroups_chk()

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


- Log -
commit a9189e29e584e89e929fdbfa8abdd04058a75e2f
Author: Andreas Schneider 
Date:   Thu Dec 2 14:41:28 2021 +0100

Bump version to 1.2.9

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 CMakeLists.txt | 4 ++--
 ChangeLog  | 4 
 2 files changed, 6 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e4af2c..457dd72 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(uid_wrapper VERSION 1.2.8 LANGUAGES C)
+project(uid_wrapper VERSION 1.2.9 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -23,7 +23,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.0.9")
+set(LIBRARY_VERSION "0.1.0")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions
diff --git a/ChangeLog b/ChangeLog
index 9dcbd8c..3b5f1e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.2.9 (released 2021-12-02)
+  * Add support for getgroups_chk()
+  * Added (de)contructor support on AIX with pragma init/finish
+
 version 1.2.8 (released 2020-03-05)
   * Fix path in pkgconfig module
   * Fix path in cmake find module


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2021-12-02 Thread Andreas Schneider
The branch, master has been updated
   via  207ecf8 uwrap: Add support for getgroups_chk()
   via  1580b91 config: Add missing define for HAVE_GETGROUPS
   via  2f31c3b Update README.install
   via  4684f31 Update README
  from  f48c658 tests: fix unused-result error in 
tests/test_uwrap_disabled.c

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


- Log -
commit 207ecf82e4c39abab7b557a9f8cdb393d3e8b148
Author: Andreas Schneider 
Date:   Mon Nov 8 16:19:12 2021 +0100

uwrap: Add support for getgroups_chk()

This is required by software built with FORTIFY_SOURCE=2.

https://bugzilla.redhat.com/show_bug.cgi?id=2021214

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 1580b9105190f4643a99b11e9326ed219e589b2b
Author: Andreas Schneider 
Date:   Wed Nov 24 10:49:01 2021 +0100

config: Add missing define for HAVE_GETGROUPS

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 2f31c3b2286a1c5fb55294562d007b6faee8fd2f
Author: Andreas Schneider 
Date:   Mon Nov 8 16:33:46 2021 +0100

Update README.install

This is detected automatically in the meantime.

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 4684f31b16c9931608aa9a15db48893398c8a2d8
Author: Andreas Schneider 
Date:   Wed Mar 25 08:22:00 2020 +0100

Update README

Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 ConfigureChecks.cmake |  1 +
 README.install|  4 
 README.md |  2 +-
 config.h.cmake|  4 
 src/uid_wrapper.c | 41 +
 5 files changed, 47 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 930904e..e299f6e 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -65,6 +65,7 @@ check_function_exists(setregid HAVE_SETREGID)
 check_function_exists(setresgid HAVE_SETRESGID)
 
 check_function_exists(getgroups HAVE_GETGROUPS)
+check_function_exists(__getgroups_chk HAVE___GETGROUPS_CHK)
 check_function_exists(setgroups HAVE_SETGROUPS)
 
 if (HAVE_SETGROUPS)
diff --git a/README.install b/README.install
index c677381..aa05faa 100644
--- a/README.install
+++ b/README.install
@@ -32,10 +32,6 @@ Next, run cmake to configure the build, e.g.
 
   $ cmake -DCMAKE_INSTALL_PREFIX= ..
 
-or on a 64 bit red hat system:
-
-  $  cmake -DCMAKE_INSTALL_PREFIX= -DLIB_SUFFIX=64 ..
-
 The "" should be replaced by the intended installation
 target prefix directory, typically /usr or /usr/local.
 
diff --git a/README.md b/README.md
index eb10497..2a0f57d 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 UID_WRAPPER
 ===
 
-This is a wrapper for the user, group and hosts NSS API.
+This is a testing tool to fake privilege separition without being root.
 
 DESCRIPTION
 ---
diff --git a/config.h.cmake b/config.h.cmake
index 8e05723..5b342e3 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -41,6 +41,10 @@
 /* Define to 1 if you have the `getresgid' function. */
 #cmakedefine HAVE_GETRESGID 1
 
+/* Define to 1 if you have the `getgroups' function. */
+#cmakedefine HAVE_GETGROUPS 1
+#cmakedefine HAVE___GETGROUPS_CHK 1
+
 /* Define to 1 if you have the `setgroups' function. */
 #cmakedefine HAVE_SETGROUPS 1
 #cmakedefine HAVE_SETGROUPS_INT 1
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 4d31f52..f04642a 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -240,6 +240,9 @@ typedef int (*__libc_getresgid)(gid_t *rgid, gid_t *egid, 
gid_t *sgid);
 typedef gid_t (*__libc_getegid)(void);
 
 typedef int (*__libc_getgroups)(int size, gid_t list[]);
+#ifdef HAVE___GETGROUPS_CHK
+typedef int (*__libc___getgroups_chk)(int size, gid_t list[], size_t listlen);
+#endif
 
 typedef int (*__libc_setgroups)(size_t size, const gid_t *list);
 
@@ -285,6 +288,9 @@ struct uwrap_libc_symbols {
 #endif
UWRAP_SYMBOL_ENTRY(getegid);
UWRAP_SYMBOL_ENTRY(getgroups);
+#ifdef HAVE___GETGROUPS_CHK
+   UWRAP_SYMBOL_ENTRY(__getgroups_chk);
+#endif
UWRAP_SYMBOL_ENTRY(setgroups);
 #ifdef HAVE_SYSCALL
UWRAP_SYMBOL_ENTRY(syscall);
@@ -637,6 +643,17 @@ static int libc_getgroups(int size, gid_t list[])
return uwrap.libc.symbols._libc_getgroups.f(size, list);
 }
 
+#ifdef HAVE___GETGROUPS_CHK
+static int libc___getgroups_chk(int size, gid_t list[], size_t listlen)
+{
+   uwrap_bind_symbol_libc(__getgroups_chk);
+
+   return uwrap.libc.symbols._libc___getgroups_chk.f(size,
+ list,
+ listlen);
+}
+#endif /* HAVE___GETGROUPS_CHK */
+
 static int libc_setgroups(size_t size, const gid_t *list)
 {

[SCM] UID Wrapper Repository - branch master updated

2021-11-08 Thread Andreas Schneider
The branch, master has been updated
   via  f48c658 tests: fix unused-result error in 
tests/test_uwrap_disabled.c
   via  9c12a53 tests: fix unused-result error in 
tests/test_setresgid_unprivileged.c
   via  df5a03e uid_wrapper.c: fall back to pragma init/fini for 
constructor/destructor if possible
   via  c011b31 configure: check for pragma init/fini for 
constructors/destructors
  from  c95573e gitlab-ci: Add Ubuntu runner

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


- Log -
commit f48c65812849e0564d66569836f3ee73e58574a2
Author: Björn Jacke 
Date:   Fri Oct 30 18:18:05 2020 +0100

tests: fix unused-result error in tests/test_uwrap_disabled.c

Signed-off-by: Bjoern Jacke 
Reviewed-by: Andreas Schneider 

commit 9c12a53610b4620be4ad96bae1af855eb4e0abdf
Author: Björn Jacke 
Date:   Fri Oct 30 18:03:08 2020 +0100

tests: fix unused-result error in tests/test_setresgid_unprivileged.c

Signed-off-by: Bjoern Jacke 
Reviewed-by: Andreas Schneider 

commit df5a03ef37c8305384d304a357da8a10c1e8edda
Author: Björn Jacke 
Date:   Fri Oct 30 15:23:02 2020 +0100

uid_wrapper.c: fall back to pragma init/fini for constructor/destructor if 
possible

Signed-off-by: Bjoern Jacke 
Reviewed-by: Andreas Schneider 

commit c011b319f7bf953e577a65ea18b9491d8cc9354c
Author: Björn Jacke 
Date:   Fri Oct 30 15:05:36 2020 +0100

configure: check for pragma init/fini for constructors/destructors

Signed-off-by: Bjoern Jacke 
Reviewed-by: Andreas Schneider 

---

Summary of changes:
 ConfigureChecks.cmake   | 26 ++
 config.h.cmake  |  2 ++
 src/uid_wrapper.c   |  7 +++
 tests/test_setresgid_unprivileged.c |  9 ++---
 tests/test_uwrap_disabled.c | 13 +
 5 files changed, 50 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 0e2d84f..930904e 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -163,6 +163,32 @@ int main(void) {
 return 0;
 }" HAVE_DESTRUCTOR_ATTRIBUTE)
 
+check_c_source_compiles("
+#pragma init (test_constructor)
+void test_constructor(void);
+
+void test_constructor(void)
+{
+ return;
+}
+
+int main(void) {
+ return 0;
+}" HAVE_PRAGMA_INIT)
+
+check_c_source_compiles("
+#pragma fini (test_destructor)
+void test_destructor(void);
+
+void test_destructor(void)
+{
+return;
+}
+
+int main(void) {
+return 0;
+}" HAVE_PRAGMA_FINI)
+
 # If this produces a warning treat it as error!
 set(CMAKE_REQUIRED_FLAGS "-Werror")
 check_c_source_compiles("
diff --git a/config.h.cmake b/config.h.cmake
index a3f3815..8e05723 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -61,6 +61,8 @@
 #cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1
 #cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_PRAGMA_INIT 1
+#cmakedefine HAVE_PRAGMA_FINI 1
 #cmakedefine HAVE_ADDRESS_SANITIZER_ATTRIBUTE 1
 #cmakedefine HAVE_FUNCTION_ATTRIBUTE_FORMAT 1
 #cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 6e4a6da..4d31f52 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -374,7 +374,14 @@ static pthread_mutex_t libpthread_symbol_binding_mutex = 
PTHREAD_MUTEX_INITIALIZ
  */
 
 bool uid_wrapper_enabled(void);
+#if ! defined(HAVE_CONSTRUCTOR_ATTRIBUTE) && defined(HAVE_PRAGMA_INIT)
+/* xlC and other oldschool compilers support (only) this */
+#pragma init (uwrap_constructor)
+#endif
 void uwrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
+#if ! defined(HAVE_DESTRUCTOR_ATTRIBUTE) && defined(HAVE_PRAGMA_FINI)
+#pragma fini (uwrap_destructor)
+#endif
 void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*
diff --git a/tests/test_setresgid_unprivileged.c 
b/tests/test_setresgid_unprivileged.c
index 121c2cc..1383d29 100644
--- a/tests/test_setresgid_unprivileged.c
+++ b/tests/test_setresgid_unprivileged.c
@@ -74,7 +74,8 @@ static void test_uwrap_setresgid_unprivileged_uid(void 
**state)
assert_int_equal(cp_egid, 0x0);
assert_int_equal(cp_sgid, 0x0);
 
-   setresuid(0x0, 0x0, 0x0);
+   rc = setresuid(0x0, 0x0, 0x0);
+   assert_int_equal(rc, 0x0);
 }
 
 static void test_uwrap_setresgid_unprivileged_uid_and_gid(void **state)
@@ -129,8 +130,10 @@ static void 
test_uwrap_setresgid_unprivileged_uid_and_gid(void **state)
assert_int_equal(rc, -1);
assert_int_equal(errno, EPERM);
 
-   setresuid(0x0, 0x0, 0x0);
-   setresgid(0x0, 0x0, 0x0);
+   rc = setresuid(0x0, 0x0, 0x0);
+   assert_int_equal(rc, 0x0);
+   rc = setresgid(0x0, 0x0, 0x0);
+   assert_int_equal(rc, 

[SCM] UID Wrapper Repository - branch master updated

2020-03-24 Thread Andreas Schneider
The branch, master has been updated
   via  c95573e gitlab-ci: Add Ubuntu runner
   via  2a9e827 gitlab-ci: Remove debian cross mips build
  from  90f563c Bump version to 1.2.8

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


- Log -
commit c95573e70b339173d9eef2182e1e64e4b4f9a934
Author: Andreas Schneider 
Date:   Tue Mar 24 10:45:45 2020 +0100

gitlab-ci: Add Ubuntu runner

Signed-off-by: Andreas Schneider 
Reviewed-by: Guenther Deschner 

commit 2a9e82727a9a37b0cb0e90cae0795f19705411f1
Author: Andreas Schneider 
Date:   Tue Mar 24 10:44:38 2020 +0100

gitlab-ci: Remove debian cross mips build

This isn't supported by Debian anymore.

Signed-off-by: Andreas Schneider 
Reviewed-by: Guenther Deschner 

---

Summary of changes:
 .gitlab-ci.yml | 44 +++-
 1 file changed, 19 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 34466ad..0cdb0ea 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,7 @@ variables:
   CENTOS7_BUILD: buildenv-centos7
   TUMBLEWEED_BUILD: buildenv-tumbleweed
   MINGW_BUILD: buildenv-mingw
-  DEBIAN_CROSS_BUILD: buildenv-debian-cross
+  UBUNTU_BUILD: buildenv-ubuntu
 
 centos7/x86_64:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
@@ -133,30 +133,6 @@ freebsd/x86_64:
 paths:
   - obj/
 
-.Debian.cross.template: _cross_template
-  stage: test
-  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_CROSS_BUILD
-  script:
-  - build=$(dpkg-architecture -qDEB_HOST_GNU_TYPE)
-  - host="${CI_JOB_NAME#*.cross.}"
-  - mkdir -p obj && cd obj && cmake
--DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-Debian-mips.cmake
--DCMAKE_BUILD_TYPE=RelWithDebInfo
--DUNIT_TESTING=ON .. && make -j$(nproc) &&
-ctest --output-on-failure
-  tags:
-  - shared
-  except:
-  - tags
-  artifacts:
-expire_in: 1 week
-when: on_failure
-paths:
-  - obj/
-
-Debian.cross.mips-linux-gnu:
-  <<: *Debian_cross_template
-
 tumbleweed/x86_64/gcc:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
@@ -233,3 +209,21 @@ tumbleweed/static-analysis:
 when: on_failure
 paths:
   - obj/scan
+
+ubuntu/x86_64:
+  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
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+expire_in: 1 week
+when: on_failure
+paths:
+  - obj/


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2020-03-05 Thread Andreas Schneider
The branch, master has been updated
   via  90f563c Bump version to 1.2.8
   via  f42fb4c cmake: Fix path in cmake config
  from  3d33dcc pkg-config: Fix installation path

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


- Log -
commit 90f563ccb3f1e2e06ba6c4c0cd27299bc1447666
Author: Andreas Schneider 
Date:   Thu Mar 5 15:43:49 2020 +0100

Bump version to 1.2.8

Signed-off-by: Andreas Schneider 
Reviewed-by: Alexander Bokovoy 

commit f42fb4c5ff9a6a050a1af2cf1f80d5eff90dd909
Author: Andreas Schneider 
Date:   Tue Mar 3 10:55:33 2020 +0100

cmake: Fix path in cmake config

Signed-off-by: Andreas Schneider 
Reviewed-by: Alexander Bokovoy 

---

Summary of changes:
 CMakeLists.txt  | 4 ++--
 ChangeLog   | 4 
 uid_wrapper-config.cmake.in | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2fe81b0..2e4af2c 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(uid_wrapper VERSION 1.2.7 LANGUAGES C)
+project(uid_wrapper VERSION 1.2.8 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -23,7 +23,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.0.8")
+set(LIBRARY_VERSION "0.0.9")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions
diff --git a/ChangeLog b/ChangeLog
index e3c6de2..9dcbd8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.2.8 (released 2020-03-05)
+  * Fix path in pkgconfig module
+  * Fix path in cmake find module
+
 version 1.2.7 (released 2019-07-15)
   * Fix unsetting initial XIDs
 
diff --git a/uid_wrapper-config.cmake.in b/uid_wrapper-config.cmake.in
index 0a3e3fd..43ab1fa 100644
--- a/uid_wrapper-config.cmake.in
+++ b/uid_wrapper-config.cmake.in
@@ -1 +1 @@
-set(UID_WRAPPER_LIBRARY @CMAKE_INSTALL_LIBDIR@/@UID_WRAPPER_LIB@)
+set(UID_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@UID_WRAPPER_LIB@)


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2020-03-03 Thread Andreas Schneider
The branch, master has been updated
   via  3d33dcc pkg-config: Fix installation path
  from  ea30cd9 cmake: Remove unsed dir definitions

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


- Log -
commit 3d33dcc550c55bd276183c110eef180728b9911f
Author: Andreas Schneider 
Date:   Wed Feb 12 09:52:40 2020 +0100

pkg-config: Fix installation path

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 uid_wrapper.pc.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/uid_wrapper.pc.cmake b/uid_wrapper.pc.cmake
index c15d3be..7e0095c 100644
--- a/uid_wrapper.pc.cmake
+++ b/uid_wrapper.pc.cmake
@@ -1,4 +1,4 @@
 Name: @PROJECT_NAME@
 Description: The uid_wrapper library
 Version: @PROJECT_VERSION@
-Libs: @CMAKE_INSTALL_LIBDIR@/@UID_WRAPPER_LIB@
+Libs: @CMAKE_INSTALL_FULL_LIBDIR@/@UID_WRAPPER_LIB@


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2019-10-20 Thread Andreas Schneider
The branch, master has been updated
   via  ea30cd9 cmake: Remove unsed dir definitions
   via  f140709 cmake: Fix BINARYDIR and SOURCEDIR
   via  c4eef87 cmake: Remove unused variable
   via  63685a6 cmake: Add missing PICKY_DEVELOPER option
  from  d966dd2 Bump version to 1.2.7

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


- Log -
commit ea30cd99d4d45fc58e7e10555a71716e9aa68380
Author: Andreas Schneider 
Date:   Thu Oct 17 17:36:36 2019 +0200

cmake: Remove unsed dir definitions

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit f140709f325ddb43431b11f655ef94d42a95e172
Author: Andreas Schneider 
Date:   Thu Oct 17 17:36:05 2019 +0200

cmake: Fix BINARYDIR and SOURCEDIR

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit c4eef87e811e1726f13db7c05850f4ce65bf991d
Author: Andreas Schneider 
Date:   Thu Oct 17 15:41:06 2019 +0200

cmake: Remove unused variable

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit 63685a67ef9a606b77f11f348f7224e71985c28e
Author: Andreas Schneider 
Date:   Thu Oct 17 15:33:46 2019 +0200

cmake: Add missing PICKY_DEVELOPER option

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 ConfigureChecks.cmake | 8 ++--
 DefineOptions.cmake   | 1 +
 config.h.cmake| 5 -
 tests/CMakeLists.txt  | 2 --
 4 files changed, 3 insertions(+), 13 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index affe7c6..0e2d84f 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -9,13 +9,9 @@ include(TestBigEndian)
 
 set(PACKAGE ${PROJECT_NAME})
 set(VERSION ${PROJECT_VERSION})
-set(DATADIR ${DATA_INSTALL_DIR})
-set(LIBDIR ${LIB_INSTALL_DIR})
-set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
-set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
 
-set(BINARYDIR ${CMAKE_BINARY_DIR})
-set(SOURCEDIR ${CMAKE_SOURCE_DIR})
+set(BINARYDIR ${uid_wrapper_BINARY_DIR})
+set(SOURCEDIR ${uid_wrapper_SOURCE_DIR})
 
 function(COMPILER_DUMPVERSION _OUTPUT_VERSION)
 # Remove whitespaces from the argument.
diff --git a/DefineOptions.cmake b/DefineOptions.cmake
index 6030e79..8fc654d 100644
--- a/DefineOptions.cmake
+++ b/DefineOptions.cmake
@@ -1 +1,2 @@
 option(UNIT_TESTING "Build with unit tests" OFF)
+option(PICKY_DEVELOPER "Build with picky developer flags" OFF)
diff --git a/config.h.cmake b/config.h.cmake
index 630a17d..a3f3815 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -4,11 +4,6 @@
 /* Version number of package */
 #cmakedefine VERSION "${PROJECT_VERSION}"
 
-#cmakedefine LOCALEDIR "${LOCALE_INSTALL_DIR}"
-#cmakedefine DATADIR "${DATADIR}"
-#cmakedefine LIBDIR "${LIBDIR}"
-#cmakedefine PLUGINDIR "${PLUGINDIR}"
-#cmakedefine SYSCONFDIR "${SYSCONFDIR}"
 #cmakedefine BINARYDIR "${BINARYDIR}"
 #cmakedefine SOURCEDIR "${SOURCEDIR}"
 
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6056937..1ae3d86 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,5 @@
 project(tests C)
 
-set(PRELOAD_LIBS ${UID_WRAPPER_LOCATION})
-
 function(ADD_CMOCKA_TEST_ENVIRONMENT _TEST_NAME)
 if (CMAKE_BUILD_TYPE)
 string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2019-07-16 Thread Andreas Schneider
The branch, master has been updated
   via  d966dd2 Bump version to 1.2.7
   via  52277f6 uwrap: Fix unsetting the the envname of initial XIDs
  from  e00f045 Bump version to 1.2.6

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


- Log -
commit d966dd2709397f334666be681aed8d86e5e9fb28
Author: Andreas Schneider 
Date:   Mon Jul 15 16:17:52 2019 +0200

Bump version to 1.2.7

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit 52277f6fbc2dc144086234eaae6294f43033566a
Author: Andreas Schneider 
Date:   Mon Jul 15 13:58:44 2019 +0200

uwrap: Fix unsetting the the envname of initial XIDs

This issue got introduced by:
1c793e19f1cb8cb33defb171c9ae719ec8a820da

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 CMakeLists.txt| 4 ++--
 ChangeLog | 3 +++
 src/uid_wrapper.c | 4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40c1ded..2fe81b0 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(uid_wrapper VERSION 1.2.6 LANGUAGES C)
+project(uid_wrapper VERSION 1.2.7 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -23,7 +23,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.0.7")
+set(LIBRARY_VERSION "0.0.8")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions
diff --git a/ChangeLog b/ChangeLog
index 8260f35..e3c6de2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 ChangeLog
 ==
 
+version 1.2.7 (released 2019-07-15)
+  * Fix unsetting initial XIDs
+
 version 1.2.6 (released 2019-07-15)
   * Fix manpage installation
   * Fix cmake-config installation
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 84c3ca5..6e4a6da 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -1009,12 +1009,12 @@ static unsigned long uwrap_get_xid_from_env(const char 
*envname)
}
 
if (env[0] == '\0') {
-   unsetenv("UID_WRAPPER_INITIAL_RUID");
+   unsetenv(envname);
return ULONG_MAX;
}
 
xid = strtoul(env, , 10);
-   unsetenv("UID_WRAPPER_INITIAL_RUID");
+   unsetenv(envname);
if (env == endp) {
return ULONG_MAX;
}


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2019-07-15 Thread Andreas Schneider
The branch, master has been updated
   via  e00f045 Bump version to 1.2.6
   via  3cc0798 gitlab-ci: Also test installation
   via  7125f43 cmake: Fix cmake config files install
   via  ac31f4d doc: Fix manpage installation
   via  68d81c6 Bump version to 1.2.5
  from  e9f1f5f doc: Document UID_WRAPPER_DISABLE_DEEPBIND

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


- Log -
commit e00f04550d077fe30ea4e817709e21c3ec7a143f
Author: Andreas Schneider 
Date:   Mon Jul 15 10:57:31 2019 +0200

Bump version to 1.2.6

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit 3cc0798c1519333150a7e09c7636ff6c4c98d292
Author: Andreas Schneider 
Date:   Mon Jul 15 10:56:27 2019 +0200

gitlab-ci: Also test installation

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit 7125f437f8c340f8a2744cf00ce2136dfc4679b3
Author: Andreas Schneider 
Date:   Mon Jul 15 10:53:53 2019 +0200

cmake: Fix cmake config files install

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit ac31f4d88db4307042cc78f820b999af52cdd3e2
Author: Andreas Schneider 
Date:   Mon Jul 15 10:53:32 2019 +0200

doc: Fix manpage installation

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit 68d81c63f4864c2d3337b93a0417ac6dcbcb66b0
Author: Andreas Schneider 
Date:   Mon Jul 15 08:15:22 2019 +0200

Bump version to 1.2.5

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 .gitlab-ci.yml | 3 ++-
 CMakeLists.txt | 6 +++---
 ChangeLog  | 7 +++
 doc/CMakeLists.txt | 2 +-
 4 files changed, 13 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f516947..34466ad 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,10 +29,11 @@ fedora/x86_64:
   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 -j$(nproc) && ctest --output-on-failure && make install
   tags:
   - shared
   except:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cdebea6..40c1ded 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(uid_wrapper VERSION 1.1.5 LANGUAGES C)
+project(uid_wrapper VERSION 1.2.6 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -23,7 +23,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.0.6")
+set(LIBRARY_VERSION "0.0.7")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions
@@ -75,7 +75,7 @@ install(
 ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake
 ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config.cmake
 DESTINATION
-${CMAKE_INSTALL_LIBDIR}/uid_wrapper
+${CMAKE_INSTALL_LIBDIR}/cmake/uid_wrapper
 COMPONENT
 devel
 )
diff --git a/ChangeLog b/ChangeLog
index b57d876..8260f35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
 ChangeLog
 ==
 
+version 1.2.6 (released 2019-07-15)
+  * Fix manpage installation
+  * Fix cmake-config installation
+
+version 1.2.5 (released 2019-07-15)
+  * Fixed running with sanitizers
+
 version 1.2.4 (released 2017-07-24)
   * Added deadlock workaround for glibc < 2.24
   * Fixed a possible deadlock bug if uid_wrapper is turned off
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 7ce0e22..9255c5c 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,4 +1,4 @@
 install(FILES
 uid_wrapper.1
 DESTINATION
-${MAN_INSTALL_DIR}/man1)
+${CMAKE_INSTALL_MANDIR}/man1)


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2019-07-15 Thread Andreas Schneider
The branch, master has been updated
   via  e9f1f5f doc: Document UID_WRAPPER_DISABLE_DEEPBIND
  from  0ae7595 gitlab-ci: Setup CI for uid_wrapper

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


- Log -
commit e9f1f5ff306eb75eec64f6b091be5a086e882ef8
Author: Andreas Schneider 
Date:   Sat Sep 1 19:43:20 2018 +0200

doc: Document UID_WRAPPER_DISABLE_DEEPBIND

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 doc/uid_wrapper.1 | 9 +++--
 doc/uid_wrapper.1.txt | 5 +
 2 files changed, 12 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/doc/uid_wrapper.1 b/doc/uid_wrapper.1
index c66d143..acee141 100644
--- a/doc/uid_wrapper.1
+++ b/doc/uid_wrapper.1
@@ -1,7 +1,7 @@
 '\" t
 .\" Title: uid_wrapper
-.\"Author: [FIXME: author] [see http://docbook.sf.net/el/author]
-.\" Generator: DocBook XSL Stylesheets v1.78.1 
+.\"Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
+.\" Generator: DocBook XSL Stylesheets vsnapshot 
 .\"  Date: 2015-11-03
 .\"Manual: \ \&
 .\"Source: \ \&
@@ -158,6 +158,11 @@ unsetenv("UID_WRAPPER_MYUID");
 .if n \{\
 .RE
 .\}
+.PP
+\fBUID_WRAPPER_DISABLE_DEEPBIND\fR
+.RS 4
+This allows you to disable deep binding in uid_wrapper\&. This is useful for 
running valgrind tools or sanitizers like (address, undefined, thread)\&.
+.RE
 .SH "EXAMPLE"
 .sp
 .if n \{\
diff --git a/doc/uid_wrapper.1.txt b/doc/uid_wrapper.1.txt
index 699d2c1..c40cdfa 100644
--- a/doc/uid_wrapper.1.txt
+++ b/doc/uid_wrapper.1.txt
@@ -64,6 +64,11 @@ uid = geteuid();
 unsetenv("UID_WRAPPER_MYUID");
 --
 
+*UID_WRAPPER_DISABLE_DEEPBIND*::
+
+This allows you to disable deep binding in uid_wrapper. This is useful for
+running valgrind tools or sanitizers like (address, undefined, thread).
+
 EXAMPLE
 ---
 


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2019-06-03 Thread Andreas Schneider
The branch, master has been updated
   via  0ae7595 gitlab-ci: Setup CI for uid_wrapper
   via  12fe095 cmake: Use GNUInstallDirs
   via  bc50185 tests: Don't run test_uwrap_disabled with sanitizers
   via  89ff574 cmake: Correctly set _GNU_SOURCE
   via  f8bc8c2 cmake: Fix configure check for libdl
   via  4ed04f4 cmake: Use target_include_directories()
   via  a25fbab cmake: Update AddCMockaTest.cmake
   via  e372761 cmake: Update cmocka requirement
   via  896a138 cmake: Support running the tests with AddressSanitizer
   via  de52edb cmake: Add AddressSanitizer and UndefinedSanitizer
   via  19a5414 cmake: Move Compiler flags to new file
   via  40955ff cmake: Remove obsolete DefineCompilerFlags.cmake
   via  14c4982 cmake: Improve checks for compiler flags
   via  11e2e2d cmake: Update CMake defaults
   via  b1c6704 cmake: Do not misuse CMAKE_REQUIRED_LIBRARIES
   via  37a8e23 cmake: Require at least cmake 3.5.0
   via  b657bce cpack: Fix description and vendor
   via  67280b7 README: Rename to a markdown file
   via  f8c7170 uwrap: Remove problematic FALL_THROUGH in 
uwrap_load_lib_handle()
   via  2273c8e uwrap: Don't do a deep bind if we run with libasan
  from  77f7ce8 ctest: Move to new dashboard

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


- Log -
commit 0ae7595d48913c552ddd259a990612adfb4413fd
Author: Andreas Schneider 
Date:   Tue May 7 13:03:37 2019 +0200

gitlab-ci: Setup CI for uid_wrapper

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 12fe095e01c6e2ee18ba864677d409c0d4afd529
Author: Andreas Schneider 
Date:   Tue May 7 13:02:04 2019 +0200

cmake: Use GNUInstallDirs

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit bc501857f00d6f0d5f3fc150dd73adca7dfed83c
Author: Andreas Schneider 
Date:   Tue May 7 12:58:49 2019 +0200

tests: Don't run test_uwrap_disabled with sanitizers

or on cross compiled hosts (Debian MIPS).

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 89ff574c381b6e4cc462d58e3fad9e434e362bfe
Author: Andreas Schneider 
Date:   Tue May 7 12:57:32 2019 +0200

cmake: Correctly set _GNU_SOURCE

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit f8bc8c21ce91eaf6da92abfbda3ce5621cf2075d
Author: Andreas Schneider 
Date:   Tue May 7 12:46:47 2019 +0200

cmake: Fix configure check for libdl

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 4ed04f4d6a5093edabb9b2d97de42b1d7505a0f1
Author: Andreas Schneider 
Date:   Tue May 7 12:45:48 2019 +0200

cmake: Use target_include_directories()

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit a25fbab6607e792d491f884f28b18dbcce5970a0
Author: Andreas Schneider 
Date:   Tue May 7 12:39:55 2019 +0200

cmake: Update AddCMockaTest.cmake

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit e3727612fe1487cebf10d0f65666efba308a6adc
Author: Andreas Schneider 
Date:   Tue May 7 12:33:15 2019 +0200

cmake: Update cmocka requirement

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 896a138b23ed3835967a00abfa1799131f01231a
Author: Andreas Schneider 
Date:   Tue May 7 12:32:29 2019 +0200

cmake: Support running the tests with AddressSanitizer

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit de52edbf5cd9d2a0fd3153ce1e05e0b5168086d6
Author: Andreas Schneider 
Date:   Tue May 7 12:16:11 2019 +0200

cmake: Add AddressSanitizer and UndefinedSanitizer

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 19a5414aadccae4a35cead4f9579e2c03d18cc1c
Author: Andreas Schneider 
Date:   Tue May 7 12:15:16 2019 +0200

cmake: Move Compiler flags to new file

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 40955ffad292d9d175c9a49d9b44d8bb19072b79
Author: Andreas Schneider 
Date:   Tue May 7 12:12:30 2019 +0200

cmake: Remove obsolete DefineCompilerFlags.cmake

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 14c4982ec5b211c6ae9294405810972aed3e2920
Author: Andreas Schneider 
Date:   Tue May 7 12:11:45 2019 +0200

cmake: Improve checks for compiler flags

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit 11e2e2d38a3390753d2031776d2bee6325e690ea
Author: Andreas Schneider 
Date:   Tue May 7 12:06:25 2019 +0200

cmake: Update CMake defaults

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 

commit b1c6704c5c3c46fe5a99a79a9caa8b4213046490
Author: Andreas Schneider 
Date:   Tue May 7 12:05:16 2019 +0200

cmake: Do not misuse CMAKE_REQUIRED_LIBRARIES

Signed-off-by: Andreas Schneider 
Reviewed-by: Gary Lockyer 


[SCM] UID Wrapper Repository - branch master updated

2018-08-13 Thread Andreas Schneider
The branch, master has been updated
   via  77f7ce8 ctest: Move to new dashboard
   via  9d79861 Rename COPYING to LICENSE
   via  4918b93 uwrap: Suppress fall through warnings
   via  30e36d7 cpack: Do not package build dirs in source tarball
   via  a71c89f cmake: Replace deprecated get_target_property()
  from  1c793e1 uwrap: Improve parsing IDs from env variables

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


- Log -
commit 77f7ce8d54dcf44fe63a3290943d8987adc26a9a
Author: Andreas Schneider 
Date:   Thu Jul 5 10:15:50 2018 +0200

ctest: Move to new dashboard

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit 9d79861ed979a2ca01e4a97cf66385c759332a74
Author: Andreas Schneider 
Date:   Fri Jun 22 08:50:38 2018 +0200

Rename COPYING to LICENSE

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit 4918b93a26d9f82290e00bd15614a48963b23e3a
Author: Andreas Schneider 
Date:   Thu Aug 3 10:48:45 2017 +0200

uwrap: Suppress fall through warnings

Suppress fall through warning in switch statement where the fall trough
is intentional.

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit 30e36d7feb38ad2d8dad07e8b4acc6b23149a3d1
Author: Andreas Schneider 
Date:   Fri Jun 22 08:59:32 2018 +0200

cpack: Do not package build dirs in source tarball

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit a71c89f1ba48acaebff743853d10a02757ad1a0b
Author: Andreas Schneider 
Date:   Fri Jun 22 08:56:02 2018 +0200

cmake: Replace deprecated get_target_property()

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

---

Summary of changes:
 CPackConfig.cmake |  4 ++--
 CTestConfig.cmake |  6 +++---
 ConfigureChecks.cmake | 27 +++
 COPYING => LICENSE|  0
 config.h.cmake|  1 +
 src/CMakeLists.txt|  7 +--
 src/uid_wrapper.c | 12 ++--
 7 files changed, 44 insertions(+), 13 deletions(-)
 rename COPYING => LICENSE (100%)


Changeset truncated at 500 lines:

diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index 6c40f4d..e1b83ac 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -7,7 +7,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The SSH library")
 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
 set(CPACK_PACKAGE_VENDOR "The SSH Library Development Team")
 set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
 
 
 ### versions
@@ -19,7 +19,7 @@ set(CPACK_PACKAGE_VERSION 
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO
 
 ### source generator
 set(CPACK_SOURCE_GENERATOR "TGZ")
-set(CPACK_SOURCE_IGNORE_FILES 
"~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;/obj*/;tags;cscope.*")
+set(CPACK_SOURCE_IGNORE_FILES 
"~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build*;/obj*;tags;cscope.*")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME 
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
 
 if (WIN32)
diff --git a/CTestConfig.cmake b/CTestConfig.cmake
index 19bd287..7ba804c 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -1,9 +1,9 @@
 set(UPDATE_TYPE "true")
 
 set(CTEST_PROJECT_NAME "uid_wrapper")
-set(CTEST_NIGHTLY_START_TIME "01:00:00 CET")
+set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
 
 set(CTEST_DROP_METHOD "https")
-set(CTEST_DROP_SITE "mock.cryptomilk.org")
-set(CTEST_DROP_LOCATION "/submit.php?project=uidwrapper")
+set(CTEST_DROP_SITE "test.cmocka.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}")
 set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 150d89b..910a255 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -188,6 +188,33 @@ int main(void) {
 return 0;
 }" HAVE_FUNCTION_ATTRIBUTE_FORMAT)
 
+check_c_source_compiles("
+#define FALL_THROUGH __attribute__((fallthrough))
+
+enum direction_e {
+UP = 0,
+DOWN,
+};
+
+int main(void) {
+enum direction_e key = UP;
+int i = 10;
+int j = 0;
+
+switch (key) {
+case UP:
+i = 5;
+FALL_THROUGH;
+case DOWN:
+j = i * 2;
+break;
+default:
+break;
+}
+
+return 0;
+}" HAVE_FALLTHROUGH_ATTRIBUTE)
+
 # SYSTEM LIBRARIES
 
 check_library_exists(dl dlopen "" HAVE_LIBDL)
diff --git a/COPYING b/LICENSE
similarity index 100%
rename from COPYING
rename to LICENSE
diff --git a/config.h.cmake b/config.h.cmake
index b862048..c32af7b 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -68,6 +68,7 @@
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_ADDRESS_SANITIZER_ATTRIBUTE 1
 #cmakedefine HAVE_FUNCTION_ATTRIBUTE_FORMAT 1
+#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
 
 

[SCM] UID Wrapper Repository - branch master updated

2017-08-01 Thread Andreas Schneider
The branch, master has been updated
   via  1c793e1 uwrap: Improve parsing IDs from env variables
   via  7d12d4e uwrap: Fix integer overflowed argument
  from  111ac8e uwrap: Use calloc to allocate groups array

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


- Log -
commit 1c793e19f1cb8cb33defb171c9ae719ec8a820da
Author: Andreas Schneider 
Date:   Tue Aug 1 08:14:30 2017 +0200

uwrap: Improve parsing IDs from env variables

Signed-off-by: Andreas Schneider 
Reviewed-by: Volker Lendecke 

commit 7d12d4eb01ee0d0d1bd3ee1d02f20d99009c4c73
Author: Andreas Schneider 
Date:   Tue Aug 1 08:11:28 2017 +0200

uwrap: Fix integer overflowed argument

The previous fix did not address the conversion from 64bit to 32bit.

CID 165232

Signed-off-by: Andreas Schneider 
Reviewed-by: Volker Lendecke 

---

Summary of changes:
 src/uid_wrapper.c | 89 +++
 1 file changed, 57 insertions(+), 32 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index b3d12c5..9c4b0ee 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -34,6 +34,7 @@
 #include 
 #endif
 #include 
+#include 
 
 #include 
 
@@ -972,6 +973,31 @@ static void uwrap_thread_child(void)
UWRAP_UNLOCK_ALL;
 }
 
+static unsigned long uwrap_get_xid_from_env(const char *envname)
+{
+   unsigned long xid;
+   const char *env = NULL;
+   char *endp = NULL;
+
+   env = getenv(envname);
+   if (env == NULL) {
+   return ULONG_MAX;
+   }
+
+   if (env[0] == '\0') {
+   unsetenv("UID_WRAPPER_INITIAL_RUID");
+   return ULONG_MAX;
+   }
+
+   xid = strtoul(env, , 10);
+   unsetenv("UID_WRAPPER_INITIAL_RUID");
+   if (env == endp) {
+   return ULONG_MAX;
+   }
+
+   return xid;
+}
+
 /*
  * This initializes uid_wrapper with the IDs exported to the environment. Those
  * are normally set after we forked and executed.
@@ -980,56 +1006,55 @@ static void uwrap_init_env(struct uwrap_thread *id)
 {
const char *env;
int ngroups = 0;
+   unsigned long xid;
 
-   env = getenv("UID_WRAPPER_INITIAL_RUID");
-   if (env != NULL && env[0] != '\0') {
-   UWRAP_LOG(UWRAP_LOG_DEBUG, "Initialize ruid with %s", env);
-   id->ruid = strtoul(env, (char **)NULL, 10);
-   unsetenv("UID_WRAPPER_INITIAL_RUID");
+   /* UIDs */
+   xid = uwrap_get_xid_from_env("UID_WRAPPER_INITIAL_RUID");
+   if (xid != ULONG_MAX) {
+   id->ruid = (uid_t)xid;
}
 
-   env = getenv("UID_WRAPPER_INITIAL_EUID");
-   if (env != NULL && env[0] != '\0') {
-   UWRAP_LOG(UWRAP_LOG_DEBUG, "Initalize euid with %s", env);
-   id->euid = strtoul(env, (char **)NULL, 10);
-   unsetenv("UID_WRAPPER_INITIAL_EUID");
+   xid = uwrap_get_xid_from_env("UID_WRAPPER_INITIAL_EUID");
+   if (xid != ULONG_MAX) {
+   id->euid = (uid_t)xid;
}
 
-   env = getenv("UID_WRAPPER_INITIAL_SUID");
-   if (env != NULL && env[0] != '\0') {
-   UWRAP_LOG(UWRAP_LOG_DEBUG, "Initalize suid with %s", env);
-   id->suid = strtoul(env, (char **)NULL, 10);
-   unsetenv("UID_WRAPPER_INITIAL_SUID");
+   xid = uwrap_get_xid_from_env("UID_WRAPPER_INITIAL_SUID");
+   if (xid != ULONG_MAX) {
+   id->suid = (uid_t)xid;
}
 
-   env = getenv("UID_WRAPPER_INITIAL_RGID");
-   if (env != NULL && env[0] != '\0') {
-   UWRAP_LOG(UWRAP_LOG_DEBUG, "Initialize ruid with %s", env);
-   id->rgid = strtoul(env, (char **)NULL, 10);
-   unsetenv("UID_WRAPPER_INITIAL_RGID");
+   /* GIDs */
+   xid = uwrap_get_xid_from_env("UID_WRAPPER_INITIAL_RGID");
+   if (xid != ULONG_MAX) {
+   id->rgid = (gid_t)xid;
}
 
-   env = getenv("UID_WRAPPER_INITIAL_EGID");
-   if (env != NULL && env[0] != '\0') {
-   UWRAP_LOG(UWRAP_LOG_DEBUG, "Initalize egid with %s", env);
-   id->egid = strtoul(env, (char **)NULL, 10);
-   unsetenv("UID_WRAPPER_INITIAL_EGID");
+   xid = uwrap_get_xid_from_env("UID_WRAPPER_INITIAL_EGID");
+   if (xid != ULONG_MAX) {
+   id->egid = (gid_t)xid;
}
 
-   env = getenv("UID_WRAPPER_INITIAL_SGID");
-   if (env != NULL && env[0] != '\0') {
-   UWRAP_LOG(UWRAP_LOG_DEBUG, "Initalize sgid with %s", env);
-   id->sgid = strtoul(env, (char **)NULL, 10);
-   unsetenv("UID_WRAPPER_INITIAL_SGID");
+   xid = 

[SCM] UID Wrapper Repository - branch master updated

2017-07-31 Thread Andreas Schneider
The branch, master has been updated
   via  111ac8e uwrap: Use calloc to allocate groups array
   via  857dba0 uwrap: Fix integer overflowed argument
  from  701a0d0 Bump version to 1.2.4

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


- Log -
commit 111ac8ebdafacb9370d94bd6eb20ef8ded67ec35
Author: Andreas Schneider 
Date:   Thu Jul 27 15:55:58 2017 +0200

uwrap: Use calloc to allocate groups array

Signed-off-by: Andreas Schneider 
Reviewed-by: Volker Lendecke 

commit 857dba064c93d4dbef77c2ab00fdb8253b2eee89
Author: Volker Lendecke 
Date:   Thu Jul 27 15:55:18 2017 +0200

uwrap: Fix integer overflowed argument

Found by Coverity

Signed-off-by: Volker Lendecke 
Reviewed-by: Andreas Schneider 

---

Summary of changes:
 src/uid_wrapper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 0d74d20..b3d12c5 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -749,7 +749,7 @@ static int uwrap_pthread_create(pthread_t *thread,
 
UWRAP_LOCK(uwrap_id);
 
-   args->id->groups = malloc(sizeof(gid_t) * src_id->ngroups);
+   args->id->groups = calloc(src_id->ngroups, sizeof(gid_t));
if (args->id->groups == NULL) {
UWRAP_UNLOCK(uwrap_id);
SAFE_FREE(args->id);
@@ -1035,7 +1035,7 @@ static void uwrap_init_env(struct uwrap_thread *id)
id->ngroups = 0;
 
free(id->groups);
-   id->groups = malloc(sizeof(gid_t) * ngroups);
+   id->groups = calloc(ngroups, sizeof(gid_t));
if (id->groups == NULL) {
UWRAP_LOG(UWRAP_LOG_ERROR,
  "Unable to allocate memory");


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2017-07-27 Thread Andreas Schneider
The branch, master has been updated
   via  701a0d0 Bump version to 1.2.4
  from  4ec0dfc uwrap: Add a workaround for glibc malloc mutex deadlock bug

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


- Log -
commit 701a0d03503ee1cd5263afe94bb09b2ff67078d1
Author: Andreas Schneider 
Date:   Fri Jul 21 11:58:08 2017 +0200

Bump version to 1.2.4

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 CMakeLists.txt | 2 +-
 ChangeLog  | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 97f0e30..9dba9d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
 set(APPLICATION_VERSION_MINOR "2")
-set(APPLICATION_VERSION_PATCH "3")
+set(APPLICATION_VERSION_PATCH "4")
 
 set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
diff --git a/ChangeLog b/ChangeLog
index 33a879e..b57d876 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.2.4 (released 2017-07-24)
+  * Added deadlock workaround for glibc < 2.24
+  * Fixed a possible deadlock bug if uid_wrapper is turned off
+
 version 1.2.3 (released 2017-07-14)
   * Logging is always turned on now
   * Fixed a memory leak


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2017-07-21 Thread Andreas Schneider
The branch, master has been updated
   via  4ec0dfc uwrap: Add a workaround for glibc malloc mutex deadlock bug
   via  d178906 uwrap: First do garbage collection before exporting ids
   via  0bfd224 tests: Add setgroups to test_fork_exec
   via  2fae075 uwrap: Improve groups string creation
   via  e242f39 uwrap: Make the unsigned_str smaller
   via  c1a6e70 uwrap: Fix type of len value
   via  f1d0330 uwrap: Fix two error messages
   via  61139e0 uwrap: Fix a typo
   via  6568b53 uwrap: Fix a deadlock if uid_wrapper is not enabled
   via  8fb7450 uwrap: Fix logging on optimized build
  from  7386dc6 Bump version to 1.2.3

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


- Log -
commit 4ec0dfc252961c411f8770560236a3c27596b3ad
Author: Andreas Schneider 
Date:   Fri Jul 21 10:54:05 2017 +0200

uwrap: Add a workaround for glibc malloc mutex deadlock bug

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit d178906bcd1f1e2a067e7ddfdf82d24cb49128c7
Author: Andreas Schneider 
Date:   Wed Jul 19 16:27:05 2017 +0200

uwrap: First do garbage collection before exporting ids

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 0bfd22468247105523a171ffbbe8678de07b1a55
Author: Andreas Schneider 
Date:   Wed Jul 19 16:22:39 2017 +0200

tests: Add setgroups to test_fork_exec

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 2fae075fd0b1a3aef2041118e16755edbedc3a90
Author: Andreas Schneider 
Date:   Wed Jul 19 15:57:34 2017 +0200

uwrap: Improve groups string creation

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit e242f39a5abf93d9b4b6ffbef1b808e2926739a2
Author: Andreas Schneider 
Date:   Wed Jul 19 15:44:32 2017 +0200

uwrap: Make the unsigned_str smaller

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit c1a6e70d62aa14efab4bf41ce2230b76aa455807
Author: Andreas Schneider 
Date:   Wed Jul 19 15:43:13 2017 +0200

uwrap: Fix type of len value

snprintf return an 'int'.

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit f1d03308d84944914318053314112cdfcc6222da
Author: Andreas Schneider 
Date:   Wed Jul 19 12:15:16 2017 +0200

uwrap: Fix two error messages

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 61139e06f4479d41bed166a0b2b6185d50a11dd3
Author: Andreas Schneider 
Date:   Wed Jul 19 12:14:15 2017 +0200

uwrap: Fix a typo

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 6568b531e58cb387a306c17f9c30ff599c30b81c
Author: Andreas Schneider 
Date:   Fri Jul 21 08:28:50 2017 +0200

uwrap: Fix a deadlock if uid_wrapper is not enabled

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 8fb7450712e94a6e1ceaddab4ac2a4d9670d715a
Author: Andreas Schneider 
Date:   Fri Jul 21 11:39:59 2017 +0200

uwrap: Fix logging on optimized build

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 src/uid_wrapper.c  | 92 ++
 tests/test_fork_exec.c |  7 
 2 files changed, 70 insertions(+), 29 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 0e9be96..0d74d20 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -825,7 +825,7 @@ static void uwrap_export_ids(struct uwrap_thread *id)
 {
char groups_str[GROUP_STRING_SIZE] = {0};
size_t groups_str_size = sizeof(groups_str);
-   char unsigned_str[32] = {0};
+   char unsigned_str[16] = {0}; /* We need 10 + 1 (+ 1) */
int i;
 
/* UIDS */
@@ -851,35 +851,51 @@ static void uwrap_export_ids(struct uwrap_thread *id)
if (id->ngroups > GROUP_MAX_COUNT) {
UWRAP_LOG(UWRAP_LOG_ERROR,
  "ERROR: Number of groups (%u) exceeds maximum value "
- "uid_wrapper will handle (%u).",
+ "uid_wrapper can handle (%u).",
  id->ngroups,
  GROUP_MAX_COUNT);
exit(-1);
}
 
  

[SCM] UID Wrapper Repository - branch master updated

2017-07-14 Thread Andreas Schneider
The branch, master has been updated
   via  7386dc6 Bump version to 1.2.3
   via  4cbcf1f uwrap: Do an early return if log level doesn't match
   via  c59500e uwrap: Always enable logging
   via  a337fc9 uwrap: Add log message before exit
   via  3a43ef7 uwrap: Add mamximum for groups we can handle while forking
   via  c71fb12 uwrap: Do not leak groups_str
  from  27e9f76 Bump version to 1.2.2

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


- Log -
commit 7386dc6dfa2e4b78e1616acbdff88efc8e089dd7
Author: Andreas Schneider 
Date:   Fri Jul 14 10:39:53 2017 +0200

Bump version to 1.2.3

Signed-off-by: Andreas Schneider 
Blessed-by: Stefan Metzmacher 

commit 4cbcf1fd1746bbc2e933401628a2cb71c0f1c45d
Author: Andreas Schneider 
Date:   Fri Jul 14 10:34:48 2017 +0200

uwrap: Do an early return if log level doesn't match

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit c59500ee54aa95ebbc43c43ada06eeab41267cd7
Author: Andreas Schneider 
Date:   Fri Jul 14 10:33:46 2017 +0200

uwrap: Always enable logging

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit a337fc93269d50a265df1f568a99db490865702f
Author: Andreas Schneider 
Date:   Fri Jul 14 10:31:05 2017 +0200

uwrap: Add log message before exit

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 3a43ef7330fc84e61c8545709e36440affd26950
Author: Andreas Schneider 
Date:   Fri Jul 14 09:05:26 2017 +0200

uwrap: Add mamximum for groups we can handle while forking

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit c71fb1219b9d08f7faf27a15977163bb7c86c7a0
Author: Andreas Schneider 
Date:   Fri Jul 14 09:07:19 2017 +0200

uwrap: Do not leak groups_str

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 CMakeLists.txt|  2 +-
 ChangeLog |  7 +-
 src/uid_wrapper.c | 71 +--
 3 files changed, 50 insertions(+), 30 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4dc42f2..97f0e30 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
 set(APPLICATION_VERSION_MINOR "2")
-set(APPLICATION_VERSION_PATCH "2")
+set(APPLICATION_VERSION_PATCH "3")
 
 set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
diff --git a/ChangeLog b/ChangeLog
index cc02554..33a879e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
 ChangeLog
 ==
 
-version 1.2.2 (released 2107-07-13)
+version 1.2.3 (released 2017-07-14)
+  * Logging is always turned on now
+  * Fixed a memory leak
+  * Limited number of groups during fork+exec
+
+version 1.2.2 (released 2017-07-13)
   * Added support for fork'ed and then exec'ed processes
   * Added support for Alpha
 
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 6e39eb6..0e9be96 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -133,9 +133,6 @@ enum uwrap_dbglvl_e {
UWRAP_LOG_TRACE
 };
 
-#ifdef NDEBUG
-# define UWRAP_LOG(...)
-#else /* NDEBUG */
 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__)
 
@@ -145,42 +142,43 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const 
char *function, const ch
va_list va;
const char *d;
unsigned int lvl = 0;
+   const char *prefix = "UWRAP";
 
d = getenv("UID_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) {
-   const char *prefix = "UWRAP";
-   switch (dbglvl) {
-   case UWRAP_LOG_ERROR:
-   prefix = "UWRAP_ERROR";
-   break;
-   case UWRAP_LOG_WARN:
-   prefix = "UWRAP_WARN";
-   break;
-   case UWRAP_LOG_DEBUG:
-   prefix = "UWRAP_DEBUG";
-   break;
-

[SCM] UID Wrapper Repository - branch master updated

2017-07-13 Thread Andreas Schneider
The branch, master has been updated
   via  27e9f76 Bump version to 1.2.2
   via  6d69fef tests: Add a fork and exec test
   via  b5168be uwrap: Add support to initialize groups while forking
  from  0580449 tests: fix a comment typo

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


- Log -
commit 27e9f76f1ddc72987f0323f19341b2b6afefa5cd
Author: Andreas Schneider 
Date:   Wed Jul 12 13:03:35 2017 +0200

Bump version to 1.2.2

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 6d69fefcc5b39cf2007ad9b43fe4972c3b835d80
Author: Andreas Schneider 
Date:   Wed Jul 12 09:16:30 2017 +0200

tests: Add a fork and exec test

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit b5168be4128d7585c30ba98da31926cd3d0066e5
Author: Andreas Schneider 
Date:   Tue Jul 11 11:59:33 2017 +0200

uwrap: Add support to initialize groups while forking

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 CMakeLists.txt |   2 +-
 ChangeLog  |   4 ++
 src/uid_wrapper.c  | 163 +
 tests/CMakeLists.txt   |   4 +-
 tests/mock_exec_uid.c  | 157 +++
 tests/test_fork_exec.c |  88 ++
 6 files changed, 416 insertions(+), 2 deletions(-)
 create mode 100644 tests/mock_exec_uid.c
 create mode 100644 tests/test_fork_exec.c


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 898440e..4dc42f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
 set(APPLICATION_VERSION_MINOR "2")
-set(APPLICATION_VERSION_PATCH "1")
+set(APPLICATION_VERSION_PATCH "2")
 
 set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
diff --git a/ChangeLog b/ChangeLog
index 6f776de..cc02554 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.2.2 (released 2107-07-13)
+  * Added support for fork'ed and then exec'ed processes
+  * Added support for Alpha
+
 version 1.2.1 (released 2016-03-16)
   * Documented missing options.
   * Fixed a comipilation issue with -O3.
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index ded857a..6e39eb6 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -815,6 +815,66 @@ int pthread_create(pthread_t *thread,
  * UWRAP ID HANDLING
  */
 
+#define GROUP_STRING_SIZE 16384
+
+/**
+ * This function exports all the IDs of the current user so if
+ * we fork and then exec we can setup uid_wrapper in the new process
+ * with those IDs.
+ */
+static void uwrap_export_ids(struct uwrap_thread *id)
+{
+   char groups_str[GROUP_STRING_SIZE] = {0};
+   size_t groups_str_size = sizeof(groups_str);
+   char unsigned_str[32] = {0};
+   int i;
+
+   /* UIDS */
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->ruid);
+   setenv("UID_WRAPPER_INITIAL_RUID", unsigned_str, 1);
+
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->euid);
+   setenv("UID_WRAPPER_INITIAL_EUID", unsigned_str, 1);
+
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->suid);
+   setenv("UID_WRAPPER_INITIAL_SUID", unsigned_str, 1);
+
+   /* GIDS */
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->rgid);
+   setenv("UID_WRAPPER_INITIAL_RGID", unsigned_str, 1);
+
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->egid);
+   setenv("UID_WRAPPER_INITIAL_EGID", unsigned_str, 1);
+
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->sgid);
+   setenv("UID_WRAPPER_INITIAL_SGID", unsigned_str, 1);
+
+   /* GROUPS */
+   snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->ngroups);
+   setenv("UID_WRAPPER_INITIAL_GROUPS_COUNT", unsigned_str, 1);
+
+   for (i = 0; i < id->ngroups; i++) {
+   size_t groups_str_len = strlen(groups_str);
+   size_t groups_str_avail = groups_str_size - groups_str_len;
+   size_t len;
+
+   len = snprintf(unsigned_str, sizeof(unsigned_str), ",%u", 
id->groups[i]);
+   if (len <= 1) {
+   continue;
+   }
+   if (len < groups_str_avail) {
+   snprintf(groups_str + groups_str_len,
+groups_str_size - groups_str_len,
+"%s",
+i == 0 ? unsigned_str + 1 : unsigned_str);
+  

[SCM] UID Wrapper Repository - branch master updated

2016-09-22 Thread Andreas Schneider
The branch, master has been updated
   via  0580449 tests: fix a comment typo
  from  c026252 tests: Use alpha-specific syscalls.

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


- Log -
commit 0580449fc4749f7340c1904f90b385f809430e72
Author: Michael Adam 
Date:   Thu Sep 22 02:29:34 2016 +0200

tests: fix a comment typo

Signed-off-by: Michael Adam 
Reviewed-by: Andreas Schneider 

---

Summary of changes:
 tests/test_thread_sync_setreuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_thread_sync_setreuid.c 
b/tests/test_thread_sync_setreuid.c
index 1e6d68c..a30e8a3 100644
--- a/tests/test_thread_sync_setreuid.c
+++ b/tests/test_thread_sync_setreuid.c
@@ -123,7 +123,7 @@ static void test_sync_setreuid(void **state)
   (void *)[i]);
}
 
-   /* wait for the reads to set euid to 0 */
+   /* wait for the threads to set euid to 0 */
for (i = 0; i < NUM_THREADS; i++) {
while (p[i].ready != 1) {
sleep(1);


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2016-06-06 Thread Andreas Schneider
The branch, master has been updated
   via  c026252 tests: Use alpha-specific syscalls.
   via  cf2b353 uwrap: Use alpha-specific syscalls.
   via  a00a6b8 uwrap: Attempt to dlopen libc.so.*.1 as a fallback.
  from  2bd91fc Bump version to 1.2.1

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


- Log -
commit c026252807478862e9d718b00b6ae4493a84b976
Author: Matt Turner 
Date:   Tue Apr 5 13:28:56 2016 -0700

tests: Use alpha-specific syscalls.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11821

Signed-off-by: Matt Turner 
Reviewed-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit cf2b35344d4de927f158a1e6d5b6bbc1be2ffd96
Author: Matt Turner 
Date:   Tue Apr 5 13:28:30 2016 -0700

uwrap: Use alpha-specific syscalls.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11821

Signed-off-by: Matt Turner 
Reviewed-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

commit a00a6b8b300b7baa867191e2bc016b835cf8d1b3
Author: Matt Turner 
Date:   Tue Apr 5 13:41:13 2016 -0700

uwrap: Attempt to dlopen libc.so.*.1 as a fallback.

glibc on Alpha and IA64 is libc.so.6.1.

Without this, uwrap.libc.handle is set to RTLD_NEXT, leading to a
segmentation fault in the unit tests when dlclose() is called.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11821

Signed-off-by: Matt Turner 
Reviewed-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 src/uid_wrapper.c   | 15 +++
 tests/test_syscall.c|  4 
 tests/test_syscall_gid.c|  4 
 tests/test_syscall_setuid.c |  4 
 4 files changed, 27 insertions(+)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 743d590..ded857a 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -407,6 +407,13 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
if (handle != NULL) {
break;
}
+
+   /* glibc on Alpha and IA64 is libc.so.6.1 */
+   snprintf(soname, sizeof(soname), 
"libc.so.%d.1", i);
+   handle = dlopen(soname, flags);
+   if (handle != NULL) {
+   break;
+   }
}
 
uwrap.libc.handle = handle;
@@ -1894,7 +1901,11 @@ static long int uwrap_syscall (long int sysno, va_list 
vp)
 
switch (sysno) {
/* gid */
+#ifdef __alpha__
+   case SYS_getxgid:
+#else
case SYS_getgid:
+#endif
 #ifdef HAVE_LINUX_32BIT_SYSCALLS
case SYS_getgid32:
 #endif
@@ -1963,7 +1974,11 @@ static long int uwrap_syscall (long int sysno, va_list 
vp)
 #endif /* SYS_getresgid && HAVE_GETRESGID */
 
/* uid */
+#ifdef __alpha__
+   case SYS_getxuid:
+#else
case SYS_getuid:
+#endif
 #ifdef HAVE_LINUX_32BIT_SYSCALLS
case SYS_getuid32:
 #endif
diff --git a/tests/test_syscall.c b/tests/test_syscall.c
index c43f1f9..912686f 100644
--- a/tests/test_syscall.c
+++ b/tests/test_syscall.c
@@ -26,7 +26,11 @@ static void test_uwrap_syscall(void **state)
 
(void) state; /* unused */
 
+#ifdef __alpha__
+   rc = syscall(SYS_getxpid);
+#else
rc = syscall(SYS_getpid);
+#endif
assert_int_equal(rc, getpid());
 
ZERO_STRUCT(tv1);
diff --git a/tests/test_syscall_gid.c b/tests/test_syscall_gid.c
index 3ccdd4a..5664dc2 100644
--- a/tests/test_syscall_gid.c
+++ b/tests/test_syscall_gid.c
@@ -33,7 +33,11 @@ static void test_uwrap_syscall_setgid(void **state)
 
g = getgid();
assert_int_equal(g, 1);
+#ifdef __alpha__
+   assert_int_equal(g, syscall(SYS_getxgid));
+#else
assert_int_equal(g, syscall(SYS_getgid));
+#endif
 }
 
 static void test_uwrap_syscall_setregid(void **state)
diff --git a/tests/test_syscall_setuid.c b/tests/test_syscall_setuid.c
index fbe9200..d237e27 100644
--- a/tests/test_syscall_setuid.c
+++ b/tests/test_syscall_setuid.c
@@ -69,7 +69,11 @@ static void test_uwrap_syscall_setuid(void **state)
 
u = getuid();
assert_int_equal(u, );
+#ifdef __alpha
+   assert_int_equal(u, syscall(SYS_getxuid));
+#else
assert_int_equal(u, syscall(SYS_getuid));
+#endif
 
rc = syscall(SYS_setuid, 0);
assert_int_equal(rc, -1);


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2016-03-18 Thread Andreas Schneider
The branch, master has been updated
   via  2bd91fc Bump version to 1.2.1
  from  3df97e0 uwrap: Make sure prefix is not used uninitialized

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


- Log -
commit 2bd91fc2049d88612260f083cd604112bec4c83b
Author: Andreas Schneider 
Date:   Wed Mar 16 14:53:37 2016 +0100

Bump version to 1.2.1

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 CMakeLists.txt | 4 ++--
 ChangeLog  | 4 
 2 files changed, 6 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2c6699..898440e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
 set(APPLICATION_VERSION_MINOR "2")
-set(APPLICATION_VERSION_PATCH "0")
+set(APPLICATION_VERSION_PATCH "1")
 
 set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.0.5")
+set(LIBRARY_VERSION "0.0.6")
 set(LIBRARY_SOVERSION "0")
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 70c659f..6f776de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.2.1 (released 2016-03-16)
+  * Documented missing options.
+  * Fixed a comipilation issue with -O3.
+
 version 1.2.0 (released 2015-10-29)
   * Added privilege checks for all set*uid and set*gid functions.
   * Added a lot more and accurate tests which work as root.


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-11-13 Thread Andreas Schneider
The branch, master has been updated
   via  3df97e0 uwrap: Make sure prefix is not used uninitialized
  from  18a6057 doc: Document missing options

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


- Log -
commit 3df97e0e690fe811f620ee9afef898bf896eb41c
Author: Andreas Schneider 
Date:   Fri Nov 13 13:46:24 2015 +0100

uwrap: Make sure prefix is not used uninitialized

Signed-off-by: Andreas Schneider 

---

Summary of changes:
 src/uid_wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index ab47dd0..743d590 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -156,7 +156,7 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const 
char *function, const ch
va_end(va);
 
if (lvl >= dbglvl) {
-   const char *prefix;
+   const char *prefix = "UWRAP";
switch (dbglvl) {
case UWRAP_LOG_ERROR:
prefix = "UWRAP_ERROR";


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-11-03 Thread Andreas Schneider
The branch, master has been updated
   via  18a6057 doc: Document missing options
  from  4ae5073 Bump version to 1.2.0

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


- Log -
commit 18a60576e396c3944b72a5e631957393a5db05b1
Author: Andreas Schneider 
Date:   Tue Nov 3 10:54:07 2015 +0100

doc: Document missing options

Signed-off-by: Andreas Schneider 

---

Summary of changes:
 doc/uid_wrapper.1 | 43 ---
 doc/uid_wrapper.1.txt | 36 ++--
 2 files changed, 74 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/doc/uid_wrapper.1 b/doc/uid_wrapper.1
index 0faff95..c66d143 100644
--- a/doc/uid_wrapper.1
+++ b/doc/uid_wrapper.1
@@ -2,12 +2,12 @@
 .\" Title: uid_wrapper
 .\"Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 
-.\"  Date: 2014-07-11
+.\"  Date: 2015-11-03
 .\"Manual: \ \&
 .\"Source: \ \&
 .\"  Language: English
 .\"
-.TH "UID_WRAPPER" "1" "2014\-07\-11" "\ \&" "\ \&"
+.TH "UID_WRAPPER" "1" "2015\-11\-03" "\ \&" "\ \&"
 .\" -
 .\" * Define some portability stuff
 .\" -
@@ -139,6 +139,25 @@ If you need to see what is going on in uid_wrapper itself 
or try to find a bug,
 3 = TRACE
 .RE
 .RE
+.PP
+\fBUID_WRAPPER_MYUID\fR
+.RS 4
+This environment variable can be used to tell uid_wrapper to let geteuid() 
return the real (instead of the faked) UID of the user who started the process 
with uid_wrapper\&.
+.RE
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+uid_t uid;
+
+setenv("UID_WRAPPER_MYUID", "1", 1);
+uid = geteuid();
+unsetenv("UID_WRAPPER_MYUID");
+.fi
+.if n \{\
+.RE
+.\}
 .SH "EXAMPLE"
 .sp
 .if n \{\
@@ -146,8 +165,26 @@ If you need to see what is going on in uid_wrapper itself 
or try to find a bug,
 .\}
 .nf
 $ LD_PRELOAD=libuid_wrapper\&.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 id
-uid=0(root) gid=0(root) groups=100(users),0(root)
+uid=0(root) gid=0(root) 0(root)
 .fi
 .if n \{\
 .RE
 .\}
+.SH "WORKAROUNDS"
+.sp
+If you need to write code that behaves differently depending on whether 
uid_wrapper is enabled or not, for example in cases where you have to file 
permissions, you can predefine the uid_wrapper_enabled() function in your 
project as follows:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+bool uid_wrapper_enabled(void)
+{
+return false;
+}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Since uid_wrapper overloads this function if enabled, you can use it in your 
code to detect uid_wrapper\&.
diff --git a/doc/uid_wrapper.1.txt b/doc/uid_wrapper.1.txt
index dec69e6..699d2c1 100644
--- a/doc/uid_wrapper.1.txt
+++ b/doc/uid_wrapper.1.txt
@@ -1,6 +1,6 @@
 uid_wrapper(1)
 ==
-:revdate: 2014-07-11
+:revdate: 2015-11-03
 
 NAME
 
@@ -50,8 +50,40 @@ debug symbols.
 - 2 = DEBUG
 - 3 = TRACE
 
+*UID_WRAPPER_MYUID*::
+
+This environment variable can be used to tell uid_wrapper to let geteuid()
+return the real (instead of the faked) UID of the user who started the process
+with uid_wrapper.
+
+--
+uid_t uid;
+
+setenv("UID_WRAPPER_MYUID", "1", 1);
+uid = geteuid();
+unsetenv("UID_WRAPPER_MYUID");
+--
+
 EXAMPLE
 ---
 
   $ LD_PRELOAD=libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 id
-  uid=0(root) gid=0(root) groups=100(users),0(root)
+  uid=0(root) gid=0(root) 0(root)
+
+WORKAROUNDS
+---
+
+If you need to write code that behaves differently depending on whether
+uid_wrapper is  enabled or not, for example in cases where you have to file
+permissions, you can predefine the uid_wrapper_enabled() function in your
+project as follows:
+
+--
+bool uid_wrapper_enabled(void)
+{
+return false;
+}
+--
+
+Since uid_wrapper overloads this function if enabled, you can use it in your
+code to detect uid_wrapper.


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-10-29 Thread Andreas Schneider
The branch, master has been updated
   via  4ae5073 Bump version to 1.2.0
   via  625802d tests: Add checks for return values in test_thread_setreuid
  from  f0a2720 tests: Rename test_syscall_gid32 to test_syscall_setgroups32

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


- Log -
commit 4ae50736aab63bbcb6ddce6b84aa9e7228a0d531
Author: Andreas Schneider 
Date:   Thu Oct 29 08:21:21 2015 +0100

Bump version to 1.2.0

Signed-off-by: Andreas Schneider 

commit 625802d1049a2d59a61acfab52d753134a0f1fed
Author: Andreas Schneider 
Date:   Thu Oct 29 08:16:32 2015 +0100

tests: Add checks for return values in test_thread_setreuid

CID #131817

Signed-off-by: Andreas Schneider 

---

Summary of changes:
 CMakeLists.txt   | 6 +++---
 ChangeLog| 5 +
 tests/test_thread_setreuid.c | 2 ++
 3 files changed, 10 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4ddb0a..a2c6699 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 2.8.0)
 set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
-set(APPLICATION_VERSION_MINOR "1")
-set(APPLICATION_VERSION_PATCH "1")
+set(APPLICATION_VERSION_MINOR "2")
+set(APPLICATION_VERSION_PATCH "0")
 
 set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
"${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION "0.0.4")
+set(LIBRARY_VERSION "0.0.5")
 set(LIBRARY_SOVERSION "0")
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 7242b20..70c659f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.2.0 (released 2015-10-29)
+  * Added privilege checks for all set*uid and set*gid functions.
+  * Added a lot more and accurate tests which work as root.
+  * Fixed some minor issues
+
 version 1.1.1 (released 2015-08-20)
   * Fixed getres(uid|gid) detection if unsupported.
   * Fixed the configure on Solaris
diff --git a/tests/test_thread_setreuid.c b/tests/test_thread_setreuid.c
index 7679a96..4b40f7b 100644
--- a/tests/test_thread_setreuid.c
+++ b/tests/test_thread_setreuid.c
@@ -49,8 +49,10 @@ static void *syscall_setreuid(void *arg)
assert_int_equal(u, eu);
 
rc = syscall(SYS_setreuid, -1, 0);
+   assert_return_code(rc, errno);
}
rc = syscall(SYS_setreuid, -1, 666);
+   assert_return_code(rc, errno);
 
return NULL;
 }


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-10-28 Thread Andreas Schneider
The branch, master has been updated
   via  f0a2720 tests: Rename test_syscall_gid32 to test_syscall_setgroups32
   via  9d6423c tests: Move syscall setregid32 test to own executable
   via  7927d70 tests: Move syscall setregid32 test to own executable
   via  1a90764 tests: Move syscall setgid32 test to own executable
   via  5ebd9cd tests: Rename syscall setresuid32 test and improve it
   via  b9c3fc4 tests: Move syscall setreuid32 test to own executable
   via  78cc57f tests: Move syscall setuid32 test to own executable
   via  218e642 uwrap: Fix build warning with release build
   via  c273d99 Ignore build and all obj* directories
  from  82ff081 cmake: Run threaded tests also on BSD and Solaris

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


- Log -
commit f0a2720817d5d340ebda554939d303c282359be1
Author: Andreas Schneider 
Date:   Wed Oct 28 09:34:18 2015 +0100

tests: Rename test_syscall_gid32 to test_syscall_setgroups32

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 9d6423cc1e33e5444b8e459e515ca889799656e5
Author: Andreas Schneider 
Date:   Wed Oct 28 09:33:16 2015 +0100

tests: Move syscall setregid32 test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 7927d700b632377d23649c0a325d00047631f345
Author: Andreas Schneider 
Date:   Wed Oct 28 09:23:23 2015 +0100

tests: Move syscall setregid32 test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 1a90764f7effea83b54f3e85bfdf2579ef796218
Author: Andreas Schneider 
Date:   Wed Oct 28 08:36:53 2015 +0100

tests: Move syscall setgid32 test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 5ebd9cd421eda784ecf095e945860631ebbb1a33
Author: Andreas Schneider 
Date:   Wed Oct 28 08:26:32 2015 +0100

tests: Rename syscall setresuid32 test and improve it

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit b9c3fc40cd946c7807cf5afb9c14de8289639c73
Author: Andreas Schneider 
Date:   Wed Oct 28 08:19:43 2015 +0100

tests: Move syscall setreuid32 test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 78cc57fb564738e8e0df11719a60de3b6ebe0c6c
Author: Andreas Schneider 
Date:   Wed Oct 28 08:15:37 2015 +0100

tests: Move syscall setuid32 test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 218e64271dc0947721a0592e48f9f59f73565580
Author: Andreas Schneider 
Date:   Wed Oct 28 08:05:11 2015 +0100

uwrap: Fix build warning with release build

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit c273d99f9091b089081b5bc7a5cfbe00cd164164
Author: Andreas Schneider 
Date:   Wed Oct 28 09:24:08 2015 +0100

Ignore build and all obj* directories

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 .gitignore |   4 +-
 CPackConfig.cmake  |   2 +-
 src/uid_wrapper.c  |   8 ++
 tests/CMakeLists.txt   |   9 +-
 tests/test_syscall_gid32.c | 127 -
 tests/{test_setgid.c => test_syscall_setgid32.c}   |  39 ---
 ...test_setgroups.c => test_syscall_setgroups32.c} |  34 ++
 .../{test_setregid.c => test_syscall_setregid32.c} |  36 +++---
 ...test_setresgid.c => test_syscall_setresgid32.c} |  39 ---
 ...test_setresuid.c => test_syscall_setresuid32.c} |  80 +++--
 .../{test_setreuid.c => test_syscall_setreuid32.c} |  21 ++--
 tests/{test_setuid.c => test_syscall_setuid32.c}   |  21 ++--
 tests/test_syscall_uid32.c | 101 
 13 files changed, 170 insertions(+), 351 deletions(-)
 delete mode 100644 tests/test_syscall_gid32.c
 copy tests/{test_setgid.c => test_syscall_setgid32.c} (78%)
 copy tests/{test_setgroups.c => test_syscall_setgroups32.c} (62%)
 copy tests/{test_setregid.c => test_syscall_setregid32.c} (83%)
 copy tests/{test_setresgid.c => test_syscall_setresgid32.c} (83%)
 copy tests/{test_setresuid.c => test_syscall_setresuid32.c} (74%)
 copy tests/{test_setreuid.c => 

[SCM] UID Wrapper Repository - branch master updated

2015-10-27 Thread Andreas Schneider
The branch, master has been updated
   via  82ff081 cmake: Run threaded tests also on BSD and Solaris
   via  35d070c tests: Get the tests working on BSD
   via  77fdff7 tests: Rename test_gid to test_setgroups
   via  64505d6 tests: Add setresgid unprivileged user test
   via  4a0e9d4 tests: Move setresgid test to own executable
   via  246a94b tests: Move setregid test to own executable
   via  f02727a tests: Move setegid test to own executable
   via  5d38a57 tests: Move setgid test to own executable
   via  ee7795d tests: Add new test_setuid_euid1 and test_setuid_euid2
   via  a6eb467 tests: Create a test for threaded SYS_setuid
   via  0006b60 tests: Fix test_syscall_setuid to work with privilege checks
   via  7cde22c tests: Create a test for threaded sync SYS_setreuid
   via  9f45e90 tests: Create a test for threaded SYS_setreuid
   via  1b9b469 tests: Fix test_syscall_setreuid to work with privilege 
checks
   via  f3d9e8e tests: Make syscall setresuid test from test_syscall_uid
   via  d113176 tests: Move syscall setreuid test to own executable
   via  156d99a tests: Add test_getresuid out of test_uid
   via  2156fd0 tests: Move setresuid test to own executable
   via  f5ddff7 tests: Move setreuid test to own executable
   via  b0e109d tests: Move seteuid test to own executable
   via  e459734 tests: Move setuid test to own executable
   via  a54d1d6 cmake: Always set UID_WRAPPER_ROOT=1 for tests
   via  caff321 uwrap: Add the EINVAL check to setegid()
   via  e89cf7c uwrap: Allow setgid calls only for privileged users
   via  f71da32 uwrap: Allow setregid calls only for privileged users
   via  38a13d2 uwrap: Allow setresgid calls only for privileged users
   via  7cd26ff uwrap: Move the EINVAL check down in seteuid()
   via  1044270 uwrap: Allow setuid calls only for privileged users
   via  54510cf uwrap: Allow setreuid calls only for privileged users
   via  ac17973 uwrap: Allow setresuid calls only for privileged users
   via  9e2642c uwrap: Fix a possible null pointer dereference
   via  199b143 uwrap: Improve debug output
   via  0353a18 uwrap: Fix debug line in uwrap_init()
  from  10424ba Bump version to 1.1.1

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


- Log -
commit 82ff0812e4287ba4786c97a1d56ce04d92d3ca6b
Author: Andreas Schneider 
Date:   Mon Oct 12 18:41:16 2015 +0200

cmake: Run threaded tests also on BSD and Solaris

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 35d070cb178fe07f1f902eaa5c9d91ea734dc932
Author: Andreas Schneider 
Date:   Thu Oct 8 17:03:48 2015 +0200

tests: Get the tests working on BSD

The setuid and seteuid behaviour is different to Linux and Solaris.

The setuid euid tests on BSD look like a bug?

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 77fdff705f6e82a923f0b66ea0859bbd1f1358d6
Author: Andreas Schneider 
Date:   Fri Oct 9 13:22:35 2015 +0200

tests: Rename test_gid to test_setgroups

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 64505d6964a52ad636ede36ab3a5f973189a954d
Author: Andreas Schneider 
Date:   Tue Oct 27 10:42:35 2015 +0100

tests: Add setresgid unprivileged user test

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 4a0e9d4da9be669755263b68adefba507f5e3ea9
Author: Andreas Schneider 
Date:   Fri Oct 9 13:21:20 2015 +0200

tests: Move setresgid test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 246a94bffd8224baa01d6a4f20cf2b58b5ff5a76
Author: Andreas Schneider 
Date:   Fri Oct 9 13:10:23 2015 +0200

tests: Move setregid test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit f02727a26dd5a010028057f0ed4b8744b1c5818b
Author: Andreas Schneider 
Date:   Fri Oct 9 09:40:14 2015 +0200

tests: Move setegid test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 5d38a571daf996f1a181c753403934188fa49c47
Author: Andreas Schneider 
Date:   Fri Oct 9 09:31:10 2015 +0200

tests: Move setgid test to own executable

Signed-off-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit ee7795df63783a787e40dd5dfcf41574a0dfc3a7
Author: Andreas Schneider 
Date:   Thu 

[SCM] UID Wrapper Repository - branch master updated

2015-08-20 Thread Andreas Schneider
The branch, master has been updated
   via  10424ba Bump version to 1.1.1
  from  74d0f0a doc: Make the manpage reproducible

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


- Log -
commit 10424bad9bfa5d547f78a27e045e04bf74d62234
Author: Andreas Schneider a...@samba.org
Date:   Thu Aug 20 10:20:31 2015 +0200

Bump version to 1.1.1

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 CMakeLists.txt | 4 ++--
 ChangeLog  | 5 +
 2 files changed, 7 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5984728..b4ddb0a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 1)
-set(APPLICATION_VERSION_PATCH 0)
+set(APPLICATION_VERSION_PATCH 1)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.0.3)
+set(LIBRARY_VERSION 0.0.4)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 08ce5cb..7242b20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.1 (released 2015-08-20)
+  * Fixed getres(uid|gid) detection if unsupported.
+  * Fixed the configure on Solaris
+  * Added a lot more tests
+
 version 1.1.0 (released 2015-01-20)
   * Added support for gesresuid().
   * Added support for gesresgid().


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-08-18 Thread Andreas Schneider
The branch, master has been updated
   via  940aa64 tests: Fix tests on Solaris
  from  319c52b uwrap: Removed double newline

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


- Log -
commit 940aa64fde39a46c311eade4e9992e9a9bc65253
Author: Andreas Schneider a...@samba.org
Date:   Tue Aug 18 10:10:41 2015 +0200

tests: Fix tests on Solaris

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Volker Lendecke v...@samba.org

---

Summary of changes:
 tests/test_syscall_gid.c | 10 --
 tests/test_syscall_uid.c | 13 -
 2 files changed, 16 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_syscall_gid.c b/tests/test_syscall_gid.c
index d87bb84..3ccdd4a 100644
--- a/tests/test_syscall_gid.c
+++ b/tests/test_syscall_gid.c
@@ -48,7 +48,9 @@ static void test_uwrap_syscall_setregid(void **state)
 
g = getegid();
assert_int_equal(g, 0);
+#ifdef SYS_getegid /* not available on Solaris */
assert_int_equal(g, syscall(SYS_getegid));
+#endif
 
rc = syscall(SYS_setregid, -1, 42);
assert_int_equal(rc, 0);
@@ -59,7 +61,7 @@ static void test_uwrap_syscall_setregid(void **state)
assert_int_equal(g, 42);
 }
 
-#if defined(SYS_setresgid)  defined(SYS_getresgid)
+#if defined(SYS_setresgid)
 static void test_uwrap_syscall_setresgid(void **state)
 {
long int rc;
@@ -72,11 +74,15 @@ static void test_uwrap_syscall_setresgid(void **state)
assert_int_equal(rc, 0);
 
g = getegid();
+   assert_int_equal(g, 0);
+
+#ifdef SYS_getresgid /* not available on Solaris */
rc = syscall(SYS_getresgid, g_r, g_e, g_s);
assert_return_code(rc, errno);
 
assert_int_equal(g_r, 42);
assert_int_equal(g, g_e);
+#endif
 
rc = syscall(SYS_setregid, -1, 42);
assert_return_code(rc, errno);
@@ -121,7 +127,7 @@ int main(void) {
const struct CMUnitTest uwrap_tests[] = {
cmocka_unit_test(test_uwrap_syscall_setgid),
cmocka_unit_test(test_uwrap_syscall_setregid),
-#if defined(SYS_setresgid)  defined(SYS_getresgid)
+#if defined(SYS_setresgid)
cmocka_unit_test(test_uwrap_syscall_setresgid),
 #endif
 #if defined(SYS_setgroups)
diff --git a/tests/test_syscall_uid.c b/tests/test_syscall_uid.c
index 7c702c3..c7f8ef3 100644
--- a/tests/test_syscall_uid.c
+++ b/tests/test_syscall_uid.c
@@ -44,7 +44,10 @@ static void test_uwrap_syscall_setreuid(void **state)
assert_int_equal(rc, 0);
 
u = geteuid();
+   assert_int_equal(u, 0);
+#ifdef SYS_geteuid /* not available on Solaris */
assert_int_equal(u, syscall(SYS_geteuid));
+#endif
 
rc = syscall(SYS_setreuid, -1, 42);
assert_int_equal(rc, 0);
@@ -56,8 +59,7 @@ static void test_uwrap_syscall_setreuid(void **state)
assert_int_equal(u, 2);
 }
 
-/* not available on Solaris */
-#if defined(SYS_setresuid)  defined(SYS_getresuid)
+#if defined(SYS_setresuid)
 static void test_uwrap_syscall_setresuid(void **state)
 {
long int rc;
@@ -69,15 +71,16 @@ static void test_uwrap_syscall_setresuid(void **state)
rc = syscall(SYS_setresuid, 3, 0, 1);
assert_int_equal(rc, 0);
 
+   u = geteuid();
+   assert_int_equal(u, 0);
+#ifdef SYS_getresuid /* not available on Solaris */
rc = syscall(SYS_getresuid, u_r, u_e, u_s);
assert_return_code(rc, errno);
 
assert_int_equal(u_r, 3);
-
-   u = geteuid();
assert_int_equal(u_e, u);
-
assert_int_equal(u_s, 1);
+#endif
 
rc = syscall(SYS_setresuid, -1, 42, -1);
assert_return_code(rc, errno);


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-08-18 Thread Andreas Schneider
The branch, master has been updated
   via  74d0f0a doc: Make the manpage reproducible
  from  940aa64 tests: Fix tests on Solaris

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


- Log -
commit 74d0f0acd0a888eef24b82d90ed091ef137e0573
Author: Andreas Schneider a...@samba.org
Date:   Tue Aug 18 12:32:03 2015 +0200

doc: Make the manpage reproducible

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Guenther Deschner g...@samba.org

---

Summary of changes:
 doc/uid_wrapper.1 | 4 ++--
 doc/uid_wrapper.1.txt | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/doc/uid_wrapper.1 b/doc/uid_wrapper.1
index f6ff0df..0faff95 100644
--- a/doc/uid_wrapper.1
+++ b/doc/uid_wrapper.1
@@ -2,12 +2,12 @@
 .\ Title: uid_wrapper
 .\Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\ Generator: DocBook XSL Stylesheets v1.78.1 http://docbook.sf.net/
-.\  Date: 07/11/2014
+.\  Date: 2014-07-11
 .\Manual: \ \
 .\Source: \ \
 .\  Language: English
 .\
-.TH UID_WRAPPER 1 07/11/2014 \ \ \ \
+.TH UID_WRAPPER 1 2014\-07\-11 \ \ \ \
 .\ -
 .\ * Define some portability stuff
 .\ -
diff --git a/doc/uid_wrapper.1.txt b/doc/uid_wrapper.1.txt
index 51cdb73..dec69e6 100644
--- a/doc/uid_wrapper.1.txt
+++ b/doc/uid_wrapper.1.txt
@@ -1,5 +1,6 @@
 uid_wrapper(1)
 ==
+:revdate: 2014-07-11
 
 NAME
 


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-08-17 Thread Andreas Schneider
The branch, master has been updated
   via  319c52b uwrap: Removed double newline
   via  bd88d4f tests: Add 32bit syscall gid tests
   via  677b0da tests: Improve syscall gid tests
   via  ba8c6cf tests: Add 32bit syscall uid tests
   via  9daf8ee tests: Improve syscall uid tests
   via  40c0bc9 tests: Rename testsuite to test_syscall_gid
   via  6e5ed70 tests: Move syscall uid tests to own test
   via  4b8f2f3 tests: Move syscall test to own test
   via  ff30175 tests: Move set(re)gid function to own test
   via  cf86be4 tests: Move set(re)uid function to own test
  from  c023936 cmake: Do not optimize the code by default

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


- Log -
commit 319c52b80a5186f8f375722c143172867e740e57
Author: Andreas Schneider a...@samba.org
Date:   Mon Aug 17 10:43:55 2015 +0200

uwrap: Removed double newline

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit bd88d4f14a0da022db7062ac8d63475a2fc279e8
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 09:04:13 2015 +0200

tests: Add 32bit syscall gid tests

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 677b0da7efe794213ea94270d9761617173470f7
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 09:01:02 2015 +0200

tests: Improve syscall gid tests

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit ba8c6cf15280f03d60929d0eb89be6cd9957b480
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:52:08 2015 +0200

tests: Add 32bit syscall uid tests

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 9daf8ee7f8e5f9cffa1df5714f8d85f648784831
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:43:55 2015 +0200

tests: Improve syscall uid tests

The plan is to have a 32bit version compiled dependent on the support
for it.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 40c0bc993955d6c6b069cbf945db0f2dc8a9a7b5
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:27:14 2015 +0200

tests: Rename testsuite to test_syscall_gid

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 6e5ed70966ebd1db0bcfcf7151bc6758404bf9cc
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:26:17 2015 +0200

tests: Move syscall uid tests to own test

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 4b8f2f3b28145d266207e3190efcbcf02a7690b2
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:20:57 2015 +0200

tests: Move syscall test to own test

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit ff30175461c490ce9329a6fe043c2f59ff51bdb1
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:17:34 2015 +0200

tests: Move set(re)gid function to own test

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit cf86be4c1ff0c37b05ff85fa6d5c0560e75c050e
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 14 08:11:58 2015 +0200

tests: Move set(re)uid function to own test

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 src/uid_wrapper.c  |   2 +-
 tests/CMakeLists.txt   |  62 --
 tests/test_gid.c   | 157 ++
 tests/test_syscall.c   |  62 ++
 tests/test_syscall_gid.c   | 135 +
 tests/test_syscall_gid32.c | 127 
 tests/test_syscall_uid.c   | 106 ++
 tests/test_syscall_uid32.c | 101 +
 tests/test_uid.c   | 134 
 tests/testsuite.c  | 494 -
 10 files changed, 866 insertions(+), 514 deletions(-)
 create mode 100644 tests/test_gid.c
 create mode 100644 tests/test_syscall.c
 create mode 100644 tests/test_syscall_gid.c
 create mode 100644 tests/test_syscall_gid32.c
 create mode 100644 tests/test_syscall_uid.c
 create mode 100644 tests/test_syscall_uid32.c
 create mode 100644 tests/test_uid.c
 delete mode 100644 tests/testsuite.c


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index a5e4fe5..2961b87 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -1634,7 +1634,7 @@ static long int uwrap_syscall (long int sysno, va_list vp)
break;
default:

[SCM] UID Wrapper Repository - branch master updated

2015-08-12 Thread Andreas Schneider
The branch, master has been updated
   via  c023936 cmake: Do not optimize the code by default
  from  b41c6d9 tests: Add test_uwrap_syscall_setresuid()

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


- Log -
commit c023936e442198ad5604a4ff7421b84ac90b9a5e
Author: Andreas Schneider a...@samba.org
Date:   Wed Aug 12 10:21:36 2015 +0200

cmake: Do not optimize the code by default

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 cmake/Modules/DefineCompilerFlags.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/cmake/Modules/DefineCompilerFlags.cmake 
b/cmake/Modules/DefineCompilerFlags.cmake
index 067ca32..97c0781 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -14,7 +14,7 @@ if (UNIX AND NOT WIN32)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow 
-Wmissing-prototypes -Wdeclaration-after-statement)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wunused -Wfloat-equal 
-Wpointer-arith -Wwrite-strings -Wformat-security)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wmissing-format-attribute)
-set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fstrict-aliasing 
-Wstrict-aliasing=2 -O2)
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fstrict-aliasing 
-Wstrict-aliasing=2)
 
 # with -fPIC
 check_c_compiler_flag(-fPIC WITH_FPIC)


-- 
UID Wrapper Repository



[SCM] UID Wrapper Repository - branch master updated

2015-07-31 Thread Andreas Schneider
The branch, master has been updated
   via  b41c6d9 tests: Add test_uwrap_syscall_setresuid()
   via  b1de1e9 tests: Fix syscall detection
   via  c0edc8f tests: Add test for syscall SYS_setresgid
   via  ddd8310 tests: Update to new cmocka test runner
   via  bb127f5 uwrap: Fix build if getres(uid|gid) are not available.
  from  544a538 cmake: Drop test results via https.

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


- Log -
commit b41c6d98229d97e3517179e49f655bd16e314193
Author: Andreas Schneider a...@samba.org
Date:   Fri Jul 31 14:25:21 2015 +0200

tests: Add test_uwrap_syscall_setresuid()

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit b1de1e9b55a99f5324875b3ba7e18037fe2906db
Author: Andreas Schneider a...@samba.org
Date:   Fri Jul 31 14:11:45 2015 +0200

tests: Fix syscall detection

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit c0edc8f4ee88b59ecb8a24019a6915588ea74be9
Author: Andreas Schneider a...@samba.org
Date:   Fri Jul 31 14:07:20 2015 +0200

tests: Add test for syscall SYS_setresgid

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit ddd831096360e9f3197a1d394c83c18da8590dbf
Author: Andreas Schneider a...@samba.org
Date:   Fri Jul 31 14:03:19 2015 +0200

tests: Update to new cmocka test runner

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit bb127f58e468524b167a015b864ac3ba12e9c5ed
Author: Andreas Schneider a...@samba.org
Date:   Fri Jan 23 16:01:49 2015 +0100

uwrap: Fix build if getres(uid|gid) are not available.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 src/uid_wrapper.c |   8 +--
 tests/test_glibc_thread_support.c |  18 ++---
 tests/test_uwrap_disabled.c   |  30 +
 tests/test_uwrap_enabled.c|   6 +-
 tests/testsuite.c | 138 +++---
 5 files changed, 148 insertions(+), 52 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 1d49a85..a5e4fe5 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -1537,7 +1537,7 @@ static long int uwrap_syscall (long int sysno, va_list vp)
}
break;
 #endif /* SYS_setresgid */
-#ifdef SYS_getresgid
+#if defined(SYS_getresgid)  defined(HAVE_GETRESGID)
case SYS_getresgid:
 #ifdef HAVE_LINUX_32BIT_SYSCALLS
case SYS_getresgid32:
@@ -1550,7 +1550,7 @@ static long int uwrap_syscall (long int sysno, va_list vp)
rc = uwrap_getresgid(rgid, egid, sgid);
}
break;
-#endif /* SYS_getresgid */
+#endif /* SYS_getresgid  HAVE_GETRESGID */
 
/* uid */
case SYS_getuid:
@@ -1606,7 +1606,7 @@ static long int uwrap_syscall (long int sysno, va_list vp)
}
break;
 #endif /* SYS_setresuid */
-#ifdef SYS_getresuid
+#if defined(SYS_getresuid)  defined(HAVE_GETRESUID)
case SYS_getresuid:
 #ifdef HAVE_LINUX_32BIT_SYSCALLS
case SYS_getresuid32:
@@ -1619,7 +1619,7 @@ static long int uwrap_syscall (long int sysno, va_list vp)
rc = uwrap_getresuid(ruid, euid, suid);
}
break;
-#endif /* SYS_getresuid */
+#endif /* SYS_getresuid  HAVE_GETRESUID*/
/* groups */
case SYS_setgroups:
 #ifdef HAVE_LINUX_32BIT_SYSCALLS
diff --git a/tests/test_glibc_thread_support.c 
b/tests/test_glibc_thread_support.c
index 31a7b7b..e902b0d 100644
--- a/tests/test_glibc_thread_support.c
+++ b/tests/test_glibc_thread_support.c
@@ -454,17 +454,17 @@ static void test_thread_create_thread_setgid(void **state)
 int main(void) {
int rc;
 
-   const UnitTest tests[] = {
-   unit_test(test_syscall_setreuid),
-   unit_test(test_sync_setreuid),
-   unit_test(test_sync_setgid),
-   unit_test(test_sync_setgid_syscall),
-   unit_test(test_real_sync_setuid),
-   unit_test(test_sync_setgroups),
-   unit_test(test_thread_create_thread_setgid),
+   const struct CMUnitTest thread_tests[] = {
+   cmocka_unit_test(test_syscall_setreuid),
+   cmocka_unit_test(test_sync_setreuid),
+   cmocka_unit_test(test_sync_setgid),
+   cmocka_unit_test(test_sync_setgid_syscall),
+   cmocka_unit_test(test_real_sync_setuid),
+   

[SCM] UID Wrapper Repository - branch master updated

2015-02-25 Thread Andreas Schneider
The branch, master has been updated
   via  544a538 cmake: Drop test results via https.
  from  e9d4871 Bump version to 1.1.0.

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


- Log -
commit 544a538713fac96f0cca50876e9f4719aed0a694
Author: Andreas Schneider a...@samba.org
Date:   Wed Feb 25 11:21:19 2015 +0100

cmake: Drop test results via https.

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 CTestConfig.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/CTestConfig.cmake b/CTestConfig.cmake
index 93edf1d..19bd287 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -3,7 +3,7 @@ set(UPDATE_TYPE true)
 set(CTEST_PROJECT_NAME uid_wrapper)
 set(CTEST_NIGHTLY_START_TIME 01:00:00 CET)
 
-set(CTEST_DROP_METHOD http)
+set(CTEST_DROP_METHOD https)
 set(CTEST_DROP_SITE mock.cryptomilk.org)
 set(CTEST_DROP_LOCATION /submit.php?project=uidwrapper)
 set(CTEST_DROP_SITE_CDASH TRUE)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2015-01-20 Thread Andreas Schneider
The branch, master has been updated
   via  e9d4871 Bump version to 1.1.0.
  from  87dc54b uwrap: Make sure we leave if the id is NULL.

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


- Log -
commit e9d4871713d3754cc02eadc541a42a9de9128a7d
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 19 17:06:10 2015 +0100

Bump version to 1.1.0.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 CMakeLists.txt | 6 +++---
 ChangeLog  | 8 
 2 files changed, 11 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d591fd..5984728 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 2.8.0)
 set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
-set(APPLICATION_VERSION_MINOR 0)
-set(APPLICATION_VERSION_PATCH 2)
+set(APPLICATION_VERSION_MINOR 1)
+set(APPLICATION_VERSION_PATCH 0)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.0.2)
+set(LIBRARY_VERSION 0.0.3)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 4fdb805..08ce5cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 ChangeLog
 ==
 
+version 1.1.0 (released 2015-01-20)
+  * Added support for gesresuid().
+  * Added support for gesresgid().
+  * Added MacOSX support.
+  * Added fully working thread support.
+  * Added more tests.
+  * Fixed issues with older gcc versions.
+
 version 1.0.2 (released 2014-07-31)
   * Added better logging system.
   * Added a mapnpage


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2015-01-08 Thread Andreas Schneider
The branch, master has been updated
   via  87dc54b uwrap: Make sure we leave if the id is NULL.
  from  ddafdd6 tests: Add new test_thread_create_thread_setgid.

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


- Log -
commit 87dc54b173bc15db556b38fe7f3a529e40975a26
Author: Andreas Schneider a...@samba.org
Date:   Thu Jan 8 10:10:52 2015 +0100

uwrap: Make sure we leave if the id is NULL.

CID #97616

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 src/uid_wrapper.c | 1 +
 1 file changed, 1 insertion(+)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 44ef8c1..1d49a85 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -656,6 +656,7 @@ static void uwrap_pthread_exit(void *retval)
if (id == NULL) {
UWRAP_UNLOCK(uwrap_id);
libpthread_pthread_exit(retval);
+   return;
}
 
UWRAP_DLIST_REMOVE(uwrap.ids, id);


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2015-01-07 Thread Andreas Schneider
The branch, master has been updated
   via  ddafdd6 tests: Add new test_thread_create_thread_setgid.
   via  53ed862 uwrap: Support scenario where threads fork or creates 
threads.
   via  ed13fb7 uwrap: Prepare for overload of libpthread functions.
   via  f842837 uwrap: Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL macros
   via  103a7f0 uwrap: Rewrite uwrap_libc_fns struct to pass strict 
aliasing rules.
   via  ba33cdd uwrap: Fix wrong data types in syscalls switch.
   via  dd5b185 tests: Add new test_uwrap_getresuid().
   via  04f13b9 uwrap: Add support for getresuid() and getresgid() 
glibc/syscall.
   via  d63240b tests: Add new test test_sync_setgroups().
   via  329fa14 uwrap: Extend support for (set|get)groups libc functions 
and syscalls.
   via  882246d tests: Fix test_uwrap_getgroups.
   via  c8d2593 tests: Add test_real_sync_setuid().
   via  fc959bd uwrap: Extend support for syscalls called from threads or 
main process.
   via  5bdc9cf uwrap: Small uwrap_init optimalization.
   via  f1ec2b8 uwrap: Add more authors to AUTHORS file.
   via  9dee5c0 tests: Enable test_glibc_thread_support.c on MacOSX.
   via  f1f0b52 src: Add support for running with address sanitizer.
  from  fdbdb8a uwrap: Reflect changes of uid/gid in threads to main 
process.

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


- Log -
commit ddafdd67734584205bd525c25d7fbc7f4f209499
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Dec 5 10:51:15 2014 +0100

tests: Add new test_thread_create_thread_setgid.

Test aims case where thread change uid/gid and then create new thread.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 53ed862d740dc76cadf79633ca325467ba031ca0
Author: Robin Hack hack.ro...@gmail.com
Date:   Tue Oct 21 08:55:56 2014 +0200

uwrap: Support scenario where threads fork or creates threads.

When fork() is called here there is no need to disable uwrap as a whole.
This change disables only uwrap for the thread which called fork().

uwrap catches calls of pthread_create() and pthread_exit() functions
from libpthread library now.

Pair-Programmed-With: Andreas Schneider a...@samba.org
Pair-Programmed-With: Stefan Metzmacher me...@samba.org

Signed-off-by: Robin Hack hack.ro...@gmail.com
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Stefan Metzmacher me...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit ed13fb77de8e505d4521616e377a27dea1442092
Author: Robin Hack hack.ro...@gmail.com
Date:   Tue Dec 16 12:09:55 2014 +0100

uwrap: Prepare for overload of libpthread functions.

uwrap_bind_symbol are now renamed to uwrap_bind_symbol_libc
and simlilar uwrap_bind_symbol_libpthread are introduced.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit f842837bcb33296a55c4ff8ae6c9873570b11586
Author: Robin Hack hack.ro...@gmail.com
Date:   Tue Dec 16 12:00:31 2014 +0100

uwrap: Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL macros

Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL which make
locking easier.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 103a7f028f91ac6e5aa3f7c0c1f0286bd9d85f9e
Author: Robin Hack hack.ro...@gmail.com
Date:   Wed Oct 29 10:29:27 2014 +0100

uwrap: Rewrite uwrap_libc_fns struct to pass strict aliasing rules.

Now uwrap is compiled with -O2 -fstrict-aliasing -Wstrict-aliasing=2
C compiler flags.

Also rename struct uwrap_libc_fns fns to uwrap_libc_symbols and
uwrap_load_lib_function to uwrap_bind_symbol (same for _uwrap_load_...
variant.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit ba33cdd2e78f7f4350288ceeb24f23106212
Author: Robin Hack hack.ro...@gmail.com
Date:   Thu Oct 16 12:23:53 2014 +0200

uwrap: Fix wrong data types in syscalls switch.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit dd5b185701210cf42eb586b176750d6579e4ace8
Author: Robin Hack hack.ro...@gmail.com
Date:   Tue Oct 21 08:54:04 2014 +0200

tests: Add new test_uwrap_getresuid().

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 04f13b938b8ba85986f23a12a29eb49de8dca1b9

[SCM] UID Wrapper Repository - branch master updated

2014-10-06 Thread Andreas Schneider
The branch, master has been updated
   via  fdbdb8a uwrap: Reflect changes of uid/gid in threads to main 
process.
   via  cd254f6 tests: Extend test_sync_setgid in 
test_glibc_thread_support.c
   via  afc62c9 uwrap: Small optimalization of uwrap_init().
   via  9b042d7 tests: test_glibc_thread_support: Add bigger load.
   via  9a4fc57 tests: Added two new tests aimed to setgid() and getgid() 
functions.
   via  6440f8e tests: Small phtread_attr cleanup.
   via  a8d0bc7 tests: Get rid of malloc calls in 
test_glibc_thread_support.c.
   via  e88afed uwrap: Optimalization of uid_wrapper_enabled() function.
   via  0c80f0c uid_wrapper: Fix race condition - uwrap_init.
   via  401d92a uwrap: Fix race condition - glibc lookups.
   via  724409c uwrap: Add library constructor and move pthread_atfork 
inside.
   via  973a784 uwrap: Use UWRAP_LOCK/UNLOCK macros instead of 
pthread_mutex_lock/unlock calls.
  from  ba53521 uwrap: Fix the handle loop for older gcc versions.

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


- Log -
commit fdbdb8ad1a6e745b5b4e7bf7f714ff11700a1227
Author: Robin Hack hack.ro...@gmail.com
Date:   Mon Sep 29 09:53:21 2014 +0200

uwrap: Reflect changes of uid/gid in threads to main process.

When thread changes uid/gid this change must be reflected to main
process.

Syscalls changes only uid/gid of thread. Call of libc functions changes
also uid/gid of main process.

TESTS: Fix test_sync_setgid_syscall in test_glibc_thread_support.c

When changes of gid (and uid of course) is reflected to main process
test must check if call of setgid syscall changes gid of thread ONLY.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit cd254f6c787cc008b4e926c5c8e84fa531543e4a
Author: Robin Hack hack.ro...@gmail.com
Date:   Sun Sep 28 21:19:13 2014 +0200

tests: Extend test_sync_setgid in test_glibc_thread_support.c

Extend test to case when thread changes gid of main process.
After this change main process start new thread which should have
same gid set as a main process.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit afc62c9c321c4d2be8246f90fd21a80096def09e
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Sep 26 16:25:58 2014 +0200

uwrap: Small optimalization of uwrap_init().

Don't call getenv(UID_WRAPPER) on start of uwrap_init().

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 9b042d73d8f80dea94090c2793281618895aa4e3
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Sep 26 16:19:09 2014 +0200

tests: test_glibc_thread_support: Add bigger load.

This can help (and helped) with revealing race conditions.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 9a4fc5759d5f5af59024dbe48d262277b7e91ce9
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Sep 26 16:17:18 2014 +0200

tests: Added two new tests aimed to setgid() and getgid() functions.

New tests:
 * test_sync_setgid - test if call of setgid() in thread changes gid
  of main process
 * test_sync_setgid_syscall - test setgid() syscall

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 6440f8e7f368c06b56622c9b9b443041d932db88
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Sep 26 15:25:09 2014 +0200

tests: Small phtread_attr cleanup.

This change should make valgrind happy.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit a8d0bc7279a44141477f508dcde177bee57957a7
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Sep 26 14:31:39 2014 +0200

tests: Get rid of malloc calls in test_glibc_thread_support.c.

Thread structures are allocated on stack now.

Signed-off-by: Robin Hack hack.ro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit e88afed067f2a04d2afd3a24458315143319871c
Author: Robin Hack hack.ro...@gmail.com
Date:   Fri Sep 26 14:00:27 2014 +0200

uwrap: Optimalization of uid_wrapper_enabled() function.

Check only bool variable inside uwrap structure instead
of calling whole uid_init().

In the best case only one mutex lock is need when check.

NOTES:
 * 

[SCM] UID Wrapper Repository - branch master updated

2014-10-01 Thread Andreas Schneider
The branch, master has been updated
   via  ba53521 uwrap: Fix the handle loop for older gcc versions.
  from  45b044d TESTS: SYS_gettimeofday behaves differently on OS X

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


- Log -
commit ba5352114b7f8783455633f8086b97113e91b5c4
Author: Andreas Schneider a...@samba.org
Date:   Wed Oct 1 17:17:43 2014 +0200

uwrap: Fix the handle loop for older gcc versions.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 src/uid_wrapper.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 2181767..c1dc56b 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -271,11 +271,14 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
case UWRAP_LIBC:
handle = uwrap.libc.handle;
if (handle == NULL) {
-   for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
+   for (i = 10; i = 0; i--) {
char soname[256] = {0};
 
snprintf(soname, sizeof(soname), libc.so.%d, 
i);
handle = dlopen(soname, flags);
+   if (handle != NULL) {
+   break;
+   }
}
 
uwrap.libc.handle = handle;


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-09-02 Thread Michael Adam
The branch, master has been updated
   via  45b044d TESTS: SYS_gettimeofday behaves differently on OS X
   via  a7ff27e TESTS: add -DOSX if building on OS X
   via  0322556 testsuite: Fix comparison
  from  1122f2a tests: Remove test with legacy access system call.

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


- Log -
commit 45b044d753eeb9ec15c7e3d58d9a2d20c1b1fe80
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Sun Aug 24 00:52:26 2014 +0200

TESTS: SYS_gettimeofday behaves differently on OS X

SYS_gettimeofday returns the number of seconds on OS X and doesn't set
the tz parameter.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit a7ff27e9889236776cd98fc04c15c733bf5250a5
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Sun Aug 24 00:50:18 2014 +0200

TESTS: add -DOSX if building on OS X

We need some OS X specific branch in the tests.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 03225567bbb6cb34b395d878d48d81e57039c753
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Sun Aug 24 00:54:18 2014 +0200

testsuite: Fix comparison

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 tests/CMakeLists.txt |1 +
 tests/testsuite.c|8 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9b1f4bb..7d54876 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -8,6 +8,7 @@ include_directories(
 
 if (OSX)
 set(TEST_ENVIRONMENT 
DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${UID_WRAPPER_LOCATION};UID_WRAPPER=1)
+add_definitions(-DOSX)
 else ()
 set(TEST_ENVIRONMENT LD_PRELOAD=${UID_WRAPPER_LOCATION};UID_WRAPPER=1)
 endif ()
diff --git a/tests/testsuite.c b/tests/testsuite.c
index c88b051..1a053b1 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -203,12 +203,16 @@ static void test_uwrap_syscall(void **state)
rc = gettimeofday(tv1, tz1);
assert_int_equal(rc, 0);
 
+#ifdef OSX
+   tv2.tv_sec = syscall(SYS_gettimeofday, tv2, NULL);
+#else
rc = syscall(SYS_gettimeofday, tv2, tz2);
assert_int_equal(rc, 0);
+   assert_int_equal(tz1.tz_dsttime, tz2.tz_dsttime);
+   assert_int_equal(tz1.tz_minuteswest, tz2.tz_minuteswest);
+#endif
 
assert_int_equal(tv1.tv_sec, tv2.tv_sec);
-   assert_int_equal(tz2.tz_dsttime, tz2.tz_dsttime);
-   assert_int_equal(tz2.tz_minuteswest, tz2.tz_minuteswest);
 }
 
 static void test_uwrap_syscall_setreuid(void **state)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-08-06 Thread Andreas Schneider
The branch, master has been updated
   via  1122f2a tests: Remove test with legacy access system call.
  from  05893df Bump version to 1.0.2.

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


- Log -
commit 1122f2a1046892100e9157fbfc91178685127a89
Author: Marcin Juszkiewicz mjuszkiew...@redhat.com
Date:   Mon Aug 4 11:56:50 2014 +0200

tests: Remove test with legacy access system call.

AArch64 architecture does not implement legacy system calls and as a
result SYS_access is not defined (as it got replaced with accessat
syscall).

Signed-off-by: Marcin Juszkiewicz mjuszkiew...@redhat.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 tests/testsuite.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index 828cb42..c88b051 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -195,12 +195,6 @@ static void test_uwrap_syscall(void **state)
rc = syscall(SYS_getpid);
assert_int_equal(rc, getpid());
 
-   rc = access(., R_OK);
-   assert_int_equal(rc, 0);
-
-   rc = syscall(SYS_access, ., R_OK);
-   assert_int_equal(rc, 0);
-
ZERO_STRUCT(tv1);
ZERO_STRUCT(tv2);
ZERO_STRUCT(tz1);


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-07-31 Thread Andreas Schneider
The branch, master has been updated
   via  05893df Bump version to 1.0.2.
   via  0b46313 uwrap: Support dropping all supplemetary groups with 
setgroups()
  from  6e1a69f doc: Add a manpage for uid_wrapper.

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


- Log -
commit 05893dfad64dc5da232ec7ea505655de5b6841c3
Author: Andreas Schneider a...@samba.org
Date:   Wed Jul 30 14:48:04 2014 +0200

Bump version to 1.0.2.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 0b46313c34a9ecceee9eeb2cbae0abe01133c96b
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Tue Jul 29 19:20:07 2014 +0200

uwrap: Support dropping all supplemetary groups with setgroups()

Dropping all supplementary groups is a common practice when changing
UIDs. This patch adds support for dropping all supplementary groups when
setgroups is called with size=0.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

tests: Fix test for dopping supplementary groups.

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 CMakeLists.txt|4 ++--
 ChangeLog |6 ++
 src/uid_wrapper.c |   14 --
 tests/testsuite.c |   25 +
 4 files changed, 45 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index af76cb8..1d591fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 0)
-set(APPLICATION_VERSION_PATCH 1)
+set(APPLICATION_VERSION_PATCH 2)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.0.1)
+set(LIBRARY_VERSION 0.0.2)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index b15ee88..4fdb805 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 ChangeLog
 ==
 
+version 1.0.2 (released 2014-07-31)
+  * Added better logging system.
+  * Added a mapnpage
+  * Added build and install instructions
+  * Fixed threading issue in the desctructor.
+
 version 1.0.1 (released 2014-02-04)
   * Added --libs to pkg-config.
   * Added socket_wrapper-config.cmake
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index f53aa47..2181767 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -956,7 +956,11 @@ static int uwrap_setgroups_thread(size_t size, const gid_t 
*list)
 
pthread_mutex_lock(uwrap_id_mutex);
 
-   if (size  0) {
+   if (size == 0) {
+   free(id-groups);
+   id-groups = NULL;
+   id-ngroups = 0;
+   } else if (size  0) {
gid_t *tmp;
 
tmp = realloc(id-groups, sizeof(gid_t) * size);
@@ -984,7 +988,13 @@ static int uwrap_setgroups(size_t size, const gid_t *list)
 
pthread_mutex_lock(uwrap_id_mutex);
 
-   if (size  0) {
+   if (size == 0) {
+   for (id = uwrap.ids; id; id = id-next) {
+   free(id-groups);
+   id-groups = NULL;
+   id-ngroups = 0;
+   }
+   } else if (size  0) {
for (id = uwrap.ids; id; id = id-next) {
gid_t *tmp;
 
diff --git a/tests/testsuite.c b/tests/testsuite.c
index beff0fe..828cb42 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -288,6 +288,17 @@ static void test_uwrap_setgroups(void **state)
assert_int_equal(rc, 5);
 
assert_memory_equal(glist, rlist, sizeof(glist));
+
+   /* Drop all supplementary groups. This is often done by daemons */
+   memset(rlist, 0, sizeof(rlist));
+
+   rc = setgroups(0, NULL);
+   assert_int_equal(rc, 0);
+
+   rc = getgroups(ARRAY_SIZE(rlist), rlist);
+   assert_int_equal(rc, 0);
+
+   assert_int_equal(rlist[0], 0);
 }
 
 #if defined(SYS_setgroups) || defined(SYS_setroups32)
@@ -310,6 +321,20 @@ static void test_uwrap_syscall_setgroups(void **state)
assert_int_equal(rc, 5);
 
assert_memory_equal(glist, rlist, sizeof(glist));
+
+   /* Drop all supplementary groups. This is often done by daemons */
+   memset(rlist, 0, sizeof(rlist));
+#ifdef SYS_setgroups
+   rc = syscall(SYS_setgroups, 0, NULL);
+#elif SYS_setgroups32
+   rc = 

[SCM] UID Wrapper Repository - branch master updated

2014-07-14 Thread Andreas Schneider
The branch, master has been updated
   via  6e1a69f doc: Add a manpage for uid_wrapper.
  from  80932d7 uwrap: Add logging if uwrap is enabled correctly.

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


- Log -
commit 6e1a69f52c1a5de968f0bc38af71ee99c1297021
Author: Andreas Schneider a...@samba.org
Date:   Thu Jul 10 17:09:50 2014 +0200

doc: Add a manpage for uid_wrapper.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 CMakeLists.txt|2 +
 README|   46 +--
 doc/CMakeLists.txt|4 +
 doc/README|3 +
 doc/uid_wrapper.1 |  153 +
 doc/uid_wrapper.1.txt |   56 ++
 6 files changed, 232 insertions(+), 32 deletions(-)
 create mode 100644 doc/CMakeLists.txt
 create mode 100644 doc/README
 create mode 100644 doc/uid_wrapper.1
 create mode 100644 doc/uid_wrapper.1.txt


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80fcaf1..af76cb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -81,3 +81,5 @@ install(
 COMPONENT
 devel
 )
+
+add_subdirectory(doc)
diff --git a/README b/README
index 6f19b38..764fd36 100644
--- a/README
+++ b/README
@@ -1,42 +1,24 @@
-UID wrapper library
-
+UID_WRAPPER
+===
 
-Privilege separation - Some projects like a file server need privilege
-separation to be able to switch to the connnection user and do file operations.
-uid_wrapper convincingly lies to the application letting it believe it is
-operating as root and even switching betwen uids and gids as needed.
+This is a wrapper for the user, group and hosts NSS API.
 
-More precise this library intercepts seteuid and related calls, and simulates
-them in a manner similar to the nss_wrapper and socket_wrapper libraries.
+DESCRIPTION
+---
 
-This allows you to do user switching when testing e.g. file servers.
+More details can be found in the manpage:
 
-To use it set the following environment variables:
+  man -l ./doc/uid_wrapper.1
 
-LD_PRELOAD=libuid_wrapper.so
-UID_WRAPPER=1
+or the raw text version:
 
-If you unset the variable or set it to 0 you can disable uwrap even if it is
-loaded. If you need the application to think it is root at startup you can set:
+  less ./doc/uid_wrapper.1.txt
 
-UID_WRAPPER_ROOT=1
+For installation instructions please take a look at the README.install file.
 
-If you set the environment variable to UID_WRAPPER_MYUID=1 before you call
-geteuid() then it will return the real uid.
+MAILINGLIST
+---
 
-To find out if uid_wrapper is enabled, we suggest to implment the following
-function in a library your application loads:
+As the mailing list samba-technical is used and can be found here:
 
-int uid_wrapper_enabled(void)
-{
-return 0;
-}
-
-Then you can use:
-
-if (uid_wrapper_enabled()) {
-/* special uid_wrapper handling code */
-}
-
-uid_wrapper implements this funciton too and it will be loaded before your
-library gets loaded.
+https://lists.samba.org/mailman/listinfo/samba-technical
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 000..7ce0e22
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,4 @@
+install(FILES
+uid_wrapper.1
+DESTINATION
+${MAN_INSTALL_DIR}/man1)
diff --git a/doc/README b/doc/README
new file mode 100644
index 000..c97ae11
--- /dev/null
+++ b/doc/README
@@ -0,0 +1,3 @@
+The manpage is written with asciidoc. To generate the manpage use:
+
+a2x --doctype manpage --format manpage doc/uid_wrapper.1.txt
diff --git a/doc/uid_wrapper.1 b/doc/uid_wrapper.1
new file mode 100644
index 000..f6ff0df
--- /dev/null
+++ b/doc/uid_wrapper.1
@@ -0,0 +1,153 @@
+'\ t
+.\ Title: uid_wrapper
+.\Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\ Generator: DocBook XSL Stylesheets v1.78.1 http://docbook.sf.net/
+.\  Date: 07/11/2014
+.\Manual: \ \
+.\Source: \ \
+.\  Language: English
+.\
+.TH UID_WRAPPER 1 07/11/2014 \ \ \ \
+.\ -
+.\ * Define some portability stuff
+.\ -
+.\ ~
+.\ http://bugs.debian.org/507673
+.\ http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\ ~
+.ie \n(.g .ds Aq \(aq
+.el   .ds Aq '
+.\ -
+.\ * set default formatting
+.\ -
+.\ disable hyphenation
+.nh
+.\ disable justification (adjust text to left margin only)
+.ad 

[SCM] UID Wrapper Repository - branch master updated

2014-06-02 Thread Michael Adam
The branch, master has been updated
   via  80932d7 uwrap: Add logging if uwrap is enabled correctly.
   via  a4d3db5 uwrap: Log error if we are out of memory.
   via  135582e uwrap: Add a better logging function.
   via  334c562 cmake: Check for HAVE_FUNCTION_ATTRIBUTE_FORMAT.
  from  690da04 uwrap: Fall back to RTLD_NEXT if we can't find libc.

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


- Log -
commit 80932d786bdf8ce6f8e4fb1f6b09f1252caba302
Author: Andreas Schneider a...@samba.org
Date:   Fri May 30 15:52:19 2014 +0200

uwrap: Add logging if uwrap is enabled correctly.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit a4d3db55d723048ad07e76a3365b7500ad3262a5
Author: Andreas Schneider a...@samba.org
Date:   Fri May 30 15:52:00 2014 +0200

uwrap: Log error if we are out of memory.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 135582e8e9230ae0bfb0f99e3e549ec9e29c8183
Author: Andreas Schneider a...@samba.org
Date:   Fri May 30 15:44:39 2014 +0200

uwrap: Add a better logging function.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 334c562f100fb0bd007ee5461e0fef299ff768b4
Author: Andreas Schneider a...@samba.org
Date:   Fri May 30 15:59:17 2014 +0200

cmake: Check for HAVE_FUNCTION_ATTRIBUTE_FORMAT.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 ConfigureChecks.cmake |7 
 config.h.cmake|1 +
 src/uid_wrapper.c |   88 +---
 3 files changed, 90 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 123128f..899d905 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -143,6 +143,13 @@ int main(void) {
 return 0;
 } HAVE_DESTRUCTOR_ATTRIBUTE)
 
+check_c_source_compiles(
+void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+
+int main(void) {
+return 0;
+} HAVE_FUNCTION_ATTRIBUTE_FORMAT)
+
 # SYSTEM LIBRARIES
 
 check_library_exists(dl dlopen  HAVE_LIBDL)
diff --git a/config.h.cmake b/config.h.cmake
index 0e67b23..840b5d4 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -58,6 +58,7 @@
 
 #cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_FUNCTION_ATTRIBUTE_FORMAT 1
 
 /*** ENDIAN */
 
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index e9c7d5a..f53aa47 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -49,11 +49,12 @@
 #define DESTRUCTOR_ATTRIBUTE
 #endif /* HAVE_DESTRUCTOR_ATTRIBUTE */
 
-#ifdef NDEBUG
-#define UWRAP_DEBUG(...)
+/* GCC have printf type attribute check. */
+#ifdef HAVE_FUNCTION_ATTRIBUTE_FORMAT
+#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
 #else
-#define UWRAP_DEBUG(...) fprintf(stderr, __VA_ARGS__)
-#endif
+#define PRINTF_ATTRIBUTE(a,b)
+#endif /* HAVE_FUNCTION_ATTRIBUTE_FORMAT */
 
 #define UWRAP_DLIST_ADD(list,item) do { \
if (!(list)) { \
@@ -90,6 +91,70 @@
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
 #endif
 
+/*
+ * LOGGING
+ */
+
+enum uwrap_dbglvl_e {
+   UWRAP_LOG_ERROR = 0,
+   UWRAP_LOG_WARN,
+   UWRAP_LOG_DEBUG,
+   UWRAP_LOG_TRACE
+};
+
+#ifdef NDEBUG
+# define UWRAP_LOG(...)
+#else /* NDEBUG */
+static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *format, ...) 
PRINTF_ATTRIBUTE(2, 3);
+# define UWRAP_LOG(dbglvl, ...) uwrap_log((dbglvl), __VA_ARGS__)
+
+static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *format, ...)
+{
+   char buffer[1024];
+   va_list va;
+   const char *d;
+   unsigned int lvl = 0;
+
+   d = getenv(UID_WRAPPER_DEBUGLEVEL);
+   if (d != NULL) {
+   lvl = atoi(d);
+   }
+
+   va_start(va, format);
+   vsnprintf(buffer, sizeof(buffer), format, va);
+   va_end(va);
+
+   if (lvl = dbglvl) {
+   switch (dbglvl) {
+   case UWRAP_LOG_ERROR:
+   fprintf(stderr,
+   UWRAP_ERROR(%d): %s\n,
+   (int)getpid(), buffer);
+   break;
+   case UWRAP_LOG_WARN:
+   fprintf(stderr,
+   UWRAP_WARN(%d): %s\n,
+   (int)getpid(), buffer);
+   break;
+   case UWRAP_LOG_DEBUG:
+   

[SCM] UID Wrapper Repository - branch master updated

2014-05-28 Thread Michael Adam
The branch, master has been updated
   via  f4df629 uwrap: Add mutex in uwrap_destructor().
   via  96ba355 cmake: Fix a typo in uid_wrapper-config.cmake.in.
   via  2030b01 Add README.install - instructions for building and 
installing.
  from  15d3bb8 cmake: Fix policy check.

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


- Log -
commit f4df62958749097fd56063af0640465d944546dc
Author: Andreas Schneider a...@samba.org
Date:   Fri May 9 17:10:57 2014 +0200

uwrap: Add mutex in uwrap_destructor().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 96ba355e433f874f312cfc9db41c6bd9176f12e2
Author: Andreas Schneider a...@samba.org
Date:   Wed May 28 16:13:22 2014 +0200

cmake: Fix a typo in uid_wrapper-config.cmake.in.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 2030b0149119fecbb05e0b28604a46240c3dda73
Author: Michael Adam ob...@samba.org
Date:   Tue May 27 23:23:58 2014 +0200

Add README.install - instructions for building and installing.

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 README.install  |   78 +++
 src/uid_wrapper.c   |2 +
 uid_wrapper-config.cmake.in |2 +-
 3 files changed, 81 insertions(+), 1 deletions(-)
 create mode 100644 README.install


Changeset truncated at 500 lines:

diff --git a/README.install b/README.install
new file mode 100644
index 000..c677381
--- /dev/null
+++ b/README.install
@@ -0,0 +1,78 @@
+Obtaining the sources
+=
+
+Source tarballs for uid_wrapper can be downloaded from
+
+  https://ftp.samba.org/pub/cwrap/
+
+The source code repository for socket wrapper is located under
+
+  git://git.samba.org/uid_wrapper.git
+
+To create a local copy, run
+
+  $ git clone git://git.samba.org/uid_wrapper.git
+  $ cd uid_wrapper
+
+Building from sources
+=
+
+uid_wrapper uses cmake (www.cmake.org) as its build system.
+
+In an unpacked sources base directory, create a directory to
+contain the build results, e.g.
+
+  $ mkdir obj
+  $ cd obj
+
+Note that obj is just an example. The directory can
+be named arbitrarily.
+
+Next, run cmake to configure the build, e.g.
+
+  $ cmake -DCMAKE_INSTALL_PREFIX=prefix ..
+
+or on a 64 bit red hat system:
+
+  $  cmake -DCMAKE_INSTALL_PREFIX=prefix -DLIB_SUFFIX=64 ..
+
+The prefix should be replaced by the intended installation
+target prefix directory, typically /usr or /usr/local.
+
+Note that the target directory does not have to be a direct
+or indirect subdirectory of the source base directory: It can
+be an arbitrary directory in the system. In the general case,
+.. has to be replaced by a relative or absolute path of the
+source base directory in the cmake command line.
+
+One can control the build type with -DCMAKE_BUILD_TYPE=mode
+where mode can be one of Debug, Release, RelWithDebInfo, and
+some more (see cmake.org). The default is RelWithDebInfo.
+
+After configuring with cmake, run the build with
+
+  $ make
+
+Unit testing
+
+
+In order to support running the test suite after building,
+the cmocka unit test framework needs to be installed (cmocka.org),
+and you need to specify
+
+  -DUNIT_TESTING=ON
+
+in the cmake run. After running make,
+
+  $ make test
+
+runs the test suite.
+
+Installing
+==
+
+uid_wrapper is installed into the prefix directory
+after running cmake and make with
+
+  $ make install
+
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 742903a..b77aa02 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -1162,6 +1162,7 @@ void uwrap_destructor(void)
 {
struct uwrap_thread *u = uwrap.ids;
 
+   pthread_mutex_lock(uwrap_id_mutex);
while (u != NULL) {
UWRAP_DLIST_REMOVE(uwrap.ids, u);
 
@@ -1170,6 +1171,7 @@ void uwrap_destructor(void)
 
u = uwrap.ids;
}
+   pthread_mutex_unlock(uwrap_id_mutex);
 
if (uwrap.libc.handle != NULL) {
dlclose(uwrap.libc.handle);
diff --git a/uid_wrapper-config.cmake.in b/uid_wrapper-config.cmake.in
index 4649901..2431867 100644
--- a/uid_wrapper-config.cmake.in
+++ b/uid_wrapper-config.cmake.in
@@ -1 +1 @@
-set(UID_WRAPPER_LIRBARY @LIB_INSTALL_DIR@/@UID_WRAPPER_LIB@)
+set(UID_WRAPPER_LIBRARY @LIB_INSTALL_DIR@/@UID_WRAPPER_LIB@)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-05-28 Thread Michael Adam
The branch, master has been updated
   via  690da04 uwrap: Fall back to RTLD_NEXT if we can't find libc.
  from  f4df629 uwrap: Add mutex in uwrap_destructor().

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


- Log -
commit 690da04acae08facfacb476f80c06a8f58b3cfef
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 29 15:11:40 2014 +0200

uwrap: Fall back to RTLD_NEXT if we can't find libc.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 src/uid_wrapper.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index b77aa02..e9c7d5a 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -194,10 +194,6 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
void *handle = NULL;
int i;
 
-#ifdef HAVE_APPLE
-   return RTLD_NEXT;
-#endif
-
 #ifdef RTLD_DEEPBIND
flags |= RTLD_DEEPBIND;
 #endif
@@ -223,10 +219,14 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
}
 
if (handle == NULL) {
+#ifdef RTLD_NEXT
+   handle = uwrap.libc.handle = RTLD_NEXT;
+#else
fprintf(stderr,
Failed to dlopen library: %s\n,
dlerror());
exit(-1);
+#endif
}
 
return handle;


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-04-25 Thread Andreas Schneider
The branch, master has been updated
   via  15d3bb8 cmake: Fix policy check.
   via  8d2d0dd cmake: Install cmake config into the correct directory.
  from  30abe3c cmake: Use 2.8.13 as version to check.

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


- Log -
commit 15d3bb846ee2efb527c5ab48e652f83fbdd4cec3
Author: Andreas Schneider a...@samba.org
Date:   Fri Apr 25 14:00:39 2014 +0200

cmake: Fix policy check.

commit 8d2d0ddae725c5cf475c9b2a7e20eb0cfe65689d
Author: Andreas Schneider a...@samba.org
Date:   Wed Apr 16 15:47:34 2014 +0200

cmake: Install cmake config into the correct directory.

---

Summary of changes:
 CMakeLists.txt |2 +-
 src/CMakeLists.txt |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1513ed0..80fcaf1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,7 +77,7 @@ install(
 ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake
 ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config.cmake
 DESTINATION
-${CMAKE_INSTALL_DIR}
+${CMAKE_INSTALL_DIR}/uid_wrapper
 COMPONENT
 devel
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 88b65f5..9dbfb75 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,7 +22,7 @@ install(
 )
 
 # This needs to be at the end
-if (CMAKE_VERSION VERSION_GREATER 2.8.13)
+if (POLICY CMP0026)
 cmake_policy(SET CMP0026 OLD)
 endif()
 get_target_property(UWRAP_LOCATION uid_wrapper LOCATION)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-04-10 Thread Andreas Schneider
The branch, master has been updated
   via  30abe3c cmake: Use 2.8.13 as version to check.
  from  b4a3718 uwrap: Fix memory leak on error.

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


- Log -
commit 30abe3c0fc12961d9242285b20c246ad5253010a
Author: Andreas Schneider a...@samba.org
Date:   Wed Apr 9 12:00:25 2014 +0200

cmake: Use 2.8.13 as version to check.

---

Summary of changes:
 src/CMakeLists.txt |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be1bede..88b65f5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,7 +22,7 @@ install(
 )
 
 # This needs to be at the end
-if (CMAKE_VERSION VERSION_GREATER 2.8.12)
+if (CMAKE_VERSION VERSION_GREATER 2.8.13)
 cmake_policy(SET CMP0026 OLD)
 endif()
 get_target_property(UWRAP_LOCATION uid_wrapper LOCATION)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-04-08 Thread Andreas Schneider
The branch, master has been updated
   via  b4a3718 uwrap: Fix memory leak on error.
   via  5c0131b cmake: Only set policy in cmake 3.0.
  from  6f441ee cmake: Fix configure warning with cmake 3.0.

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


- Log -
commit b4a3718808f650f8a19bcaf43fca00a2cec265a0
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:24:42 2014 +0200

uwrap: Fix memory leak on error.

Found by Coverity.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 5c0131b517bb8319095f2a7c35576708a310e3a4
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:24:21 2014 +0200

cmake: Only set policy in cmake 3.0.

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 src/CMakeLists.txt |4 +++-
 src/uid_wrapper.c  |1 +
 2 files changed, 4 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e0f2011..be1bede 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,6 +22,8 @@ install(
 )
 
 # This needs to be at the end
-cmake_policy(SET CMP0026 OLD)
+if (CMAKE_VERSION VERSION_GREATER 2.8.12)
+cmake_policy(SET CMP0026 OLD)
+endif()
 get_target_property(UWRAP_LOCATION uid_wrapper LOCATION)
 set(UID_WRAPPER_LOCATION ${UWRAP_LOCATION} PARENT_SCOPE)
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index cb99481..742903a 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -431,6 +431,7 @@ static int uwrap_new_id(pthread_t tid, bool do_alloc)
 
id-groups = malloc(sizeof(gid_t) * 1);
if (id-groups == NULL) {
+   SAFE_FREE(id);
errno = ENOMEM;
return -1;
}


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-04-07 Thread Andreas Schneider
The branch, master has been updated
   via  6f441ee cmake: Fix configure warning with cmake 3.0.
   via  d8e12e1 cmake: Create the compile command database by default.
  from  0ea952c Bump version to 1.0.1.

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


- Log -
commit 6f441eebd445998b1854bc07bb691e1503ba1fff
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 7 12:17:16 2014 +0200

cmake: Fix configure warning with cmake 3.0.

Signed-off-by: Andreas Schneider a...@samba.org

commit d8e12e1e553ae193326e04db64c7089ca144e362
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 7 12:17:01 2014 +0200

cmake: Create the compile command database by default.

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 cmake/Modules/DefineCMakeDefaults.cmake |3 +++
 src/CMakeLists.txt  |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/cmake/Modules/DefineCMakeDefaults.cmake 
b/cmake/Modules/DefineCMakeDefaults.cmake
index 72893c3..22eda6f 100644
--- a/cmake/Modules/DefineCMakeDefaults.cmake
+++ b/cmake/Modules/DefineCMakeDefaults.cmake
@@ -25,3 +25,6 @@ if (NOT CMAKE_BUILD_TYPE)
   Choose the type of build, options are: None Debug Release 
RelWithDebInfo MinSizeRel.
   )
 endif (NOT CMAKE_BUILD_TYPE)
+
+# Create the compile command database for clang by default
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3476d5c..e0f2011 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,5 +22,6 @@ install(
 )
 
 # This needs to be at the end
+cmake_policy(SET CMP0026 OLD)
 get_target_property(UWRAP_LOCATION uid_wrapper LOCATION)
 set(UID_WRAPPER_LOCATION ${UWRAP_LOCATION} PARENT_SCOPE)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-02-04 Thread Andreas Schneider
The branch, master has been updated
   via  0ea952c Bump version to 1.0.1.
   via  1963913 cmake: Add uid_wrapper-config.cmake.
   via  ef1ff0c cmake: Use UID_WRAPPER_LOCATION.
   via  80bc81c cmake: Add --libs output for pkg-config.
   via  277d719 cpack: Don't package the obj directory.
   via  fe8d6b2 tests: Use bool in the prototype too.
  from  2fea9dc tests: Use a bool for the test_uwrap_enabled test.

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


- Log -
commit 0ea952cce266f684272f5855209998762c3d80d4
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:39:33 2014 +0100

Bump version to 1.0.1.

commit 1963913a597fbcebd61a910775d1aba1cf3cfc36
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:37:30 2014 +0100

cmake: Add uid_wrapper-config.cmake.

commit ef1ff0c0c04324913d3d49b9dbce026033d46bea
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:35:11 2014 +0100

cmake: Use UID_WRAPPER_LOCATION.

commit 80bc81c45731a9e129b9ffe25668ee1602c4243f
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:32:49 2014 +0100

cmake: Add --libs output for pkg-config.

commit 277d7194c1c7babc810bfa38e42b2ebd58d23372
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:38:11 2014 +0100

cpack: Don't package the obj directory.

commit fe8d6b2895c24a195fc1b7d035cc661f85838bfb
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Feb 3 22:16:15 2014 +0100

tests: Use bool in the prototype too.

Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 CMakeLists.txt  |   24 ++--
 CPackConfig.cmake   |2 +-
 ChangeLog   |5 +
 src/CMakeLists.txt  |4 
 tests/CMakeLists.txt|4 ++--
 tests/test_uwrap_enabled.c  |2 +-
 uid_wrapper-config.cmake.in |1 +
 uid_wrapper.pc.cmake|1 +
 8 files changed, 29 insertions(+), 14 deletions(-)
 create mode 100644 uid_wrapper-config.cmake.in


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b806e62..1513ed0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 0)
-set(APPLICATION_VERSION_PATCH 0)
+set(APPLICATION_VERSION_PATCH 1)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -47,7 +47,18 @@ find_package(Threads)
 include(ConfigureChecks.cmake)
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
+# check subdirectories
+add_subdirectory(src)
+
+if (UNIT_TESTING)
+find_package(CMocka REQUIRED)
+include(AddCMockaTest)
+add_subdirectory(tests)
+endif (UNIT_TESTING)
+
 # pkg-config file
+get_filename_component(UID_WRAPPER_LIB ${UID_WRAPPER_LOCATION} NAME)
+
 configure_file(uid_wrapper.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper.pc 
@ONLY)
 install(
   FILES
@@ -60,20 +71,13 @@ install(
 
 # cmake config files
 configure_file(uid_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake @ONLY)
+configure_file(uid_wrapper-config.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config.cmake @ONLY)
 install(
 FILES
 ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake
+${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config.cmake
 DESTINATION
 ${CMAKE_INSTALL_DIR}
 COMPONENT
 devel
 )
-
-# check subdirectories
-add_subdirectory(src)
-
-if (UNIT_TESTING)
-find_package(CMocka REQUIRED)
-include(AddCMockaTest)
-add_subdirectory(tests)
-endif (UNIT_TESTING)
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index e5d1ce8..dc74dfa 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -19,7 +19,7 @@ set(CPACK_PACKAGE_VERSION 
${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO
 
 ### source generator
 set(CPACK_SOURCE_GENERATOR TGZ)
-set(CPACK_SOURCE_IGNORE_FILES 
~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*)
+set(CPACK_SOURCE_IGNORE_FILES 
~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;/obj/;tags;cscope.*)
 set(CPACK_SOURCE_PACKAGE_FILE_NAME 
${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
 
 if (WIN32)
diff --git a/ChangeLog b/ChangeLog
index d2f5d4e..b15ee88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 ChangeLog
 ==
 
+version 1.0.1 (released 2014-02-04)
+  * Added --libs to pkg-config.
+  * Added socket_wrapper-config.cmake
+  * Fixed a bug packaging the obj directory.
+
 version 1.0.0 (released 2014-02-02)
   * Initial release
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e1fb0b2..3476d5c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,3 +20,7 @@ install(
   LIBRARY DESTINATION 

[SCM] UID Wrapper Repository - branch master updated

2014-02-01 Thread Andreas Schneider
The branch, master has been updated
   via  2c761ef src: Use a bool for uid_wrapper_enabled().
  from  84a3e42 Add ChangeLog.

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


- Log -
commit 2c761ef132c21ca6a79a126d74ed0915a22b1bc7
Author: Andreas Schneider a...@cryptomilk.org
Date:   Sat Feb 1 14:32:03 2014 +0100

src: Use a bool for uid_wrapper_enabled().

Reviewed-by: Jeremy Allison j...@samba.org

---

Summary of changes:
 src/uid_wrapper.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 0120510..cb99481 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -175,7 +175,7 @@ static pthread_mutex_t uwrap_id_mutex = 
PTHREAD_MUTEX_INITIALIZER;
  * UWRAP PROTOTYPES
  */
 
-int uid_wrapper_enabled(void);
+bool uid_wrapper_enabled(void);
 void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*
@@ -548,11 +548,11 @@ static void uwrap_init(void)
pthread_mutex_unlock(uwrap_id_mutex);
 }
 
-int uid_wrapper_enabled(void)
+bool uid_wrapper_enabled(void)
 {
uwrap_init();
 
-   return uwrap.enabled ? 1 : 0;
+   return uwrap.enabled ? true : false;
 }
 
 static int uwrap_setresuid_thread(uid_t ruid, uid_t euid, uid_t suid)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-02-01 Thread Andreas Schneider
The branch, master has been updated
   via  2fea9dc tests: Use a bool for the test_uwrap_enabled test.
  from  2c761ef src: Use a bool for uid_wrapper_enabled().

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


- Log -
commit 2fea9dc3ac18f05e59cd6d8379c6f544e56b4e03
Author: Andreas Schneider a...@cryptomilk.org
Date:   Sun Feb 2 08:54:27 2014 +0100

tests: Use a bool for the test_uwrap_enabled test.

Reviewed-by: Jeremy Allison j...@samba.org

---

Summary of changes:
 tests/test_uwrap_enabled.c |8 +---
 tests/uwrap_enabled.c  |8 +---
 2 files changed, 10 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_uwrap_enabled.c b/tests/test_uwrap_enabled.c
index c06e904..b8aac44 100644
--- a/tests/test_uwrap_enabled.c
+++ b/tests/test_uwrap_enabled.c
@@ -5,16 +5,18 @@
 #include setjmp.h
 #include cmocka.h
 
+#include stdbool.h
+
 int uid_wrapper_enabled(void);
 
 static void test_uid_wrapper_enabled(void **state)
 {
-int rc;
+bool ok;
 
 (void)state; /* unused */
 
-rc = uid_wrapper_enabled();
-assert_int_equal(rc, 1);
+ok = uid_wrapper_enabled();
+assert_true(ok);
 }
 
 int main(void) {
diff --git a/tests/uwrap_enabled.c b/tests/uwrap_enabled.c
index 59af3bb..9e982d4 100644
--- a/tests/uwrap_enabled.c
+++ b/tests/uwrap_enabled.c
@@ -1,6 +1,8 @@
-int uid_wrapper_enabled(void);
+#include stdbool.h
 
-int uid_wrapper_enabled(void)
+bool uid_wrapper_enabled(void);
+
+bool uid_wrapper_enabled(void)
 {
-return 0;
+   return false;
 }


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-01-30 Thread Andreas Schneider
The branch, master has been updated
   via  84a3e42 Add ChangeLog.
  from  914e54c Add TODO

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


- Log -
commit 84a3e42db0a94367af85e5bc4c15f3ac190e4165
Author: Andreas Schneider a...@samba.org
Date:   Thu Jan 30 18:15:14 2014 +0100

Add ChangeLog.

---

Summary of changes:
 ChangeLog |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ChangeLog b/ChangeLog
index e69de29..d2f5d4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,5 @@
+ChangeLog
+==
+
+version 1.0.0 (released 2014-02-02)
+  * Initial release


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-01-24 Thread Andreas Schneider
The branch, master has been updated
   via  914e54c Add TODO
  from  ea4387a cmake: Add cmake version file.

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


- Log -
commit 914e54c8daf6a651432b339a813f8e7dd4a166e7
Author: Andreas Schneider a...@samba.org
Date:   Fri Jan 24 10:47:09 2014 +0100

Add TODO

---

Summary of changes:
 TODO |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)
 create mode 100644 TODO


Changeset truncated at 500 lines:

diff --git a/TODO b/TODO
new file mode 100644
index 000..9654e22
--- /dev/null
+++ b/TODO
@@ -0,0 +1,14 @@
+TODO
+=
+
+Library:
+-
+
+Testing:
+-
+
+* More threading tests for linux.
+* Add missing tests.
+  Check the code coverage on
+  http://mock.cryptomilk.org/index.php?project=uidwrapper
+  to see what tests are still needed.


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-01-20 Thread Andreas Schneider
The branch, master has been updated
   via  ea4387a cmake: Add cmake version file.
   via  33608ec cmake: Add a pkg-config file.
  from  3ded8a3 Update README.

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


- Log -
commit ea4387af7c66e2c0a667afd5f775e1f23e34e59e
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 20 12:43:21 2014 +0100

cmake: Add cmake version file.

commit 33608ec26a836ee21b41acbacf4f65d5cb07e6f9
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 20 12:43:08 2014 +0100

cmake: Add a pkg-config file.

---

Summary of changes:
 CMakeLists.txt  |   22 
 cmake/Modules/DefineInstallationPaths.cmake |   29 +++---
 uid_wrapper-config-version.cmake.in |   11 ++
 uid_wrapper.pc.cmake|3 ++
 4 files changed, 53 insertions(+), 12 deletions(-)
 create mode 100644 uid_wrapper-config-version.cmake.in
 create mode 100644 uid_wrapper.pc.cmake


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2be515a..b806e62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,28 @@ find_package(Threads)
 include(ConfigureChecks.cmake)
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
+# pkg-config file
+configure_file(uid_wrapper.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper.pc 
@ONLY)
+install(
+  FILES
+${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper.pc
+  DESTINATION
+${LIB_INSTALL_DIR}/pkgconfig
+  COMPONENT
+pkgconfig
+)
+
+# cmake config files
+configure_file(uid_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake @ONLY)
+install(
+FILES
+${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake
+DESTINATION
+${CMAKE_INSTALL_DIR}
+COMPONENT
+devel
+)
+
 # check subdirectories
 add_subdirectory(src)
 
diff --git a/cmake/Modules/DefineInstallationPaths.cmake 
b/cmake/Modules/DefineInstallationPaths.cmake
index d857871..88e08ca 100644
--- a/cmake/Modules/DefineInstallationPaths.cmake
+++ b/cmake/Modules/DefineInstallationPaths.cmake
@@ -1,15 +1,4 @@
-if (WIN32)
-  # Same same
-  set(BIN_INSTALL_DIR bin CACHE PATH -)
-  set(SBIN_INSTALL_DIR . CACHE PATH -)
-  set(LIB_INSTALL_DIR lib CACHE PATH -)
-  set(INCLUDE_INSTALL_DIR include CACHE PATH -)
-  set(PLUGIN_INSTALL_DIR plugins CACHE PATH -)
-  set(HTML_INSTALL_DIR doc/HTML CACHE PATH -)
-  set(ICON_INSTALL_DIR . CACHE PATH -)
-  set(SOUND_INSTALL_DIR . CACHE PATH -)
-  set(LOCALE_INSTALL_DIR lang CACHE PATH -)
-elseif (UNIX OR OS2)
+if (UNIX OR OS2)
   IF (NOT APPLICATION_NAME)
 MESSAGE(STATUS ${PROJECT_NAME} is used as APPLICATION_NAME)
 SET(APPLICATION_NAME ${PROJECT_NAME})
@@ -58,6 +47,10 @@ elseif (UNIX OR OS2)
 CACHE PATH The subdirectory to the header prefix (default prefix/include)
   )
 
+  set(CMAKE_INSTALL_DIR
+${LIB_INSTALL_DIR}/cmake
+CACHE PATH The subdirectory to install cmake config files)
+
   SET(DATA_INSTALL_DIR
 ${DATA_INSTALL_PREFIX}
 CACHE PATH The parent directory where applications can install their data 
(default prefix/share/${APPLICATION_NAME})
@@ -101,4 +94,16 @@ elseif (UNIX OR OS2)
 ${SHARE_INSTALL_PREFIX}/info
 CACHE PATH The ${APPLICATION_NAME} info install dir (default prefix/info)
   )
+else()
+  # Same same
+  set(BIN_INSTALL_DIR bin CACHE PATH -)
+  set(SBIN_INSTALL_DIR sbin CACHE PATH -)
+  set(LIB_INSTALL_DIR lib${LIB_SUFFIX} CACHE PATH -)
+  set(INCLUDE_INSTALL_DIR include CACHE PATH -)
+  set(CMAKE_INSTALL_DIR CMake CACHE PATH -)
+  set(PLUGIN_INSTALL_DIR plugins CACHE PATH -)
+  set(HTML_INSTALL_DIR doc/HTML CACHE PATH -)
+  set(ICON_INSTALL_DIR icons CACHE PATH -)
+  set(SOUND_INSTALL_DIR soudns CACHE PATH -)
+  set(LOCALE_INSTALL_DIR lang CACHE PATH -)
 endif ()
diff --git a/uid_wrapper-config-version.cmake.in 
b/uid_wrapper-config-version.cmake.in
new file mode 100644
index 000..98f292c
--- /dev/null
+++ b/uid_wrapper-config-version.cmake.in
@@ -0,0 +1,11 @@
+set(PACKAGE_VERSION @APPLICATION_VERSION@)
+
+# Check whether the requested PACKAGE_FIND_VERSION is compatible
+if(${PACKAGE_VERSION} VERSION_LESS ${PACKAGE_FIND_VERSION})
+set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+set(PACKAGE_VERSION_COMPATIBLE TRUE)
+if (${PACKAGE_VERSION} VERSION_EQUAL ${PACKAGE_FIND_VERSION})
+set(PACKAGE_VERSION_EXACT TRUE)
+endif()
+endif()
diff --git a/uid_wrapper.pc.cmake b/uid_wrapper.pc.cmake
new file mode 100644
index 000..688e104
--- /dev/null
+++ b/uid_wrapper.pc.cmake
@@ -0,0 +1,3 @@
+Name: @APPLICATION_NAME@
+Description: The uid_wrapper library
+Version: @APPLICATION_VERSION@


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-01-19 Thread Andreas Schneider
The branch, master has been updated
   via  3ded8a3 Update README.
  from  307d1bb uwrap: Rename uwrap_enabled() to uid_wrapper_enabled().

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


- Log -
commit 3ded8a33bd70a97df3bfb551ac5da6a280a1945a
Author: Andreas Schneider a...@cryptomilk.org
Date:   Sun Jan 19 20:23:01 2014 +0100

Update README.

---

Summary of changes:
 README |   26 --
 1 files changed, 24 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/README b/README
index aac2285..6f19b38 100644
--- a/README
+++ b/README
@@ -1,8 +1,13 @@
 UID wrapper library
 
 
-This library intercepts seteuid and related calls, and simulates them
-in a manner similar to the nss_wrapper and socket_wrapper libraries.
+Privilege separation - Some projects like a file server need privilege
+separation to be able to switch to the connnection user and do file operations.
+uid_wrapper convincingly lies to the application letting it believe it is
+operating as root and even switching betwen uids and gids as needed.
+
+More precise this library intercepts seteuid and related calls, and simulates
+them in a manner similar to the nss_wrapper and socket_wrapper libraries.
 
 This allows you to do user switching when testing e.g. file servers.
 
@@ -18,3 +23,20 @@ UID_WRAPPER_ROOT=1
 
 If you set the environment variable to UID_WRAPPER_MYUID=1 before you call
 geteuid() then it will return the real uid.
+
+To find out if uid_wrapper is enabled, we suggest to implment the following
+function in a library your application loads:
+
+int uid_wrapper_enabled(void)
+{
+return 0;
+}
+
+Then you can use:
+
+if (uid_wrapper_enabled()) {
+/* special uid_wrapper handling code */
+}
+
+uid_wrapper implements this funciton too and it will be loaded before your
+library gets loaded.


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2014-01-17 Thread Andreas Schneider
The branch, master has been updated
   via  307d1bb uwrap: Rename uwrap_enabled() to uid_wrapper_enabled().
  from  efc5f66 uwrap: Rename the variable to get myuid from geteuid().

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


- Log -
commit 307d1bb17e888b58e32241244d41c57a642d652c
Author: Andreas Schneider a...@samba.org
Date:   Fri Jan 17 15:30:32 2014 +0100

uwrap: Rename uwrap_enabled() to uid_wrapper_enabled().

---

Summary of changes:
 src/uid_wrapper.c  |   34 +-
 tests/test_uwrap_enabled.c |8 
 tests/uwrap_enabled.c  |4 ++--
 3 files changed, 23 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index d2cb618..0120510 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -175,7 +175,7 @@ static pthread_mutex_t uwrap_id_mutex = 
PTHREAD_MUTEX_INITIALIZER;
  * UWRAP PROTOTYPES
  */
 
-int uwrap_enabled(void);
+int uid_wrapper_enabled(void);
 void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*
@@ -548,7 +548,7 @@ static void uwrap_init(void)
pthread_mutex_unlock(uwrap_id_mutex);
 }
 
-int uwrap_enabled(void)
+int uid_wrapper_enabled(void)
 {
uwrap_init();
 
@@ -618,7 +618,7 @@ static int uwrap_setresuid(uid_t ruid, uid_t euid, uid_t 
suid)
  */
 int setuid(uid_t uid)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setuid(uid);
}
 
@@ -633,7 +633,7 @@ int seteuid(uid_t euid)
return -1;
}
 
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_seteuid(euid);
}
 
@@ -649,7 +649,7 @@ int setreuid(uid_t ruid, uid_t euid)
return -1;
}
 
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setreuid(ruid, euid);
}
 
@@ -660,7 +660,7 @@ int setreuid(uid_t ruid, uid_t euid)
 #ifdef HAVE_SETRESUID
 int setresuid(uid_t ruid, uid_t euid, uid_t suid)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setresuid(ruid, euid, suid);
}
 
@@ -685,7 +685,7 @@ static uid_t uwrap_getuid(void)
 
 uid_t getuid(void)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_getuid();
}
 
@@ -715,7 +715,7 @@ static uid_t uwrap_geteuid(void)
 
 uid_t geteuid(void)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_geteuid();
}
 
@@ -785,7 +785,7 @@ static int uwrap_setresgid(gid_t rgid, gid_t egid, gid_t 
sgid)
  */
 int setgid(gid_t gid)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setgid(gid);
}
 
@@ -795,7 +795,7 @@ int setgid(gid_t gid)
 #ifdef HAVE_SETEGID
 int setegid(gid_t egid)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setegid(egid);
}
 
@@ -806,7 +806,7 @@ int setegid(gid_t egid)
 #ifdef HAVE_SETREGID
 int setregid(gid_t rgid, gid_t egid)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setregid(rgid, egid);
}
 
@@ -817,7 +817,7 @@ int setregid(gid_t rgid, gid_t egid)
 #ifdef HAVE_SETRESGID
 int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setresgid(rgid, egid, sgid);
}
 
@@ -842,7 +842,7 @@ static gid_t uwrap_getgid(void)
 
 gid_t getgid(void)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_getgid();
}
 
@@ -866,7 +866,7 @@ static uid_t uwrap_getegid(void)
 
 uid_t getegid(void)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_getegid();
}
 
@@ -937,7 +937,7 @@ int setgroups(int size, const gid_t *list)
 int setgroups(size_t size, const gid_t *list)
 #endif
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_setgroups(size, list);
}
 
@@ -972,7 +972,7 @@ out:
 
 int getgroups(int size, gid_t *list)
 {
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
return libc_getgroups(size, list);
}
 
@@ -1135,7 +1135,7 @@ long int syscall (long int sysno, ...)
 
va_start(va, sysno);
 
-   if (!uwrap_enabled()) {
+   if (!uid_wrapper_enabled()) {
rc = libc_vsyscall(sysno, va);
va_end(va);
return rc;
diff --git a/tests/test_uwrap_enabled.c 

[SCM] UID Wrapper Repository - branch master updated

2014-01-07 Thread Andreas Schneider
The branch, master has been updated
   via  efc5f66 uwrap: Rename the variable to get myuid from geteuid().
   via  553b3dc uwrap: Make uwrap_enabled public so we can use it.
  from  c1a96dc tests: Fix some memory leaks.

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


- Log -
commit efc5f660a10fe6b978837609983ce7a080998a75
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Jan 7 13:31:58 2014 +0100

uwrap: Rename the variable to get myuid from geteuid().

commit 553b3dc15e5e16c81e7375084eafd95c7ad42d20
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Jan 7 13:30:06 2014 +0100

uwrap: Make uwrap_enabled public so we can use it.

---

Summary of changes:
 README |2 +-
 src/uid_wrapper.c  |7 ---
 tests/CMakeLists.txt   |8 
 tests/test_uwrap_enabled.c |   30 ++
 tests/uwrap_enabled.c  |6 ++
 5 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 tests/test_uwrap_enabled.c
 create mode 100644 tests/uwrap_enabled.c


Changeset truncated at 500 lines:

diff --git a/README b/README
index 9aa508b..aac2285 100644
--- a/README
+++ b/README
@@ -16,5 +16,5 @@ loaded. If you need the application to think it is root at 
startup you can set:
 
 UID_WRAPPER_ROOT=1
 
-If you set the environment variable to UID_WRAPPER_ROOT=2 before you call
+If you set the environment variable to UID_WRAPPER_MYUID=1 before you call
 geteuid() then it will return the real uid.
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 077bef7..d2cb618 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -175,6 +175,7 @@ static pthread_mutex_t uwrap_id_mutex = 
PTHREAD_MUTEX_INITIALIZER;
  * UWRAP PROTOTYPES
  */
 
+int uwrap_enabled(void);
 void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*
@@ -547,7 +548,7 @@ static void uwrap_init(void)
pthread_mutex_unlock(uwrap_id_mutex);
 }
 
-static int uwrap_enabled(void)
+int uwrap_enabled(void)
 {
uwrap_init();
 
@@ -696,7 +697,7 @@ uid_t getuid(void)
  */
 static uid_t uwrap_geteuid(void)
 {
-   const char *env = getenv(UID_WRAPPER_ROOT);
+   const char *env = getenv(UID_WRAPPER_MYUID);
struct uwrap_thread *id = uwrap_tls_id;
uid_t uid;
 
@@ -705,7 +706,7 @@ static uid_t uwrap_geteuid(void)
pthread_mutex_unlock(uwrap_id_mutex);
 
/* Disable root and return myuid */
-   if (env != NULL  env[0] == '2') {
+   if (env != NULL  env[0] == '1') {
uid = uwrap.myuid;
}
 
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 76fdb6b..3c6ab2b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -19,6 +19,14 @@ set_property(
 PROPERTY
 ENVIRONMENT ${TEST_ENVIRONMENT})
 
+add_library(uwrap_enabled SHARED uwrap_enabled.c)
+add_cmocka_test(test_uwrap_enabled test_uwrap_enabled.c ${CMOCKA_LIBRARY} 
uwrap_enabled)
+set_property(
+TEST
+test_uwrap_enabled
+PROPERTY
+ENVIRONMENT ${TEST_ENVIRONMENT})
+
 if (LINUX)
 add_cmocka_test(test_glibc_thread_support test_glibc_thread_support.c 
${CMOCKA_LIBRARY})
 target_link_libraries(test_glibc_thread_support ${CMAKE_THREAD_LIBS_INIT})
diff --git a/tests/test_uwrap_enabled.c b/tests/test_uwrap_enabled.c
new file mode 100644
index 000..1ff5531
--- /dev/null
+++ b/tests/test_uwrap_enabled.c
@@ -0,0 +1,30 @@
+#include config.h
+
+#include stdarg.h
+#include stddef.h
+#include setjmp.h
+#include cmocka.h
+
+int uwrap_enabled(void);
+
+static void test_uwrap_enabled(void **state)
+{
+int rc;
+
+(void)state; /* unused */
+
+rc = uwrap_enabled();
+assert_int_equal(rc, 1);
+}
+
+int main(void) {
+   int rc;
+
+   const UnitTest tests[] = {
+   unit_test(test_uwrap_enabled),
+   };
+
+   rc = run_tests(tests);
+
+   return rc;
+}
diff --git a/tests/uwrap_enabled.c b/tests/uwrap_enabled.c
new file mode 100644
index 000..c1bcf3a
--- /dev/null
+++ b/tests/uwrap_enabled.c
@@ -0,0 +1,6 @@
+int uwrap_enabled(void);
+
+int uwrap_enabled(void)
+{
+return 0;
+}


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  a9bb877 uwrap: Pass bool values to uwrap_new_id().
   via  8ac9882 uwrap: Fix a memory leak when we reuse an allocated id.
   via  8bcb0ab uwrap: Add a destructor to free resources.
   via  0d0adbf cmake: Add check for HAVE_DESTRUCTOR_ATTRIBUTE.
   via  b20dbe2 uwrap: Use realloc for setgroups().
   via  f7bedda uwrap: Fix loading the system libraries.
  from  623bed5 tests: Add test_uwrap_disabled.

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


- Log -
commit a9bb87790557a74328b77f423c6b62b3814cd157
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:03:04 2013 +0100

uwrap: Pass bool values to uwrap_new_id().

commit 8ac9882e33c8df7c6c985673495d208265e409dd
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:02:37 2013 +0100

uwrap: Fix a memory leak when we reuse an allocated id.

commit 8bcb0ab1c9db8d03f1bdc998b6765eb2d76a4357
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:02:03 2013 +0100

uwrap: Add a destructor to free resources.

commit 0d0adbf10a5f6359a5f63f611bf5e4b71a801e13
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:01:27 2013 +0100

cmake: Add check for HAVE_DESTRUCTOR_ATTRIBUTE.

commit b20dbe2122988a2aaace30ba010de87af8b5a755
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 12:54:14 2013 +0100

uwrap: Use realloc for setgroups().

commit f7bedda4695cb84aacf5140e5784758e4db65ef3
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 11:09:15 2013 +0100

uwrap: Fix loading the system libraries.

Thanks metze!

---

Summary of changes:
 ConfigureChecks.cmake |   11 ++
 config.h.cmake|1 +
 src/uid_wrapper.c |   94 
 3 files changed, 82 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 77a701f..123128f 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -131,6 +131,17 @@ int main(void) {
 return 0;
 } HAVE_GCC_THREAD_LOCAL_STORAGE)
 
+check_c_source_compiles(
+void test_destructor_attribute(void) __attribute__ ((destructor));
+
+void test_destructor_attribute(void)
+{
+return;
+}
+
+int main(void) {
+return 0;
+} HAVE_DESTRUCTOR_ATTRIBUTE)
 
 # SYSTEM LIBRARIES
 
diff --git a/config.h.cmake b/config.h.cmake
index 679390c..0e67b23 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -57,6 +57,7 @@
 #cmakedefine HAVE_LINUX_32BIT_SYSCALLS 1
 
 #cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
+#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
 
 /*** ENDIAN */
 
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index ff2639f..077bef7 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -43,6 +43,12 @@
 # define UWRAP_THREAD
 #endif
 
+#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
+#define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
+#else
+#define DESTRUCTOR_ATTRIBUTE
+#endif /* HAVE_DESTRUCTOR_ATTRIBUTE */
+
 #ifdef NDEBUG
 #define UWRAP_DEBUG(...)
 #else
@@ -80,6 +86,10 @@
(item)-next= NULL; \
 } while (0)
 
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
+#endif
+
 #define LIBC_NAME libc.so
 
 struct uwrap_libc_fns {
@@ -162,6 +172,12 @@ static UWRAP_THREAD struct uwrap_thread *uwrap_tls_id;
 static pthread_mutex_t uwrap_id_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 /*
+ * UWRAP PROTOTYPES
+ */
+
+void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
+
+/*
  * UWRAP LIBC LOADER FUNCTIONS
  */
 
@@ -191,6 +207,7 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
case UWRAP_LIBSOCKET:
/* FALL TROUGH */
case UWRAP_LIBC:
+   handle = uwrap.libc.handle;
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -200,8 +217,6 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
}
 
uwrap.libc.handle = handle;
-   } else {
-   handle = uwrap.libc.handle;
}
break;
}
@@ -412,6 +427,15 @@ static int uwrap_new_id(pthread_t tid, bool do_alloc)
errno = ENOMEM;
return -1;
}
+
+   id-groups = malloc(sizeof(gid_t) * 1);
+   if (id-groups == NULL) {
+   errno = ENOMEM;
+   return -1;
+

[SCM] UID Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  c1a96dc tests: Fix some memory leaks.
   via  f2f1e56 cmake: Add valgrind suppression file.
  from  a9bb877 uwrap: Pass bool values to uwrap_new_id().

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


- Log -
commit c1a96dcb8a75809cb2efed79519d1e0518089c13
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:18:46 2013 +0100

tests: Fix some memory leaks.

commit f2f1e5624bfcb8a6c828d2e5f729213849dfb577
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:18:34 2013 +0100

cmake: Add valgrind suppression file.

---

Summary of changes:
 tests/test_glibc_thread_support.c |5 +
 tests/valgrind.supp   |   16 
 2 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 tests/valgrind.supp


Changeset truncated at 500 lines:

diff --git a/tests/test_glibc_thread_support.c 
b/tests/test_glibc_thread_support.c
index 159cf91..357862e 100644
--- a/tests/test_glibc_thread_support.c
+++ b/tests/test_glibc_thread_support.c
@@ -67,6 +67,8 @@ static void test_syscall_setreuid(void **state)
for (i = 0; i  NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
}
+
+   free(threads);
 }
 
 static void *sync_setreuid(void *arg)
@@ -132,6 +134,9 @@ static void test_sync_setreuid(void **state)
for (i = 0; i  NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
}
+
+   free(threads);
+   free(p);
 }
 
 int main(void) {
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
new file mode 100644
index 000..9857825
--- /dev/null
+++ b/tests/valgrind.supp
@@ -0,0 +1,16 @@
+### GLIBC
+{
+   glibc_dlopen_alloc
+   Memcheck:Leak
+   fun:calloc
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.2.5
+}
+
+{
+   glibc_dlclose_alloc
+   Memcheck:Leak
+   fun:calloc
+   fun:_dlerror_run
+   fun:dlclose
+}


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2013-12-19 Thread Andreas Schneider
The branch, master has been updated
   via  623bed5 tests: Add test_uwrap_disabled.
   via  71ef97c testsuite: Add missing include.
  from  cf9d399 cmake: Fix HAVE_SETRESUID and HAVE_SETRESGID.

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


- Log -
commit 623bed5045974272d0c434203ff7f99375171bcc
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 09:52:22 2013 +0100

tests: Add test_uwrap_disabled.

commit 71ef97c1134539c69df036458a9f24b25f2f7821
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 09:52:05 2013 +0100

testsuite: Add missing include.

---

Summary of changes:
 tests/CMakeLists.txt|7 +
 tests/test_uwrap_disabled.c |  261 +++
 tests/testsuite.c   |1 +
 3 files changed, 269 insertions(+), 0 deletions(-)
 create mode 100644 tests/test_uwrap_disabled.c


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 871905b..76fdb6b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -32,3 +32,10 @@ endif(LINUX)
 if (LINUX)
 add_executable(getuids getuids.c)
 endif (LINUX)
+
+add_cmocka_test(test_uwrap_disabled test_uwrap_disabled.c ${CMOCKA_LIBRARY})
+set_property(
+TEST
+test_uwrap_disabled
+PROPERTY
+ENVIRONMENT LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libuid_wrapper.so)
diff --git a/tests/test_uwrap_disabled.c b/tests/test_uwrap_disabled.c
new file mode 100644
index 000..f2336a4
--- /dev/null
+++ b/tests/test_uwrap_disabled.c
@@ -0,0 +1,261 @@
+#include config.h
+
+#include stdarg.h
+#include stddef.h
+#include setjmp.h
+#include cmocka.h
+
+#include sys/types.h
+#include pwd.h
+#include grp.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+
+#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, 
sizeof(*(x))); } while(0)
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+struct test_opts {
+   int root_mode;
+   uid_t myuid;
+   gid_t mygid;
+   uid_t nbuid;
+   gid_t nbgid;
+};
+
+static void setup(void **state)
+{
+   struct test_opts *t;
+   struct passwd *pwd;
+
+   pwd = getpwnam(nobody);
+   assert_non_null(pwd);
+
+   t = malloc(sizeof(struct test_opts));
+   assert_non_null(t);
+
+   ZERO_STRUCTP(t);
+
+   t-myuid = getuid();
+   t-mygid = getgid();
+
+   t-nbuid = pwd-pw_uid;
+   t-nbgid = pwd-pw_gid;
+
+   if (getuid() == (uid_t)0 || geteuid() == (uid_t)0) {
+   t-root_mode = 1;
+   }
+
+   *state = t;
+}
+
+static void teardown(void **state)
+{
+   struct test_opts *t = (struct test_opts *)*state;
+
+   setuid(t-myuid);
+   seteuid(t-myuid);
+   setgid(t-mygid);
+   setegid(t-mygid);
+
+   free(t);
+}
+
+static void test_uwrap_setuid(void **state)
+{
+   struct test_opts *t = (struct test_opts *)*state;
+   int rc;
+
+   if (t-root_mode) {
+   return;
+   } else {
+   rc = setuid(t-nbuid);
+   assert_int_equal(rc, -1);
+   }
+}
+
+static void test_uwrap_seteuid(void **state)
+{
+   struct test_opts *t = (struct test_opts *)*state;
+   uid_t u;
+   int rc;
+
+   if (t-root_mode) {
+   rc = seteuid(t-nbuid);
+   assert_int_equal(rc, 0);
+
+   u = geteuid();
+   assert_int_equal(u, t-nbuid);
+   } else {
+   rc = seteuid(t-nbuid);
+   assert_int_equal(rc, -1);
+   }
+}
+
+#ifdef HAVE_SETREUID
+static void test_uwrap_setreuid(void **state)
+{
+   struct test_opts *t = (struct test_opts *)*state;
+   uid_t u;
+   int rc;
+
+   if (t-root_mode) {
+   rc = setreuid(-1, t-nbuid);
+   assert_int_equal(rc, 0);
+
+   u = geteuid();
+   assert_int_equal(u, t-nbuid);
+   } else {
+   rc = setreuid(-1, t-nbuid);
+   assert_int_equal(rc, -1);
+   }
+}
+#endif
+
+#ifdef HAVE_SETRESUID
+static void test_uwrap_setresuid(void **state)
+{
+   struct test_opts *t = (struct test_opts *)*state;
+   uid_t u;
+   int rc;
+
+   if (t-root_mode) {
+   rc = setresuid(-1, t-nbuid, -1);
+   assert_int_equal(rc, 0);
+
+   u = geteuid();
+   assert_int_equal(u, t-nbuid);
+   } else {
+   rc = setresuid(-1, t-nbuid, -1);
+   assert_int_equal(rc, -1);
+   }
+}
+#endif
+
+static void test_uwrap_setgid(void **state)
+{
+   struct test_opts *t = (struct test_opts *)*state;
+   int rc;
+
+   if (t-root_mode) {
+   return;
+   } else {
+   rc = setgid(t-nbgid);
+   assert_int_equal(rc, -1);
+   }
+}
+
+static void test_uwrap_setegid(void **state)
+{
+   struct 

[SCM] UID Wrapper Repository - branch master updated

2013-12-18 Thread Andreas Schneider
The branch, master has been updated
   via  b36c8e1 tests: Add test_uwrap_syscall_setgroups().
   via  c4326d1 tests: Add test_uwrap_setresuid().
   via  c1b1430 tests: Add test_uwrap_setreuid().
   via  a1341ef tests: Add test_uwrap_setresgid().
   via  d0270b9 tests: Add test_uwrap_setregid().
   via  b4fdaa9 tests: The tests should always be executed with uid_wrapper.
   via  1cbcd32 nwrap: Fix prototype of libc_setresuid().
   via  280d918 cmake: Fix defines for setres(u|g)id.
  from  8f8e057 uwrap: Remove obsolete uwrap_libc_fn().

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


- Log -
commit b36c8e1e269daacc60031fa437477665a0171f7c
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 17:23:31 2013 +0100

tests: Add test_uwrap_syscall_setgroups().

commit c4326d1ac83ad239822e2b65a228a3078e641c92
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 17:11:14 2013 +0100

tests: Add test_uwrap_setresuid().

commit c1b14304e4b3677dc69398958739f387925ee2ca
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 17:09:15 2013 +0100

tests: Add test_uwrap_setreuid().

commit a1341eff5e63842d8367039220a446fe1d9875b7
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 17:06:46 2013 +0100

tests: Add test_uwrap_setresgid().

commit d0270b9d54b3e7aa9e76940deeeb5aba8db5e6b3
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 16:59:54 2013 +0100

tests: Add test_uwrap_setregid().

commit b4fdaa903d71651751a7d535ea7eb854da7c64d1
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 16:53:17 2013 +0100

tests: The tests should always be executed with uid_wrapper.

commit 1cbcd32be96a8116e036d272cc8f8c82d3990649
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 17:05:57 2013 +0100

nwrap: Fix prototype of libc_setresuid().

commit 280d918269e63f971402fbae4418ab2bc64876bb
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 17:02:08 2013 +0100

cmake: Fix defines for setres(u|g)id.

---

Summary of changes:
 config.h.cmake|4 +-
 src/uid_wrapper.c |2 +-
 tests/testsuite.c |  163 +
 3 files changed, 117 insertions(+), 52 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config.h.cmake b/config.h.cmake
index a714ccf..679390c 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -29,7 +29,7 @@
 #cmakedefine HAVE_SETREUID 1
 
 /* Define to 1 if you have the `setresuid' function. */
-#cmakedefine HAVE_SETREUID 1
+#cmakedefine HAVE_SETRESUID 1
 
 /* Define to 1 if you have the `setegid' function. */
 #cmakedefine HAVE_SETEGID 1
@@ -38,7 +38,7 @@
 #cmakedefine HAVE_SETREGID 1
 
 /* Define to 1 if you have the `setresgid' function. */
-#cmakedefine HAVE_SETREGID 1
+#cmakedefine HAVE_SETRESGID 1
 
 /* Define to 1 if you have the `setgroups' function. */
 #cmakedefine HAVE_SETGROUPS 1
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 2f3d3ad..ff2639f 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -281,7 +281,7 @@ static int libc_setreuid(uid_t ruid, uid_t euid)
 #endif
 
 #ifdef HAVE_SETRESUID
-int libc_setresuid(uid_t ruid, uid_t euid, uid_t suid);
+static int libc_setresuid(uid_t ruid, uid_t euid, uid_t suid)
 {
uwrap_load_lib_function(UWRAP_LIBC, setresuid);
 
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 67836fa..412b50f 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -30,13 +30,6 @@ static void test_uwrap_seteuid(void **state)
 {
int rc;
uid_t u;
-   char *env;
-
-   env = getenv(UID_WRAPPER);
-   if (env == NULL) {
-   printf(UID_WRAPPER env not set, uid_wrapper is disabled\n);
-   return;
-   }
 
(void) state; /* unused */
 
@@ -58,17 +51,48 @@ static void test_uwrap_seteuid(void **state)
assert_int_equal(u, 42);
 }
 
-static void test_uwrap_setuid(void **state)
+#ifdef HAVE_SETREUID
+static void test_uwrap_setreuid(void **state)
 {
int rc;
uid_t u;
-   char *env;
 
-   env = getenv(UID_WRAPPER);
-   if (env == NULL) {
-   printf(UID_WRAPPER env not set, uid_wrapper is disabled\n);
-   return;
-   }
+   (void) state; /* unused */
+
+   rc = setreuid(1, 2);
+   assert_int_equal(rc, 0);
+
+   u = getuid();
+   assert_int_equal(u, 1);
+
+   u = geteuid();
+   assert_int_equal(u, 2);
+}
+#endif
+
+#ifdef HAVE_SETRESUID
+static void test_uwrap_setresuid(void **state)
+{
+   int rc;
+   uid_t u;
+
+   (void) state; /* unused */
+
+   rc = setresuid(1, 2, -1);
+   assert_int_equal(rc, 0);
+
+   u = getuid();
+   assert_int_equal(u, 1);
+
+   u = geteuid();
+   assert_int_equal(u, 2);
+}
+#endif
+
+static void test_uwrap_setuid(void **state)
+{
+   

[SCM] UID Wrapper Repository - branch master updated

2013-12-18 Thread Andreas Schneider
The branch, master has been updated
   via  cf9d399 cmake: Fix HAVE_SETRESUID and HAVE_SETRESGID.
  from  b36c8e1 tests: Add test_uwrap_syscall_setgroups().

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


- Log -
commit cf9d399d9d7dbf00b0fbf3b91dd2676e83d7dcd9
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 08:46:45 2013 +0100

cmake: Fix HAVE_SETRESUID and HAVE_SETRESGID.

---

Summary of changes:
 ConfigureChecks.cmake |4 ++--
 tests/testsuite.c |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index fe0623e..77a701f 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -60,11 +60,11 @@ check_function_exists(snprintf HAVE_SNPRINTF)
 
 check_function_exists(seteuid HAVE_SETEUID)
 check_function_exists(setreuid HAVE_SETREUID)
-check_function_exists(setreuid HAVE_SETRESUID)
+check_function_exists(setresuid HAVE_SETRESUID)
 
 check_function_exists(setegid HAVE_SETEGID)
 check_function_exists(setregid HAVE_SETREGID)
-check_function_exists(setregid HAVE_SETRESGID)
+check_function_exists(setresgid HAVE_SETRESGID)
 
 check_function_exists(getgroups HAVE_GETGROUPS)
 check_function_exists(setgroups HAVE_SETGROUPS)
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 412b50f..6fa8d74 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -323,7 +323,7 @@ int main(void) {
 #ifdef HAVE_SETREUID
unit_test(test_uwrap_setreuid),
 #endif
-#ifdef HAVE_SETREUID
+#ifdef HAVE_SETRESUID
unit_test(test_uwrap_setresuid),
 #endif
unit_test(test_uwrap_setuid),


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2013-12-17 Thread Andreas Schneider
The branch, master has been updated
   via  8f8e057 uwrap: Remove obsolete uwrap_libc_fn().
   via  0a2f692 uwrap: Load libc_syscall correctly.
   via  9655c33 uwrap: Add libc_getgroups().
   via  40b3089 uwrap: Add libc_getgroups().
   via  496597f uwrap: Add libc_getegid().
   via  5e7437d uwrap: Add libc_setregid().
   via  0a08fb9 uwrap: Add libc_setregid().
   via  75d4358 uwrap: Add libc_setgeid().
   via  cd7caf4 uwarp: Add libc_getgid().
   via  189235a uwrap: Add libc_setgid().
   via  27b8eac uwrap: Add libc_geteuid().
   via  863fa03 uwrap: Add libc_setresuid().
   via  acc5f58 uwrap: Add libc_setreuid().
   via  e26dcbd uwrap: Add libc_seteuid().
   via  1693c1e uwrap: Add libc_getuid().
   via  1a2f908 uwrap: Add libc_setuid().
   via  bc56160 uwrap: Add uwrap_load_lib_function().
   via  ac320d3 uwrap: Add uwrap_load_lib_handle().
  from  644c98e tests: Add a test for getgroups().

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


- Log -
commit 8f8e057dfe0c3bd47e9b77d9ec0f659d9cb5fb39
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:39:42 2013 +0100

uwrap: Remove obsolete uwrap_libc_fn().

commit 0a2f692d22b1e95aad34f2c540a361d03ae82b9b
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:38:30 2013 +0100

uwrap: Load libc_syscall correctly.

commit 9655c33988a82cea5215a0bb51becf53b2536e63
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:36:15 2013 +0100

uwrap: Add libc_getgroups().

commit 40b30893e36cd2b30c02163665a1b95825038f0a
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:35:21 2013 +0100

uwrap: Add libc_getgroups().

commit 496597f7bde16d350f0d3f1c7835b84b88c95b84
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:33:57 2013 +0100

uwrap: Add libc_getegid().

commit 5e7437ddc154ca2b2091a7eb4aa140caabc60c61
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:31:28 2013 +0100

uwrap: Add libc_setregid().

commit 0a08fb98edc881fae7565c10c825d2c3597c3c99
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:28:37 2013 +0100

uwrap: Add libc_setregid().

commit 75d435884d29b0e0d873438c8e6acddbd6bcb2d2
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:27:12 2013 +0100

uwrap: Add libc_setgeid().

commit cd7caf4088c448422ec3fdac282c63eb8bf13c56
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:26:04 2013 +0100

uwarp: Add libc_getgid().

commit 189235a8556971c39c9cf4770fbfa16ba1493da8
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:24:59 2013 +0100

uwrap: Add libc_setgid().

commit 27b8eac9bc3e0a7e62dc5ded95850e31f720d671
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:20:02 2013 +0100

uwrap: Add libc_geteuid().

commit 863fa03a7d065b279f6cd13388b00625c5a34c88
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:10:08 2013 +0100

uwrap: Add libc_setresuid().

commit acc5f58a663f7058b8d286804fa9331b0716c54d
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:08:16 2013 +0100

uwrap: Add libc_setreuid().

commit e26dcbd3cb18d754865ba866b0fd8df16169a4fe
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:06:49 2013 +0100

uwrap: Add libc_seteuid().

commit 1693c1e67943d57d6f551b06a0514ed8ded054ab
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:05:34 2013 +0100

uwrap: Add libc_getuid().

commit 1a2f908cb8229dbd606917ad026925d3dbfe3ab7
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 13:03:40 2013 +0100

uwrap: Add libc_setuid().

commit bc56160b5659a7345524402258ae3a674fcc84a5
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:59:49 2013 +0100

uwrap: Add uwrap_load_lib_function().

commit ac320d3eedc88584e9bafab0111616fd5228ae84
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:57:29 2013 +0100

uwrap: Add uwrap_load_lib_handle().

---

Summary of changes:
 src/uid_wrapper.c |  301 +
 1 files changed, 212 insertions(+), 89 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 2ea1cdf..2f3d3ad 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -92,7 +92,7 @@ struct uwrap_libc_fns {
 #ifdef HAVE_SETREUID
int (*_libc_setreuid)(uid_t ruid, uid_t euid);
 #endif
-#ifdef HAVE_SETREUID
+#ifdef HAVE_SETRESUID
int (*_libc_setresuid)(uid_t ruid, uid_t euid, uid_t suid);
 #endif
uid_t (*_libc_geteuid)(void);
@@ -105,7 +105,7 @@ struct uwrap_libc_fns {
 #ifdef HAVE_SETREGID
int (*_libc_setregid)(uid_t rgid, uid_t egid);
 #endif
-#ifdef HAVE_SETREGID
+#ifdef HAVE_SETRESGID
int (*_libc_setresgid)(uid_t rgid, uid_t egid, uid_t sgid);
 #endif

[SCM] UID Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  6d5eb67 tests: Use SYS_gettimeofday for testing.
  from  37076a7 tests: Fix testsuite on Solaris.

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


- Log -
commit 6d5eb67f67ce37e409aa26721d70b0400c7b2cee
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 17:08:19 2013 +0100

tests: Use SYS_gettimeofday for testing.

SYS_stat is a bad idea cause you need to know kernel internals.

---

Summary of changes:
 tests/testsuite.c |   23 ---
 1 files changed, 20 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index a666067..ddf3ee4 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -11,6 +11,7 @@
 #include stdio.h
 #include sys/types.h
 #include sys/stat.h
+#include sys/time.h
 #include unistd.h
 
 #ifdef HAVE_SYS_SYSCALL_H
@@ -20,6 +21,8 @@
 #include syscall.h
 #endif
 
+#define ZERO_STRUCT(x) memset((char *)(x), 0, sizeof(x))
+
 static void test_uwrap_seteuid(void **state)
 {
int rc;
@@ -109,7 +112,8 @@ static void test_uwrap_syscall(void **state)
 {
long int rc;
char *env;
-   struct stat sb;
+   struct timeval tv1, tv2;
+   struct timezone tz1, tz2;
 
env = getenv(UID_WRAPPER);
if (env == NULL) {
@@ -119,16 +123,29 @@ static void test_uwrap_syscall(void **state)
 
(void) state; /* unused */
 
+   rc = syscall(SYS_getpid);
+   assert_int_equal(rc, getpid());
+
rc = access(., R_OK);
assert_int_equal(rc, 0);
 
rc = syscall(SYS_access, ., R_OK);
assert_int_equal(rc, 0);
 
-   rc = syscall(SYS_stat, ., sb);
+   ZERO_STRUCT(tv1);
+   ZERO_STRUCT(tv2);
+   ZERO_STRUCT(tz1);
+   ZERO_STRUCT(tz2);
+
+   rc = gettimeofday(tv1, tz1);
+   assert_int_equal(rc, 0);
+
+   rc = syscall(SYS_gettimeofday, tv2, tz2);
assert_int_equal(rc, 0);
 
-   assert_true(S_ISDIR(sb.st_mode));
+   assert_int_equal(tv1.tv_sec, tv2.tv_sec);
+   assert_int_equal(tz2.tz_dsttime, tz2.tz_dsttime);
+   assert_int_equal(tz2.tz_minuteswest, tz2.tz_minuteswest);
 }
 
 static void test_uwrap_syscall_setreuid(void **state)


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  764af96 cmake: Set _FORTIFY_SOURCE only for optimized builds.
  from  6d5eb67 tests: Use SYS_gettimeofday for testing.

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


- Log -
commit 764af969f05d58a77829d5fa4edb1cb9ea85235b
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 17:38:52 2013 +0100

cmake: Set _FORTIFY_SOURCE only for optimized builds.

---

Summary of changes:
 cmake/Modules/DefineCompilerFlags.cmake |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/cmake/Modules/DefineCompilerFlags.cmake 
b/cmake/Modules/DefineCompilerFlags.cmake
index 582ea1c..0ab8802 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -28,10 +28,10 @@ if (UNIX AND NOT WIN32)
 
 if (CMAKE_BUILD_TYPE)
 string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
-if (NOT CMAKE_BUILD_TYPE_LOWER MATCHES debug)
-check_c_compiler_flag(-D_FORTIFY_SOURCE=2 
WITH_FORTIFY_SOURCE)
+if (CMAKE_BUILD_TYPE_LOWER MATCHES 
(release|relwithdebinfo|minsizerel))
+check_c_compiler_flag(-Wp,-D_FORTIFY_SOURCE=2 
WITH_FORTIFY_SOURCE)
 if (WITH_FORTIFY_SOURCE)
-set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2)
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} 
-Wp,-D_FORTIFY_SOURCE=2)
 endif (WITH_FORTIFY_SOURCE)
 endif()
 endif()


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  7e534a7 tests: Add a test for setgroups().
   via  d9f5ea1 tests: Add a test for setgid().
  from  764af96 cmake: Set _FORTIFY_SOURCE only for optimized builds.

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


- Log -
commit 7e534a70cede4c8516e25f7754909285a3bc7d6b
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 17:58:44 2013 +0100

tests: Add a test for setgroups().

commit d9f5ea16e37ccc2fcffc90f6e263e1bf73ee895b
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 17:44:53 2013 +0100

tests: Add a test for setgid().

---

Summary of changes:
 tests/testsuite.c |   46 ++
 1 files changed, 46 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index ddf3ee4..1a36346 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -14,6 +14,8 @@
 #include sys/time.h
 #include unistd.h
 
+#include grp.h
+
 #ifdef HAVE_SYS_SYSCALL_H
 #include sys/syscall.h
 #endif
@@ -22,6 +24,7 @@
 #endif
 
 #define ZERO_STRUCT(x) memset((char *)(x), 0, sizeof(x))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
 static void test_uwrap_seteuid(void **state)
 {
@@ -108,6 +111,30 @@ static void test_uwrap_setegid(void **state)
assert_int_equal(u, 42);
 }
 
+static void test_uwrap_setgid(void **state)
+{
+   int rc;
+   gid_t u;
+   char *env;
+
+   env = getenv(UID_WRAPPER);
+   if (env == NULL) {
+   printf(UID_WRAPPER env not set, uid_wrapper is disabled\n);
+   return;
+   }
+
+   (void) state; /* unused */
+
+   rc = setgid(-1);
+   assert_int_equal(rc, -1);
+
+   rc = setgid(42);
+   assert_int_equal(rc, 0);
+
+   u = getgid();
+   assert_int_equal(u, 42);
+}
+
 static void test_uwrap_syscall(void **state)
 {
long int rc;
@@ -206,6 +233,23 @@ static void test_uwrap_syscall_setregid(void **state)
assert_int_equal(g, 42);
 }
 
+static void test_uwrap_setgroups(void **state)
+{
+   gid_t glist[] = { 100, 200, 300, 400, 500 };
+   gid_t rlist[16];
+   int rc;
+
+   (void) state; /* unused */
+
+   rc = setgroups(ARRAY_SIZE(glist), glist);
+   assert_int_equal(rc, 0);
+
+   rc = getgroups(ARRAY_SIZE(rlist), rlist);
+   assert_int_equal(rc, 5);
+
+   assert_memory_equal(glist, rlist, sizeof(glist));
+}
+
 int main(void) {
int rc;
 
@@ -214,8 +258,10 @@ int main(void) {
unit_test(test_uwrap_seteuid),
unit_test(test_uwrap_setuid),
unit_test(test_uwrap_setegid),
+   unit_test(test_uwrap_setgid),
unit_test(test_uwrap_syscall_setreuid),
unit_test(test_uwrap_syscall_setregid),
+   unit_test(test_uwrap_setgroups),
};
 
rc = run_tests(tests);


-- 
UID Wrapper Repository


[SCM] UID Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  644c98e tests: Add a test for getgroups().
  from  7e534a7 tests: Add a test for setgroups().

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


- Log -
commit 644c98eac3246a676845077f5094834df9a50374
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 18:07:54 2013 +0100

tests: Add a test for getgroups().

---

Summary of changes:
 tests/testsuite.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index 1a36346..67836fa 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -233,6 +233,18 @@ static void test_uwrap_syscall_setregid(void **state)
assert_int_equal(g, 42);
 }
 
+static void test_uwrap_getgroups(void **state)
+{
+   gid_t rlist[16] = {0};
+   int rc;
+
+   (void) state; /* unused */
+
+   rc = getgroups(ARRAY_SIZE(rlist), rlist);
+   assert_int_equal(rc, 1);
+   assert_int_equal(rlist[0], getegid());
+}
+
 static void test_uwrap_setgroups(void **state)
 {
gid_t glist[] = { 100, 200, 300, 400, 500 };
@@ -255,6 +267,8 @@ int main(void) {
 
const UnitTest tests[] = {
unit_test(test_uwrap_syscall),
+   unit_test(test_uwrap_getgroups),
+
unit_test(test_uwrap_seteuid),
unit_test(test_uwrap_setuid),
unit_test(test_uwrap_setegid),


-- 
UID Wrapper Repository