[SCM] NSS Wrapper Repository - branch master updated

2023-08-09 Thread Andreas Schneider
The branch, master has been updated
   via  2dd91af src: use LIBC_SO and LIBNSL_SO from GNU libc, if available
   via  3a4e4a2 doc/nss_wrapper.1: Fix typo of 'environment'.
  from  2c879a0 cmake: Fix cmocka >= 1.1.6 find_package() in CONFIG mode

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


- Log -
commit 2dd91af5fe572ffebf7eb44d8386aec99cd50ab9
Author: Pino Toscano 
Date:   Fri May 30 19:01:29 2014 +0200

src: use LIBC_SO and LIBNSL_SO from GNU libc, if available

Look for gnu/lib-names.h and use the LIBC_SO and LIBNSL_SO defines to
dlopen libc and libnsl, so the right library is loaded without manually
searching for libc.so.N or libnsl.so.N.

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

commit 3a4e4a2103e7871534e4fa1d85428b0b72ea001a
Author: Simon Josefsson 
Date:   Sat Aug 5 19:13:08 2023 +0200

doc/nss_wrapper.1: Fix typo of 'environment'.

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

---

Summary of changes:
 ConfigureChecks.cmake |  1 +
 config.h.cmake|  1 +
 doc/nss_wrapper.1 |  2 +-
 doc/nss_wrapper.1.txt |  2 +-
 src/nss_wrapper.c | 18 ++
 5 files changed, 22 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 5bd69db..e74e83e 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -54,6 +54,7 @@ check_include_file(shadow.h HAVE_SHADOW_H)
 check_include_file(grp.h HAVE_GRP_H)
 check_include_file(nss.h HAVE_NSS_H)
 check_include_file(nss_common.h HAVE_NSS_COMMON_H)
+check_include_file(gnu/lib-names.h HAVE_GNU_LIB_NAMES_H)
 
 # FUNCTIONS
 check_function_exists(strncpy HAVE_STRNCPY)
diff --git a/config.h.cmake b/config.h.cmake
index 6199962..37cd700 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -20,6 +20,7 @@
 #cmakedefine HAVE_GRP_H 1
 #cmakedefine HAVE_NSS_H 1
 #cmakedefine HAVE_NSS_COMMON_H 1
+#cmakedefine HAVE_GNU_LIB_NAMES_H 1
 
 /*** FUNCTIONS ***/
 
diff --git a/doc/nss_wrapper.1 b/doc/nss_wrapper.1
index 3ef5a89..78727b3 100644
--- a/doc/nss_wrapper.1
+++ b/doc/nss_wrapper.1
@@ -88,7 +88,7 @@ and the group file in
 .PP
 \fBNSS_WRAPPER_HOSTS\fR
 .RS 4
-If you also need to emulate network name resolution in your enviornment, 
especially with socket_wrapper, you can write a hosts file\&. The format is 
described in
+If you also need to emulate network name resolution in your environment, 
especially with socket_wrapper, you can write a hosts file\&. The format is 
described in
 \fIman 5 hosts\fR\&. Then you can point nss_wrapper to your hosts file using: 
NSS_WRAPPER_HOSTS=/path/to/your/hosts
 .RE
 .PP
diff --git a/doc/nss_wrapper.1.txt b/doc/nss_wrapper.1.txt
index 4811dde..85a567a 100644
--- a/doc/nss_wrapper.1.txt
+++ b/doc/nss_wrapper.1.txt
@@ -54,7 +54,7 @@ NSS_WRAPPER_GROUP=/path/to/your/group.
 
 *NSS_WRAPPER_HOSTS*::
 
-If you also need to emulate network name resolution in your enviornment,
+If you also need to emulate network name resolution in your environment,
 especially with socket_wrapper, you can write a hosts file. The format is
 described in 'man 5 hosts'. Then you can point nss_wrapper to your hosts
 file using: NSS_WRAPPER_HOSTS=/path/to/your/hosts
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 3399f06..78d88dc 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -61,6 +61,10 @@
 #include 
 #include 
 
+#ifdef HAVE_GNU_LIB_NAMES_H
+#include 
+#endif
+
 #include "nss_utils.h"
 /*
  * Defining _POSIX_PTHREAD_SEMANTICS before including pwd.h and grp.h  gives us
@@ -1156,6 +1160,13 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
case NWRAP_LIBNSL:
 #ifdef HAVE_LIBNSL
handle = nwrap_main_global->libc->nsl_handle;
+#ifdef LIBNSL_SO
+   if (handle == NULL) {
+   handle = dlopen(LIBNSL_SO, flags);
+
+   nwrap_main_global->libc->nsl_handle = handle;
+   }
+#endif
if (handle == NULL) {
for (i = 10; i >= 0; i--) {
char soname[256] = {0};
@@ -1193,6 +1204,13 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
/* FALL TROUGH */
case NWRAP_LIBC:
handle = nwrap_main_global->libc->handle;
+#ifdef LIBC_SO
+   if (handle == NULL) {
+   handle = dlopen(LIBC_SO, flags);
+
+   nwrap_main_global->libc->handle = handle;
+   }
+#endif
if (handle == NULL) {
for (i = 10; i >= 0; i--) {
char soname[256] = {0};


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2023-02-27 Thread Andreas Schneider
The branch, master has been updated
   via  2c879a0 cmake: Fix cmocka >= 1.1.6 find_package() in CONFIG mode
  from  db887c0 Bump version to 1.1.15

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


- Log -
commit 2c879a0ffa70cee33329291d7576ec971d420da2
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 3b94076..733cc4e 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()
+
 set(TESTSUITE_LIBRARIES nss_utils ${NWRAP_REQUIRED_LIBRARIES} 
${CMOCKA_LIBRARY})
 string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2023-01-25 Thread Andreas Schneider
The branch, master has been updated
   via  db887c0 Bump version to 1.1.15
   via  21447f6 tests: Fix a memory leak in test_nwrap_initgroups()
   via  baa8dad cmake: Set default compile flags for nss_utils
   via  e686be6 cmake: We need to link nss_nwrap against nss_utils
  from  3291b07 Bump version to 1.1.14

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


- Log -
commit db887c00d35b1504abe72a30fe386111e9a25ed2
Author: Andreas Schneider 
Date:   Wed Jan 25 12:43:23 2023 +0100

Bump version to 1.1.15

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

commit 21447f6c38390118984853adee978ab48b24e432
Author: Andreas Schneider 
Date:   Wed Jan 25 13:23:35 2023 +0100

tests: Fix a memory leak in test_nwrap_initgroups()

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

commit baa8dadd6ab9f654024873c8b170d66285782f3b
Author: Andreas Schneider 
Date:   Wed Jan 25 12:38:01 2023 +0100

cmake: Set default compile flags for nss_utils

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

commit e686be6ff3da062225287980a3d27ab2f385651f
Author: Andreas Schneider 
Date:   Wed Jan 25 12:34:57 2023 +0100

cmake: We need to link nss_nwrap against nss_utils

tests/nss_nwrap.c:240: undefined reference to `nwrap_gr_copy_r'

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

---

Summary of changes:
 CHANGELOG   | 4 
 CMakeLists.txt  | 2 +-
 src/CMakeLists.txt  | 4 
 tests/CMakeLists.txt| 1 +
 tests/test_initgroups.c | 1 +
 5 files changed, 11 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/CHANGELOG b/CHANGELOG
index aed76b3..2cd0423 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.1.15 (released 2023-01-25)
+  * Fixed linking issue in tests
+  * Fixed a memory leak in tests
+
 version 1.1.14 (released 2023-01-25)
   * Fixed implementation of initgroups()
   * Fixed implementation of getgrouplist()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd3b663..2f7c91a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.14 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.15 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f56aad5..a920191 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,10 @@
 project(libnss_wrapper C)
 
 add_library(nss_utils STATIC nss_utils.c)
+target_compile_options(nss_utils
+   PRIVATE
+  ${DEFAULT_C_COMPILE_FLAGS})
+
 add_library(nss_wrapper SHARED nss_wrapper.c)
 target_compile_options(nss_wrapper
PRIVATE
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 425395b..3b94076 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -11,6 +11,7 @@ target_include_directories(nss_nwrap
PRIVATE
${CMAKE_BINARY_DIR}
${CMOCKA_INCLUDE_DIR})
+target_link_libraries(nss_nwrap PRIVATE nss_utils)
 
 set(HOMEDIR ${CMAKE_CURRENT_BINARY_DIR})
 
diff --git a/tests/test_initgroups.c b/tests/test_initgroups.c
index 959ae4d..1ec2220 100644
--- a/tests/test_initgroups.c
+++ b/tests/test_initgroups.c
@@ -35,6 +35,7 @@ static void test_nwrap_initgroups(void **state)
for (i = 0; i < 6; i++) {
assert_int_equal(groups1[i], groups2[i]);
}
+   free(groups2);
}
 }
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2023-01-25 Thread Andreas Schneider
The branch, master has been updated
   via  3291b07 Bump version to 1.1.14
  from  4b1e6b8 cmake: Print a message that nss_wrapper was found with 
find_package()

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


- Log -
commit 3291b0728beef244ee46b51882f95aeb618aed9f
Author: Andreas Schneider 
Date:   Wed Jan 25 12:03:44 2023 +0100

Bump version to 1.1.14

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

---

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


Changeset truncated at 500 lines:

diff --git a/CHANGELOG b/CHANGELOG
index e3a9299..aed76b3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.14 (released 2023-01-25)
+  * Fixed implementation of initgroups()
+  * Fixed implementation of getgrouplist()
+  * Avoid dclose(RTLD_NEXT)
+
 version 1.1.13 (released 2022-10-09)
   * Fixed possible mutex and threading issues
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ba3822..bd3b663 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.13 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.14 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -25,7 +25,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment PATCH.
 set(LIBRARY_VERSION_MAJOR 0)
 set(LIBRARY_VERSION_MINOR 3)
-set(LIBRARY_VERSION_PATCH 3)
+set(LIBRARY_VERSION_PATCH 4)
 set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2023-01-25 Thread Andreas Schneider
The branch, master has been updated
   via  4b1e6b8 cmake: Print a message that nss_wrapper was found with 
find_package()
   via  adce22a cmake: Improve version detection to support ranges
  from  b33232f tests: Add test_initgroups

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


- Log -
commit 4b1e6b840cc8c8fbbf3e5e50ca8449941deb4e13
Author: Andreas Schneider 
Date:   Wed Jan 25 11:20:51 2023 +0100

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

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

commit adce22a356e47c81a7e583ea48040dbba2c534a0
Author: Andreas Schneider 
Date:   Wed Jan 25 11:20:45 2023 +0100

cmake: Improve version detection to support ranges

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

---

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


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 163fa10..3ba3822 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,6 +84,9 @@ install(
 )
 
 # cmake config files
+set(PACKAGE_NAME nss_wrapper)
+set(PACKAGE_NAME_UPPER NSS_WRAPPER)
+
 configure_file(nss_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake @ONLY)
 configure_file(nss_wrapper-config.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config.cmake @ONLY)
 install(
diff --git a/nss_wrapper-config-version.cmake.in 
b/nss_wrapper-config-version.cmake.in
index 4bff45e..c59f6c8 100644
--- a/nss_wrapper-config-version.cmake.in
+++ b/nss_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/nss_wrapper-config.cmake.in b/nss_wrapper-config.cmake.in
index 9375f5c..ba5711b 100644
--- a/nss_wrapper-config.cmake.in
+++ b/nss_wrapper-config.cmake.in
@@ -1 +1,14 @@
-set(NSS_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@NSS_WRAPPER_LIB@)
+set(@PACKAGE_NAME_UPPER@_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@NSS_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}]")


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2023-01-25 Thread Andreas Schneider
The branch, master has been updated
   via  b33232f tests: Add test_initgroups
   via  91974ea tests: Add more groups and groups members
   via  0c90c43 tests: Implement _nss_nwrap_initgroups_dyn(), 
_nss_nwrap_getgrent_r(), _nss_nwrap_getgrnam_r() and _nss_nwrap_getgrgid_r()
   via  1a010f2 nwrap,tests: Use nwrap_gr_copy_r() from lib nss_utils
   via  e60ad71 nwrap: Create library nss_utils
   via  34a6808 nwrap: Implement initgroups() using nwrap_getgrouplist()
   via  01b66b0 nwrap: Implement getgrouplist() correctly
   via  5b60119 nwrap: Implement nwrap_files_initgroups_dyn()
   via  666bd92 nwrap: Add MIN(), MAX() macros
   via  cce021a nwrap: Correctly implement initgroups_dyn() for the modules
   via  24c7064 nwrap: Remove incorrect implementation of nwrap_initgroups()
   via  5243f74 Add clang-format definitions
  from  25a5a11 Avoid dclose(RTLD_NEXT)

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


- Log -
commit b33232ff661cc377a0bb75b40dd5ea6b1754e4fb
Author: Pavel Filipenský 
Date:   Thu Jan 19 22:35:00 2023 +0100

tests: Add test_initgroups

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

commit 91974ea4b6985febe58aadaf9924bc62cdcbcbc4
Author: Pavel Filipenský 
Date:   Mon Jan 16 21:30:46 2023 +0100

tests: Add more groups and groups members

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

commit 0c90c4380a52615460c5e98b3aed09f7e14de907
Author: Pavel Filipenský 
Date:   Mon Jan 16 21:27:05 2023 +0100

tests: Implement _nss_nwrap_initgroups_dyn(), _nss_nwrap_getgrent_r(), 
_nss_nwrap_getgrnam_r() and _nss_nwrap_getgrgid_r()

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

commit 1a010f2c9de81e0ee2dc9b3e660ad65bcdddf7bd
Author: Pavel Filipenský 
Date:   Tue Jan 17 11:50:08 2023 +0100

nwrap,tests: Use nwrap_gr_copy_r() from lib nss_utils

nss_utils must be added to both nwrap,tests at the same time

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

commit e60ad71576352995d91036f2555f672291837591
Author: Pavel Filipenský 
Date:   Tue Jan 17 11:48:12 2023 +0100

nwrap: Create library nss_utils

Will be used to share function nwrap_gr_copy_r among src and test

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

commit 34a6808f34f5ce805ec39ffea3657901434479d2
Author: Pavel Filipenský 
Date:   Mon Jan 16 20:58:17 2023 +0100

nwrap: Implement initgroups() using nwrap_getgrouplist()

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

commit 01b66b0a51deb538cfc5a31230053cc5128b0a46
Author: Pavel Filipenský 
Date:   Mon Jan 16 20:52:45 2023 +0100

nwrap: Implement getgrouplist() correctly

The main job is done in nwrap_getgrouplist() that will be used also by
initgroups() next.

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

commit 5b601190c87f768f1bf77fd8b993f6b3ad98ac24
Author: Pavel Filipenský 
Date:   Tue Jan 17 09:51:08 2023 +0100

nwrap: Implement nwrap_files_initgroups_dyn()

This implements the initgroups_dyn() for the files part correctly. We need 
to
reimplement initgroups() later.

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

commit 666bd92a7f40c4930cb2b20bd81a8c66effad090
Author: Pavel Filipenský 
Date:   Tue Jan 17 07:21:34 2023 +0100

nwrap: Add MIN(), MAX() macros

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

commit cce021aed6ab893eb131e6a47879d7333ff01d69
Author: Pavel Filipenský 
Date:   Tue Jan 17 09:50:22 2023 +0100

nwrap: Correctly implement initgroups_dyn() for the modules

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

commit 24c7064e7bfc8288028708af973cb793d6a1bba0
Author: Pavel Filipenský 
Date:   Tue Jan 17 09:43:45 2023 +0100

nwrap: Remove incorrect implementation of nwrap_initgroups()

This will be correctly implemented later. The backends actually don't have 
an
initgroups() function but initgroups_dyn().

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

commit 5243f743db1e43f8607403700c159a833eeef25a
Author: Pavel Filipenský 
Date:   Tue Jan 17 09:34:50 2023 +0100

Add clang-format definitions

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

---

Summary of changes:
 .clang-format   |  26 +++
 src/CMakeLists.txt  |   3 +-
 src/nss_utils.c | 131 
 src/nss_utils.h |  46 ++
 src/nss_wrapper.c   | 409 ++--
 tests/CMakeLists.txt|  19 ++-
 tests/group.in  |   3 +-
 tests/nss_nwrap.c   | 191 +-
 

[SCM] NSS Wrapper Repository - branch master updated

2023-01-23 Thread Andreas Schneider
The branch, master has been updated
   via  25a5a11 Avoid dclose(RTLD_NEXT)
  from  edb5665 Bump version to 1.1.13

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


- Log -
commit 25a5a112a87796b7ff309eb10d7e58519a641029
Author: Samuel Thibault 
Date:   Thu Nov 10 18:38:17 2022 +

Avoid dclose(RTLD_NEXT)

In case the libc was not found and RTLD_NEXT is used instead, we should not
dlclose it, otherwise mayhem happens.

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

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

---

Summary of changes:
 src/nss_wrapper.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 07c9757..0b2066c 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -6499,13 +6499,25 @@ void nwrap_destructor(void)
 
/* libc */
if (m->libc != NULL) {
-   if (m->libc->handle != NULL) {
+   if (m->libc->handle != NULL
+#ifdef RTLD_NEXT
+   && m->libc->handle != RTLD_NEXT
+#endif
+  ) {
dlclose(m->libc->handle);
}
-   if (m->libc->nsl_handle != NULL) {
+   if (m->libc->nsl_handle != NULL
+#ifdef RTLD_NEXT
+   && m->libc->nsl_handle != RTLD_NEXT
+#endif
+  ) {
dlclose(m->libc->nsl_handle);
}
-   if (m->libc->sock_handle != NULL) {
+   if (m->libc->sock_handle != NULL
+#ifdef RTLD_NEXT
+   && m->libc->sock_handle != RTLD_NEXT
+#endif
+  ) {
dlclose(m->libc->sock_handle);
}
SAFE_FREE(m->libc);


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2022-11-08 Thread Andreas Schneider
The branch, master has been updated
   via  edb5665 Bump version to 1.1.13
  from  ff54c5b gitlab-ci: Add runner for ThreadSanitizer

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


- Log -
commit edb56658f0c3177d10a041aed9ac28687851d4e6
Author: Andreas Schneider 
Date:   Mon Nov 7 14:17:24 2022 +0100

Bump version to 1.1.13

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

---

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


Changeset truncated at 500 lines:

diff --git a/CHANGELOG b/CHANGELOG
index 25b599e..e3a9299 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 ChangeLog
 ==
 
+version 1.1.13 (released 2022-10-09)
+  * Fixed possible mutex and threading issues
+
 version 1.1.12 (released 2022-06-24)
   * Added (de)contructor support on AIX with pragma init/finish
   * Fixed possible crash in getaddrinfo()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2496f6e..163fa10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@
 cmake_minimum_required(VERSION 3.5.0)
 cmake_policy(SET CMP0048 NEW)
 
-# Specify search path for CMake modules to be loaded by include() 
+# Specify search path for CMake modules to be loaded by include()
 # and find_package()
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.12 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.13 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -25,7 +25,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment PATCH.
 set(LIBRARY_VERSION_MAJOR 0)
 set(LIBRARY_VERSION_MINOR 3)
-set(LIBRARY_VERSION_PATCH 2)
+set(LIBRARY_VERSION_PATCH 3)
 set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

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

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


- Log -
commit ff54c5b94eed33ae86cd2cea6e70300d828259c9
Author: Andreas Schneider 
Date:   Fri Nov 4 09:46:06 2022 +0100

gitlab-ci: Add runner for ThreadSanitizer

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

commit 84a24c27ab3f935e06783c3aefad33f1d349c128
Author: Andreas Schneider 
Date:   Fri Nov 4 09:48:31 2022 +0100

gitlab-ci: Format yaml file

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

commit a5687c30077ae177c49d8e18a8a7b2ec0c4bb5ce
Author: Andreas Schneider 
Date:   Fri Nov 4 09:44:44 2022 +0100

gitlab-ci: Add stages

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

commit 8a495a5e9a4977f7226dce8da334f5fb4a724225
Author: Andreas Schneider 
Date:   Fri Nov 4 14:47:16 2022 +0100

nwrap: Add NWRAP_REINIT_ALL to initialize mutexes

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

commit 92f0f6a93037685fdb7fffbacc32efdc13a2980a
Author: Andreas Schneider 
Date:   Fri Nov 4 14:35:50 2022 +0100

nwrap: Remove unneeded nss_module_symbol_binding_mutex

This loading of nss symbols already is protected by the mutex of 
nwrap_init().

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

commit 8c35ff4bd5bfdcc61a57dc81cbc165901d81f02b
Author: Andreas Schneider 
Date:   Fri Nov 4 14:24:54 2022 +0100

nwrap: Bind symbols only once

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

commit 5461b4e9403f1a39ed3de1f63368ce180529e68a
Author: Andreas Schneider 
Date:   Fri Nov 4 13:57:23 2022 +0100

nwrap: Introduce nwrap_mutex_(un)lock() for better debugging

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

commit 5187e32fcc89271c02480221c896eb6ed70ecc78
Author: Andreas Schneider 
Date:   Fri Nov 4 13:52:05 2022 +0100

nwrap: Move nwrap_thread_*() to the end

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

commit da2f3f5ce3828f572415c168555274cf51fd9d9c
Author: Andreas Schneider 
Date:   Fri Nov 4 13:19:55 2022 +0100

nwrap: Fix mutex unlocking in nwrap_init()

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

commit 71e56b8abea3cbbc6f461f4fb426faf46c5a09c9
Author: Andreas Schneider 
Date:   Fri Nov 4 14:41:19 2022 +0100

tests: Disable deep binding with ThreadSanitizer

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

commit 4dab609787bf58db4a652694a9c05067bc9be1a0
Author: Andreas Schneider 
Date:   Fri Nov 4 09:42:06 2022 +0100

cmake: Add support for ThreadSanitizer

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

commit b698b7e17615c8434f0c0e2f815cc314fbcf0f36
Author: Andreas Schneider 
Date:   Fri Nov 4 13:26:19 2022 +0100

Add editorconfig

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

---

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


Changeset truncated at 500 lines:

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 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
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dbf5351..f35b1f3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,4 @@

[SCM] NSS Wrapper Repository - branch master updated

2022-06-24 Thread Andreas Schneider
The branch, master has been updated
   via  ea36a64 Bump version to 1.1.12
  from  1139a3c nwrap: Fix endpwent and setgrent to call the functions

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


- Log -
commit ea36a64d449ccbf312413f303a3b0289eed99e30
Author: Andreas Schneider 
Date:   Fri Jun 24 09:54:21 2022 +0200

Bump version to 1.1.12

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

---

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


Changeset truncated at 500 lines:

diff --git a/CHANGELOG b/CHANGELOG
index dddc981..25b599e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,12 @@
 ChangeLog
 ==
 
+version 1.1.12 (released 2022-06-24)
+  * Added (de)contructor support on AIX with pragma init/finish
+  * Fixed possible crash in getaddrinfo()
+  * Fixed issues with processes closing all fds when forking
+  * Fixed issues with setgrent() and endpwent() nss module support
+
 version 1.1.11 (released 2020-04-02)
   * Fixed strict aliasing issues on armv7hl (32bit)
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51fdb15..2496f6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.11 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.12 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -25,7 +25,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment PATCH.
 set(LIBRARY_VERSION_MAJOR 0)
 set(LIBRARY_VERSION_MINOR 3)
-set(LIBRARY_VERSION_PATCH 1)
+set(LIBRARY_VERSION_PATCH 2)
 set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2022-06-24 Thread Andreas Schneider
The branch, master has been updated
   via  1139a3c nwrap: Fix endpwent and setgrent to call the functions
  from  0884724 nss_wrapper: fall back to pragma init/fini for 
constructor/destructor if possible

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


- Log -
commit 1139a3c51395a21908e98c8edebf41037ff1369c
Author: Pavel Filipenský 
Date:   Thu Jun 23 19:29:29 2022 +0200

nwrap: Fix endpwent and setgrent to call the functions

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

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index d43c296..88e81d9 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -4487,7 +4487,7 @@ static int nwrap_module_getpwent_r(struct nwrap_backend 
*b,
 
 static void nwrap_module_endpwent(struct nwrap_backend *b)
 {
-   if (b->symbols->_nss_endpwent.f) {
+   if (b->symbols->_nss_endpwent.f == NULL) {
return;
}
 
@@ -4659,7 +4659,7 @@ static int nwrap_module_getgrgid_r(struct nwrap_backend 
*b,
 
 static void nwrap_module_setgrent(struct nwrap_backend *b)
 {
-   if (b->symbols->_nss_setgrent.f) {
+   if (b->symbols->_nss_setgrent.f == NULL) {
return;
}
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-11-04 Thread Andreas Schneider
The branch, master has been updated
   via  0884724 nss_wrapper: fall back to pragma init/fini for 
constructor/destructor if possible
   via  fed22a4 configure: check for pragma init/fini for 
constructors/destructors
  from  7bdf2f8 nwrap_files_cache_reload: add close for ebadf fd just incase

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


- Log -
commit 0884724ec2016cf19f8cb81c1e527cde6f747955
Author: Björn Jacke 
Date:   Fri Oct 30 15:11:54 2020 +0100

nss_wrapper: fall back to pragma init/fini for constructor/destructor if 
possible

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

commit fed22a4ebadaffdefa9e2cf52e7de955e8532369
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/nss_wrapper.c |  7 +++
 3 files changed, 35 insertions(+)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 30510d8..5bd69db 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -263,6 +263,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)
+
 find_library(DLFCN_LIBRARY dl)
 if (DLFCN_LIBRARY)
 list(APPEND _REQUIRED_LIBRARIES ${DLFCN_LIBRARY})
diff --git a/config.h.cmake b/config.h.cmake
index 41b2531..6199962 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -104,6 +104,8 @@
 #cmakedefine HAVE_ATTRIBUTE_PRINTF_FORMAT 1
 #cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_PRAGMA_INIT 1
+#cmakedefine HAVE_PRAGMA_FINI 1
 
 /*** ENDIAN */
 
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 877f6d1..d43c296 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -1070,7 +1070,14 @@ static struct nwrap_he nwrap_he_global;
 
 static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_gr_unload(struct nwrap_cache *nwrap);
+#if ! defined(HAVE_CONSTRUCTOR_ATTRIBUTE) && defined(HAVE_PRAGMA_INIT)
+/* xlC and other oldschool compilers support (only) this */
+#pragma init (nwrap_constructor)
+#endif
 void nwrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
+#if ! defined(HAVE_DESTRUCTOR_ATTRIBUTE) && defined(HAVE_PRAGMA_FINI)
+#pragma fini (nwrap_destructor)
+#endif
 void nwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-11-04 Thread Andreas Schneider
The branch, master has been updated
   via  7bdf2f8 nwrap_files_cache_reload: add close for ebadf fd just incase
   via  5d2b47f nwrap_files_cache_reload: add test for closed handles error
   via  95b1e79 nwrap_files_cache_reload: avoid error on EBADF during stat
  from  86420d9 nwrap_files_getaddrinfo: avoid crash on empty name

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


- Log -
commit 7bdf2f87f4e63d57f0d9a939e0e78349d1b71342
Author: TJ Miller 
Date:   Wed Oct 28 13:55:59 2020 -0700

nwrap_files_cache_reload: add close for ebadf fd just incase

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

commit 5d2b47fdd89c3834b226a56703cb51be8b937d21
Author: TJ Miller 
Date:   Wed Oct 28 13:54:48 2020 -0700

nwrap_files_cache_reload: add test for closed handles error

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

commit 95b1e79a1f6ee0f1248723a3466fcce125db650f
Author: TJ Miller 
Date:   Thu Oct 15 12:07:17 2020 -0700

nwrap_files_cache_reload: avoid error on EBADF during stat

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

---

Summary of changes:
 src/nss_wrapper.c| 16 +++-
 tests/test_getpwuid_module.c | 25 +
 2 files changed, 40 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 4f4dc93..877f6d1 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -2129,7 +2129,21 @@ reopen:
}
 
ret = fstat(nwrap->fd, );
-   if (ret != 0) {
+   if (ret != 0 && errno == EBADF && retried == false) {
+   /* maybe something closed the fd on our behalf */
+   NWRAP_LOG(NWRAP_LOG_TRACE,
+ "fstat(%s) - %d:%s - reopen",
+ nwrap->path,
+ ret,
+ strerror(errno));
+   retried = true;
+   memset(>st, 0, sizeof(nwrap->st));
+   fclose(nwrap->fp);
+   nwrap->fp = NULL;
+   nwrap->fd = -1;
+   goto reopen;
+   }
+   else if (ret != 0) {
NWRAP_LOG(NWRAP_LOG_ERROR,
  "fstat(%s) - %d:%s",
  nwrap->path,
diff --git a/tests/test_getpwuid_module.c b/tests/test_getpwuid_module.c
index 2dbecb1..a06a49d 100644
--- a/tests/test_getpwuid_module.c
+++ b/tests/test_getpwuid_module.c
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -22,12 +23,36 @@ static void test_nwrap_passwd(void **state)
assert_int_equal(pwd->pw_gid, id);
 }
 
+static void test_nwrap_passwd_closed_handles(void **state)
+{
+   struct passwd *pwd;
+   uid_t id = 424242;
+   long maxfd;
+
+   (void) state; /* unused */
+
+   pwd = getpwuid(id);
+   assert_non_null(pwd);
+
+   maxfd = sysconf(_SC_OPEN_MAX);
+   if (maxfd < 0) {
+   maxfd = 1024;
+   }
+   for (long fd = 3; fd < maxfd; fd++) {
+   close(fd);
+   }
+
+   pwd = getpwuid(id);
+   assert_non_null(pwd);
+}
+
 int main(void)
 {
int rc;
 
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_nwrap_passwd),
+   cmocka_unit_test(test_nwrap_passwd_closed_handles),
};
 
rc = cmocka_run_group_tests(tests, NULL, NULL);


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-07-10 Thread Andreas Schneider
The branch, master has been updated
   via  86420d9 nwrap_files_getaddrinfo: avoid crash on empty name
  from  b20ae47 Bump version 1.1.11

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


- Log -
commit 86420d91ddc22d71ffeed4dcbc02bef0f6042cbe
Author: Douglas Bagnall 
Date:   Sun May 17 13:14:08 2020 +1200

nwrap_files_getaddrinfo: avoid crash on empty name

When name is "", we would deref name[-1]. If by chance name[-1] was
'.', we also tried to copy all of memory from one place to another.

Rather than just guard the immediate next branch, let's assume the
empty name is never found.

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

---

Summary of changes:
 src/nss_wrapper.c | 4 
 1 file changed, 4 insertions(+)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 17c8732..4f4dc93 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -4070,6 +4070,10 @@ static int nwrap_files_getaddrinfo(const char *name,
}
 
name_len = strlen(name);
+   if (name_len == 0) {
+   return EAI_NONAME;
+   }
+
if (name_len < sizeof(canon_name) && name[name_len - 1] == '.') {
memcpy(canon_name, name, name_len - 1);
canon_name[name_len] = '\0';


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-04-02 Thread Andreas Schneider
The branch, master has been updated
   via  b20ae47 Bump version 1.1.11
  from  a195562 cpack: Ignore compile_commands.json file

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


- Log -
commit b20ae4762af9ce0ca4bf798a26a46f171255f7bd
Author: Andreas Schneider 
Date:   Thu Apr 2 12:08:35 2020 +0200

Bump version 1.1.11

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

---

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


Changeset truncated at 500 lines:

diff --git a/CHANGELOG b/CHANGELOG
index e649ee8..dddc981 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 ChangeLog
 ==
 
+version 1.1.11 (released 2020-04-02)
+  * Fixed strict aliasing issues on armv7hl (32bit)
+
 version 1.1.10 (released 2020-03-19)
   * Fixed crash bug in OpenLDAP libraries with gethostbyname_r()
   * Code cleanup in gethostbyname(2)(_r) functions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64e3412..51fdb15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.10 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.11 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -25,7 +25,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 # Increment PATCH.
 set(LIBRARY_VERSION_MAJOR 0)
 set(LIBRARY_VERSION_MINOR 3)
-set(LIBRARY_VERSION_PATCH 0)
+set(LIBRARY_VERSION_PATCH 1)
 set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-04-02 Thread Andreas Schneider
The branch, master has been updated
   via  a195562 cpack: Ignore compile_commands.json file
   via  411e44f gitignore: Ignore all obj directories
   via  f29bece nwrap: Correctly handle realloc() in nwrap_module_init()
   via  f62f26c nwrap: Always fully initialze an nwrap_backend
   via  6ec14bb nwrap: Rewrite symbol binding for nss modules
   via  9776c14 nwrap: Add mutex for nss module symbol binding
   via  c007cbd nwrap: Rewrite symbol binding for libc, libnsl and libsocket
   via  b5a67df nwrap: Add mutex for libc symbol binding
   via  bf1b667 tests: Add a basic test to check if the NSS module works
  from  24c3254 gitlab-ci: Add Ubuntu runner

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


- Log -
commit a195562409b0f48a558829c50fd32bd94892c2d1
Author: Andreas Schneider 
Date:   Thu Apr 2 09:30:42 2020 +0200

cpack: Ignore compile_commands.json file

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

commit 411e44f3e6188674e92eb2dc36c9fafcecc50257
Author: Andreas Schneider 
Date:   Thu Apr 2 09:30:07 2020 +0200

gitignore: Ignore all obj directories

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

commit f29becec25f22d2eef8e2538a59042af735b315b
Author: Andreas Schneider 
Date:   Thu Apr 2 09:51:22 2020 +0200

nwrap: Correctly handle realloc() in nwrap_module_init()

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

commit f62f26cb960086d3f6445c417f8ccf0fc4520fc3
Author: Andreas Schneider 
Date:   Thu Apr 2 09:37:54 2020 +0200

nwrap: Always fully initialze an nwrap_backend

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

commit 6ec14bb96f0e0447132472910657569f1188149b
Author: Andreas Schneider 
Date:   Wed Apr 1 18:32:59 2020 +0200

nwrap: Rewrite symbol binding for nss modules

Fixes strict aliasing.

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

commit 9776c146771d87b18118542422758a1532a953b3
Author: Andreas Schneider 
Date:   Wed Apr 1 18:22:50 2020 +0200

nwrap: Add mutex for nss module symbol binding

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

commit c007cbdf655f2dfd1914849a8882eb0297b2b120
Author: Andreas Schneider 
Date:   Wed Apr 1 18:32:32 2020 +0200

nwrap: Rewrite symbol binding for libc, libnsl and libsocket

This fixes strict aliasing issues which cause segfaults at least on
armhfp.

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

commit b5a67dfa64ebb7733c883b2b0eea18bb557ee1d0
Author: Andreas Schneider 
Date:   Wed Apr 1 18:21:55 2020 +0200

nwrap: Add mutex for libc symbol binding

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

commit bf1b66738387648d633ed96d2a6d94bff184ffe0
Author: Andreas Schneider 
Date:   Thu Apr 2 10:41:47 2020 +0200

tests: Add a basic test to check if the NSS module works

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

---

Summary of changes:
 .gitignore   |   2 +-
 CPackConfig.cmake|   2 +-
 src/nss_wrapper.c| 878 +++
 tests/CMakeLists.txt |   3 +-
 tests/nss_nwrap.c|  87 -
 tests/test_getpwuid_module.c |  36 ++
 6 files changed, 674 insertions(+), 334 deletions(-)
 create mode 100644 tests/test_getpwuid_module.c


Changeset truncated at 500 lines:

diff --git a/.gitignore b/.gitignore
index 4de573c..fe4bcd8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
 *.swp
 *~$
 build
-obj
+obj*/
 cscope.*
 tags
 compile_commands.json
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index 3a554a9..c4290ab 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -14,7 +14,7 @@ set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
 
 ### 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.*;compile_commands.json")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME 
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
 
 if (WIN32)
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index d90264c..17c8732 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -185,6 +185,8 @@ typedef nss_status_t NSS_STATUS;
pthread_mutex_unlock(&( m ## _mutex)); \
 } while(0)
 
+static pthread_mutex_t libc_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t nss_module_symbol_binding_mutex = 
PTHREAD_MUTEX_INITIALIZER;
 
 static bool nwrap_initialized = false;
 static pthread_mutex_t nwrap_initialized_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -201,6 +203,8 @@ static 

[SCM] NSS Wrapper Repository - branch master updated

2020-03-24 Thread Andreas Schneider
The branch, master has been updated
   via  24c3254 gitlab-ci: Add Ubuntu runner
   via  ff0be04 gitlab-ci: Remove debian cross mips build
  from  6020d05 Bump version to 1.1.10

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


- Log -
commit 24c3254cbe618134794194ea1e396e68745f9c31
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 ff0be04699b4dfa2825e5a0779364ba186c33a92
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 699896e..dbf5351 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,7 +4,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
@@ -129,30 +129,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:
@@ -229,3 +205,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/


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-03-19 Thread Andreas Schneider
The branch, master has been updated
   via  6020d05 Bump version to 1.1.10
   via  d8e591b tests: Add tests for gethostbyname2_r, IPv4 and IPv6
   via  14e90a8 nwrap: Account for ending NULL pointer when checking the 
buffer length
   via  0d0c018 nwrap: Forward ERANGE error to caller in gethostbyname[2]_r
   via  7149d57 nwrap: Filter by family in gethostbyname2_r
   via  0df9940 tests: Check that gethostbyname_r() zeros return values
   via  ba1d362 nwrap: Check paramters and make sure return values are 
zeored
   via  0f30d31 nwrap: Zero the result in case we return with an error
   via  36c5192 nwrap: Use SAFE_FREE() in nwrap_files_gethostbyname2_r()
   via  a3ff3c2 nwrap: Use calloc() to allocate addr_list vector
   via  008913f nwrap: Add missing check for gethostbyname2_r()
   via  5788a92 nwrap: Fix build if system doesn't provide gethostbyname2
  from  d24aec9 Bump version to 1.1.9

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


- Log -
commit 6020d05c6ab9b885741670ebd6a0f2ebf99052cf
Author: Andreas Schneider 
Date:   Thu Mar 19 10:08:16 2020 +0100

Bump version to 1.1.10

The library version is set to 0.3.0 because gethostbyname2_r() is
provided now.

This wasn't exported due to a missing configure check for it.

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

commit d8e591be8211c48ffbc034ccd2c22c63c7f2b8fb
Author: Samuel Cabrero 
Date:   Wed Mar 18 13:19:28 2020 +0100

tests: Add tests for gethostbyname2_r, IPv4 and IPv6

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

commit 14e90a84f6e2566a87e641821802428b355b1b62
Author: Samuel Cabrero 
Date:   Wed Mar 18 13:43:23 2020 +0100

nwrap: Account for ending NULL pointer when checking the buffer length

The hostent->h_addr_list ends with a NULL pointer, take it into account
when checking the provided buffer length.

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

commit 0d0c0188616cb0772c4cd2eb1b4da8a39171a3fa
Author: Samuel Cabrero 
Date:   Wed Mar 18 13:18:49 2020 +0100

nwrap: Forward ERANGE error to caller in gethostbyname[2]_r

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

commit 7149d5786903eee72f5e776568b0287dc18c1be8
Author: Samuel Cabrero 
Date:   Wed Mar 18 13:18:17 2020 +0100

nwrap: Filter by family in gethostbyname2_r

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

commit 0df994033be3e728910355480f3453497507d570
Author: Andreas Schneider 
Date:   Thu Mar 19 09:53:30 2020 +0100

tests: Check that gethostbyname_r() zeros return values

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

commit ba1d362c0bad254cf5de1015a1d90df5397f1aa6
Author: Andreas Schneider 
Date:   Thu Mar 19 09:16:24 2020 +0100

nwrap: Check paramters and make sure return values are zeored

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

commit 0f30d319d5200f36d53014c42d1a45468ab4041c
Author: Andreas Schneider 
Date:   Thu Mar 19 09:45:09 2020 +0100

nwrap: Zero the result in case we return with an error

This fixes a crash bug in OpenLDAP libraries which do not check the
return value of gethostbyname_r().

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

commit 36c51922f16d8e0c4308b7372799d2f83937b76b
Author: Andreas Schneider 
Date:   Thu Mar 19 09:39:16 2020 +0100

nwrap: Use SAFE_FREE() in nwrap_files_gethostbyname2_r()

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

commit a3ff3c2b430f8c5f8e82539cd54d388e109c0f8b
Author: Andreas Schneider 
Date:   Tue Mar 17 20:13:19 2020 +0100

nwrap: Use calloc() to allocate addr_list vector

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

commit 008913fb8a4968023fd94a8c7aed3d5de75ac2e4
Author: Andreas Schneider 
Date:   Tue Mar 17 18:07:44 2020 +0100

nwrap: Add missing check for gethostbyname2_r()

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

commit 5788a920629e3114f457809febfd2d1229467f0f
Author: Andreas Schneider 
Date:   Mon Mar 16 17:43:20 2020 +0100

nwrap: Fix build if system doesn't provide gethostbyname2

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

---

Summary of 

[SCM] NSS Wrapper Repository - branch master updated

2020-03-16 Thread Andreas Schneider
The branch, master has been updated
   via  d24aec9 Bump version to 1.1.9
   via  cc4092e cmake: Make setting LIBRARY_VERSION easier
   via  e983a70 cmake: Add a link to the compile database for .clangd
   via  32399d4 cmake: Add a dist target to create source tarball
  from  812a5b0 nwrap: Only warn if we can't find a symbol in an nss module

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


- Log -
commit d24aec96dd7329acad1adbdccd77483714a20820
Author: Andreas Schneider 
Date:   Mon Mar 16 16:55:57 2020 +0100

Bump version to 1.1.9

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

commit cc4092e10d824d5d5ad0b9ea9b0366e6f64f8a12
Author: Andreas Schneider 
Date:   Mon Mar 16 16:55:38 2020 +0100

cmake: Make setting LIBRARY_VERSION easier

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

commit e983a70c927ad5dd73a4343affe87c152d52a2cf
Author: Andreas Schneider 
Date:   Mon Mar 16 16:53:11 2020 +0100

cmake: Add a link to the compile database for .clangd

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

commit 32399d4bf8174ecb8308baf3db79f9a2daeb87bf
Author: Andreas Schneider 
Date:   Mon Mar 16 16:52:24 2020 +0100

cmake: Add a dist target to create source tarball

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

---

Summary of changes:
 .gitignore |  1 +
 CHANGELOG  |  3 +++
 CMakeLists.txt | 26 +++---
 3 files changed, 23 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/.gitignore b/.gitignore
index 8fd1310..4de573c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ build
 obj
 cscope.*
 tags
+compile_commands.json
diff --git a/CHANGELOG b/CHANGELOG
index f15355d..5e76d70 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 ChangeLog
 ==
 
+version 1.1.9 (released 2020-03-16)
+  * Fixed log spam when loading modules
+
 version 1.1.8 (released 2020-02-17)
   * Fixed path to library in nss_wrapper.pc
   * Try different backends for gethostbyaddr nd gethostbyname
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa75ef8..c520d16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,20 +11,23 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.8 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.9 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
 
-# SOVERSION scheme: CURRENT.AGE.REVISION
+# SOVERSION scheme: MAJOR.MINOR.PATCH
 #   If there was an incompatible interface change:
-# Increment CURRENT. Set AGE and REVISION to 0
+# Increment MAJOR. Set MINOR and PATCH to 0
 #   If there was a compatible interface change:
-# Increment AGE. Set REVISION to 0
+# Increment MINOR. Set PATCH to 0
 #   If the source code was changed, but there were no interface changes:
-# Increment REVISION.
-set(LIBRARY_VERSION "0.2.7")
-set(LIBRARY_SOVERSION "0")
+# Increment PATCH.
+set(LIBRARY_VERSION_MAJOR 0)
+set(LIBRARY_VERSION_MINOR 2)
+set(LIBRARY_VERSION_PATCH 8)
+set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
+set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 
 # add definitions
 include(DefineCMakeDefaults)
@@ -94,3 +97,12 @@ install(
 )
 
 add_subdirectory(doc)
+
+# Add 'make dist' target which makes sure to invoke cmake before
+add_custom_target(dist
+  COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
+
+# Link combile database for clangd
+execute_process(COMMAND cmake -E create_symlink
+"${CMAKE_BINARY_DIR}/compile_commands.json"
+"${CMAKE_SOURCE_DIR}/compile_commands.json")


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-03-05 Thread Andreas Schneider
The branch, master has been updated
   via  812a5b0 nwrap: Only warn if we can't find a symbol in an nss module
   via  589f8aa nwrap: Some code cleanup for nwrap_load_module_fn()
  from  e2d59b1 Bump version to 1.1.8

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


- Log -
commit 812a5b023478ecb021d6bd9ec322637b67f0effc
Author: Andreas Schneider 
Date:   Mon Feb 17 12:44:26 2020 +0100

nwrap: Only warn if we can't find a symbol in an nss module

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

commit 589f8aacf11fbf1615da8d87200afb95ebb03802
Author: Andreas Schneider 
Date:   Mon Feb 17 11:56:38 2020 +0100

nwrap: Some code cleanup for nwrap_load_module_fn()

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

---

Summary of changes:
 src/nss_wrapper.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 5c4c972..d6639eb 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -1471,22 +1471,24 @@ static int libc_getnameinfo(const struct sockaddr *sa,
 static void *nwrap_load_module_fn(struct nwrap_backend *b,
  const char *fn_name)
 {
-   void *res;
-   char *s;
+   void *res = NULL;
+   char *s = NULL;
+   int rc;
 
-   if (!b->so_handle) {
+   if (b->so_handle == NULL) {
NWRAP_LOG(NWRAP_LOG_ERROR, "No handle");
return NULL;
}
 
-   if (asprintf(, "_nss_%s_%s", b->name, fn_name) == -1) {
+   rc = asprintf(, "_nss_%s_%s", b->name, fn_name);
+   if (rc == -1) {
NWRAP_LOG(NWRAP_LOG_ERROR, "Out of memory");
return NULL;
}
 
res = dlsym(b->so_handle, s);
-   if (!res) {
-   NWRAP_LOG(NWRAP_LOG_ERROR,
+   if (res == NULL) {
+   NWRAP_LOG(NWRAP_LOG_WARN,
  "Cannot find function %s in %s",
  s, b->so_path);
}


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2020-02-17 Thread Andreas Schneider
The branch, master has been updated
   via  e2d59b1 Bump version to 1.1.8
   via  50bd3a0 Rename to CHANGELOG
   via  b8b734e nwrap: Fix memory leak on error in 
nwrap_module_gethostbyname2()
   via  4d7f54d nwrap: Fix memory leak on error in 
nwrap_module_gethostbyname()
   via  a47d0a1 nwrap: Fix memory leak on error in 
nwrap_module_gethostbyaddr()
   via  3f40372 tests: Make sure that current_grp is initialized
  from  79b4874 nwrap: Use size_t for iterations, can't be negative

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


- Log -
commit e2d59b13cbaf6d22dba15ecd9844ff79f2b2f74d
Author: Andreas Schneider 
Date:   Mon Feb 17 09:37:17 2020 +0100

Bump version to 1.1.8

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

commit 50bd3a0b68be13c0612e2e2b391f1ac38f85047d
Author: Andreas Schneider 
Date:   Mon Feb 17 09:38:04 2020 +0100

Rename to CHANGELOG

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

commit b8b734e8708072b1e4ce6064dd2d5f8e2e29b4bb
Author: Andreas Schneider 
Date:   Mon Feb 17 09:49:54 2020 +0100

nwrap: Fix memory leak on error in nwrap_module_gethostbyname2()

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

commit 4d7f54d21c8f35d9d370fafad30ada61a9cd83ff
Author: Andreas Schneider 
Date:   Mon Feb 17 09:48:44 2020 +0100

nwrap: Fix memory leak on error in nwrap_module_gethostbyname()

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

commit a47d0a1bda0d9e1b5be974f036278d919c568267
Author: Andreas Schneider 
Date:   Mon Feb 17 09:46:56 2020 +0100

nwrap: Fix memory leak on error in nwrap_module_gethostbyaddr()

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

commit 3f40372e98ea954dbf72ac4c217eedd838901d9e
Author: Andreas Schneider 
Date:   Mon Feb 17 09:34:31 2020 +0100

tests: Make sure that current_grp is initialized

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

---

Summary of changes:
 ChangeLog => CHANGELOG |  4 
 CMakeLists.txt |  4 ++--
 src/nss_wrapper.c  | 24 ++--
 tests/testsuite.c  |  4 +++-
 4 files changed, 27 insertions(+), 9 deletions(-)
 rename ChangeLog => CHANGELOG (93%)


Changeset truncated at 500 lines:

diff --git a/ChangeLog b/CHANGELOG
similarity index 93%
rename from ChangeLog
rename to CHANGELOG
index 3645f4a..f15355d 100644
--- a/ChangeLog
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.1.8 (released 2020-02-17)
+  * Fixed path to library in nss_wrapper.pc
+  * Try different backends for gethostbyaddr nd gethostbyname
+
 version 1.1.7 (released 2019-11-11)
   * Added NSS_WRAPPER_DISABLE_DEEPBIND env variable
   * Improvded logging
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0939416..fa75ef8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.7 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.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.2.6")
+set(LIBRARY_VERSION "0.2.7")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index ff41eeb..5c4c972 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -4487,11 +4487,15 @@ again:
status = b->fns->_nss_gethostbyaddr_r(addr, len, type, ,
  buf, buflen, , _errno);
if (status == NSS_STATUS_TRYAGAIN) {
+   char *p = NULL;
+
buflen *= 2;
-   buf = (char *)realloc(buf, buflen);
-   if (buf == NULL) {
+   p = (char *)realloc(buf, buflen);
+   if (p == NULL) {
+   SAFE_FREE(buf);
return NULL;
}
+   buf = p;
goto again;
}
if (status == NSS_STATUS_NOTFOUND) {
@@ -4567,11 +4571,15 @@ again:
status = b->fns->_nss_gethostbyname2_r(name, AF_UNSPEC, ,
   buf, buflen, , _errno);
if (status == NSS_STATUS_TRYAGAIN) {
+   char *p = NULL;
+
buflen *= 2;
-   buf = (char *)realloc(buf, buflen);
-   if (buf == NULL) {
+   p = (char *)realloc(buf, buflen);
+   if (p == NULL) {
+   SAFE_FREE(buf);
return NULL;

[SCM] NSS Wrapper Repository - branch master updated

2019-11-18 Thread Andreas Schneider
The branch, master has been updated
   via  79b4874 nwrap: Use size_t for iterations, can't be negative
   via  19b9b95 nwrap: Try different backends for gethostbyname[2][_r]
   via  6b81c15 nwrap: Try different backends in gethostbyaddr
  from  9d72b6e pkgconfig: Fix path to library in nss_wrapper.pc

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


- Log -
commit 79b48745f55cc4947b437f0f1912cbad51eade63
Author: Samuel Cabrero 
Date:   Mon Nov 11 18:31:17 2019 +0100

nwrap: Use size_t for iterations, can't be negative

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

commit 19b9b95f1e91359c3e43e3136b4ba8b284807252
Author: Samuel Cabrero 
Date:   Thu Oct 10 18:12:08 2019 +0200

nwrap: Try different backends for gethostbyname[2][_r]

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

commit 6b81c152eae18b8cf9f4a80fb33b31ddf3af0a7f
Author: Samuel Cabrero 
Date:   Thu Oct 10 13:47:06 2019 +0200

nwrap: Try different backends in gethostbyaddr

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

---

Summary of changes:
 src/nss_wrapper.c | 457 --
 1 file changed, 412 insertions(+), 45 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 1bcd3b1..ff41eeb 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -395,6 +395,14 @@ struct nwrap_module_nss_fns {
NSS_STATUS (*_nss_getgrent_r)(struct group *result, char *buffer,
  size_t buflen, int *errnop);
NSS_STATUS (*_nss_endgrent)(void);
+   NSS_STATUS (*_nss_gethostbyaddr_r)(const void *addr, socklen_t addrlen,
+  int af, struct hostent *result,
+  char *buffer, size_t buflen,
+  int *errnop, int *h_errnop);
+   NSS_STATUS (*_nss_gethostbyname2_r)(const char *name, int af,
+   struct hostent *result,
+   char *buffer, size_t buflen,
+   int *errnop, int *h_errnop);
 };
 
 struct nwrap_backend {
@@ -405,6 +413,8 @@ struct nwrap_backend {
struct nwrap_module_nss_fns *fns;
 };
 
+struct nwrap_vector;
+
 struct nwrap_ops {
struct passwd * (*nw_getpwnam)(struct nwrap_backend *b,
   const char *name);
@@ -440,6 +450,18 @@ struct nwrap_ops {
 struct group *grdst, char *buf,
 size_t buflen, struct group **grdstp);
void(*nw_endgrent)(struct nwrap_backend *b);
+   struct hostent *(*nw_gethostbyaddr)(struct nwrap_backend *b,
+   const void *addr,
+   socklen_t len, int type);
+   struct hostent *(*nw_gethostbyname)(struct nwrap_backend *b,
+   const char *name);
+   struct hostent *(*nw_gethostbyname2)(struct nwrap_backend *b,
+const char *name, int af);
+   int (*nw_gethostbyname2_r)(struct nwrap_backend *b,
+  const char *name, int af,
+  struct hostent *hedst,
+  char *buf, size_t buflen,
+  struct hostent **hedstp);
 };
 
 /* Public prototypes */
@@ -485,6 +507,18 @@ static int nwrap_files_getgrent_r(struct nwrap_backend *b,
  struct group *grdst, char *buf,
  size_t buflen, struct group **grdstp);
 static void nwrap_files_endgrent(struct nwrap_backend *b);
+static struct hostent *nwrap_files_gethostbyaddr(struct nwrap_backend *b,
+const void *addr,
+socklen_t len, int type);
+static struct hostent *nwrap_files_gethostbyname(struct nwrap_backend *b,
+const char *name);
+static struct hostent *nwrap_files_gethostbyname2(struct nwrap_backend *b,
+ const char *name, int af);
+static int nwrap_files_gethostbyname2_r(struct nwrap_backend *b,
+   const char *name, int af,
+   struct hostent *hedst,
+   char *buf, size_t buflen,
+   struct hostent **hedstp);
 
 /* prototypes for module backend */
 
@@ -522,6 +556,18 @@ static 

[SCM] NSS Wrapper Repository - branch master updated

2019-11-18 Thread Andreas Schneider
The branch, master has been updated
   via  9d72b6e pkgconfig: Fix path to library in nss_wrapper.pc
  from  80982e8 Bump version to 1.1.7

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


- Log -
commit 9d72b6e5dac0e07be468122c0a909341cbf942bc
Author: Andreas Schneider 
Date:   Thu Nov 14 10:35:27 2019 +0100

pkgconfig: Fix path to library in nss_wrapper.pc

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

[SCM] NSS Wrapper Repository - branch master updated

2019-11-12 Thread Andreas Schneider
The branch, master has been updated
   via  80982e8 Bump version to 1.1.7
   via  7c34da8 nwrap: Improve logging function
   via  8076f3d cmake: Check for getprogname() and getexecname()
   via  6c12eed nwrap: Always provide logging
   via  f81e1e0 cmake: Fix path to nss_wrapper library
  from  2c754bf Update TODO

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


- Log -
commit 80982e8bc36f36b13b010486810a01bb89ce9254
Author: Andreas Schneider 
Date:   Mon Nov 11 15:46:08 2019 +0100

Bump version to 1.1.7

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

commit 7c34da8278adbc57b4f18c8290cdfb5d71629ef5
Author: Andreas Schneider 
Date:   Wed Nov 6 18:33:59 2019 +0100

nwrap: Improve logging function

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

commit 8076f3d59b88d9a8d6649b1b98815089ad217b5f
Author: Andreas Schneider 
Date:   Wed Nov 6 18:33:43 2019 +0100

cmake: Check for getprogname() and getexecname()

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

commit 6c12eeddb57cc43b970d4795ba5c7d0d752ed7a9
Author: Andreas Schneider 
Date:   Wed Nov 6 18:29:27 2019 +0100

nwrap: Always provide logging

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

commit f81e1e032c6828951b7a1ddc5bb4782923f0dbe9
Author: Andreas Schneider 
Date:   Wed Nov 6 18:43:29 2019 +0100

cmake: Fix path to nss_wrapper library

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

---

Summary of changes:
 CMakeLists.txt  |  2 +-
 ChangeLog   |  5 
 ConfigureChecks.cmake   |  3 ++
 config.h.cmake  |  3 ++
 nss_wrapper-config.cmake.in |  2 +-
 src/nss_wrapper.c   | 71 +++--
 6 files changed, 55 insertions(+), 31 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e87842b..0939416 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.6 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.7 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
diff --git a/ChangeLog b/ChangeLog
index 83a2380..3645f4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.7 (released 2019-11-11)
+  * Added NSS_WRAPPER_DISABLE_DEEPBIND env variable
+  * Improvded logging
+  * Fixed location in cmake config
+
 version 1.1.6 (released 2019-05-19)
   * Fixed issues with memory alignment of getgrnam()
   * Fixed getpwnam() on FreeBSD
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index d0e1e0d..2947a8e 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -78,6 +78,9 @@ check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
 
 check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
 
+check_function_exists(getprogname HAVE_GETPROGNAME)
+check_function_exists(getexecname HAVE_GETEXECNAME)
+
 if (WIN32)
 check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
 check_function_exists(_vsnprintf HAVE__VSNPRINTF)
diff --git a/config.h.cmake b/config.h.cmake
index 15f6afc..de0b5df 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -59,6 +59,9 @@
 /* Define to 1 if you have the `gethostbyname2' function. */
 #cmakedefine HAVE_GETHOSTBYNAME2 1
 
+#cmakedefine HAVE_GETPROGNAME 1
+#cmakedefine HAVE_GETEXECNAME 1
+
 #cmakedefine HAVE___POSIX_GETPWNAM_R 1
 #cmakedefine HAVE___POSIX_GETPWUID_R 1
 
diff --git a/nss_wrapper-config.cmake.in b/nss_wrapper-config.cmake.in
index 8f10f25..9375f5c 100644
--- a/nss_wrapper-config.cmake.in
+++ b/nss_wrapper-config.cmake.in
@@ -1 +1 @@
-set(NSS_WRAPPER_LIBRARY @CMAKE_INSTALL_LIBDIR@/@NSS_WRAPPER_LIB@)
+set(NSS_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@NSS_WRAPPER_LIB@)
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 33b610b..1bcd3b1 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -243,9 +243,18 @@ enum nwrap_dbglvl_e {
NWRAP_LOG_TRACE
 };
 
-#ifdef NDEBUG
-# define NWRAP_LOG(...)
+#ifndef HAVE_GETPROGNAME
+static const char *getprogname(void)
+{
+#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
+   return program_invocation_short_name;
+#elif defined(HAVE_GETEXECNAME)
+   return getexecname();
 #else
+   return NULL;
+#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
+}
+#endif /* HAVE_GETPROGNAME */
 
 static void nwrap_log(enum nwrap_dbglvl_e dbglvl, const char *func, const char 
*format, ...) PRINTF_ATTRIBUTE(3, 4);
 # define NWRAP_LOG(dbglvl, ...) nwrap_log((dbglvl), __func__, __VA_ARGS__)
@@ -258,43 +267,49 @@ static void nwrap_log(enum nwrap_dbglvl_e dbglvl,

[SCM] NSS Wrapper Repository - branch master updated

2019-07-15 Thread Andreas Schneider
The branch, master has been updated
   via  2c754bf Update TODO
   via  f767c52 doc: Add description for NSS_WRAPPER_DISABLE_DEEPBIND
   via  abaae7a nwrap: Add NSS_WRAPPER_DISABLE_DEEPBIND env variable
  from  c18484e Bump version to 1.1.6

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


- Log -
commit 2c754bf4e36a6d6ea4670dc587be8ba92c50d2fd
Author: Andreas Schneider 
Date:   Thu Jun 13 17:09:15 2019 +0200

Update TODO

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

commit f767c52eec4f6121763b30d1bf2f39c6466acafb
Author: Andreas Schneider 
Date:   Tue May 21 08:29:12 2019 +0200

doc: Add description for NSS_WRAPPER_DISABLE_DEEPBIND

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

commit abaae7a89c215c6c88e81b9b2251a9284e629b4b
Author: Andreas Schneider 
Date:   Tue May 21 08:30:53 2019 +0200

nwrap: Add NSS_WRAPPER_DISABLE_DEEPBIND env variable

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

---

Summary of changes:
 TODO  |  2 +-
 doc/nss_wrapper.1 | 19 +++
 doc/nss_wrapper.1.txt |  8 +++-
 src/nss_wrapper.c | 20 +++-
 4 files changed, 38 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/TODO b/TODO
index a83f850..f0a31ab 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,7 @@ TODO
 
 Library
 
-* None at the moment.
+* Replace hcreate() as it messes with applications also using it.
 
 Testing
 
diff --git a/doc/nss_wrapper.1 b/doc/nss_wrapper.1
index 940438d..3ef5a89 100644
--- a/doc/nss_wrapper.1
+++ b/doc/nss_wrapper.1
@@ -1,13 +1,13 @@
 '\" t
 .\" Title: nss_wrapper
-.\"Author: [FIXME: author] [see http://docbook.sf.net/el/author]
-.\" Generator: DocBook XSL Stylesheets v1.78.1 
-.\"  Date: 2015-09-12
+.\"Author: Samba Team
+.\" Generator: DocBook XSL Stylesheets vsnapshot 
+.\"  Date: 2019-05-21
 .\"Manual: \ \&
 .\"Source: \ \&
 .\"  Language: English
 .\"
-.TH "NSS_WRAPPER" "1" "2015\-09\-12" "\ \&" "\ \&"
+.TH "NSS_WRAPPER" "1" "2019\-05\-21" "\ \&" "\ \&"
 .\" -
 .\" * Define some portability stuff
 .\" -
@@ -162,6 +162,11 @@ If you need to see what is going on in nss_wrapper itself 
or try to find a bug,
 3 = TRACE
 .RE
 .RE
+.PP
+\fBNSS_WRAPPER_DISABLE_DEEPBIND\fR
+.RS 4
+This allows you to disable deep binding in nss_wrapper\&. This is useful for 
running valgrind tools or sanitizers like (address, undefined, thread)\&.
+.RE
 .SH "EXAMPLE"
 .sp
 .if n \{\
@@ -181,3 +186,9 @@ test\&.example\&.org
 .if n \{\
 .RE
 .\}
+.SH "AUTHOR"
+.PP
+\fBSamba Team\fR
+.RS 4
+Author.
+.RE
diff --git a/doc/nss_wrapper.1.txt b/doc/nss_wrapper.1.txt
index d541e31..4811dde 100644
--- a/doc/nss_wrapper.1.txt
+++ b/doc/nss_wrapper.1.txt
@@ -1,6 +1,7 @@
 nss_wrapper(1)
 ==
-:revdate: 2015-09-12
+:revdate: 2019-05-21
+:author: Samba Team
 
 NAME
 
@@ -90,6 +91,11 @@ debug symbols.
 - 2 = DEBUG
 - 3 = TRACE
 
+*NSS_WRAPPER_DISABLE_DEEPBIND*::
+
+This allows you to disable deep binding in nss_wrapper. This is useful for
+running valgrind tools or sanitizers like (address, undefined, thread).
+
 EXAMPLE
 ---
 
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 62c7af1..33b610b 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -848,15 +848,25 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
int i;
 
 #ifdef RTLD_DEEPBIND
-   const char *env = getenv("LD_PRELOAD");
+   const char *env_preload = getenv("LD_PRELOAD");
+   const char *env_deepbind = getenv("NSS_WRAPPER_DISABLE_DEEPBIND");
+   bool enable_deepbind = true;
 
/* Don't do a deepbind if we run with libasan */
-   if (env != NULL && strlen(env) < 1024) {
-   const char *p = strstr(env, "libasan.so");
-   if (p == NULL) {
-   flags |= RTLD_DEEPBIND;
+   if (env_preload != NULL && strlen(env_preload) < 1024) {
+   const char *p = strstr(env_preload, "libasan.so");
+   if (p != NULL) {
+   enable_deepbind = false;
}
}
+
+   if (env_deepbind != NULL && strlen(env_deepbind) >= 1) {
+   enable_deepbind = false;
+   }
+
+   if (enable_deepbind) {
+   flags |= RTLD_DEEPBIND;
+   }
 #endif
 
switch (lib) {


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2019-05-16 Thread Andreas Schneider
The branch, master has been updated
   via  c18484e Bump version to 1.1.6
   via  d55a8c7 cpack: Fix description and vendor
  from  7979c97 gitlab-ci: Setup CI for nss_wrapper

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


- Log -
commit c18484ec4f20da846a7673a415a1b4db8bc144e8
Author: Andreas Schneider 
Date:   Fri May 17 07:44:30 2019 +0200

Bump version to 1.1.6

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

commit d55a8c74c77a518169debc59d44324a4c0208a88
Author: Andreas Schneider 
Date:   Tue May 7 11:58:49 2019 +0200

cpack: Fix description and vendor

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

---

Summary of changes:
 CMakeLists.txt| 4 ++--
 CPackConfig.cmake | 4 ++--
 ChangeLog | 5 +
 3 files changed, 9 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4507a15..e87842b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH 
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.5 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.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.2.5")
+set(LIBRARY_VERSION "0.2.6")
 set(LIBRARY_SOVERSION "0")
 
 # add definitions
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index 827b518..3a554a9 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -3,9 +3,9 @@
 
 ### general settings
 set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The SSH library")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The NSS wrapper library")
 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
-set(CPACK_PACKAGE_VENDOR "The SSH Library Development Team")
+set(CPACK_PACKAGE_VENDOR "The Samba Team")
 set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
 
diff --git a/ChangeLog b/ChangeLog
index b158baf..83a2380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.6 (released 2019-05-19)
+  * Fixed issues with memory alignment of getgrnam()
+  * Fixed getpwnam() on FreeBSD
+  * Started to use modern cmake (>= 3.5.0)
+
 version 1.1.5 (released 2018-10-31)
   * Fixed running on older distributions
 


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2019-02-28 Thread Andreas Schneider
The branch, master has been updated
   via  7979c97 gitlab-ci: Setup CI for nss_wrapper
   via  baf74fc cmake: Use GNUInstallDirs
   via  1d8fd4d cmake: Do not run test_nwrap_disabled with sanitizers
   via  5e81a6f cmake: Disable source code execution when cross compiling
   via  4846f43 cmake: Put defines in config.h
   via  36fe8b5 cmake: Fix configure check for libdl
   via  f67c82e cmake: Use target_include_directories()
   via  dfdc976 cmake: Update AddCMockaTest.cmake
   via  84df0f5 cmake: Update cmocka requirement
   via  0d9bb5b cmake: Support running the tests with AddressSanitizer
   via  43670a3 cmake: Add AddressSanitizer and UndefinedSanitizer
   via  405b315 cmake: Move Compiler flags to new file
   via  51da1fd cmake: Remove obsolete DefineCompilerFlags.cmake
   via  5277cd0 cmake: Improve checks for compiler flags
   via  ae637af cmake: Update CMake defaults
   via  e03ec17 cmake: Do not misuse CMAKE_REQUIRED_LIBRARIES
   via  fda5618 cmake: Require at least cmake 3.5.0
   via  4995ab1 tests: Fix strict aliasing issues in test_nwrap_disabled
   via  98f7b80 tests: Fix sockaddr alignment issues in test_getaddrinfo
   via  f5f9a76 tests: Fix passwd entry for alice
   via  205e3f2 nwrap: Fix copying 'struct passwd' on FreeBSD
   via  a0f38b4 nwrap: Rewrite nwrap_gr_copy_r() to take memory alignment 
into account
   via  fbb37b1 nwrap: Also check for NUL-byte in group loop
   via  633e822 nwrap: Fix strict aliasing issue with sockaddr
   via  d0c03e3 nwrap: Fix strict aliasing issues
   via  2eb9e76 nwrap: Use memcpy instead of strncpy
   via  5c24605 README: Rename to a markdown file
  from  05f50d2 Bump version to 1.1.5

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


- Log -
commit 7979c97d8bf10c54cbe422d191ddbb5cc0a2ae0e
Author: Andreas Schneider 
Date:   Fri Feb 15 13:29:08 2019 +0100

gitlab-ci: Setup CI for nss_wrapper

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

commit baf74fcbb776f459ce0dc987210d01b1bb5e5d64
Author: Andreas Schneider 
Date:   Wed Feb 20 10:35:27 2019 +0100

cmake: Use GNUInstallDirs

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

commit 1d8fd4d1a5336df2bcebc8cde3a0a4f6ea8d6442
Author: Andreas Schneider 
Date:   Fri Feb 15 13:54:31 2019 +0100

cmake: Do not run test_nwrap_disabled with sanitizers

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

commit 5e81a6fc1f8677cd7708cd12f410f0626ee32178
Author: Andreas Schneider 
Date:   Fri Feb 15 13:46:32 2019 +0100

cmake: Disable source code execution when cross compiling

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

commit 4846f435eabba3c92adcf21a31e22f05d9232703
Author: Andreas Schneider 
Date:   Fri Feb 15 13:45:12 2019 +0100

cmake: Put defines in config.h

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

commit 36fe8b5c55f791154103a7aa3737261b6608b728
Author: Andreas Schneider 
Date:   Fri Feb 15 13:26:42 2019 +0100

cmake: Fix configure check for libdl

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

commit f67c82ec07b25b0c4f51013c9804ebd8aff3
Author: Andreas Schneider 
Date:   Fri Feb 15 13:24:31 2019 +0100

cmake: Use target_include_directories()

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

commit dfdc976df864b8289185a5a4b0668544c78ddc2e
Author: Andreas Schneider 
Date:   Fri Feb 15 12:13:18 2019 +0100

cmake: Update AddCMockaTest.cmake

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

commit 84df0f5485e620bb4cdaa261925ac64e66935ba9
Author: Andreas Schneider 
Date:   Fri Feb 15 12:05:18 2019 +0100

cmake: Update cmocka requirement

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

commit 0d9bb5b5a5ec796333ab5827cc2c65a92dab60d1
Author: Andreas Schneider 
Date:   Fri Feb 15 12:04:20 2019 +0100

cmake: Support running the tests with AddressSanitizer

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

commit 43670a36dc549a885becccbe79f556829243b674
Author: Andreas Schneider 
Date:   Fri Feb 15 11:57:38 2019 +0100

cmake: Add AddressSanitizer and UndefinedSanitizer

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

commit 405b3152e280bf8e27f55d5ec45484fc0165a777
Author: Andreas Schneider 
Date:   Fri Feb 15 11:57:11 2019 +0100

cmake: Move Compiler flags to new file

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

commit 51da1fd9c3b57f385609ff8993b44c47e81d9e73
Author: Andreas Schneider 
Date:   Fri Feb 15 11:54:55 2019 +0100

cmake: Remove obsolete DefineCompilerFlags.cmake

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

commit 

[SCM] NSS Wrapper Repository - branch master updated

2018-10-31 Thread Andreas Schneider
The branch, master has been updated
   via  05f50d2 Bump version to 1.1.5
   via  7799438 nwrap: Do not call nwrap_init() in the constructor
   via  bab893a nwrap: Call exit() if something goes wrong during 
initialization
   via  92c1b22 nwrap: Use calloc in nwrap_libc_init()
  from  8963f3f Bump version to 1.1.4

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


- Log -
commit 05f50d22e0219baf6152f1540db3a3765f095950
Author: Andreas Schneider 
Date:   Wed Oct 31 13:23:30 2018 +0100

Bump version to 1.1.5

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

commit 7799438252cd152fa44ea56b736862fb9bf507a6
Author: Andreas Schneider 
Date:   Wed Oct 31 11:11:05 2018 +0100

nwrap: Do not call nwrap_init() in the constructor

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

commit bab893a851c1c9291b148522c2790e887bf77bc1
Author: Andreas Schneider 
Date:   Wed Oct 31 11:10:37 2018 +0100

nwrap: Call exit() if something goes wrong during initialization

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

commit 92c1b223275ac49c7af3275c6fb480164841eead
Author: Andreas Schneider 
Date:   Wed Oct 31 11:10:08 2018 +0100

nwrap: Use calloc in nwrap_libc_init()

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

---

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


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bbdba4c..e91c266 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 "4")
+set(APPLICATION_VERSION_PATCH "5")
 
 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.2.4")
+set(LIBRARY_VERSION "0.2.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 46ef626..b158baf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 ChangeLog
 ==
 
+version 1.1.5 (released 2018-10-31)
+  * Fixed running on older distributions
+
 version 1.1.4 (released 2018-10-31)
   * Fixed module getpw* functions
   * Fixed nss_wrapper.pl to use correct perl binary
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index dd16fe6..81d900c 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -218,8 +218,11 @@ static pthread_mutex_t nwrap_sp_global_mutex = 
PTHREAD_MUTEX_INITIALIZER;
NWRAP_UNLOCK(nwrap_initialized); \
 } while (0);
 
+static void nwrap_init(void);
+
 static void nwrap_thread_prepare(void)
 {
+   nwrap_init();
NWRAP_LOCK_ALL;
 }
 
@@ -806,7 +809,6 @@ static struct nwrap_he nwrap_he_global;
  * NWRAP PROTOTYPES
  */
 
-static void nwrap_init(void);
 static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_gr_unload(struct nwrap_cache *nwrap);
 void nwrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
@@ -1512,19 +1514,17 @@ static bool nwrap_module_init(const char *name,
 
 static void nwrap_libc_init(struct nwrap_main *r)
 {
-   r->libc = malloc(sizeof(struct nwrap_libc));
+   r->libc = calloc(1, sizeof(struct nwrap_libc));
if (r->libc == NULL) {
printf("Failed to allocate memory for libc");
exit(-1);
}
-   ZERO_STRUCTP(r->libc);
 
-   r->libc->fns = malloc(sizeof(struct nwrap_libc_fns));
+   r->libc->fns = calloc(1, sizeof(struct nwrap_libc_fns));
if (r->libc->fns == NULL) {
printf("Failed to allocate memory for libc functions");
exit(-1);
}
-   ZERO_STRUCTP(r->libc->fns);
 }
 
 static void nwrap_backend_init(struct nwrap_main *r)
@@ -1565,6 +1565,7 @@ static void nwrap_init(void)
const char *env;
char *endptr;
size_t max_hostents_tmp;
+   int ok;
 
NWRAP_LOCK(nwrap_initialized);
if (nwrap_initialized) {
@@ -1604,10 +1605,11 @@ static void nwrap_init(void)
NWRAP_LOG(NWRAP_LOG_DEBUG,
  "Initializing hash table of size %lu items.",
  (unsigned long)max_hostents);
-   if (hcreate(max_hostents) == 0) {
+   ok = hcreate(max_hostents);
+   if (!ok) {

[SCM] NSS Wrapper Repository - branch master updated

2018-10-31 Thread Andreas Schneider
The branch, master has been updated
   via  8963f3f Bump version to 1.1.4
  from  70fb58a nwrap: Don't do a deep bind if we run with libasan

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


- Log -
commit 8963f3f25af0e0608b298d65598df7d01a6f028b
Author: Andreas Schneider 
Date:   Tue Oct 30 10:04:41 2018 +0100

Bump version to 1.1.4

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

---

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 5d34dd0..bbdba4c 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 "3")
+set(APPLICATION_VERSION_PATCH "4")
 
 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.2.3")
+set(LIBRARY_VERSION "0.2.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 959f0f5..46ef626 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.4 (released 2018-10-31)
+  * Fixed module getpw* functions
+  * Fixed nss_wrapper.pl to use correct perl binary
+  * Fixed compatibility with musl-libc
+
 version 1.1.3 (released 2015-03-18)
   * Added support for BSD 'struct passwd' members
   * Replaced strcpy() with snprintf()


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2018-10-30 Thread Andreas Schneider
The branch, master has been updated
   via  70fb58a nwrap: Don't do a deep bind if we run with libasan
   via  4e67f44 tests: Check pointers of get(pw|gr)(nam|uid|gid)_r functions
   via  e171db5 nwrap: fix nwrap_module_getgrent_r
   via  c1bd13a nwrap: fix nwrap_module_getgrgid_r
   via  6bde6d5 nwrap: fix nwrap_module_getgrnam_r
   via  d3ad297 nwrap: fix nwrap_module_getpwent_r
   via  9e0b9d6 nwrap: fix nwrap_module_getpwuid_r
   via  433ab5e nwrap: fix nwrap_module_getpwnam_r
  from  2d57b2a ctest: Move to new dashboard

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


- Log -
commit 70fb58a114e07a5a9766ad0efefb7aaa6b0e4cb8
Author: Andreas Schneider 
Date:   Sat Sep 1 19:41:46 2018 +0200

nwrap: Don't do a deep bind if we run with libasan

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

commit 4e67f442f5b2b8fd67e40bc27afefb73f41f7345
Author: Andreas Schneider 
Date:   Tue Oct 30 11:04:22 2018 +0100

tests: Check pointers of get(pw|gr)(nam|uid|gid)_r functions

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

commit e171db5578ecc25eec8979e20924a5eabcb9ea85
Author: Ralph Wuerthner 
Date:   Fri Oct 19 15:24:21 2018 +0200

nwrap: fix nwrap_module_getgrent_r

On success *grdstp must point to grdst, on error return NULL instead.

Signed-off-by: Ralph Wuerthner 
Reviewed-by: Volker Lendecke 
Reviewed-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

commit c1bd13a582fb885ea2e8385fec5b5eea94a7e2fc
Author: Ralph Wuerthner 
Date:   Fri Oct 19 15:22:23 2018 +0200

nwrap: fix nwrap_module_getgrgid_r

On success *grdstp must point to grdst, on error return NULL instead.

Signed-off-by: Ralph Wuerthner 
Reviewed-by: Volker Lendecke 
Reviewed-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

commit 6bde6d573508d11ecdeb549fb70e0f07beeb4027
Author: Ralph Wuerthner 
Date:   Fri Oct 19 15:19:28 2018 +0200

nwrap: fix nwrap_module_getgrnam_r

On success *grdstp must point to grdst, on error return NULL instead.

Signed-off-by: Ralph Wuerthner 
Reviewed-by: Volker Lendecke 
Reviewed-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

commit d3ad297a9420c7a752d7262a9870e16a29ab0a82
Author: Ralph Wuerthner 
Date:   Fri Oct 19 12:19:17 2018 +0200

nwrap: fix nwrap_module_getpwent_r

On success *pwdstp must point to pwdst, on error return NULL instead.

Signed-off-by: Ralph Wuerthner 
Reviewed-by: Volker Lendecke 
Reviewed-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

commit 9e0b9d6d4872db507b65989f975b8e145cf81e8b
Author: Ralph Wuerthner 
Date:   Fri Oct 19 12:15:53 2018 +0200

nwrap: fix nwrap_module_getpwuid_r

On success *pwdstp must point to pwdst, on error return NULL instead.

Signed-off-by: Ralph Wuerthner 
Reviewed-by: Volker Lendecke 
Reviewed-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

commit 433ab5ed5766150bf0786ba6c48e701205cd1a1c
Author: Ralph Wuerthner 
Date:   Fri Oct 19 11:27:04 2018 +0200

nwrap: fix nwrap_module_getpwnam_r

On success *pwdstp must point to pwdst, on error return NULL instead.

Signed-off-by: Ralph Wuerthner 
Reviewed-by: Volker Lendecke 
Reviewed-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

---

Summary of changes:
 src/nss_wrapper.c | 30 +-
 tests/testsuite.c |  4 
 2 files changed, 25 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index dd0848a..dd16fe6 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -846,7 +846,15 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
int i;
 
 #ifdef RTLD_DEEPBIND
-   flags |= RTLD_DEEPBIND;
+   const char *env = getenv("LD_PRELOAD");
+
+   /* Don't do a deepbind if we run with libasan */
+   if (env != NULL && strlen(env) < 1024) {
+   const char *p = strstr(env, "libasan.so");
+   if (p == NULL) {
+   flags |= RTLD_DEEPBIND;
+   }
+   }
 #endif
 
switch (lib) {
@@ -3846,9 +3854,7 @@ static int nwrap_module_getpwnam_r(struct nwrap_backend 
*b,
 {
int ret;
 
-   (void) b; /* unused */
-   (void) pwdst; /* unused */
-   (void) pwdstp; /* unused */
+   *pwdstp = NULL;
 
if (!b->fns->_nss_getpwnam_r) {
return NSS_STATUS_NOTFOUND;
@@ -3857,6 +3863,7 @@ static int nwrap_module_getpwnam_r(struct nwrap_backend 
*b,
ret = b->fns->_nss_getpwnam_r(name, pwdst, buf, buflen, );
switch (ret) {
case NSS_STATUS_SUCCESS:
+   *pwdstp = pwdst;
return 0;
case NSS_STATUS_NOTFOUND:
if 

[SCM] NSS Wrapper Repository - branch master updated

2018-08-09 Thread Andreas Schneider
The branch, master has been updated
   via  2d57b2a ctest: Move to new dashboard
   via  31fa6a7 nwrap: Update header
   via  35c8ff2 Update LICENSE file
   via  fb1ef75 Rename COPYING to LICENSE
   via  c6d06bf nwrap: Print errno when hsearch() returns NULL
   via  853ae24 tests: Add musl-libc 1.1 compatibility (gethostent())
   via  54fb274 tests: Add musl-libc 1.1 compatibility (getaddrinfo(), 
EAI_SERVICE)
   via  8ba1653 tests: Add musl-libc 1.1 compatibility (getaddrinfo(), 
IP-addresses)
   via  f8bb2de cpack: Do not package build dirs in source tarball
   via  52c79f2 cmake: Replace deprecated get_target_property()
  from  4298e3f nwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS

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


- Log -
commit 2d57b2a56ddcfc229e0b6445c534c558094e336b
Author: Andreas Schneider 
Date:   Thu Jul 5 10:15:11 2018 +0200

ctest: Move to new dashboard

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

commit 31fa6a7c7a9453d91ef4683581814fb02c2a3a45
Author: Andreas Schneider 
Date:   Fri Jun 22 08:46:06 2018 +0200

nwrap: Update header

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

commit 35c8ff28450ec5dbd16d9619cac936db9e00ee3d
Author: Andreas Schneider 
Date:   Fri Jun 22 08:34:27 2018 +0200

Update LICENSE file

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

commit fb1ef750dc442a561e17536b8212261841478536
Author: Andreas Schneider 
Date:   Fri Jun 22 08:32:43 2018 +0200

Rename COPYING to LICENSE

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

commit c6d06bf617d25cb2b751853f5c6af0fe0e152f69
Author: Andreas Schneider 
Date:   Mon Jan 22 17:30:33 2018 +0100

nwrap: Print errno when hsearch() returns NULL

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

commit 853ae24558611ee7738e60ecd0e4d805df7c6b00
Author: Dennis Schridde 
Date:   Wed Jan 25 22:25:24 2017 +0100

tests: Add musl-libc 1.1 compatibility (gethostent())

musl-libc stubs gethostent() and replies with NULL in any case. Thus we 
have to
 check the sensibility of the function before performing tests.

Tested with musl-libc 1.1.16-r13 on Alpine Linux 3.6. Also confirmed to not
 break with GNU libc 2.23-0ubuntu9 on Ubuntu 16.04.3 LTS.

Signed-Off-By: Dennis Schridde 
Reviewed-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 54fb2748b2e0f720017982678d50357e90b695d9
Author: Dennis Schridde 
Date:   Thu Aug 3 11:34:07 2017 +0200

tests: Add musl-libc 1.1 compatibility (getaddrinfo(), EAI_SERVICE)

The tests of getaddrinfo() had to be adapted, because musl-libc, unlike 
glibc
 and others, returns EAI_SERVICE if the requested service is not available 
for
 the requested socket type.

Tested with musl-libc 1.1.16-r13 on Alpine Linux 3.6. Also confirmed to not
 break with GNU libc 2.23-0ubuntu9 on Ubuntu 16.04.3 LTS.

Signed-Off-By: Dennis Schridde 
Reviewed-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit 8ba16534b6f02c6337106cc17ced3c1f48b903fa
Author: Dennis Schridde 
Date:   Wed Jan 25 22:25:24 2017 +0100

tests: Add musl-libc 1.1 compatibility (getaddrinfo(), IP-addresses)

The tests of getaddrinfo() had to be adapted, because musl-libc, unlike 
glibc
 and others, replies with the same canonical name that was used in the 
original
 request, if the requested "node" was an IP-address

Tested with musl-libc 1.1.16-r13 on Alpine Linux 3.6. Also confirmed to not
 break with GNU libc 2.23-0ubuntu9 on Ubuntu 16.04.3 LTS.

Signed-Off-By: Dennis Schridde 
Reviewed-by: Andreas Schneider 
Reviewed-by: Stefan Metzmacher 

commit f8bb2dea54ac9f4276b73befcb83fdf0d120d6ba
Author: Andreas Schneider 
Date:   Fri Jun 22 09:00:30 2018 +0200

cpack: Do not package build dirs in source tarball

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

commit 52c79f2e0284baa04a180280dc92875cef13f757
Author: Andreas Schneider 
Date:   Fri Jun 22 08:55:40 2018 +0200

cmake: Replace deprecated get_target_property()

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

---

Summary of changes:
 CPackConfig.cmake   |  4 +--
 CTestConfig.cmake   |  6 ++--
 ConfigureChecks.cmake   | 69 +
 COPYING => LICENSE  |  9 --
 src/CMakeLists.txt  |  7 +
 src/nss_wrapper.c   | 13 ++---
 tests/test_getaddrinfo.c| 20 +
 tests/test_nwrap_disabled.c | 12 
 8 files changed, 122 insertions(+), 18 deletions(-)
 rename COPYING => LICENSE (82%)


Changeset 

[SCM] NSS Wrapper Repository - branch master updated

2017-10-13 Thread Andreas Schneider
The branch, master has been updated
   via  4298e3f nwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS
  from  7523b05 testsuite: Add compatibility for musl-libc 1.1

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


- Log -
commit 4298e3f08fed7be612155ef7e03998c1aaf9a2ac
Author: Douglas Bagnall 
Date:   Wed Aug 16 10:35:28 2017 +1200

nwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS

The env and endptr pointers need to be dereferenced, but that is not
enough: we don't really want to regard an empty string (*env == '\0')
as a valid number.

Found by GCC 8.0.0 20170705 (experimental).

[2095/4103] Compiling lib/nss_wrapper/nss_wrapper.c
../lib/nss_wrapper/nss_wrapper.c: In function ‘nwrap_init’:
../lib/nss_wrapper/nss_wrapper.c:1571:13: warning: comparison between 
pointer and zero character constant [-Wpointer-compare]
   if (((env != '\0') && (endptr == '\0')) ||
^~
../lib/nss_wrapper/nss_wrapper.c:1571:9: note: did you mean 
to dereference the pointer?
   if (((env != '\0') && (endptr == '\0')) ||
^
../lib/nss_wrapper/nss_wrapper.c:1571:33: warning: comparison 
between pointer and zero character constant [-Wpointer-compare]
   if (((env != '\0') && (endptr == '\0')) ||
^~

../lib/nss_wrapper/nss_wrapper.c:1571:26: note: did you mean to dereference the 
pointer?
   if (((env != '\0') && (endptr == '\0')) ||

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

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 70a5989..835bc87 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -1576,8 +1576,9 @@ static void nwrap_init(void)
 
env = getenv("NSS_WRAPPER_MAX_HOSTENTS");
if (env != NULL) {
-   max_hostents_tmp = (size_t)strtol(env, , 10);
-   if (((env != '\0') && (endptr == '\0')) ||
+   max_hostents_tmp = (size_t)strtoul(env, , 10);
+   if ((*env == '\0') ||
+   (*endptr != '\0') ||
(max_hostents_tmp == 0)) {
NWRAP_LOG(NWRAP_LOG_DEBUG,
  "Error parsing NSS_WRAPPER_MAX_HOSTENTS "


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2017-05-31 Thread Andreas Schneider
The branch, master has been updated
   via  7523b05 testsuite: Add compatibility for musl-libc 1.1
   via  09bb07c nwrap: Add compatibility for musl-libc 1.1
   via  bba5eec nwrap: Add a comment to the pthread_atfork() call
   via  2b80c4c nwrap: Use a constructor to initialize pthread and nwrap
   via  52490af cmake: Check for contructor attribute support
   via  4b7e685 nwrap: Add NULL checks for destructor
  from  d66ce39 nss_wrapper: Use perl via "env"

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


- Log -
commit 7523b05f0e84e8d9a1c27c06805d0ba72ec33373
Author: Dennis Schridde 
Date:   Wed Jan 25 22:25:24 2017 +0100

testsuite: Add compatibility for musl-libc 1.1

The major difference is that getpwent_r and getgrent_r do not exist in
musl-libc. The testsuite was adapted to skip these tests if the
functions themselves are missing.

Signed-Off-By: Dennis Schridde 
Reviewed-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit 09bb07c4aec3da9d555d0a608b2c98dde46ff886
Author: Dennis Schridde 
Date:   Mon Mar 27 16:26:11 2017 +0200

nwrap: Add compatibility for musl-libc 1.1

The major difference is that getpwent_r and getgrent_r do not exist in
musl-libc. Hence it is sufficient to compile the wrappers for those only
conditionally.

Tested with musl-libc 1.1.15-r5 on Alpine Linux 3.5. Also confirmed to
not break with GNU libc 2.24-8 on Debian "Stretch" / 9.

Signed-Off-By: Dennis Schridde 
Reviewed-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit bba5eecf377b2617dfa25f78bcc11a240c3f5266
Author: Andreas Schneider 
Date:   Wed May 31 15:25:30 2017 +0200

nwrap: Add a comment to the pthread_atfork() call

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

commit 2b80c4ce0be8a43fb6ea6abcd4f97105982e239a
Author: Andreas Schneider 
Date:   Mon Mar 27 16:23:08 2017 +0200

nwrap: Use a constructor to initialize pthread and nwrap

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

commit 52490af39c319a107fc04c99ee35ddd80a82ce67
Author: Andreas Schneider 
Date:   Mon Mar 27 16:22:45 2017 +0200

cmake: Check for contructor attribute support

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

commit 4b7e685ef79d3a993ac4da20b1cca328c9354ee8
Author: Andreas Schneider 
Date:   Mon Mar 27 16:38:53 2017 +0200

nwrap: Add NULL checks for destructor

If we call init early and leave early they are not filled.

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

---

Summary of changes:
 ConfigureChecks.cmake |  12 ++
 config.h.cmake|   1 +
 src/nss_wrapper.c | 115 +-
 tests/testsuite.c |  18 +---
 4 files changed, 102 insertions(+), 44 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 462b166..6f760e6 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -235,6 +235,18 @@ int main(void) {
 }" HAVE_ATTRIBUTE_PRINTF_FORMAT)
 
 check_c_source_compiles("
+void test_constructor_attribute(void) __attribute__ ((constructor));
+
+void test_constructor_attribute(void)
+{
+ return;
+}
+
+int main(void) {
+ return 0;
+}" HAVE_CONSTRUCTOR_ATTRIBUTE)
+
+check_c_source_compiles("
 void test_destructor_attribute(void) __attribute__ ((destructor));
 
 void test_destructor_attribute(void)
diff --git a/config.h.cmake b/config.h.cmake
index 75c92ed..b18dff2 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -93,6 +93,7 @@
 #cmakedefine HAVE_IPV6 1
 
 #cmakedefine HAVE_ATTRIBUTE_PRINTF_FORMAT 1
+#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
 
 /*** ENDIAN */
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 82581b1..70a5989 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -142,6 +142,12 @@ typedef nss_status_t NSS_STATUS;
 #define PRINTF_ATTRIBUTE(a,b)
 #endif /* HAVE_ATTRIBUTE_PRINTF_FORMAT */
 
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+#define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
+#else
+#define CONSTRUCTOR_ATTRIBUTE
+#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
+
 #ifdef HAVE_DESTRUCTOR_ATTRIBUTE
 #define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
 #else
@@ -292,11 +298,13 @@ struct nwrap_libc_fns 

[SCM] NSS Wrapper Repository - branch master updated

2017-05-04 Thread Andreas Schneider
The branch, master has been updated
   via  d66ce39 nss_wrapper: Use perl via "env"
  from  abbdf8d Bump version to 1.1.3

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


- Log -
commit d66ce3932c2461b9e892b34ed6180fcd28725de7
Author: Volker Lendecke 
Date:   Mon May 1 19:52:07 2017 +0200

nss_wrapper: Use perl via "env"

FreeBSD has perl under /usr/local/bin

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

---

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


Changeset truncated at 500 lines:

diff --git a/nss_wrapper.pl b/nss_wrapper.pl
index 48fa2c5..1171e80 100755
--- a/nss_wrapper.pl
+++ b/nss_wrapper.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 
 use strict;


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2016-03-19 Thread Jeremy Allison
The branch, master has been updated
   via  962cf22 nwrap: Use snprintf() instead of strcpy()
   via  79f1b29 tests: Add testing for BSD 'struct passwd' members
   via  7df4b1c nwrap: Support FreeBSD 'struct passwd' members
  from  03018f8 Bump version to 1.1.2

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


- Log -
commit 962cf22a01f07008bb80711f48afaafc9b3bc087
Author: Andreas Schneider 
Date:   Wed Mar 16 18:13:00 2016 +0100

nwrap: Use snprintf() instead of strcpy()

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

commit 79f1b29e5daafbb6e624bbee3700ce07e39f72fd
Author: Andreas Schneider 
Date:   Thu Jan 21 13:51:08 2016 +0100

tests: Add testing for BSD 'struct passwd' members

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

commit 7df4b1c2bcc2fc96d1203c6814472fe77c9c82a0
Author: Andreas Schneider 
Date:   Thu Jan 21 13:47:27 2016 +0100

nwrap: Support FreeBSD 'struct passwd' members

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

---

Summary of changes:
 ConfigureChecks.cmake |  3 +++
 config.h.cmake|  4 
 src/nss_wrapper.c | 34 --
 tests/testsuite.c | 12 
 4 files changed, 51 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 1b6ba01..462b166 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -191,6 +191,9 @@ check_prototype_definition(getnameinfo
 
 # STRUCT MEMBERS
 check_struct_has_member("struct sockaddr" sa_len "sys/socket.h netinet/in.h" 
HAVE_STRUCT_SOCKADDR_SA_LEN)
+check_struct_has_member("struct passwd" pw_class "pwd.h" 
HAVE_STRUCT_PASSWD_PW_CLASS)
+check_struct_has_member("struct passwd" pw_change "pwd.h" 
HAVE_STRUCT_PASSWD_PW_CHANGE)
+check_struct_has_member("struct passwd" pw_expire "pwd.h" 
HAVE_STRUCT_PASSWD_PW_EXPIRE)
 
 # IPV6
 check_c_source_compiles("
diff --git a/config.h.cmake b/config.h.cmake
index f00c2a4..75c92ed 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -86,6 +86,10 @@
 #cmakedefine HAVE_LINUX_GETNAMEINFO_UNSIGNED 1
 
 #cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1
+#cmakedefine HAVE_STRUCT_PASSWD_PW_CLASS 1
+#cmakedefine HAVE_STRUCT_PASSWD_PW_CHANGE 1
+#cmakedefine HAVE_STRUCT_PASSWD_PW_EXPIRE 1
+
 #cmakedefine HAVE_IPV6 1
 
 #cmakedefine HAVE_ATTRIBUTE_PRINTF_FORMAT 1
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index c4f1b33..82581b1 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -154,6 +154,14 @@ typedef nss_status_t NSS_STATUS;
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
 #endif
 
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+#ifndef discard_const_p
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+#endif
+
 #ifdef HAVE_IPV6
 #define NWRAP_INET_ADDRSTRLEN INET6_ADDRSTRLEN
 #else
@@ -1963,6 +1971,28 @@ static bool nwrap_pw_parse_line(struct nwrap_cache 
*nwrap, char *line)
 
NWRAP_LOG(NWRAP_LOG_TRACE, "gid[%u]\n", pw->pw_gid);
 
+#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
+   pw->pw_class = discard_const_p(char, "");
+
+   NWRAP_LOG(NWRAP_LOG_TRACE, "class[%s]", pw->pw_class);
+#endif /* HAVE_STRUCT_PASSWD_PW_CLASS */
+
+#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
+   pw->pw_change = 0;
+
+   NWRAP_LOG(NWRAP_LOG_TRACE,
+ "change[%lu]",
+ (unsigned long)pw->pw_change);
+#endif /* HAVE_STRUCT_PASSWD_PW_CHANGE */
+
+#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
+   pw->pw_expire = 0;
+
+   NWRAP_LOG(NWRAP_LOG_TRACE,
+ "expire[%lu]",
+ (unsigned long)pw->pw_expire);
+#endif /* HAVE_STRUCT_PASSWD_PW_EXPIRE */
+
/* gecos */
p = strchr(c, ':');
if (!p) {
@@ -5421,7 +5451,7 @@ static int nwrap_getnameinfo(const struct sockaddr *sa, 
socklen_t salen,
if (he != NULL && he->h_name != NULL) {
if (strlen(he->h_name) >= hostlen)
return EAI_OVERFLOW;
-   strcpy(host, he->h_name);
+   snprintf(host, hostlen, "%s", he->h_name);
if (flags & NI_NOFQDN)
host[strcspn(host, ".")] = '\0';
} else {
@@ -5439,7 +5469,7 @@ static int nwrap_getnameinfo(const struct sockaddr *sa, 
socklen_t salen,
if (service != NULL) {
if (strlen(service->s_name) >= servlen)
return EAI_OVERFLOW;
-   strcpy(serv, service->s_name);
+   snprintf(serv, servlen, 

[SCM] NSS Wrapper Repository - branch master updated

2016-03-19 Thread Andreas Schneider
The branch, master has been updated
   via  abbdf8d Bump version to 1.1.3
  from  962cf22 nwrap: Use snprintf() instead of strcpy()

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


- Log -
commit abbdf8d9dc965e898141b96c33f21703289855e2
Author: Andreas Schneider 
Date:   Fri Mar 18 11:58:13 2016 +0100

Bump version to 1.1.3

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

---

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 8b352cb..5d34dd0 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 "2")
+set(APPLICATION_VERSION_PATCH "3")
 
 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.2.2")
+set(LIBRARY_VERSION "0.2.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 8d55fc3..959f0f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.1.3 (released 2015-03-18)
+  * Added support for BSD 'struct passwd' members
+  * Replaced strcpy() with snprintf()
+
 version 1.1.2 (released 2015-12-17)
   * Fixed segfault while reloading hosts file
   * Fixed issue where are not fault tolerant if an alias has already


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-12-17 Thread Michael Adam
The branch, master has been updated
   via  03018f8 Bump version to 1.1.2
   via  a93a07d tests: Add reload test for the hosts file
   via  6406714 nwrap: Fix segfaults while reloading hosts file
  from  581a412 tests: Add the same alias again

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


- Log -
commit 03018f8b035cd2b627298cf47290f2563f821e76
Author: Andreas Schneider 
Date:   Thu Dec 17 09:00:30 2015 +0100

Bump version to 1.1.2

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

commit a93a07d5e122b50dcec2e8fe7dbee022e5d5d301
Author: Andreas Schneider 
Date:   Thu Dec 17 08:56:05 2015 +0100

tests: Add reload test for the hosts file

With this valgrind should show issues if the hash table is not
recreated.

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

commit 64067145b4e013d4223bf17011984988bddbe43e
Author: Andreas Schneider 
Date:   Thu Dec 17 08:46:33 2015 +0100

nwrap: Fix segfaults while reloading hosts file

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

---

Summary of changes:
 CMakeLists.txt   |  4 ++--
 ChangeLog|  5 +
 src/nss_wrapper.c| 13 
 tests/test_getaddrinfo.c | 51 
 4 files changed, 71 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1ed061..8b352cb 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 "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.2.1")
+set(LIBRARY_VERSION "0.2.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 139d4fa..8d55fc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.2 (released 2015-12-17)
+  * Fixed segfault while reloading hosts file
+  * Fixed issue where are not fault tolerant if an alias has already
+been added
+
 version 1.1.1 (released 2015-11-23)
   * Fixed nss_wrapper build on Solaris
 
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index f48b9cc..c4f1b33 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -2890,6 +2890,7 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap)
struct nwrap_entdata *ed;
struct nwrap_entlist *el;
size_t i;
+   int rc;
 
nwrap_vector_foreach (ed, nwrap_he->entries, i)
{
@@ -2915,6 +2916,18 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap)
 
nwrap_he->num = 0;
nwrap_he->idx = 0;
+
+   /*
+* If we unload the file, the pointers in the hash table point to
+* invalid memory. So we need to destroy the hash table and recreate
+* it.
+*/
+   hdestroy();
+   rc = hcreate(max_hostents);
+   if (rc == 0) {
+   NWRAP_LOG(NWRAP_LOG_ERROR, "Failed to initialize hash table");
+   exit(-1);
+   }
 }
 
 
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index b200275..438ea12 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -5,8 +5,10 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -83,6 +85,54 @@ static void test_nwrap_getaddrinfo(void **state)
freeaddrinfo(res);
 }
 
+/*
+ * The purpose of this test is to verify that reloading of the hosts
+ * file (triggered by a timestamp change) correctly frees and re-creates
+ * the internal data structures, so we do not end up using invalid memory.
+ */
+static void test_nwrap_getaddrinfo_reload(void **state)
+{
+   struct addrinfo hints;
+   struct addrinfo *res = NULL;
+   const char *env;
+   char touch_cmd[1024];
+   int rc;
+
+   (void) state; /* unused */
+
+   /* IPv4 */
+   memset(, 0, sizeof(struct addrinfo));
+   hints.ai_family = AF_UNSPEC;/* Allow IPv4 or IPv6 */
+   hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
+   hints.ai_flags = AI_PASSIVE;/* For wildcard IP address */
+   hints.ai_protocol = 0;  /* Any protocol 

[SCM] NSS Wrapper Repository - branch master updated

2015-11-24 Thread Michael Adam
The branch, master has been updated
   via  581a412 tests: Add the same alias again
   via  604a7ae nwrap: Don't fail if we want to add an existing entry
  from  0b3d6ec Bump version to 1.1.1

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


- Log -
commit 581a4123d0aff4349814c6d1f7504390ffcb9429
Author: Andreas Schneider 
Date:   Tue Nov 24 17:33:49 2015 +0100

tests: Add the same alias again

We should be fault tolerant here.

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

commit 604a7ae8cf438d428e25841c729a73d50ed86cff
Author: Andreas Schneider 
Date:   Tue Nov 24 17:32:47 2015 +0100

nwrap: Don't fail if we want to add an existing entry

Pair-Programmed-With: Michael Adam 
Signed-off-by: Andreas Schneider 
Signed-off-by: Michael Adam 

---

Summary of changes:
 src/nss_wrapper.c | 6 --
 tests/hosts.in| 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index a080b80..f48b9cc 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -2622,12 +2622,14 @@ static bool nwrap_ed_inventarize_add_to_existing(struct 
nwrap_entdata *const ed,
for (cursor = el; cursor->next != NULL; cursor = cursor->next)
{
if (cursor->ed == ed) {
-   return false;
+   /* The entry already exists in this list. */
+   return true;
}
}
 
if (cursor->ed == ed) {
-   return false;
+   /* The entry already exists in this list. */
+   return true;
}
 
el_new = nwrap_entlist_init(ed);
diff --git a/tests/hosts.in b/tests/hosts.in
index 0d97bbc..9f767c3 100644
--- a/tests/hosts.in
+++ b/tests/hosts.in
@@ -5,7 +5,7 @@
 ::13beteigeuze.galaxy.site beteigeuze mail   
 127.0.0.14 krikkit.galaxy.site
 ::14 krikkit.galaxy.site
-127.1.1.1  pumpkin.bunny.net
+127.1.1.1  pumpkin.bunny.net pumpkin.bunny.net
 127.0.0.66 pumpkin.bunny.net
 2666::22   pumpkin.bunny.net
 DEAD:BEEF:1:2:3::4 pumpkin.bunny.net


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-24 Thread Andreas Schneider
The branch, master has been updated
   via  0b3d6ec Bump version to 1.1.1
   via  bac7fd1 nwrap: Fix the build on Solaris
  from  1d3b2fb Bump version to 1.1.0

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


- Log -
commit 0b3d6ec4a058292293cc0118c1acf86ae4d72871
Author: Andreas Schneider 
Date:   Mon Nov 23 08:34:13 2015 +0100

Bump version to 1.1.1

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

commit bac7fd164f0a6e4c76d4366ecd5e34bff117c5dc
Author: Andreas Schneider 
Date:   Mon Nov 23 08:33:02 2015 +0100

nwrap: Fix the build on Solaris

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

---

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


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2fd3d2..a1ed061 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.2.0")
+set(LIBRARY_VERSION "0.2.1")
 set(LIBRARY_SOVERSION "0")
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 631a7a5..139d4fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 ChangeLog
 ==
 
+version 1.1.1 (released 2015-11-23)
+  * Fixed nss_wrapper build on Solaris
+
 version 1.1.0 (released 2015-11-20)
   * Added support for initgroups()
   * Added support for shadow files (getspnam(), etc.)
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index be977df..a080b80 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -5578,7 +5578,9 @@ void nwrap_destructor(void)
}
 
free(user_addrlist.items);
+#ifdef HAVE_GETHOSTBYNAME2
free(user_addrlist2.items);
+#endif
 
hdestroy();
NWRAP_UNLOCK_ALL;


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-20 Thread Michael Adam
The branch, master has been updated
   via  75a22b4 tests: add __sha512_crypt to suppression file.
   via  bfd11d7 tests: Set the valgrind suppression file
   via  50101ce tests: Add valgrind suppression for glibc error
  from  23a7a85 nwrap: Don't leak memory from gethostbyname*() functions

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


- Log -
commit 75a22b46dc995baa4f9f362e4113ef86f4d605d6
Author: Michael Adam 
Date:   Fri Nov 20 10:51:11 2015 +0100

tests: add __sha512_crypt to suppression file.

While the manpage crypt(3) states that the function
returns a pointer to static memory, this does not
seem to be true for the __sha512 variant.

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

commit bfd11d7a1511a678539597905c2fce2ab033aa4c
Author: Andreas Schneider 
Date:   Fri Nov 20 09:59:58 2015 +0100

tests: Set the valgrind suppression file

You can run 'make ExperimentalMemcheck' with valgrind suppression now.

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

commit 50101ce09b125892456085ea69cd4cc55ea2691c
Author: Andreas Schneider 
Date:   Fri Nov 20 09:22:36 2015 +0100

tests: Add valgrind suppression for glibc error

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

---

Summary of changes:
 CMakeLists.txt  |  9 +
 tests/valgrind.supp | 24 
 2 files changed, 33 insertions(+)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f73a46c..c23802e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,6 +58,15 @@ install(
 
 if (UNIT_TESTING)
 find_package(CMocka REQUIRED)
+
+file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/tests/valgrind.supp" 
VALGRIND_SUPPRESSION_FILE)
+# add the valgrind suppressions
+set(MEMORYCHECK_SUPPRESSIONS_FILE
+${VALGRIND_SUPPRESSION_FILE}
+CACHE
+FILEPATH
+"Path to the memory checking command, used for memory error 
detection.")
+
 include(AddCMockaTest)
 add_subdirectory(tests)
 endif (UNIT_TESTING)
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
index 95c980b..aac3f28 100644
--- a/tests/valgrind.supp
+++ b/tests/valgrind.supp
@@ -13,3 +13,27 @@
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
 }
+
+{
+   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
+}
+
+{
+   glibc___sha512_crypt_alloc
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:__sha512_crypt
+}


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-20 Thread Andreas Schneider
The branch, master has been updated
   via  1d3b2fb Bump version to 1.1.0
  from  75a22b4 tests: add __sha512_crypt to suppression file.

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


- Log -
commit 1d3b2fba61caae0eba8bbfd59979a442f9a96514
Author: Andreas Schneider 
Date:   Fri Nov 20 10:13:09 2015 +0100

Bump version to 1.1.0

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

---

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


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c23802e..c2fd3d2 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 "3")
+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.1.0")
+set(LIBRARY_VERSION "0.2.0")
 set(LIBRARY_SOVERSION "0")
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 2d25383..631a7a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
 ChangeLog
 ==
 
+version 1.1.0 (released 2015-11-20)
+  * Added support for initgroups()
+  * Added support for shadow files (getspnam(), etc.)
+  * Improved support for multi address handling in getaddrinfo()
+  * Improved file parser
+  * Fixed compilation on machines without IPv4 support
+  * Fixed service string sanity check in getaddrinfo() (bso #11501)
+  * Fixed AI_NUMERICHOST handling in getaddrinfo() (bso # 11477)
+
 version 1.0.3 (released 2014-09-11)
   * Added a nss_wrapper manpage.
   * Fixed cmake find_package configs.


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-20 Thread Michael Adam
The branch, master has been updated
   via  23a7a85 nwrap: Don't leak memory from gethostbyname*() functions
  from  3ddf857 nwrap: Fix the build on FreeBSD

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


- Log -
commit 23a7a85a7688f1c6948db55eacb1101ba808d6db
Author: Andreas Schneider 
Date:   Fri Nov 20 09:38:16 2015 +0100

nwrap: Don't leak memory from gethostbyname*() functions

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

---

Summary of changes:
 src/nss_wrapper.c | 3 +++
 1 file changed, 3 insertions(+)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index a8c97e1..be977df 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -5577,6 +5577,9 @@ void nwrap_destructor(void)
nwrap_he_global.num = 0;
}
 
+   free(user_addrlist.items);
+   free(user_addrlist2.items);
+
hdestroy();
NWRAP_UNLOCK_ALL;
 }


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-20 Thread Michael Adam
The branch, master has been updated
   via  3ddf857 nwrap: Fix the build on FreeBSD
   via  b2ae3be nwrap: fix a copy and paste error in the destructor.
  from  18c1d17 nwrap: Cleanup shadow  getspnam() memory

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


- Log -
commit 3ddf8573866601088be02df44f0b04300b502058
Author: Andreas Schneider 
Date:   Fri Nov 20 08:51:49 2015 +0100

nwrap: Fix the build on FreeBSD

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

commit b2ae3be3ebfece9d59df6f9f945ecff6fb05c586
Author: Michael Adam 
Date:   Fri Nov 20 09:01:01 2015 +0100

nwrap: fix a copy and paste error in the destructor.

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

---

Summary of changes:
 src/nss_wrapper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 914cd26..a8c97e1 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -5551,6 +5551,7 @@ void nwrap_destructor(void)
nwrap_pw_global.num = 0;
}
 
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
if (nwrap_sp_global.cache != NULL) {
struct nwrap_cache *c = nwrap_sp_global.cache;
 
@@ -5560,8 +5561,9 @@ void nwrap_destructor(void)
c->fd = -1;
}
 
-   nwrap_he_global.num = 0;
+   nwrap_sp_global.num = 0;
}
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
 
if (nwrap_he_global.cache != NULL) {
struct nwrap_cache *c = nwrap_he_global.cache;


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-19 Thread Andreas Schneider
The branch, master has been updated
   via  18c1d17 nwrap: Cleanup shadow  getspnam() memory
   via  17a4fa5 nwrap: fix leaking the entlists
   via  aa5aa9e nwrap: catch error to add item to vector in 
nwrap_he_parse_line()
   via  1797373 nwrap: rename nwrap_he.entdata to nwrap_he.entries
   via  21c10b8 nwrap: remove unused member list from struct nwrap_he
   via  57b7b9d nwrap: Small code shift in 
nwrap_ed_inventarize_add_to_existing()
   via  72ecc23 tests: Fix memory leaks in getaddrinfo test
  from  174f7a1 nwrap: Cast max_hostents to avoid warnings

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


- Log -
commit 18c1d1723a7364419eb6f2cb8de1238848f68f16
Author: Andreas Schneider 
Date:   Thu Nov 19 09:02:46 2015 +0100

nwrap: Cleanup shadow  getspnam() memory

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

commit 17a4fa5d1ec7b79eea7da2967fe3a48aaa63a12c
Author: Michael Adam 
Date:   Thu Nov 19 01:00:16 2015 +0100

nwrap: fix leaking the entlists

Track the list heads in a vector in the newrap_he_global
struct and free the structures upon nwrap_he_unload.

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

commit aa5aa9e8eed87b52ac1a85698d587c1e0ecd7a19
Author: Michael Adam 
Date:   Thu Nov 19 00:34:54 2015 +0100

nwrap: catch error to add item to vector in nwrap_he_parse_line()

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

commit 1797373faeee0bdc60bc02ad75179bc3837f7269
Author: Michael Adam 
Date:   Thu Nov 19 00:30:17 2015 +0100

nwrap: rename nwrap_he.entdata to nwrap_he.entries

That's what is is the list of entries. In the guise
nwrap_entdata structures but the code reads more
naturally this way.

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

commit 21c10b80fa9bca3806426720c19937795f01a829
Author: Michael Adam 
Date:   Thu Nov 19 00:24:14 2015 +0100

nwrap: remove unused member list from struct nwrap_he

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

commit 57b7b9d14cbdc258c6123334d6ff93931b675283
Author: Robin Hack 
Date:   Mon Nov 16 23:38:51 2015 +0100

nwrap: Small code shift in nwrap_ed_inventarize_add_to_existing()

Allocate memory only when necessary.

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

commit 72ecc23042859c0626943afff4901b5b9dcb6316
Author: Andreas Schneider 
Date:   Mon Nov 16 20:43:00 2015 +0100

tests: Fix memory leaks in getaddrinfo test

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

---

Summary of changes:
 src/nss_wrapper.c| 75 +---
 tests/test_getaddrinfo.c | 12 
 2 files changed, 71 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index a8cbc22..914cd26 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -770,8 +770,8 @@ struct nwrap_entlist {
 struct nwrap_he {
struct nwrap_cache *cache;
 
-   struct nwrap_entdata *list;
-   struct nwrap_vector entdata;
+   struct nwrap_vector entries;
+   struct nwrap_vector lists;
 
int num;
int idx;
@@ -2576,6 +2576,7 @@ static bool nwrap_ed_inventarize_add_new(char *const 
h_name,
ENTRY e;
ENTRY *p;
struct nwrap_entlist *el;
+   bool ok;
 
if (h_name == NULL) {
NWRAP_LOG(NWRAP_LOG_ERROR, "h_name NULL - can't add");
@@ -2596,6 +2597,13 @@ static bool nwrap_ed_inventarize_add_new(char *const 
h_name,
return false;
}
 
+   ok = nwrap_vector_add_item(&(nwrap_he_global.lists), (void *)el);
+   if (!ok) {
+   NWRAP_LOG(NWRAP_LOG_ERROR,
+ "Failed to add list entry to vector.");
+   return false;
+   }
+
return true;
 }
 
@@ -2610,21 +2618,20 @@ static bool nwrap_ed_inventarize_add_to_existing(struct 
nwrap_entdata *const ed,
return false;
}
 
-   el_new = nwrap_entlist_init(ed);
-   if (el_new == NULL) {
-   return false;
-   }
 
for (cursor = el; cursor->next != NULL; cursor = cursor->next)
{
if (cursor->ed == ed) {
-   free(el_new);
return false;
}
}
 
 

[SCM] NSS Wrapper Repository - branch master updated

2015-11-16 Thread Andreas Schneider
The branch, master has been updated
   via  174f7a1 nwrap: Cast max_hostents to avoid warnings
   via  451a4d7 nwrap: Fix initialization of e entry
   via  6e74b6d tests: Silence compiler warnings about uninitialized 
variables
   via  48a952b tests: Fix getaddrinfo test on BSD
  from  0f089bd add me to AUTHORS

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


- Log -
commit 174f7a1341a015eec18cd70c9e4a9b15d0dc9e99
Author: Andreas Schneider 
Date:   Mon Nov 16 10:19:27 2015 +0100

nwrap: Cast max_hostents to avoid warnings

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

commit 451a4d7c33778bb8200b9cbd1775eee1bda96527
Author: Andreas Schneider 
Date:   Mon Nov 16 10:17:39 2015 +0100

nwrap: Fix initialization of e entry

This fixes a compiler warning.

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

commit 6e74b6d87f9273ffe3a30ea3414c4ee3765108c5
Author: Andreas Schneider 
Date:   Mon Nov 16 10:15:06 2015 +0100

tests: Silence compiler warnings about uninitialized variables

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

commit 48a952b09f1eee5604d9ec666b49a7bc062b4ab2
Author: Andreas Schneider 
Date:   Mon Nov 16 10:12:03 2015 +0100

tests: Fix getaddrinfo test on BSD

EAI_ADDRFAMILY is a GNU extension. EAI_FAMILY is the return value on
BSD.

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

---

Summary of changes:
 src/nss_wrapper.c|  9 ++---
 tests/test_getaddrinfo.c | 12 ++--
 2 files changed, 16 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 9a7fbf5..a8cbc22 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -1566,14 +1566,15 @@ static void nwrap_init(void)
  "Error parsing NSS_WRAPPER_MAX_HOSTENTS "
  "value or value is too small. "
  "Using default value: %lu.",
- max_hostents);
+ (unsigned long)max_hostents);
} else {
max_hostents = max_hostents_tmp;
}
}
/* Initialize hash table */
NWRAP_LOG(NWRAP_LOG_DEBUG,
- "Initializing hash table of size %lu items.", max_hostents);
+ "Initializing hash table of size %lu items.",
+ (unsigned long)max_hostents);
if (hcreate(max_hostents) == 0) {
NWRAP_LOG(NWRAP_LOG_ERROR,
  "Failed to initialize hash table");
@@ -3518,7 +3519,9 @@ static int nwrap_files_getaddrinfo(const char *name,
size_t name_len;
char canon_name[DNS_NAME_MAX] = { 0 };
bool skip_canonname = false;
-   ENTRY e = { 0 };
+   ENTRY e = {
+   .key = NULL,
+   };
ENTRY *e_p = NULL;
int rc;
bool ok;
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index 01ae3d8..ea3e995 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -442,8 +442,8 @@ static void test_nwrap_getaddrinfo_multiple_mixed(void 
**state)
struct sockaddr_in *r_addr;
struct sockaddr_in6 *r_addr6;
 
-   const char *result;
-   const char *value;
+   const char *result = NULL;
+   const char *value = NULL;
 
/* For inet_ntop call */
char buf[4096];
@@ -595,7 +595,11 @@ static void 
test_nwrap_getaddrinfo_flags_ai_numerichost(void **state)
freeaddrinfo(res);
 
rc = getaddrinfo("::1", NULL, , );
+#ifdef EAI_ADDRFAMILY
assert_int_equal(rc, EAI_ADDRFAMILY);
+#else
+   assert_int_equal(rc, EAI_FAMILY);
+#endif
 
rc = getaddrinfo(NULL, "echo", , );
assert_int_equal(rc, 0);
@@ -616,7 +620,11 @@ static void 
test_nwrap_getaddrinfo_flags_ai_numerichost(void **state)
hints.ai_family = AF_INET6;
 
rc = getaddrinfo("127.0.0.11", NULL, , );
+#ifdef EAI_ADDRFAMILY
assert_int_equal(rc, EAI_ADDRFAMILY);
+#else
+   assert_int_equal(rc, EAI_FAMILY);
+#endif
 
rc = getaddrinfo("::1", NULL, , );
assert_int_equal(rc, 0);


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-11-13 Thread Andreas Schneider
The branch, master has been updated
   via  0f089bd add me to AUTHORS
   via  b07f05e tests: Add test to exercise internal data structures
   via  8c56086 test: add test for AI_NUMERICHOST flag.
   via  72c297c nwrap: remove ai_tail argument from 
nwrap_files_getaddrinfo()
   via  0b13b02 nwrap: rewrite the loop for duplication ai entries if 
socktype not given
   via  fbcdbed nwrap: add an explaining comment for the ai duplicating loop
   via  ac10582 nwrap: move setting of ai_{flags|socktype|protocol} into 
nwrap_convert_he_ai
   via  b6839a8 nwrap: use symbols IPPROTO_TCP and IPPROTO_UDP
   via  fb0a4cc nwrap: rename _ai -> ai_new in nwrap_files_getaddrinfo()
   via  645693a nwrap: fix a memleak in nwrap_files_getaddrinfo()
   via  84fb3ab nwrap: rename ai_prev -> ai_cur in nwrap_files_getaddrinfo()
   via  f8d4121 nwrap: Fix inventarization of IPs when loading hosts
   via  ce496c3 nwrap: refactor nwrap_add_hname_* into one 
nwrap_ed_inventarize.
   via  cab46be nwrap: treat AI_NUMERICHOST correctly in getaddrinfo.
   via  c1ce7c0 nwrap: fix treatment of EAI_ADDRINFO in 
nwrap_files_getaddrinfo
   via  deb7ea5 nwrap: correctly track EAI_ADDRINFO in 
nwrap_files_getaddrinfo
   via  99f1ca6 nwrap: in nwrap_files_getaddrinfo, treat failure of 
nwrap_convert_he_ai as error
   via  5b4976c nwrap: convert nwrap_files_getaddrinfo() to return EAI 
error codes
   via  90c6576 nwrap: use the error code from nwrap_files_cache_reload() 
in callers
   via  f3f0939 nwrap: turn nwrap_files_cache_reload() into a bool function
   via  4b5994b nwrap: better error propagation in nwrap_he_parse_line()
   via  77fa29c nwrap: log NULL alias name at ERROR level in 
nwrap_add_hname()
   via  25e541a nwrap: better error propagation in nwrap_add_hname()
   via  1ce486b nwrap: better error propagation in nwrap_add_hname_alias
   via  1363e12 nwrap: catch NULL list in nwrap_add_hname_add_to_existing
   via  56a9c4f nwrap: catch null h_name in nwrap_add_hname_add_new
   via  1dd94e3 nwrap: catch NULL ip in nwrap_add_ai
   via  d42cea9 nwrap: turn nwrap_add_hname_add_to_existing() into bool
   via  d3784fb tests: fix test_nwrap_gethostbyname2 - magrathea now has an 
IPv6 address
   via  2edebd0 nwrap: simplify nwrap_file_getaddrinfo: remove a variable
   via  88c70a1 nwrap: simplify nwrap_files_gethostbyname: remove a variable
   via  479fa87 nwrap: log hash table full message at error level
   via  e284e1d nwrap: rewrite linked-list datastructures to be properly 
separated.
   via  5df5236 nwrap: remove superfluous comments from nwrap_add_hname()
   via  d365a90 nwrap: remove superfluous comments from 
nwrap_add_hname_alias()
   via  dba9c6f nwrap: remove a superfluous comment from 
nwrap_add_hname_add_new()
   via  c049e77 nwrap: move var into scope in nwrap_add_hname()
   via  08f3fdd nwrap: simplify nwrap_add_hname
   via  cec9fce nwrap: simplify nwrap_add_hname_alias
   via  2bcac5e nwrap: initialize some variables in nwrap_files_getaddrinfo
   via  01b9087 nwrap: slightly clean flow by removing an else branch in 
nwrap_getaddrinfo
   via  cd517c7 nwrap: in nwrap_getaddrinfo, only call libc_getaddrinfo if 
we need it.
   via  fb13b6b nwrap: slightly simplify logic in nwrap_getaddrinfo()
   via  ef06bed nwrap: simplify logic in nwrap_getaddrinfo, calling 
nwrap_files_getaddrinfo
   via  3d59f93 nwrap: improve code readability in nwrap_getaddrinfo()
   via  a24369b nwrap: remove code duplication in nwrap_getaddrinfo
   via  ae1d150 tests: extend getaddrinfo_flags_ai_numericserv test to 
cover nwrap
   via  8363415 tests: fix the getaddrinfo_service test.
   via  4293eb2 nwrap: fix return code for getaddrinfo in case service is 
not valid
   via  f394978 nwrap: fix return code of getaddrinfo for AI_NUMERICSERV in 
error case
   via  64da7b7 nwrap: fix numeric port detection in nwrap_getaddrinfo
   via  969f2d4 tests: Added new test: 
test_nwrap_getaddrinfo_flags_ai_numericserv
  from  b10d23b nwrap: Better check service string sanity.

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


- Log -
commit 0f089bd55bf127db8f6a6036eba3ae27b1c9d2d5
Author: Michael Adam 
Date:   Thu Nov 12 11:55:49 2015 +0100

add me to AUTHORS

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

commit b07f05ebc1b60512a8adf836d7f6e76e99776bf6
Author: Robin Hack 
Date:   Mon Nov 2 13:48:47 2015 +0100

tests: Add test to exercise internal data structures

This uses a big hosts file from samba to avoid regressions in Samba.

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

commit 

[SCM] NSS Wrapper Repository - branch master updated

2015-11-06 Thread Michael Adam
The branch, master has been updated
   via  b10d23b nwrap: Better check service string sanity.
   via  db42fc7 nwrap: Fix memory leak in nwrap_gethostbyname_r()
   via  7cc2b35 nwrap: Fix memory leak in nwrap_files_gethostbyname()
  from  dcc2c37 nwrap: Fix memory leak in nwrap_he_unload()

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


- Log -
commit b10d23be266109e2569b4f814d554fc2b706a2a3
Author: Robin Hack 
Date:   Tue Oct 13 14:41:14 2015 +0200

nwrap: Better check service string sanity.

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

Patch use strtol() instead of atoi() to convert strings to numbers.
This helps better check sanity of service input string.

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

commit db42fc7286ed2de4b9a3d14ce76ebd55ac5c5d48
Author: Robin Hack 
Date:   Mon Oct 12 10:36:04 2015 +0200

nwrap: Fix memory leak in nwrap_gethostbyname_r()

Fix reimplements how memory is used.
Results from vector are copied to user provided buf.

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

commit 7cc2b350274a2fbad6aee25fd0374827e34f3a1d
Author: Robin Hack 
Date:   Thu Oct 8 15:27:47 2015 +0200

nwrap: Fix memory leak in nwrap_files_gethostbyname()

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

---

Summary of changes:
 src/nss_wrapper.c | 79 ++-
 1 file changed, 55 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 3496162..21fc108 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -604,6 +604,8 @@ struct nwrap_vector {
 item != NULL; \
 (item) = (vect).items[++iter])
 
+#define nwrap_vector_is_initialized(vector) ((vector)->items != NULL)
+
 static inline bool nwrap_vector_init(struct nwrap_vector *const vector)
 {
if (vector == NULL) {
@@ -3323,10 +3325,16 @@ static int nwrap_files_gethostbyname(const char *name, 
int af,
SAFE_FREE(h_name_lower);
 
/* Always cleanup vector and results */
-   if (!nwrap_vector_init(addr_list)) {
-   NWRAP_LOG(NWRAP_LOG_DEBUG,
- "Unable to initialize memory for addr_list vector");
-   goto no_ent;
+   if (!nwrap_vector_is_initialized(addr_list)) {
+   if (!nwrap_vector_init(addr_list)) {
+   NWRAP_LOG(NWRAP_LOG_DEBUG,
+ "Unable to initialize memory for addr_list 
vector");
+   goto no_ent;
+   }
+   } else {
+   /* When vector is initialized data are valid no more.
+* Quick way how to free vector is: */
+   addr_list->count = 0;
}
 
/* Iterate through results */
@@ -3398,7 +3406,21 @@ static int nwrap_gethostbyname_r(const char *name,
return -1;
}
 
-   memset(buf, '\0', buflen);
+   if (buflen < (addr_list->count * sizeof(void *))) {
+   SAFE_FREE(addr_list->items);
+   SAFE_FREE(addr_list);
+   return ERANGE;
+   }
+
+   /* Copy all to user provided buffer and change
+* pointers in returned structure.
+* +1 is for ending NULL pointer. */
+   memcpy(buf, addr_list->items, (addr_list->count + 1) * sizeof(void *));
+
+   free(addr_list->items);
+   free(addr_list);
+
+   ret->h_addr_list = (char **)buf;
*result = ret;
return 0;
 }
@@ -5055,33 +5077,42 @@ static int nwrap_getaddrinfo(const char *node,
}
 
if (service != NULL && service[0] != '\0') {
-   if (isdigit((int)service[0])) {
-   port = (unsigned short)atoi(service);
-   } else {
-   const char *proto = NULL;
-   struct servent *s;
+   const char *proto = NULL;
+   struct servent *s;
+   char *end_ptr;
+   long sl;
 
-   if (hints->ai_protocol != 0) {
-   struct protoent *pent;
+   errno = 0;
+   sl = strtol(service, _ptr, 10);
 
-   pent = getprotobynumber(hints->ai_protocol);
-   if (pent != NULL) {
-   proto = pent->p_name;
-   }
+   if (*end_ptr 

[SCM] NSS Wrapper Repository - branch master updated

2015-11-05 Thread Michael Adam
The branch, master has been updated
   via  dcc2c37 nwrap: Fix memory leak in nwrap_he_unload()
   via  7a7bf7b nwrap: Rename cont to vector in nwrap_vector_add_item()
   via  c3a8b23 nwrap: Fix memory leak inside nwrap_getaddrinfo()
   via  c0d418c nwrap: Use nwrap_vector_foreach instead of for loop
   via  04fcf29 nwrap: Fix memory leak when getline() is used.
  from  99af0e0 tests: add test for merging with empty vectors left and 
right.

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


- Log -
commit dcc2c378276a9059336d521a4b8f8d1fa64d6368
Author: Robin Hack 
Date:   Thu Oct 8 15:00:33 2015 +0200

nwrap: Fix memory leak in nwrap_he_unload()

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

commit 7a7bf7bffa7daead410948b6c1e13a0cab3e5de8
Author: Robin Hack 
Date:   Thu Oct 8 14:09:11 2015 +0200

nwrap: Rename cont to vector in nwrap_vector_add_item()

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

commit c3a8b23e64ad641754e8c09fea407c4370703024
Author: Robin Hack 
Date:   Thu Oct 8 14:02:56 2015 +0200

nwrap: Fix memory leak inside nwrap_getaddrinfo()

Memory leak was introduced by deep copy code.
Item ai_tmp->ai_addr should not have deep copy.

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

commit c0d418ce0b3f494eb09d0d8aff8c965207b80411
Author: Robin Hack 
Date:   Thu Oct 8 14:00:38 2015 +0200

nwrap: Use nwrap_vector_foreach instead of for loop

Replace for loop by nwrap_vector_foreach in nwrap_lines_unload().

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

commit 04fcf2958abade59e4fb0fe5f8eb0f47cf6ff64b
Author: Robin Hack 
Date:   Thu Oct 8 11:36:33 2015 +0200

nwrap: Fix memory leak when getline() is used.

getline() allocates memory even if return code is < 0.

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

---

Summary of changes:
 src/nss_wrapper.c | 35 +++
 1 file changed, 19 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index bf51ec2..3496162 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -622,32 +622,32 @@ static inline bool nwrap_vector_init(struct nwrap_vector 
*const vector)
return true;
 }
 
-static bool nwrap_vector_add_item(struct nwrap_vector *cont, void *const item)
+static bool nwrap_vector_add_item(struct nwrap_vector *vector, void *const 
item)
 {
-   assert (cont != NULL);
+   assert (vector != NULL);
 
-   if (cont->items == NULL) {
-   nwrap_vector_init(cont);
+   if (vector->items == NULL) {
+   nwrap_vector_init(vector);
}
 
-   if (cont->count == cont->capacity) {
+   if (vector->count == vector->capacity) {
/* Items array _MUST_ be NULL terminated because it's passed
 * as result to caller which expect NULL terminated array from 
libc.
 */
-   void **items = realloc(cont->items, sizeof(void *) * 
((cont->capacity * 2) + 1));
+   void **items = realloc(vector->items, sizeof(void *) * 
((vector->capacity * 2) + 1));
if (items == NULL) {
return false;
}
-   cont->items = items;
+   vector->items = items;
 
/* Don't count ending NULL to capacity */
-   cont->capacity *= 2;
+   vector->capacity *= 2;
}
 
-   cont->items[cont->count] = item;
+   vector->items[vector->count] = item;
 
-   cont->count += 1;
-   cont->items[cont->count] = NULL;
+   vector->count += 1;
+   vector->items[vector->count] = NULL;
 
return true;
 }
@@ -928,12 +928,13 @@ static void *_nwrap_load_lib_function(enum nwrap_lib lib, 
const char *fn_name)
 static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
 {
size_t p;
-   for (p = 0; p < nwrap->lines.count; p++) {
+   void *item;
+   nwrap_vector_foreach(item, nwrap->lines, p) {
/* Maybe some vectors were merged ... */
-   SAFE_FREE(nwrap->lines.items[p]);
+   SAFE_FREE(item);
}

[SCM] NSS Wrapper Repository - branch master updated

2015-10-12 Thread Michael Adam
The branch, master has been updated
   via  99af0e0 tests: add test for merging with empty vectors left and 
right.
   via  f69f5e6 tests: improve nwrap_vector tests
  from  dff6144 tests: Add missing include for crypt.h in test_shadow

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


- Log -
commit 99af0e0df68f19522d87f0d27f68769ec3af7193
Author: Michael Adam 
Date:   Fri Oct 9 10:16:44 2015 +0200

tests: add test for merging with empty vectors left and right.

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

commit f69f5e625974175923d8dcfca1eb2e21ab3ddb6e
Author: Michael Adam 
Date:   Fri Oct 9 10:10:44 2015 +0200

tests: improve nwrap_vector tests

Improves ordering and adds some additional checks.

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

---

Summary of changes:
 tests/test_nwrap_vector.c | 64 +++
 1 file changed, 54 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_nwrap_vector.c b/tests/test_nwrap_vector.c
index 4e9f066..26baf01 100644
--- a/tests/test_nwrap_vector.c
+++ b/tests/test_nwrap_vector.c
@@ -21,19 +21,21 @@ static void test_nwrap_vector_basic_add(void **state)
nwrap_vector_add_item(, string);
assert_null(v.items[1]);
assert_int_equal(v.count, 1);
+   assert_string_equal(v.items[0], string);
assert_int_equal(v.capacity, DEFAULT_VECTOR_CAPACITY);
 
assert_string_equal(v.items[0], "string!");
 
nwrap_vector_add_item(, string2);
+   assert_null(v.items[2]);
+   assert_int_equal(v.count, 2);
assert_string_equal(v.items[0], string);
assert_string_equal(v.items[1], string2);
-   assert_null(v.items[2]);
 
free(v.items);
 }
 
-static void test_nwrap_vector_merge(void **state)
+static void test_nwrap_vector_merge_empty(void **state)
 {
struct nwrap_vector v1;
struct nwrap_vector v2;
@@ -44,24 +46,64 @@ static void test_nwrap_vector_merge(void **state)
 
nwrap_vector_init();
assert_non_null(v1.items);
+   assert_int_equal(v1.count, 0);
 
nwrap_vector_init();
assert_non_null(v2.items);
+   assert_int_equal(v2.count, 0);
+
+   nwrap_vector_merge(, );
+   assert_int_equal(v1.count, 0);
+   assert_null(v1.items[0]);
 
nwrap_vector_add_item(, string);
nwrap_vector_add_item(, string2);
+   assert_int_equal(v1.count, 2);
+
+   nwrap_vector_merge(, );
+   assert_int_equal(v1.count, 2);
+   assert_string_equal(v1.items[0], string);
+   assert_string_equal(v1.items[1], string2);
+   assert_null(v1.items[2]);
+
+   nwrap_vector_merge(, );
+   assert_int_equal(v2.count, 2);
+   assert_string_equal(v2.items[0], string);
+   assert_string_equal(v2.items[1], string2);
+   assert_null(v2.items[2]);
 
+   free(v1.items);
+   free(v2.items);
+}
+
+static void test_nwrap_vector_merge(void **state)
+{
+   struct nwrap_vector v1;
+   struct nwrap_vector v2;
+   char string[] = "string!";
+   char string2[] = "2string!";
+
+   (void) state; /* unused */
+
+   nwrap_vector_init();
+   assert_non_null(v1.items);
+   nwrap_vector_add_item(, string);
+   nwrap_vector_add_item(, string2);
+   assert_int_equal(v1.count, 2);
+
+   nwrap_vector_init();
+   assert_non_null(v2.items);
nwrap_vector_add_item(, string2);
nwrap_vector_add_item(, string);
+   assert_int_equal(v2.count, 2);
 
nwrap_vector_merge(, );
-
+   assert_int_equal(v1.count, 4);
assert_string_equal(v1.items[0], string);
assert_string_equal(v1.items[1], string2);
assert_string_equal(v1.items[2], string2);
assert_string_equal(v1.items[3], string);
assert_null(v1.items[4]);
-   assert_int_equal(v1.count, 4);
 
free(v1.items);
free(v2.items);
@@ -80,20 +122,21 @@ static void test_nwrap_vector_merge_max(void **state)
nwrap_vector_init();
assert_non_null(v1.items);
 
-   nwrap_vector_init();
-   assert_non_null(v2.items);
-
for (p = 0; p < 64; ++p) {
nwrap_vector_add_item(, string);
}
-   nwrap_vector_merge(, );
+   assert_int_equal(v1.count, 64);
+
+   nwrap_vector_init();
+   assert_non_null(v2.items);
 
+   nwrap_vector_merge(, );
+   assert_int_equal(v2.count, 64);
for (p = 0; p < 64; ++p) {
assert_string_equal(v2.items[p], string);
}
-   assert_int_equal(v2.count, 64);
-   nwrap_vector_add_item(, string2);
 
+   nwrap_vector_add_item(, string2);

[SCM] NSS Wrapper Repository - branch master updated

2015-10-08 Thread Michael Adam
The branch, master has been updated
   via  dff6144 tests: Add missing include for crypt.h in test_shadow
  from  4f751e2 nwrap: Modify AUTHORS file.

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


- Log -
commit dff6144df484168d27192e9a97ae43ce8136
Author: Andreas Schneider 
Date:   Thu Oct 8 11:42:42 2015 +0200

tests: Add missing include for crypt.h in test_shadow

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

---

Summary of changes:
 tests/test_shadow.c | 2 ++
 1 file changed, 2 insertions(+)


Changeset truncated at 500 lines:

diff --git a/tests/test_shadow.c b/tests/test_shadow.c
index 492fb32..7af120b 100644
--- a/tests/test_shadow.c
+++ b/tests/test_shadow.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 
+#include 
+
 static void test_nwrap_getspent(void **state)
 {
struct spwd *sp;


-- 
NSS Wrapper Repository



[SCM] NSS Wrapper Repository - branch master updated

2015-10-07 Thread Michael Adam
The branch, master has been updated
   via  4f751e2 nwrap: Modify AUTHORS file.
   via  3bf0d8f TESTS: Add new test which checks multithread support.
   via  5dc7e5d nwrap: Add basic locking for support multithreaded 
applications
   via  ffc262d TESTS: Add test for getaddrinfo.
   via  f839fb8 TESTS: Add test_nwrap_gethostbyname_multiple test
   via  c28adab nwrap: Add BSD libc support for gethost*_r functios.
   via  4c956bf nwrap: Use nwrap vectors as memory backend for 
getaddrinfo() and gethostbyname()
   via  f067a6e nwrap: Add string manipulation functions.
   via  8710061 nwrap: Add nwrap_add_hname() and nwrap_add_hname_alias().
   via  449f8d9 nwrap: Add function nwrap_add_ai
   via  0ff0c85 nwrap: Add a hash table to the nwrap structure
   via  6215857 nwrap: Simplify file loading.
   via  69efe68 nwrap: Add nwrap vector memory management functions
  from  827183d tests: Only run shadow test when shadow.h is available

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


- Log -
commit 4f751e256734082f3d4ae4b2dbf35d239840d694
Author: Robin Hack 
Date:   Mon Mar 30 16:08:25 2015 +0200

nwrap: Modify AUTHORS file.

Assign emails to authors.
Also add me (Robin Hack) as a author.

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

commit 3bf0d8f63d340a844f6c1510b6eebe35581982e5
Author: Robin Hack 
Date:   Tue Mar 24 16:45:19 2015 +0100

TESTS: Add new test which checks multithread support.

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

commit 5dc7e5dbf725718a34db3dce26cbb5aa67ee4efa
Author: Robin Hack 
Date:   Tue Mar 24 17:54:34 2015 +0100

nwrap: Add basic locking for support multithreaded applications

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

commit ffc262d08c16d98f67b0005145b1690ec0b9c4b5
Author: Robin Hack 
Date:   Mon Mar 30 14:36:29 2015 +0200

TESTS: Add test for getaddrinfo.

Test tries to get multiple and mixed (ipv4 and ipv6) records.

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

commit f839fb8fbd69c0d2614c92b7f852a735912d75bc
Author: Robin Hack 
Date:   Tue Mar 24 12:03:14 2015 +0100

TESTS: Add test_nwrap_gethostbyname_multiple test

Test cover multiple records support.

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

commit c28adabf78fa8a5f62b7782c5c650db6b8ef361f
Author: Robin Hack 
Date:   Fri Mar 27 15:51:11 2015 +0100

nwrap: Add BSD libc support for gethost*_r functios.

BSD libc stores data in thread local storage.

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

commit 4c956bf0c1e79862263ef848e15e0bd70bf72a9f
Author: Robin Hack 
Date:   Thu Jul 16 16:10:20 2015 +0200

nwrap: Use nwrap vectors as memory backend for getaddrinfo() and 
gethostbyname()

Previous patches introduced nwrap vectors and hash functions.
This patch will join all together.

Main purpose of this patch is:
- support more records per hostname.
  For example: hostname now can have associated IPv4 and IPv6 address.
- better handling of big number of hostname records

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

commit f067a6e867db3752592f21bba567fb14bfbc174d
Author: Robin Hack 
Date:   Tue Mar 24 15:14:35 2015 +0100

nwrap: Add string manipulation functions.

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

commit 8710061f0ad45b5956ff98312dbe39ea1984304c
Author: Robin Hack 
Date:   Wed Jul 15 15:05:28 2015 +0200

nwrap: Add nwrap_add_hname() and nwrap_add_hname_alias().

Functions adds a hostname or an alias to the hash table.

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

commit 449f8d9a414e35a3520ff0305661119193e794c8
Author: Robin Hack 
Date:   Wed Jul 15 

[SCM] NSS Wrapper Repository - branch master updated

2015-10-06 Thread Michael Adam
The branch, master has been updated
   via  827183d tests: Only run shadow test when shadow.h is available
   via  d2de6c7 nwrap: Check for setspent and getspnam functions
   via  03dc910 src: Add configure check for shadow.h
  from  0f179c8 tests: Add test for getspnam() function

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


- Log -
commit 827183dde440b3244e766fa680b874ecd4a628c5
Author: Andreas Schneider 
Date:   Tue Oct 6 10:53:00 2015 +0200

tests: Only run shadow test when shadow.h is available

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

commit d2de6c71699c0a2700b2829d296136f619e333eb
Author: Andreas Schneider 
Date:   Tue Oct 6 10:34:20 2015 +0200

nwrap: Check for setspent and getspnam functions

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

commit 03dc910bd3c21b34021a6e0836faa2412eb5ea0e
Author: Andreas Schneider 
Date:   Tue Oct 6 10:19:48 2015 +0200

src: Add configure check for shadow.h

This is the first part to fix FreeBSD.

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

---

Summary of changes:
 ConfigureChecks.cmake |  4 
 config.h.cmake|  7 +++
 src/nss_wrapper.c | 22 ++
 tests/CMakeLists.txt  | 13 +
 4 files changed, 42 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index b74ed8d..1b6ba01 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -49,6 +49,7 @@ endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW AND NOT OS2)
 # HEADERS
 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
 check_include_file(pwd.h HAVE_PWD_H)
+check_include_file(shadow.h HAVE_SHADOW_H)
 check_include_file(grp.h HAVE_GRP_H)
 check_include_file(nss.h HAVE_NSS_H)
 check_include_file(nss_common.h HAVE_NSS_COMMON_H)
@@ -62,6 +63,9 @@ check_function_exists(getpwnam_r HAVE_GETPWNAM_R)
 check_function_exists(getpwuid_r HAVE_GETPWUID_R)
 check_function_exists(getpwent_r HAVE_GETPWENT_R)
 
+check_function_exists(setspent HAVE_SETSPENT)
+check_function_exists(getspnam HAVE_GETSPNAM)
+
 check_function_exists(getgrnam_r HAVE_GETGRNAM_R)
 check_function_exists(getgrgid_r HAVE_GETGRGID_R)
 check_function_exists(getgrent_r HAVE_GETGRENT_R)
diff --git a/config.h.cmake b/config.h.cmake
index b94b621..f00c2a4 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -16,6 +16,7 @@
 
 #cmakedefine HAVE_SYS_TYPES_H 1
 #cmakedefine HAVE_PWD_H 1
+#cmakedefine HAVE_SHADOW_H 1
 #cmakedefine HAVE_GRP_H 1
 #cmakedefine HAVE_NSS_H 1
 #cmakedefine HAVE_NSS_COMMON_H 1
@@ -31,6 +32,12 @@
 /* Define to 1 if you have the `getpwent_r' function. */
 #cmakedefine HAVE_GETPWENT_R 1
 
+/* Define to 1 if you have the `setspent' function. */
+#cmakedefine HAVE_SETSPENT 1
+
+/* Define to 1 if you have the `getspnam' function. */
+#cmakedefine HAVE_GETSPNAM 1
+
 /* Define to 1 if you have the `getgrnam_r' function. */
 #cmakedefine HAVE_GETGRNAM_R 1
 
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index ca57dfb..e985bb3 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -61,7 +61,9 @@
 
 #include 
 #include 
+#ifdef HAVE_SHADOW_H
 #include 
+#endif /* HAVE_SHADOW_H */
 
 #include 
 #include 
@@ -501,6 +503,7 @@ static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, 
char *line);
 static void nwrap_pw_unload(struct nwrap_cache *nwrap);
 
 /* shadow */
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
 struct nwrap_sp {
struct nwrap_cache *cache;
 
@@ -514,6 +517,7 @@ struct nwrap_sp nwrap_sp_global;
 
 static bool nwrap_sp_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_sp_unload(struct nwrap_cache *nwrap);
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
 
 /* group */
 struct nwrap_gr {
@@ -1279,6 +1283,7 @@ static void nwrap_init(void)
nwrap_pw_global.cache->unload = nwrap_pw_unload;
 
/* shadow */
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
nwrap_sp_global.cache = &__nwrap_cache_sp;
 
nwrap_sp_global.cache->path = getenv("NSS_WRAPPER_SHADOW");
@@ -1286,6 +1291,7 @@ static void nwrap_init(void)
nwrap_sp_global.cache->private_data = _sp_global;
nwrap_sp_global.cache->parse_line = nwrap_sp_parse_line;
nwrap_sp_global.cache->unload = nwrap_sp_unload;
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
 
/* group */
nwrap_gr_global.cache = &__nwrap_cache_gr;
@@ -1322,6 +1328,7 @@ bool nss_wrapper_enabled(void)
return true;
 }
 
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
 bool nss_wrapper_shadow_enabled(void)
 {
nwrap_init();
@@ -1333,6 

[SCM] NSS Wrapper Repository - branch master updated

2015-10-05 Thread Michael Adam
The branch, master has been updated
   via  0f179c8 tests: Add test for getspnam() function
   via  bb8fa5d nwrap: Add support for getspnam()
   via  857bc98 tests: Add test for (set|get|end)spent functions
   via  b96ecdc nwrap: Add (set|get|end)spent functions
   via  f848d19 nwrap: Add nss_wrapper_shadow_enabled() function
   via  3358c87 nwrap: Add shadow file parser
   via  bf99c1a nwrap: Remove unused struct member in nwrap_main
  from  59cec08 nwrap: Implement nwrap_files_initgroups()

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


- Log -
commit 0f179c86eea00fbbf6b45eb3505297d48110ba73
Author: Andreas Schneider 
Date:   Mon Sep 14 18:26:41 2015 +0200

tests: Add test for getspnam() function

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

commit bb8fa5de6c5e781b3e5cda1f324f615b3e41cfce
Author: Andreas Schneider 
Date:   Thu Sep 17 10:39:15 2015 +0200

nwrap: Add support for getspnam()

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

commit 857bc98b3c048a4ff5d2eab6f0cb143fe29c1299
Author: Andreas Schneider 
Date:   Thu Sep 17 10:44:30 2015 +0200

tests: Add test for (set|get|end)spent functions

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

commit b96ecdc8f1aaab4269f6bc514a7760ef7f767fcb
Author: Andreas Schneider 
Date:   Thu Sep 17 10:38:49 2015 +0200

nwrap: Add (set|get|end)spent functions

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

commit f848d190a5ac2c798d11f8a035a8edbdd5d7adf3
Author: Andreas Schneider 
Date:   Thu Sep 17 10:37:50 2015 +0200

nwrap: Add nss_wrapper_shadow_enabled() function

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

commit 3358c87309b5058b6e84c46bdd211e6b1265b361
Author: Andreas Schneider 
Date:   Thu Sep 17 10:33:58 2015 +0200

nwrap: Add shadow file parser

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

commit bf99c1a987d807b9b306af36a8822c181bfe6267
Author: Andreas Schneider 
Date:   Thu Sep 17 10:32:46 2015 +0200

nwrap: Remove unused struct member in nwrap_main

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

---

Summary of changes:
 src/nss_wrapper.c| 454 ++-
 tests/CMakeLists.txt |  13 +-
 tests/passwd.in  |   1 +
 tests/shadow.in  |   2 +
 tests/test_shadow.c  |  71 
 5 files changed, 539 insertions(+), 2 deletions(-)
 create mode 100644 tests/shadow.in
 create mode 100644 tests/test_shadow.c


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index b2b715e..ca57dfb 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -61,6 +61,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -340,6 +341,7 @@ struct nwrap_ops {
 /* Public prototypes */
 
 bool nss_wrapper_enabled(void);
+bool nss_wrapper_shadow_enabled(void);
 bool nss_wrapper_hosts_enabled(void);
 
 /* prototypes for files backend */
@@ -465,7 +467,6 @@ struct nwrap_libc {
 };
 
 struct nwrap_main {
-   const char *nwrap_switch;
int num_backends;
struct nwrap_backend *backends;
struct nwrap_libc *libc;
@@ -484,6 +485,7 @@ struct nwrap_cache {
void (*unload)(struct nwrap_cache *);
 };
 
+/* passwd */
 struct nwrap_pw {
struct nwrap_cache *cache;
 
@@ -498,6 +500,22 @@ struct nwrap_pw nwrap_pw_global;
 static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_pw_unload(struct nwrap_cache *nwrap);
 
+/* shadow */
+struct nwrap_sp {
+   struct nwrap_cache *cache;
+
+   struct spwd *list;
+   int num;
+   int idx;
+};
+
+struct nwrap_cache __nwrap_cache_sp;
+struct nwrap_sp nwrap_sp_global;
+
+static bool nwrap_sp_parse_line(struct nwrap_cache *nwrap, char *line);
+static void nwrap_sp_unload(struct nwrap_cache *nwrap);
+
+/* group */
 struct nwrap_gr {
struct nwrap_cache *cache;
 
@@ -509,6 +527,7 @@ struct nwrap_gr {
 struct nwrap_cache __nwrap_cache_gr;
 struct nwrap_gr nwrap_gr_global;
 
+/* hosts */
 static bool nwrap_he_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_he_unload(struct nwrap_cache *nwrap);
 
@@ -1250,6 +1269,7 @@ static void nwrap_init(void)
 
nwrap_backend_init(nwrap_main_global);
 
+   /* passwd */
nwrap_pw_global.cache = &__nwrap_cache_pw;
 
nwrap_pw_global.cache->path = 

[SCM] NSS Wrapper Repository - branch master updated

2015-09-14 Thread Andreas Schneider
The branch, master has been updated
   via  59cec08 nwrap: Implement nwrap_files_initgroups()
   via  0a3339b nwrap: Remove unneeded memcpy in getgrouplist()
   via  0d4dd43 nwrap: Avoid a string comparsion in getgrouplist()
  from  5c5416b TESTS: Add assertions to tests.

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


- Log -
commit 59cec08847e1b656bf230afaf4e68cdd258cd3e5
Author: Andreas Schneider 
Date:   Fri Sep 11 13:37:57 2015 +0200

nwrap: Implement nwrap_files_initgroups()

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

commit 0a3339b4a962a20d461fdb5ea3e2dd8b5ffd18a7
Author: Andreas Schneider 
Date:   Mon Sep 14 14:57:40 2015 +0200

nwrap: Remove unneeded memcpy in getgrouplist()

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

commit 0d4dd4307f3e54a241c6f634f96df42aa2a0136b
Author: Andreas Schneider 
Date:   Mon Sep 14 14:52:51 2015 +0200

nwrap: Avoid a string comparsion in getgrouplist()

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

---

Summary of changes:
 doc/nss_wrapper.1 |  7 +++--
 doc/nss_wrapper.1.txt |  8 ++
 src/nss_wrapper.c | 78 ---
 3 files changed, 74 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/doc/nss_wrapper.1 b/doc/nss_wrapper.1
index 0224f83..940438d 100644
--- a/doc/nss_wrapper.1
+++ b/doc/nss_wrapper.1
@@ -2,12 +2,12 @@
 .\" Title: nss_wrapper
 .\"Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 
-.\"  Date: 07/09/2014
+.\"  Date: 2015-09-12
 .\"Manual: \ \&
 .\"Source: \ \&
 .\"  Language: English
 .\"
-.TH "NSS_WRAPPER" "1" "07/09/2014" "\ \&" "\ \&"
+.TH "NSS_WRAPPER" "1" "2015\-09\-12" "\ \&" "\ \&"
 .\" -
 .\" * Define some portability stuff
 .\" -
@@ -70,6 +70,9 @@ Network name resolution using a hosts file\&.
 .\}
 Loading and testing of NSS modules\&.
 .RE
+.SH "LIMITATIONS"
+.sp
+Some calls in nss_wrapper will only work if uid_wrapper is loaded and 
active\&. One of this functions is initgroups() which needs to run setgroups() 
to set the groups for the user\&. setgroups() is wrapped by uid_wrapper\&.
 .SH "ENVIRONMENT VARIABLES"
 .PP
 \fBNSS_WRAPPER_PASSWD\fR, \fBNSS_WRAPPER_GROUP\fR
diff --git a/doc/nss_wrapper.1.txt b/doc/nss_wrapper.1.txt
index 1e5e929..d541e31 100644
--- a/doc/nss_wrapper.1.txt
+++ b/doc/nss_wrapper.1.txt
@@ -1,5 +1,6 @@
 nss_wrapper(1)
 ==
+:revdate: 2015-09-12
 
 NAME
 
@@ -30,6 +31,13 @@ with socket_wrapper.
 - Network name resolution using a hosts file.
 - Loading and testing of NSS modules.
 
+LIMITATIONS
+---
+
+Some calls in nss_wrapper will only work if uid_wrapper is loaded and active.
+One of this functions is initgroups() which needs to run setgroups() to set
+the groups for the user. setgroups() is wrapped by uid_wrapper.
+
 ENVIRONMENT VARIABLES
 -
 
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 2abbc24..b2b715e 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -2204,14 +2204,65 @@ static void nwrap_files_endpwent(struct nwrap_backend 
*b)
 
 /* misc functions */
 static int nwrap_files_initgroups(struct nwrap_backend *b,
- const char *user, gid_t group)
+ const char *user,
+ gid_t group)
 {
-   (void) b; /* unused */
-   (void) user; /* unused */
-   (void) group; /* used */
+   struct group *grp;
+   gid_t *groups;
+   int size = 1;
+   int rc;
+
+   groups = (gid_t *)malloc(size * sizeof(gid_t));
+   if (groups == NULL) {
+   NWRAP_LOG(NWRAP_LOG_ERROR, "Out of memory");
+   errno = ENOMEM;
+   return -1;
+   }
+   groups[0] = group;
+
+   nwrap_files_setgrent(b);
+   while ((grp = nwrap_files_getgrent(b)) != NULL) {
+   int i = 0;
+
+   NWRAP_LOG(NWRAP_LOG_DEBUG,
+ "Inspecting %s for group membership",
+ grp->gr_name);
+
+   for (i=0; grp->gr_mem && grp->gr_mem[i] != NULL; i++) {
+   if (group != grp->gr_gid &&
+   (strcmp(user, grp->gr_mem[i]) == 0)) {
+   NWRAP_LOG(NWRAP_LOG_DEBUG,
+ "%s is member of %s",
+ user,
+   

[SCM] NSS Wrapper Repository - branch master updated

2015-09-11 Thread Andreas Schneider
The branch, master has been updated
   via  5c5416b TESTS: Add assertions to tests.
   via  6b595ed TESTS: Switch tests to new CMocka API.
   via  e9e3f5a TESTS: Fix some memory leaks in testsuite.
   via  1769600 nwrap: Use ssize_t for aliases_count
   via  ef45548 nwrap: Prevent compilation failure on machine without IPv4
   via  24dcc9c nwrap: Replace free() calls by SAFE_FREE macro where 
possible.
   via  119e807 cmake: Add compilation flags
   via  6bac1f7 cmake: Add detection of -fstack-protector-strong compiler 
flag
  from  1b57476 cmake: Drop test results via https.

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


- Log -
commit 5c5416bcfe45bec2fb2899ae55eb1e0cbf824284
Author: Robin Hack 
Date:   Tue Mar 24 11:59:53 2015 +0100

TESTS: Add assertions to tests.

When function returns NULL then test raise assert fail istead of
SIGSEGV now.

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

commit 6b595ed65bf40dfb6ed2ccf9443aaf82ea799f39
Author: Robin Hack 
Date:   Wed Mar 25 11:30:35 2015 +0100

TESTS: Switch tests to new CMocka API.

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

commit e9e3f5a6795c307a80907643897f13591b8aeeba
Author: Robin Hack 
Date:   Tue Mar 24 12:02:24 2015 +0100

TESTS: Fix some memory leaks in testsuite.

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

commit 1769600bfff87e266dab666e568eb146a1d4e5c9
Author: Robin Hack 
Date:   Wed Jul 15 15:00:02 2015 +0200

nwrap: Use ssize_t for aliases_count

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

commit ef45548ef6dc45647e0b93baf46b38bd70d9e638
Author: Robin Hack 
Date:   Wed Mar 25 09:36:10 2015 +0100

nwrap: Prevent compilation failure on machine without IPv4

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

commit 24dcc9c5179aeb08d8b0ed43c4c3b607b9dc6b2c
Author: Robin Hack 
Date:   Sat Nov 29 13:22:46 2014 +0100

nwrap: Replace free() calls by SAFE_FREE macro where possible.

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

commit 119e8070783142613534b8e3cf77348e44abc108
Author: Robin Hack 
Date:   Wed Mar 25 12:50:16 2015 +0100

cmake: Add compilation flags

Flags added:
-Wbad-function-cast
-fstrict-aliasing
-Wstrict-aliasing=3

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

commit 6bac1f7e6b250c391f13ee233063d36fba7652e0
Author: Robin Hack 
Date:   Wed Mar 25 12:34:53 2015 +0100

cmake: Add detection of -fstack-protector-strong compiler flag

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

---

Summary of changes:
 cmake/Modules/DefineCompilerFlags.cmake | 21 ++---
 src/nss_wrapper.c   | 48 +
 tests/test_getaddrinfo.c| 42 +
 tests/test_gethostby_name_addr.c| 29 --
 tests/test_gethostent.c |  6 ++--
 tests/test_getnameinfo.c| 16 +-
 tests/test_nwrap_disabled.c | 12 
 tests/testsuite.c   | 54 ++---
 8 files changed, 126 insertions(+), 102 deletions(-)


Changeset truncated at 500 lines:

diff --git a/cmake/Modules/DefineCompilerFlags.cmake 
b/cmake/Modules/DefineCompilerFlags.cmake
index 0ab8802..111b2f4 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -13,7 +13,13 @@ if (UNIX AND NOT WIN32)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic 
-pedantic-errors")
 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} 

[SCM] NSS Wrapper Repository - branch master updated

2015-02-25 Thread Andreas Schneider
The branch, master has been updated
   via  1b57476 cmake: Drop test results via https.
  from  9f1da66 nwrap: Fix the handle loops for older gcc versions.

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


- Log -
commit 1b57476cb64fadaa058e4b2a1224c6b6afbae111
Author: Andreas Schneider a...@samba.org
Date:   Wed Feb 25 11:20:24 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 78a228e..47a28d0 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -3,7 +3,7 @@ set(UPDATE_TYPE true)
 set(CTEST_PROJECT_NAME nsswrapper)
 set(CTEST_NIGHTLY_START_TIME 01:00:00 UTC)
 
-set(CTEST_DROP_METHOD http)
+set(CTEST_DROP_METHOD https)
 set(CTEST_DROP_SITE mock.cryptomilk.org)
 set(CTEST_DROP_LOCATION /submit.php?project=nsswrapper)
 set(CTEST_DROP_SITE_CDASH TRUE)


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-10-01 Thread Andreas Schneider
The branch, master has been updated
   via  9f1da66 nwrap: Fix the handle loops for older gcc versions.
  from  2192e08 Bump version to 1.0.3.

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


- Log -
commit 9f1da664220a5da1d8b4c52a17f819672ace9928
Author: Andreas Schneider a...@samba.org
Date:   Wed Oct 1 17:15:35 2014 +0200

nwrap: Fix the handle loops for older gcc versions.

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

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index a41de9e..28c23d8 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -575,11 +575,14 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
 #ifdef HAVE_LIBNSL
handle = nwrap_main_global-libc-nsl_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), 
libnsl.so.%d, i);
handle = dlopen(soname, flags);
+   if (handle != NULL) {
+   break;
+   }
}
 
nwrap_main_global-libc-nsl_handle = handle;
@@ -591,11 +594,14 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
 #ifdef HAVE_LIBSOCKET
handle = nwrap_main_global-libc-sock_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), 
libsocket.so.%d, i);
handle = dlopen(soname, flags);
+   if (handle != NULL) {
+   break;
+   }
}
 
nwrap_main_global-libc-sock_handle = handle;
@@ -606,11 +612,14 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
case NWRAP_LIBC:
handle = nwrap_main_global-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;
+   }
}
 
nwrap_main_global-libc-handle = handle;


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-09-11 Thread Andreas Schneider
The branch, master has been updated
   via  2192e08 Bump version to 1.0.3.
  from  12f707b nwrap: Make sure addr is initialized.

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


- Log -
commit 2192e08b7c9f153f71bda783612a706fe3ad4b02
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 10 13:53:13 2014 +0200

Bump version to 1.0.3.

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

---

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


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 094d620..f73a46c 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 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 bd6fa10..2d25383 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
 ChangeLog
 ==
 
+version 1.0.3 (released 2014-09-11)
+  * Added a nss_wrapper manpage.
+  * Fixed cmake find_package configs.
+  * Fixed resolving hostnames with a trailing dot.
+  * Fixed an overflow when checking if a IPv6 address is IPv4.
+  * Fall back to RTLD_NEXT for symbol binding if we can't find libc.
+
 version 1.0.2 (released 2014-04-08)
   * Added public nss_wrapper_enabled().
   * Added public nss_wrapper_hosts_enabled().


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-09-10 Thread Andreas Schneider
The branch, master has been updated
   via  12f707b nwrap: Make sure addr is initialized.
   via  055e7b7 nwrap: Use DNS_NAME_MAX cause it is not available on BSD.
  from  0e50956 nwrap: Don't overflow the in_addr if convert IPv6.

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


- Log -
commit 12f707b5e44d14421db43db6c6197cf9c1498ac8
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 10 08:30:22 2014 +0200

nwrap: Make sure addr is initialized.

CID #72755

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

commit 055e7b7b1296dd0e2c0fa98261377069d11b76ec
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 10 08:26:34 2014 +0200

nwrap: Use DNS_NAME_MAX cause it is not available on BSD.

Also HOST_NAME_MAX is only for the value returned by gethostname(). It
is normally limited to 64 chars on Linux.

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

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 931aaa5..a41de9e 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -49,7 +49,6 @@
 #include string.h
 #include unistd.h
 #include ctype.h
-#include limits.h
 
 /*
  * Defining _POSIX_PTHREAD_SEMANTICS before including pwd.h and grp.h  gives us
@@ -122,6 +121,10 @@ typedef nss_status_t NSS_STATUS;
 #define __location__ __FILE__ : __LINESTR__
 #endif
 
+#ifndef DNS_NAME_MAX
+#define DNS_NAME_MAX 255
+#endif
+
 /* GCC have printf type attribute check. */
 #ifdef HAVE_ATTRIBUTE_PRINTF_FORMAT
 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
@@ -2352,7 +2355,7 @@ static void nwrap_files_endgrent(struct nwrap_backend *b)
 static struct hostent *nwrap_files_gethostbyname(const char *name, int af)
 {
struct hostent *he;
-   char canon_name[HOST_NAME_MAX] = { 0 };
+   char canon_name[DNS_NAME_MAX] = { 0 };
size_t name_len;
int i;
 
@@ -3862,7 +3865,9 @@ static int nwrap_getaddrinfo(const char *node,
struct in6_addr v6;
} in;
 #endif
-   } addr;
+   } addr = {
+   .family = AF_UNSPEC,
+   };
int eai = EAI_SYSTEM;
int ret;
int rc;


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-09-09 Thread Andreas Schneider
The branch, master has been updated
   via  0e50956 nwrap: Don't overflow the in_addr if convert IPv6.
   via  379967b tests: Add test for hostnames with a trailing dot.
   via  b65c6d8 nwrap: Fix resolving hostnames with a trailing dot.
  from  3125e76 tests: use return code of copy_group() in 
test_nwrap_getgrgid()

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


- Log -
commit 0e509561b76fc1a0fadbcfddf9602569cb681f22
Author: Andreas Schneider a...@samba.org
Date:   Tue Sep 9 11:03:24 2014 +0200

nwrap: Don't overflow the in_addr if convert IPv6.

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

commit 379967b19b9c7327e0d8ffdf0cc693011abacced
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 3 13:08:03 2014 +0200

tests: Add test for hostnames with a trailing dot.

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

commit b65c6d8ed5b4122b69ecae94eac40bc7e9649710
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 3 13:07:31 2014 +0200

nwrap: Fix resolving hostnames with a trailing dot.

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

---

Summary of changes:
 src/nss_wrapper.c|   63 ++---
 tests/test_getaddrinfo.c |   29 +
 2 files changed, 60 insertions(+), 32 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index e3943ee..931aaa5 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -49,6 +49,7 @@
 #include string.h
 #include unistd.h
 #include ctype.h
+#include limits.h
 
 /*
  * Defining _POSIX_PTHREAD_SEMANTICS before including pwd.h and grp.h  gives us
@@ -2351,10 +2352,18 @@ static void nwrap_files_endgrent(struct nwrap_backend 
*b)
 static struct hostent *nwrap_files_gethostbyname(const char *name, int af)
 {
struct hostent *he;
+   char canon_name[HOST_NAME_MAX] = { 0 };
+   size_t name_len;
int i;
 
nwrap_files_cache_reload(nwrap_he_global.cache);
 
+   name_len = strlen(name);
+   if (name_len  sizeof(canon_name)  name[name_len - 1] == '.') {
+   strncpy(canon_name, name, name_len - 1);
+   name = canon_name;
+   }
+
for (i = 0; i  nwrap_he_global.num; i++) {
int j;
 
@@ -3845,13 +3854,18 @@ static int nwrap_getaddrinfo(const char *node,
struct addrinfo *p = NULL;
unsigned short port = 0;
struct hostent *he;
-   struct in_addr in;
-   bool is_addr_ipv4 = false;
-   bool is_addr_ipv6 = false;
+   struct {
+   int family;
+   union {
+   struct in_addr v4;
+#ifdef HAVE_IPV6
+   struct in6_addr v6;
+   } in;
+#endif
+   } addr;
int eai = EAI_SYSTEM;
int ret;
int rc;
-   int af;
 
if (node == NULL  service == NULL) {
return EAI_NONAME;
@@ -3903,32 +3917,25 @@ static int nwrap_getaddrinfo(const char *node,
}
}
 
-   af = hints-ai_family;
-   if (af == AF_UNSPEC) {
-   af = AF_INET;
+   rc = 0;
+   if (hints-ai_family == AF_UNSPEC || hints-ai_family == AF_INET) {
+   rc = inet_pton(AF_INET, node, addr.in.v4);
}
-
-   rc = inet_pton(af, node, in);
if (rc == 1) {
-   is_addr_ipv4 = true;
-   if (af == AF_UNSPEC) {
-   af = AF_INET;
-   }
+   addr.family = AF_INET;
 #ifdef HAVE_IPV6
} else {
-   struct in6_addr in6;
-
-   af = AF_INET6;
-
-   rc = inet_pton(af, node, in6);
+   rc = inet_pton(AF_INET6, node, addr.in.v6);
if (rc == 1) {
-   is_addr_ipv6 = true;
+   addr.family = AF_INET6;
}
 #endif
}
 
-   if (is_addr_ipv4) {
-   he = nwrap_files_gethostbyaddr(in, sizeof(struct in_addr), af);
+   if (addr.family == AF_INET) {
+   he = nwrap_files_gethostbyaddr(addr.in.v4,
+  sizeof(struct in_addr),
+  addr.family);
if (he != NULL) {
rc = nwrap_convert_he_ai(he, port, hints, ai);
} else {
@@ -3936,18 +3943,10 @@ static int nwrap_getaddrinfo(const char *node,
rc = -1;
}
 #ifdef HAVE_IPV6
-   } else if (is_addr_ipv6) {
-   struct in6_addr in6;
-
-   rc =  inet_pton(af, node, in6);
-   if (rc = 0) {
-   eai = 

[SCM] NSS Wrapper Repository - branch master updated

2014-08-15 Thread Andreas Schneider
The branch, master has been updated
   via  e5f6917 tests: Fix possible null pointer dereference in testsuite.
  from  bb8a492 doc: Add nss_wrapper manpage.

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


- Log -
commit e5f6917c8707888bfff9b46e546c8ba77ec90962
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 15 10:48:10 2014 +0200

tests: Fix possible null pointer dereference in testsuite.

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

---

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


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index 64887cb..4a84778 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -130,10 +130,10 @@ static bool test_nwrap_getpwnam(const char *name, struct 
passwd *pwd_p)
pwd = getpwnam(name);
if (pwd != NULL) {
print_passwd(pwd);
-   }
 
-   if (pwd_p != NULL) {
-   copy_passwd(pwd, pwd_p);
+   if (pwd_p != NULL) {
+   copy_passwd(pwd, pwd_p);
+   }
}
 
return pwd != NULL ? true : false;
@@ -173,10 +173,10 @@ static bool test_nwrap_getpwuid(uid_t uid,
pwd = getpwuid(uid);
if (pwd != NULL) {
print_passwd(pwd);
-   }
 
-   if (pwd_p != NULL) {
-   copy_passwd(pwd, pwd_p);
+   if (pwd_p != NULL) {
+   copy_passwd(pwd, pwd_p);
+   }
}
 
return pwd != NULL ? true : false;
@@ -292,10 +292,10 @@ static bool test_nwrap_getgrnam(const char *name,
grp = getgrnam(name);
if (grp != NULL) {
print_group(grp);
-   }
 
-   if (grp_p != NULL) {
-   copy_group(grp, grp_p);
+   if (grp_p != NULL) {
+   copy_group(grp, grp_p);
+   }
}
 
return grp != NULL ? true : false;
@@ -337,10 +337,10 @@ static bool test_nwrap_getgrgid(gid_t gid,
grp = getgrgid(gid);
if (grp != NULL) {
print_group(grp);
-   }
 
-   if (grp_p != NULL) {
-   copy_group(grp, grp_p);
+   if (grp_p != NULL) {
+   copy_group(grp, grp_p);
+   }
}
 
return grp != NULL ? true : false;


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-08-15 Thread Michael Adam
The branch, master has been updated
   via  3125e76 tests: use return code of copy_group() in 
test_nwrap_getgrgid()
   via  36cfee6 tests: reduce indentation in test_nwrap_getgrgid() by using 
early returns.
   via  6e4e7c5 tests: use return value of copy_group() in 
test_nwrap_getgrnam().
   via  96f53f2 tests: reduce indentation in test_nwrap_getgrnam() by using 
early returns.
   via  b8dfbd2 tests: use return value of copy_passwd() in 
test_nwrap_getpwuid()
   via  0795d66 tests: reduce indentation in test_nwrap_getpwuid() by using 
early returns.
   via  add66c4 tests: use return code of copy_passwd() in 
test_nwrap_getpwnam().
   via  3f2a44c tests: reduce indentation in test_nwrap_getpwnam() by using 
early returns.
  from  e5f6917 tests: Fix possible null pointer dereference in testsuite.

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


- Log -
commit 3125e76052a97f337ffe5939288b06dec732d328
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:57:12 2014 +0200

tests: use return code of copy_group() in test_nwrap_getgrgid()

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

commit 36cfee6e11136993fd4f011a90f9a193f618a901
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:56:11 2014 +0200

tests: reduce indentation in test_nwrap_getgrgid() by using early returns.

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

commit 6e4e7c565b7526aa991460aa273455f665fe4c76
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:55:09 2014 +0200

tests: use return value of copy_group() in test_nwrap_getgrnam().

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

commit 96f53f2c5f7de225cf8c08bb40e2b8488b770c7a
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:54:06 2014 +0200

tests: reduce indentation in test_nwrap_getgrnam() by using early returns.

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

commit b8dfbd2917a4276ec42ba18d67a974d2925e7739
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:51:51 2014 +0200

tests: use return value of copy_passwd() in test_nwrap_getpwuid()

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

commit 0795d6687dac865f7a4896c663d20e9fdef3c42b
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:50:33 2014 +0200

tests: reduce indentation in test_nwrap_getpwuid() by using early returns.

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

commit add66c49914261e7dc7f674dd0b4c86b649a09a3
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 12:03:46 2014 +0200

tests: use return code of copy_passwd() in test_nwrap_getpwnam().

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

commit 3f2a44c5897dbef4173e5f44316bfc42eeff10a0
Author: Michael Adam ob...@samba.org
Date:   Fri Aug 15 11:09:40 2014 +0200

tests: reduce indentation in test_nwrap_getpwnam() by using early returns.

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

---

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


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index 4a84778..627e49c 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -124,19 +124,24 @@ static void print_passwd(struct passwd *pwd)
 static bool test_nwrap_getpwnam(const char *name, struct passwd *pwd_p)
 {
struct passwd *pwd = NULL;
+   bool ok;
 
DEBUG(Testing getpwnam: %s\n, name);
 
pwd = getpwnam(name);
-   if (pwd != NULL) {
-   print_passwd(pwd);
+   if (pwd == NULL) {
+   return false;
+   }
 
-   if (pwd_p != NULL) {
-   copy_passwd(pwd, pwd_p);
-   }
+   print_passwd(pwd);
+
+   if (pwd_p == NULL) {
+   return true;
}
 
-   return pwd != NULL ? true : false;
+   ok = copy_passwd(pwd, pwd_p);
+
+   return ok;
 }
 
 static void test_nwrap_getpwnam_r(const char *name,
@@ -167,19 +172,24 @@ static bool test_nwrap_getpwuid(uid_t uid,
struct passwd *pwd_p)
 {
struct passwd *pwd = NULL;
+   bool ok;
 
DEBUG(Testing getpwuid: %lu\n, (unsigned long)uid);
 
pwd = getpwuid(uid);
-   if (pwd != NULL) {
-   print_passwd(pwd);
+   if (pwd == NULL) {
+   return false;
+   }
 
-   if (pwd_p != 

[SCM] NSS Wrapper Repository - branch master updated

2014-07-09 Thread Andreas Schneider
The branch, master has been updated
   via  bb8a492 doc: Add nss_wrapper manpage.
  from  6ab6a09 nss_wrapper: Fix some discarding const warnings

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


- Log -
commit bb8a492e467d154b11ac19230e63cd5e13ab8577
Author: Andreas Schneider a...@samba.org
Date:   Wed Jul 9 17:29:12 2014 +0200

doc: Add nss_wrapper manpage.

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

---

Summary of changes:
 CMakeLists.txt|1 +
 README|   58 
 doc/CMakeLists.txt|4 +
 doc/README|3 +
 doc/nss_wrapper.1 |  180 +
 doc/nss_wrapper.1.txt |   96 ++
 6 files changed, 298 insertions(+), 44 deletions(-)
 create mode 100644 doc/CMakeLists.txt
 create mode 100644 doc/README
 create mode 100644 doc/nss_wrapper.1
 create mode 100644 doc/nss_wrapper.1.txt


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40d6595..094d620 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,3 +88,4 @@ install(
 devel
 )
 
+add_subdirectory(doc)
diff --git a/README b/README
index 2ffa564..2d26237 100644
--- a/README
+++ b/README
@@ -1,54 +1,24 @@
-NSS wrapper library
-
+NSS_WRAPPER
+===
 
-There are projects which provide daemons needing to be able to create, modify
-and delete unix users. Or just switch user ids to interact with the system e.g.
-a user space file server. To be able to test that you need the privilege to
-modify the passwd and groups file. With nss_wrapper it is possible to define
-your own passwd and groups file which will be used by software to act correctly
-while under test.
+This is a wrapper for the user, group and hosts NSS API.
 
-If you have a client and server under test they normally use functions to
-resolve network names to addresses (dns) or vice versa. The nss_wrappers allow
-you to create a hosts file to setup name resolution for the addresses you use
-with socket_wrapper.
+DESCRIPTION
+---
 
-The first environment variable you need to set is:
+More details can be found in the manpage:
 
-LD_PRELOAD=libnss_wrapper.so
+  man -l ./doc/nss_wrapper.1
 
-For user and group accounts you need to create two files: 'passwd' and 'group'.
-The format of the passwd file is described in 'man 5 passwd' and the group file
-in 'man 5 group'. So you can fill these files with made up accounts. You point
-nss_wrapper to them using the two variables:
+or the raw text version:
 
-NSS_WRAPPER_PASSWD=/path/to/your/passwd and
-NSS_WRAPPER_GROUP=/path/to/your/group.
+  less ./doc/nss_wrapper.1.txt
 
-If you also need to emulate network name resolution in your enviornment,
-especially with socket_wrapper, you can write a hosts file. The format is
-described in 'man 5 hosts'. Then you can point nss_wrapper to your hosts
-file using:
+For installation instructions please take a look at the README.install file.
 
-NSS_WRAPPER_HOSTS=/path/to/your/hosts
+MAILINGLIST
+---
 
-If you need to return a hostname which is different from the one of your
-machine is using you can use:
+As the mailing list samba-technical is used and can be found here:
 
-NSS_WRAPPER_HOSTNAME=test.example.org
-
-If you have a project which also provides user and group information out of a
-database, you normally write your own nss modules. nss_wrapper is able to load
-nss modules and ask them first before looking into the faked passwd and group
-file. To point nss_wrapper to the module you can do that using
-
-NSS_WRAPPER_MODULE_SO_PATH=/path/to/libnss_yourmodule.so
-
-As each nss module has a special prefix like _nss_winbind_getpwnam() you need
-to set the prefix too so nss_wrapper can load the functions with:
-
-NSS_WRAPPER_MODULE_FN_PREFIX=prefix
-
-For _nss_winbind_getpwnam() this would be:
-
-NSS_WRAPPER_MODULE_FN_PREFIX=winbind
+https://lists.samba.org/mailman/listinfo/samba-technical
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 000..353168a
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,4 @@
+install(FILES
+nss_wrapper.1
+DESTINATION
+${MAN_INSTALL_DIR}/man1)
diff --git a/doc/README b/doc/README
new file mode 100644
index 000..7217244
--- /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/nss_wrapper.1.txt
diff --git a/doc/nss_wrapper.1 b/doc/nss_wrapper.1
new file mode 100644
index 000..0224f83
--- /dev/null
+++ b/doc/nss_wrapper.1
@@ -0,0 +1,180 @@
+'\ t
+.\ Title: nss_wrapper
+.\Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\ Generator: DocBook XSL Stylesheets v1.78.1 

[SCM] NSS Wrapper Repository - branch master updated

2014-06-21 Thread Michael Adam
The branch, master has been updated
   via  6ab6a09 nss_wrapper: Fix some discarding const warnings
   via  dbaad3a nss_wrapper: Align indentation with the rest of Samba
  from  7d26793 nwrap: Fall back to RTLD_NEXT if we can't find libc.

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


- Log -
commit 6ab6a09feb599fbca4fd2886adfb9d1ec4f10ed7
Author: Volker Lendecke v...@samba.org
Date:   Sat Jun 21 10:48:56 2014 +0200

nss_wrapper: Fix some discarding const warnings

Signed-off-by: Volker Lendecke v...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit dbaad3a1710bf1bf642c9dca46300e950d0c93e2
Author: Volker Lendecke v...@samba.org
Date:   Sat Jun 21 10:47:28 2014 +0200

nss_wrapper: Align indentation with the rest of Samba

Signed-off-by: Volker Lendecke v...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 src/nss_wrapper.c |   32 
 1 files changed, 16 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 6ed48c6..e3943ee 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -4049,24 +4049,24 @@ static int nwrap_getnameinfo(const struct sockaddr *sa, 
socklen_t salen,
 
type = sa-sa_family;
switch (type) {
-   case AF_INET:
-   if (salen  sizeof(struct sockaddr_in))
-   return EAI_FAMILY;
-   addr = ((struct sockaddr_in *)sa)-sin_addr;
-   addrlen = sizeof(((struct sockaddr_in *)sa)-sin_addr);
-   port = ntohs(((struct sockaddr_in *)sa)-sin_port);
-   break;
+   case AF_INET:
+   if (salen  sizeof(struct sockaddr_in))
+   return EAI_FAMILY;
+   addr = ((const struct sockaddr_in *)sa)-sin_addr;
+   addrlen = sizeof(((const struct sockaddr_in *)sa)-sin_addr);
+   port = ntohs(((const struct sockaddr_in *)sa)-sin_port);
+   break;
 #ifdef HAVE_IPV6
-   case AF_INET6:
-   if (salen  sizeof(struct sockaddr_in6))
-   return EAI_FAMILY;
-   addr = ((struct sockaddr_in6 *)sa)-sin6_addr;
-   addrlen = sizeof(((struct sockaddr_in6 
*)sa)-sin6_addr);
-   port = ntohs(((struct sockaddr_in6 *)sa)-sin6_port);
-   break;
-#endif
-   default:
+   case AF_INET6:
+   if (salen  sizeof(struct sockaddr_in6))
return EAI_FAMILY;
+   addr = ((const struct sockaddr_in6 *)sa)-sin6_addr;
+   addrlen = sizeof(((const struct sockaddr_in6 *)sa)-sin6_addr);
+   port = ntohs(((const struct sockaddr_in6 *)sa)-sin6_port);
+   break;
+#endif
+   default:
+   return EAI_FAMILY;
}
 
if (host != NULL) {


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-05-28 Thread Michael Adam
The branch, master has been updated
   via  fa20a56 tests: getaddrinfo() should use 0 as ai_flags.
   via  3787de0 cmake: Fix a typo in nss_wrapper-config.cmake.in.
   via  e46f386 Add README.install - instructions for building and 
installing.
  from  a5b392d cmake: Fix policy check.

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


- Log -
commit fa20a56d4126dd5b111d06f84442dc972f024313
Author: Andreas Schneider a...@samba.org
Date:   Thu May 22 15:10:46 2014 +0200

tests: getaddrinfo() should use 0 as ai_flags.

This fixes an issue for the test platform configuration with IPv4 only
addresses.

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

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

commit 3787de075b856151ea49e1b07260b33e8b1b6d92
Author: Andreas Schneider a...@samba.org
Date:   Thu May 22 15:11:10 2014 +0200

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

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

commit e46f386ee6e827b0bd080d44698f66720c07349c
Author: Michael Adam ob...@samba.org
Date:   Tue May 27 14:07:17 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 +++
 nss_wrapper-config.cmake.in |2 +-
 tests/test_getaddrinfo.c|   10 +++---
 3 files changed, 84 insertions(+), 6 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..7ee4e71
--- /dev/null
+++ b/README.install
@@ -0,0 +1,78 @@
+Obtaining the sources
+=
+
+Source tarballs for nss_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/nss_wrapper.git
+
+To create a local copy, run
+
+  $ git clone git://git.samba.org/nss_wrapper.git
+  $ cd nss_wrapper
+
+Building from sources
+=
+
+nss_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
+==
+
+nss_wrapper is installed into the prefix directory
+after running cmake and make with
+
+  $ make install
+
diff --git a/nss_wrapper-config.cmake.in b/nss_wrapper-config.cmake.in
index ccf7113..3932a87 100644
--- a/nss_wrapper-config.cmake.in
+++ b/nss_wrapper-config.cmake.in
@@ -1 +1 @@
-set(NSS_WRAPPER_LIRBARY @LIB_INSTALL_DIR@/@NSS_WRAPPER_LIB@)
+set(NSS_WRAPPER_LIBRARY @LIB_INSTALL_DIR@/@NSS_WRAPPER_LIB@)
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index ce06fd9..a7714b1 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -155,7 +155,7 @@ static void test_nwrap_getaddrinfo_local(void **state)
memset(hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
-   hints.ai_flags = AI_ADDRCONFIG;
+   hints.ai_flags = 0;
 
rc = getaddrinfo(127.0.0.1, NULL, hints, res);
assert_int_equal(rc, 0);
@@ -187,7 +187,7 @@ static void test_nwrap_getaddrinfo_name(void **state)
memset(hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
-   hints.ai_flags = 

[SCM] NSS Wrapper Repository - branch master updated

2014-05-28 Thread Michael Adam
The branch, master has been updated
   via  7d26793 nwrap: Fall back to RTLD_NEXT if we can't find libc.
  from  fa20a56 tests: getaddrinfo() should use 0 as ai_flags.

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


- Log -
commit 7d26793e9cc99b3eb55fe627a4b6287e7dae37ee
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 29 15:10:00 2014 +0200

nwrap: 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/nss_wrapper.c |   11 +++
 1 files changed, 7 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 7c5a413..6ed48c6 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -562,10 +562,6 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
void *handle = NULL;
int i;
 
-#ifdef HAVE_APPLE
-   return RTLD_NEXT;
-#endif
-
 #ifdef RTLD_DEEPBIND
flags |= RTLD_DEEPBIND;
 #endif
@@ -619,10 +615,17 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
}
 
if (handle == NULL) {
+#ifdef RTLD_NEXT
+   handle = nwrap_main_global-libc-handle
+  = nwrap_main_global-libc-sock_handle
+  = nwrap_main_global-libc-nsl_handle
+  = RTLD_NEXT;
+#else
NWRAP_LOG(NWRAP_LOG_ERROR,
  Failed to dlopen library: %s\n,
  dlerror());
exit(-1);
+#endif
}
 
return handle;


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-04-25 Thread Andreas Schneider
The branch, master has been updated
   via  a5b392d cmake: Fix policy check.
   via  3f29031 cmake: Install cmake config into the correct directory.
   via  5b96753 cmake: Set version to 2.8.13.
  from  db4ac82 Update to version 1.0.2.

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


- Log -
commit a5b392db3bff57d2f6e446266e924f37112a20ba
Author: Andreas Schneider a...@samba.org
Date:   Fri Apr 25 13:59:00 2014 +0200

cmake: Fix policy check.

commit 3f29031f6a0825177c333129360dde862d696a4c
Author: Andreas Schneider a...@samba.org
Date:   Wed Apr 16 15:46:55 2014 +0200

cmake: Install cmake config into the correct directory.

commit 5b96753d877a77b91d0dcc3a886cd10a926d92d6
Author: Andreas Schneider a...@samba.org
Date:   Wed Apr 9 11:56:44 2014 +0200

cmake: Set version to 2.8.13.

---

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 fd621e9..40d6595 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ install(
 ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake
 ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config.cmake
 DESTINATION
-${CMAKE_INSTALL_DIR}
+${CMAKE_INSTALL_DIR}/nss_wrapper
 COMPONENT
 devel
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e5dccc5..36b05a8 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 (POLICY CMP0026)
 cmake_policy(SET CMP0026 OLD)
 endif()
 get_target_property(NWRAP_LOCATION nss_wrapper LOCATION)


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-04-09 Thread Andreas Schneider
The branch, master has been updated
   via  db4ac82 Update to version 1.0.2.
   via  5a2bfec testsuite: Fix NULL checks.
   via  cb7201a nwrap: Make nss_wrapper_hosts_enabled() public.
   via  b5d9b9a nwrap: Make nss_wrapper_enabled public.
   via  dd1f9ae cmake: Only set policy in cmake 3.0.
  from  62d86a3 cmake: Fix configure warning with cmake 3.0.

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


- Log -
commit db4ac828fc4741e62174647179910ef64a53ae35
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:58:01 2014 +0200

Update to version 1.0.2.

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

commit 5a2bfecb84be9a44162a1dfdf5f6562343f45ff6
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:52:40 2014 +0200

testsuite: Fix NULL checks.

Found by Coverity.

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

commit cb7201aa7d4904aa0d788d2578e2d0399c9dd701
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:44:15 2014 +0200

nwrap: Make nss_wrapper_hosts_enabled() public.

commit b5d9b9a2bbbe86cb4aea682059aea23e60f7cc94
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:43:04 2014 +0200

nwrap: Make nss_wrapper_enabled public.

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

commit dd1f9ae1bec81806da86a20e9766da127d289bbb
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:40:15 2014 +0200

cmake: Only set policy in cmake 3.0.

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

---

Summary of changes:
 CMakeLists.txt |4 +-
 ChangeLog  |6 
 src/CMakeLists.txt |4 ++-
 src/nss_wrapper.c  |   73 +++
 tests/testsuite.c  |   32 +++---
 5 files changed, 66 insertions(+), 53 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a83fb75..fd621e9 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.1.0)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index d3307aa..bd6fa10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 ChangeLog
 ==
 
+version 1.0.2 (released 2014-04-08)
+  * Added public nss_wrapper_enabled().
+  * Added public nss_wrapper_hosts_enabled().
+  * Fixed segfault in 'getent hosts' without aliases.
+  * Fixed IPv4 and IPv6 resolving with 'getent ahosts'.
+
 version 1.0.1 (released 2014-02-04)
   * Added --libs to pkg-config.
   * Added nss_wrapper-config.cmake
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c52b321..e5dccc5 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(NWRAP_LOCATION nss_wrapper LOCATION)
 set(NSS_WRAPPER_LOCATION ${NWRAP_LOCATION} PARENT_SCOPE)
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 92e2bf7..7c5a413 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -323,6 +323,11 @@ struct nwrap_ops {
void(*nw_endgrent)(struct nwrap_backend *b);
 };
 
+/* Public prototypes */
+
+bool nss_wrapper_enabled(void);
+bool nss_wrapper_hosts_enabled(void);
+
 /* prototypes for files backend */
 
 
@@ -1245,7 +1250,7 @@ static void nwrap_init(void)
nwrap_he_global.cache-unload = nwrap_he_unload;
 }
 
-static bool nwrap_enabled(void)
+bool nss_wrapper_enabled(void)
 {
nwrap_init();
 
@@ -1261,7 +1266,7 @@ static bool nwrap_enabled(void)
return true;
 }
 
-static bool nwrap_hosts_enabled(void)
+bool nss_wrapper_hosts_enabled(void)
 {
nwrap_init();
 
@@ -2402,7 +2407,7 @@ int gethostbyname_r(const char *name,
char *buf, size_t buflen,
struct hostent **result, int *h_errnop)
 {
-   if (!nwrap_hosts_enabled()) {
+   if (!nss_wrapper_hosts_enabled()) {
return libc_gethostbyname_r(name,
ret,
buf,
@@ -2471,7 +2476,7 @@ int gethostbyaddr_r(const void *addr, 

[SCM] NSS Wrapper Repository - branch master updated

2014-04-07 Thread Andreas Schneider
The branch, master has been updated
   via  62d86a3 cmake: Fix configure warning with cmake 3.0.
   via  b06224d cmake: Create the compile command database by default.
  from  4344cd3 tests: Check that the address has the correct family.

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


- Log -
commit 62d86a3d6c238e66fd67e07ec6448bd3bc0541d9
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 7 12:14:50 2014 +0200

cmake: Fix configure warning with cmake 3.0.

commit b06224d7dda52241b169b33fa0ccf5cee06658d2
Author: Andreas Schneider a...@samba.org
Date:   Fri Apr 4 09:32:21 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 089070a..c52b321 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(NWRAP_LOCATION nss_wrapper LOCATION)
 set(NSS_WRAPPER_LOCATION ${NWRAP_LOCATION} PARENT_SCOPE)


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-04-01 Thread Andreas Schneider
The branch, master has been updated
   via  4344cd3 tests: Check that the address has the correct family.
   via  64d8672 nwrap: Set correct family for IPv6 address.
  from  cf26c91 tests: Add test that getaddrinfo() returns the IPv6 address.

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


- Log -
commit 4344cd3d18e071a887bda79086035e8ba09f8222
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 1 13:26:22 2014 +0200

tests: Check that the address has the correct family.

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

commit 64d86726d2ea799537d9190112308c1e5c42f7c9
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 1 13:27:11 2014 +0200

nwrap: Set correct family for IPv6 address.

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

---

Summary of changes:
 src/nss_wrapper.c|1 +
 tests/test_getaddrinfo.c |5 +
 2 files changed, 6 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index d70dfb6..92e2bf7 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -3806,6 +3806,7 @@ static int nwrap_convert_he_ai(const struct hostent *he,
memset(sin6p, 0, sizeof(struct sockaddr_in6));
 
sin6p-sin6_port = htons(port);
+   sin6p-sin6_family = AF_INET6;
 
memcpy(sin6p-sin6_addr, he-h_addr_list[0], 
he-h_length);
}
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index 724e970..ce06fd9 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -45,6 +45,8 @@ static void test_nwrap_getaddrinfo(void **state)
assert_int_equal(res-ai_family, AF_INET);
 
sinp = (struct sockaddr_in *)res-ai_addr;
+
+   assert_int_equal(sinp-sin_family, AF_INET);
ip = inet_ntoa(sinp-sin_addr);
 
assert_string_equal(ip, 127.0.0.11);
@@ -69,6 +71,8 @@ static void test_nwrap_getaddrinfo(void **state)
assert_int_equal(res-ai_family, AF_INET6);
 
sin6p = (struct sockaddr_in6 *)res-ai_addr;
+
+   assert_int_equal(sin6p-sin6_family, AF_INET6);
inet_ntop(AF_INET6, (void *)sin6p-sin6_addr, ip6, sizeof(ip6));
 
assert_string_equal(ip6, ::13);
@@ -331,6 +335,7 @@ static void test_nwrap_getaddrinfo_ipv6(void **state)
assert_int_equal(res-ai_family, AF_INET6);
 
sin6p = (struct sockaddr_in6 *)res-ai_addr;
+   assert_int_equal(sin6p-sin6_family, AF_INET6);
inet_ntop(AF_INET6, (void *)sin6p-sin6_addr, ip6, sizeof(ip6));
 
assert_string_equal(ip6, ::14);


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-03-19 Thread Andreas Schneider
The branch, master has been updated
   via  cf26c91 tests: Add test that getaddrinfo() returns the IPv6 address.
   via  8a606d6 src: Fix looking up a fqdn with getaddrinfo().
  from  19426f4 tests: Add test for gethostbyname2().

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


- Log -
commit cf26c9167f4d30e0cd73bcdd664306d7b71127f6
Author: Andreas Schneider a...@samba.org
Date:   Tue Mar 18 09:00:36 2014 +0100

tests: Add test that getaddrinfo() returns the IPv6 address.

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

commit 8a606d69eb93076fe7824ffb90d6dc6b6ee9f7ee
Author: Andreas Schneider a...@samba.org
Date:   Tue Mar 18 08:43:21 2014 +0100

src: Fix looking up a fqdn with getaddrinfo().

This fixes 'getent ahostsv6'.

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

---

Summary of changes:
 src/nss_wrapper.c|2 +-
 tests/test_getaddrinfo.c |   32 
 2 files changed, 33 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 2706196..d70dfb6 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -3948,7 +3948,7 @@ static int nwrap_getaddrinfo(const char *node,
}
 #endif
} else {
-   he = nwrap_files_gethostbyname(node, AF_UNSPEC);
+   he = nwrap_files_gethostbyname(node, hints-ai_family);
if (he != NULL) {
rc = nwrap_convert_he_ai(he, port, hints, ai);
eai = rc;
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index 4825e77..724e970 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -307,6 +307,37 @@ static void test_nwrap_getaddrinfo_null(void **state)
freeaddrinfo(res);
 }
 
+static void test_nwrap_getaddrinfo_ipv6(void **state)
+{
+   struct addrinfo hints;
+   struct addrinfo *res = NULL;
+   struct sockaddr_in6 *sin6p;
+   char ip6[INET6_ADDRSTRLEN];
+   int rc;
+
+   (void) state; /* unused */
+
+   /*
+* krikkit.galaxy has an IPv4 and IPv6 address, this should only
+* return the IPv6 address.
+*/
+   memset(hints, 0, sizeof(struct addrinfo));
+   hints.ai_family = AF_INET6;
+
+   rc = getaddrinfo(krikkit.galaxy.site, NULL, hints, res);
+   assert_int_equal(rc, 0);
+
+   assert_non_null(res-ai_next);
+   assert_int_equal(res-ai_family, AF_INET6);
+
+   sin6p = (struct sockaddr_in6 *)res-ai_addr;
+   inet_ntop(AF_INET6, (void *)sin6p-sin6_addr, ip6, sizeof(ip6));
+
+   assert_string_equal(ip6, ::14);
+
+   freeaddrinfo(res);
+}
+
 int main(void) {
int rc;
 
@@ -317,6 +348,7 @@ int main(void) {
unit_test(test_nwrap_getaddrinfo_name),
unit_test(test_nwrap_getaddrinfo_service),
unit_test(test_nwrap_getaddrinfo_null),
+   unit_test(test_nwrap_getaddrinfo_ipv6),
};
 
rc = run_tests(tests);


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-03-17 Thread Andreas Schneider
The branch, master has been updated
   via  19426f4 tests: Add test for gethostbyname2().
   via  5034191 src: Add gethostbyname2() for getent.
   via  89b1969 src: Add address family filter to 
nwrap_files_gethostbyname().
  from  93db9fd README: Fix prefix env variable name.

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


- Log -
commit 19426f4ed8e362bd5656fd0a5ec4c627f56a071e
Author: Andreas Schneider a...@samba.org
Date:   Mon Mar 17 13:18:16 2014 +0100

tests: Add test for gethostbyname2().

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

commit 50341913140b4594f0b3a0a4774442c83e7a77b9
Author: Andreas Schneider a...@samba.org
Date:   Mon Mar 17 10:34:42 2014 +0100

src: Add gethostbyname2() for getent.

This fixes 'getent hosts fqdn' with glibc.

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

commit 89b19692e44839545001244a20a2454dc971ecda
Author: Andreas Schneider a...@samba.org
Date:   Mon Mar 17 13:19:03 2014 +0100

src: Add address family filter to nwrap_files_gethostbyname().

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

---

Summary of changes:
 ConfigureChecks.cmake|2 +
 config.h.cmake   |3 ++
 src/nss_wrapper.c|   42 ---
 tests/hosts.in   |2 +
 tests/test_gethostby_name_addr.c |   45 ++
 5 files changed, 90 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index afee1f8..b74ed8d 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -71,6 +71,8 @@ check_function_exists(getgrouplist HAVE_GETGROUPLIST)
 check_function_exists(gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
 check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
 
+check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
+
 if (WIN32)
 check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
 check_function_exists(_vsnprintf HAVE__VSNPRINTF)
diff --git a/config.h.cmake b/config.h.cmake
index 06e5738..b94b621 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -49,6 +49,9 @@
 /* Define to 1 if you have the `gethostbyname_r' function. */
 #cmakedefine HAVE_GETHOSTBYNAME_R 1
 
+/* Define to 1 if you have the `gethostbyname2' function. */
+#cmakedefine HAVE_GETHOSTBYNAME2 1
+
 #cmakedefine HAVE___POSIX_GETPWNAM_R 1
 #cmakedefine HAVE___POSIX_GETPWUID_R 1
 
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 94df6ac..2706196 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -230,6 +230,9 @@ struct nwrap_libc_fns {
void (*_libc_endhostent)(void);
 
struct hostent *(*_libc_gethostbyname)(const char *name);
+#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
+   struct hostent *(*_libc_gethostbyname2)(const char *name, int af);
+#endif
struct hostent *(*_libc_gethostbyaddr)(const void *addr, socklen_t len, 
int type);
 
int (*_libc_getaddrinfo)(const char *node, const char *service,
@@ -927,6 +930,15 @@ static struct hostent *libc_gethostbyname(const char *name)
return nwrap_main_global-libc-fns-_libc_gethostbyname(name);
 }
 
+#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
+static struct hostent *libc_gethostbyname2(const char *name, int af)
+{
+   nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname2);
+
+   return nwrap_main_global-libc-fns-_libc_gethostbyname2(name, af);
+}
+#endif
+
 static struct hostent *libc_gethostbyaddr(const void *addr,
  socklen_t len,
  int type)
@@ -2328,7 +2340,7 @@ static void nwrap_files_endgrent(struct nwrap_backend *b)
 }
 
 /* hosts functions */
-static struct hostent *nwrap_files_gethostbyname(const char *name)
+static struct hostent *nwrap_files_gethostbyname(const char *name, int af)
 {
struct hostent *he;
int i;
@@ -2340,6 +2352,11 @@ static struct hostent *nwrap_files_gethostbyname(const 
char *name)
 
he = nwrap_he_global.list[i].ht;
 
+   /* Filter by address familiy if provided */
+   if (af != AF_UNSPEC  he-h_addrtype != af) {
+   continue;
+   }
+
if (strcasecmp(he-h_name, name) == 0) {
NWRAP_LOG(NWRAP_LOG_DEBUG, name[%s] found, name);
return he;
@@ -2369,7 +2386,7 @@ static int nwrap_gethostbyname_r(const char *name,
 char *buf, size_t buflen,
 struct hostent **result, int *h_errnop)
 {
-   *result = nwrap_files_gethostbyname(name);
+   *result = 

[SCM] NSS Wrapper Repository - branch master updated

2014-03-14 Thread Andreas Schneider
The branch, master has been updated
   via  93db9fd README: Fix prefix env variable name.
   via  f24dbf6 tests: Add test_gethostent.c
  from  b928fe9 tests: Add test_gethostent.

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


- Log -
commit 93db9fd01cf556c49e4109c5901d4b4886bc1229
Author: Andreas Schneider a...@samba.org
Date:   Thu Mar 13 14:58:23 2014 +0100

README: Fix prefix env variable name.

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

commit f24dbf643575c764eb74bbc08de2ececc35f1659
Author: Andreas Schneider a...@samba.org
Date:   Thu Mar 13 13:46:22 2014 +0100

tests: Add test_gethostent.c

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

---

Summary of changes:
 README  |6 -
 tests/test_gethostent.c |   61 +++
 2 files changed, 66 insertions(+), 1 deletions(-)
 create mode 100644 tests/test_gethostent.c


Changeset truncated at 500 lines:

diff --git a/README b/README
index 3edef91..2ffa564 100644
--- a/README
+++ b/README
@@ -47,4 +47,8 @@ NSS_WRAPPER_MODULE_SO_PATH=/path/to/libnss_yourmodule.so
 As each nss module has a special prefix like _nss_winbind_getpwnam() you need
 to set the prefix too so nss_wrapper can load the functions with:
 
-NSS_WRAPPER_MODULE_FN_NAME=prefix
+NSS_WRAPPER_MODULE_FN_PREFIX=prefix
+
+For _nss_winbind_getpwnam() this would be:
+
+NSS_WRAPPER_MODULE_FN_PREFIX=winbind
diff --git a/tests/test_gethostent.c b/tests/test_gethostent.c
new file mode 100644
index 000..e95195f
--- /dev/null
+++ b/tests/test_gethostent.c
@@ -0,0 +1,61 @@
+#include config.h
+
+#include stdarg.h
+#include stddef.h
+#include setjmp.h
+#include cmocka.h
+
+#include stdio.h
+#include string.h
+#include unistd.h
+
+#include sys/socket.h
+#include netinet/in.h
+#include arpa/inet.h
+#include netdb.h
+
+static void test_nwrap_gethostent(void **state)
+{
+   struct hostent *he;
+   uint32_t i;
+
+   (void)state; /* unused */
+
+   sethostent(0);
+
+   for (he = gethostent(); he != NULL; he = gethostent()) {
+   assert_non_null(he-h_addr_list);
+   assert_non_null(he-h_aliases);
+
+   for (i = 0; he-h_addr_list[i] != NULL; i++) {
+   char buf[INET6_ADDRSTRLEN];
+   uint32_t j;
+   const char *ip;
+   
+   ip = inet_ntop(he-h_addrtype,
+  he-h_addr_list[i],
+  buf,
+  sizeof(buf));
+
+   printf(ip: %s\n, ip);
+
+   for (j = 0; he-h_aliases[j] != NULL; j++) {
+   printf(alias: %s\n, he-h_aliases[j]);
+   }
+   }
+   }
+
+   endhostent();
+}
+
+int main(void) {
+   int rc;
+
+   const UnitTest tests[] = {
+   unit_test(test_nwrap_gethostent),
+   };
+
+   rc = run_tests(tests);
+
+   return rc;
+}


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-03-13 Thread Andreas Schneider
The branch, master has been updated
   via  b928fe9 tests: Add test_gethostent.
   via  64c082a src: Fix segfault in 'getent hosts' without aliases.
  from  3d58327 Bump version to 1.0.1.

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


- Log -
commit b928fe9ff92a237ee4cffadfa517d76a4e07d80c
Author: Andreas Schneider a...@samba.org
Date:   Thu Mar 13 10:35:47 2014 +0100

tests: Add test_gethostent.

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

commit 64c082a393013e3fc9a0cce0afa5e426f55b5ccd
Author: Andreas Schneider a...@samba.org
Date:   Thu Mar 13 10:20:46 2014 +0100

src: Fix segfault in 'getent hosts' without aliases.

The glibc's 'getent' always dereferences he-h_aliases[i], so we need
to allocate it.

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

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 5685fc6..94df6ac 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -1950,7 +1950,12 @@ static bool nwrap_he_parse_line(struct nwrap_cache 
*nwrap, char *line)
 
ed-ht.h_name = n;
 
-   ed-ht.h_aliases = NULL;
+   /* glib's getent always dereferences he-h_aliases */
+   ed-ht.h_aliases = malloc(sizeof(char *));
+   if (ed-ht.h_aliases == NULL) {
+   return false;
+   }
+   ed-ht.h_aliases[0] = NULL;
 
/*
 * Aliases
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3b84829..5aab29e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -23,7 +23,7 @@ list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/hosts
 list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_MODULE_SO_PATH=${CMAKE_CURRENT_BINARY_DIR}/libnss_nwrap.so)
 list(APPEND TEST_ENVIRONMENT NSS_WRAPPER_MODULE_FN_PREFIX=nwrap)
 
-set(NWRAP_TESTS testsuite test_getaddrinfo test_getnameinfo 
test_gethostby_name_addr)
+set(NWRAP_TESTS testsuite test_getaddrinfo test_getnameinfo 
test_gethostby_name_addr test_gethostent)
 
 foreach(_NWRAP_TEST ${NWRAP_TESTS})
 add_cmocka_test(${_NWRAP_TEST} ${_NWRAP_TEST}.c ${TESTSUITE_LIBRARIES})


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-02-04 Thread Andreas Schneider
The branch, master has been updated
   via  3d58327 Bump version to 1.0.1.
   via  fb29d2d cmake: Add nss_wrapper-config.cmake.
   via  37a7c67 cmake: Use NSS_WRAPPER_LOCATION.
   via  9aeb8ae cmake: Add --libs output for pkg-config.
   via  3369dd7 cpack: Don't package the obj directory.
  from  bb1f815 src: Remove the localhost shortcut.

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


- Log -
commit 3d58327513c6bc7bbb3949cf27c5efdaafe22d69
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:24:44 2014 +0100

Bump version to 1.0.1.

commit fb29d2ddd2cf363c30cff1ce01790d25e1dfc5ae
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:23:37 2014 +0100

cmake: Add nss_wrapper-config.cmake.

commit 37a7c67728600e0947537610da7232e992844b7a
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:41:26 2014 +0100

cmake: Use NSS_WRAPPER_LOCATION.

commit 9aeb8aef5df4a4e14c55134e60c069156da4b8fc
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:22:37 2014 +0100

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

commit 3369dd74aa826954c8f8d34d2220a83f387707dc
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:19:18 2014 +0100

cpack: Don't package the obj directory.

---

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


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8359849..a83fb75 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})
 
@@ -56,7 +56,15 @@ install(
 DESTINATION
 ${BIN_INSTALL_DIR})
 
+if (UNIT_TESTING)
+find_package(CMocka REQUIRED)
+include(AddCMockaTest)
+add_subdirectory(tests)
+endif (UNIT_TESTING)
+
 # pkg-config file
+get_filename_component(NSS_WRAPPER_LIB ${NSS_WRAPPER_LOCATION} NAME)
+
 configure_file(nss_wrapper.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper.pc 
@ONLY)
 install(
   FILES
@@ -69,17 +77,14 @@ install(
 
 # cmake config files
 configure_file(nss_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake @ONLY)
+configure_file(nss_wrapper-config.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config.cmake @ONLY)
 install(
 FILES
 ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake
+${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config.cmake
 DESTINATION
 ${CMAKE_INSTALL_DIR}
 COMPONENT
 devel
 )
 
-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..d3307aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 ChangeLog
 ==
 
+version 1.0.1 (released 2014-02-04)
+  * Added --libs to pkg-config.
+  * Added nss_wrapper-config.cmake
+  * Fixed a bug packaging the obj directory.
+
 version 1.0.0 (released 2014-02-02)
   * Initial release
diff --git a/nss_wrapper-config.cmake.in b/nss_wrapper-config.cmake.in
new file mode 100644
index 000..ccf7113
--- /dev/null
+++ b/nss_wrapper-config.cmake.in
@@ -0,0 +1 @@
+set(NSS_WRAPPER_LIRBARY @LIB_INSTALL_DIR@/@NSS_WRAPPER_LIB@)
diff --git a/nss_wrapper.pc.cmake b/nss_wrapper.pc.cmake
index 6fb8ff2..9fca0f8 100644
--- a/nss_wrapper.pc.cmake
+++ b/nss_wrapper.pc.cmake
@@ -1,3 +1,4 @@
 Name: @APPLICATION_NAME@
 Description: The nss_wrapper library
 Version: @APPLICATION_VERSION@
+Libs: @LIB_INSTALL_DIR@/@NSS_WRAPPER_LIB@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b2c5012..089070a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,3 +20,7 @@ install(
   LIBRARY DESTINATION 

[SCM] NSS Wrapper Repository - branch master updated

2014-01-31 Thread Andreas Schneider
The branch, master has been updated
   via  bb1f815 src: Remove the localhost shortcut.
  from  e4c453a Add ChangeLog.

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


- Log -
commit bb1f815557255a9e9a1059510eef94e2f0ed4111
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Jan 30 16:15:07 2014 +0100

src: Remove the localhost shortcut.

If we do lookups for the hostname this could lead to wrong results if
socket_wrapper loaded and the libnss_myhostname module in use.

This could be tested with:

getent ahosts myhostname

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

---

Summary of changes:
 src/nss_wrapper.c |   28 
 1 files changed, 0 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 087dbdd..5685fc6 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -3812,34 +3812,6 @@ static int nwrap_getaddrinfo(const char *node,
ret = libc_getaddrinfo(node, service, hints, p);
if (ret == 0) {
*res = p;
-
-   switch (p-ai_family) {
-   case AF_INET:
-   {
-   struct sockaddr_in *sin =
-   (struct sockaddr_in *)p-ai_addr;
-
-   if (sin-sin_addr.s_addr == 
htonl(INADDR_LOOPBACK) ||
-   sin-sin_addr.s_addr == htonl(INADDR_ANY) ||
-   (sin-sin_addr.s_addr  htonl(0xff00)) 
== htonl(0xff00)) { /* some broadcast */
-   return ret;
-   }
-   }
-   break;
-#ifdef HAVE_IPV6
-   case AF_INET6:
-   {
-   struct sockaddr_in6 *sin6 =
-   (struct sockaddr_in6 *)p-ai_addr;
-
-   if (IN6_IS_ADDR_LOOPBACK(sin6-sin6_addr) ||
-   IN6_IS_ADDR_UNSPECIFIED(sin6-sin6_addr)) {
-   return ret;
-   }
-   }
-   break;
-#endif
-   }
}
 
/* If no node has been specified, let glibc deal with it */


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-01-30 Thread Andreas Schneider
The branch, master has been updated
   via  e4c453a Add ChangeLog.
  from  9c6b87c Add TODO.

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


- Log -
commit e4c453a5df480c0769a2fd08b878fd3b5b4cd160
Author: Andreas Schneider a...@samba.org
Date:   Thu Jan 30 18:06:56 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


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-01-24 Thread Andreas Schneider
The branch, master has been updated
   via  9c6b87c Add TODO.
  from  3f164d2 cmake: Update DefineInstallationPaths.cmake.

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


- Log -
commit 9c6b87c55c14cb471756e4df5658f1075d6f2a8d
Author: Andreas Schneider a...@samba.org
Date:   Fri Jan 24 10:45:06 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..a83f850
--- /dev/null
+++ b/TODO
@@ -0,0 +1,14 @@
+TODO
+=
+
+Library
+
+* None at the moment.
+
+Testing
+
+* Split the testsuite in several tests.
+* Add missing tests.
+  Check the code coverage on
+  http://mock.cryptomilk.org/index.php?project=nsswrapper
+  to see what tests are still needed.


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2014-01-22 Thread Andreas Schneider
The branch, master has been updated
   via  e7e1cf3 Update README.
   via  b711455 cmake: Add cmake config mode file.
   via  3f4070e cmake: Add pkgconfig file.
  from  6cf4553 nwrap: Fix fd checks.

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


- Log -
commit e7e1cf368958d20b8174e035e9faca8be291341e
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 22 10:33:06 2014 +0100

Update README.

commit b711455f25980f0e8bc6049c9f800d3fdbeac20a
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 22 10:29:07 2014 +0100

cmake: Add cmake config mode file.

commit 3f4070e7d15528e785fe11de8ca62ba56613f059
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 22 10:28:11 2014 +0100

cmake: Add pkgconfig file.

---

Summary of changes:
 CMakeLists.txt  |   22 
 README  |   47 +--
 nss_wrapper-config-version.cmake.in |   11 
 nss_wrapper.pc.cmake|3 ++
 4 files changed, 75 insertions(+), 8 deletions(-)
 create mode 100644 nss_wrapper-config-version.cmake.in
 create mode 100644 nss_wrapper.pc.cmake


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e8b0ad0..8359849 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,6 +56,28 @@ install(
 DESTINATION
 ${BIN_INSTALL_DIR})
 
+# pkg-config file
+configure_file(nss_wrapper.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper.pc 
@ONLY)
+install(
+  FILES
+${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper.pc
+  DESTINATION
+${LIB_INSTALL_DIR}/pkgconfig
+  COMPONENT
+pkgconfig
+)
+
+# cmake config files
+configure_file(nss_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake @ONLY)
+install(
+FILES
+${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake
+DESTINATION
+${CMAKE_INSTALL_DIR}
+COMPONENT
+devel
+)
+
 if (UNIT_TESTING)
 find_package(CMocka REQUIRED)
 include(AddCMockaTest)
diff --git a/README b/README
index 53646c7..3edef91 100644
--- a/README
+++ b/README
@@ -1,19 +1,50 @@
 NSS wrapper library
 
 
-This is a wrapper for the user, group and hosts NSS API allowing the use of
-other data sources.
+There are projects which provide daemons needing to be able to create, modify
+and delete unix users. Or just switch user ids to interact with the system e.g.
+a user space file server. To be able to test that you need the privilege to
+modify the passwd and groups file. With nss_wrapper it is possible to define
+your own passwd and groups file which will be used by software to act correctly
+while under test.
 
-To be able to use it you need to set the following environment variables:
+If you have a client and server under test they normally use functions to
+resolve network names to addresses (dns) or vice versa. The nss_wrappers allow
+you to create a hosts file to setup name resolution for the addresses you use
+with socket_wrapper.
+
+The first environment variable you need to set is:
 
 LD_PRELOAD=libnss_wrapper.so
-NSS_WRAPPER_PASSWD=/path/to/your/passwd
-NSS_WRAPPER_GROUP=/path/to/your/group
+
+For user and group accounts you need to create two files: 'passwd' and 'group'.
+The format of the passwd file is described in 'man 5 passwd' and the group file
+in 'man 5 group'. So you can fill these files with made up accounts. You point
+nss_wrapper to them using the two variables:
+
+NSS_WRAPPER_PASSWD=/path/to/your/passwd and
+NSS_WRAPPER_GROUP=/path/to/your/group.
+
+If you also need to emulate network name resolution in your enviornment,
+especially with socket_wrapper, you can write a hosts file. The format is
+described in 'man 5 hosts'. Then you can point nss_wrapper to your hosts
+file using:
 
 NSS_WRAPPER_HOSTS=/path/to/your/hosts
 
+If you need to return a hostname which is different from the one of your
+machine is using you can use:
+
 NSS_WRAPPER_HOSTNAME=test.example.org
 
-You can either enable user and group resolving or only hosts. If you don't know
-how the passwd file should look like, please read 'man 5 passwd', for the
-groups file 'man 5 group' and for hosts 'man 5 hosts'.
+If you have a project which also provides user and group information out of a
+database, you normally write your own nss modules. nss_wrapper is able to load
+nss modules and ask them first before looking into the faked passwd and group
+file. To point nss_wrapper to the module you can do that using
+
+NSS_WRAPPER_MODULE_SO_PATH=/path/to/libnss_yourmodule.so
+
+As each nss module has a special prefix like _nss_winbind_getpwnam() you need
+to set the prefix too so nss_wrapper can load the functions with:
+
+NSS_WRAPPER_MODULE_FN_NAME=prefix
diff --git a/nss_wrapper-config-version.cmake.in 

[SCM] NSS Wrapper Repository - branch master updated

2014-01-22 Thread Andreas Schneider
The branch, master has been updated
   via  3f164d2 cmake: Update DefineInstallationPaths.cmake.
  from  e7e1cf3 Update README.

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


- Log -
commit 3f164d209a727508b259037328b85060e6f4843e
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 22 10:33:40 2014 +0100

cmake: Update DefineInstallationPaths.cmake.

---

Summary of changes:
 cmake/Modules/DefineInstallationPaths.cmake |   29 +++---
 1 files changed, 17 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

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 ()


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  55b6717 tests: Fix building nss module on Solaris.
  from  8327732 tests: Add a dummy nss module and load it.

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


- Log -
commit 55b6717906de003c44dbb64a488d98af7cdf493f
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 09:10:21 2013 +0100

tests: Fix building nss module on Solaris.

---

Summary of changes:
 tests/nss_nwrap.c |   22 +-
 1 files changed, 21 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/nss_nwrap.c b/tests/nss_nwrap.c
index 5c59022..1e63dce 100644
--- a/tests/nss_nwrap.c
+++ b/tests/nss_nwrap.c
@@ -1,8 +1,28 @@
-#include nss.h
+#include config.h
+
 #include pwd.h
 #include grp.h
 
+#if defined(HAVE_NSS_H)
+/* Linux and BSD */
+#include nss.h
+
 typedef enum nss_status NSS_STATUS;
+#elif defined(HAVE_NSS_COMMON_H)
+/* Solaris */
+#include nss_common.h
+#include nss_dbdefs.h
+#include nsswitch.h
+
+typedef nss_status_t NSS_STATUS;
+
+# define NSS_STATUS_SUCCESS NSS_SUCCESS
+# define NSS_STATUS_NOTFOUNDNSS_NOTFOUND
+# define NSS_STATUS_UNAVAIL NSS_UNAVAIL
+# define NSS_STATUS_TRYAGAINNSS_TRYAGAIN
+#else
+# error No nsswitch support detected
+#endif
 
 NSS_STATUS _nss_nwrap_setpwent(void);
 NSS_STATUS _nss_nwrap_endpwent(void);


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  4ad5d31 cmake: Fix the env name for the module variables.
  from  55b6717 tests: Fix building nss module on Solaris.

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


- Log -
commit 4ad5d31e4a1f7c5391ccc0e7d95c13ef56986e12
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 09:20:32 2013 +0100

cmake: Fix the env name for the module variables.

---

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


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 34d718f..d73ec2f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -20,8 +20,8 @@ set(TEST_ENVIRONMENT 
LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libnss_wrapper.so)
 list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_PASSWD=${CMAKE_CURRENT_BINARY_DIR}/passwd)
 list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_GROUP=${CMAKE_CURRENT_BINARY_DIR}/group)
 list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/hosts)
-list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_SO_PATH=${CMAKE_CURRENT_BINARY_DIR}/libnss_nwrap.so)
-list(APPEND TEST_ENVIRONMENT NSS_WRAPPER_SO_PREFIX=nwrap)
+list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_MODULE_SO_PATH=${CMAKE_CURRENT_BINARY_DIR}/libnss_nwrap.so)
+list(APPEND TEST_ENVIRONMENT NSS_WRAPPER_MODULE_FN_PREFIX=nwrap)
 
 set(NWRAP_TESTS testsuite test_getaddrinfo test_getnameinfo 
test_gethostby_name_addr)
 


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  83948bc nwrap: Add a destructor to free resources.
   via  50b0fd9 cmake: Check for printf format attribute.
  from  4ad5d31 cmake: Fix the env name for the module variables.

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


- Log -
commit 83948bc7c16bbb4ceefaf4e1f4634e8510c2d3ad
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 10:35:38 2013 +0100

nwrap: Add a destructor to free resources.

commit 50b0fd9153dd2ffe7ec5428e5b64d87406a76130
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 09:33:00 2013 +0100

cmake: Check for printf format attribute.

---

Summary of changes:
 ConfigureChecks.cmake |   19 +++
 config.h.cmake|3 ++
 src/nss_wrapper.c |   87 +++-
 3 files changed, 107 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 8c7539a..afee1f8 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -218,6 +218,25 @@ int main(void) {
 return 0;
 } HAVE_IPV6)
 
+check_c_source_compiles(
+void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+
+int main(void) {
+return 0;
+} HAVE_ATTRIBUTE_PRINTF_FORMAT)
+
+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)
+
 check_library_exists(dl dlopen  HAVE_LIBDL)
 if (HAVE_LIBDL)
 find_library(DLFCN_LIBRARY dl)
diff --git a/config.h.cmake b/config.h.cmake
index 1fd9281..06e5738 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -78,6 +78,9 @@
 #cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1
 #cmakedefine HAVE_IPV6 1
 
+#cmakedefine HAVE_ATTRIBUTE_PRINTF_FORMAT 1
+#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+
 /*** ENDIAN */
 
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 3e6d072..6b50c68 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -122,11 +122,17 @@ typedef nss_status_t NSS_STATUS;
 #endif
 
 /* GCC have printf type attribute check. */
-#ifdef __GNUC__
+#ifdef HAVE_ATTRIBUTE_PRINTF_FORMAT
 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
 #else
 #define PRINTF_ATTRIBUTE(a,b)
-#endif /* __GNUC__ */
+#endif /* HAVE_ATTRIBUTE_PRINTF_FORMAT */
+
+#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
+#define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
+#else
+#define DESTRUCTOR_ATTRIBUTE
+#endif /* HAVE_DESTRUCTOR_ATTRIBUTE */
 
 #define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, 
sizeof(*(x))); } while(0)
 
@@ -505,9 +511,15 @@ struct nwrap_he {
 struct nwrap_cache __nwrap_cache_he;
 struct nwrap_he nwrap_he_global;
 
+
+/*
+ * NWRAP PROTOTYPES
+ */
+
 static void nwrap_init(void);
 static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_gr_unload(struct nwrap_cache *nwrap);
+void nwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*
  * NWRAP LIBC LOADER FUNCTIONS
@@ -4127,3 +4139,74 @@ int gethostname(char *name, size_t len)
 
return nwrap_gethostname(name, len);
 }
+
+/
+ * DESTRUCTOR
+ ***/
+
+/*
+ * This function is called when the library is unloaded and makes sure that
+ * sockets get closed and the unix file for the socket are unlinked.
+ */
+void nwrap_destructor(void)
+{
+   int i;
+
+   if (nwrap_main_global != NULL) {
+   struct nwrap_main *m = nwrap_main_global;
+
+   /* libc */
+   SAFE_FREE(m-libc-fns);
+   if (m-libc-handle != NULL) {
+   dlclose(m-libc-handle);
+   }
+   if (m-libc-nsl_handle != NULL) {
+   dlclose(m-libc-nsl_handle);
+   }
+   if (m-libc-sock_handle != NULL) {
+   dlclose(m-libc-sock_handle);
+   }
+   SAFE_FREE(m-libc);
+
+   /* backends */
+   for (i = 0; i  m-num_backends; i++) {
+   struct nwrap_backend *b = (m-backends[i]);
+
+   if (b-so_handle != NULL) {
+   dlclose(b-so_handle);
+   }
+   SAFE_FREE(b-fns);
+   }
+   SAFE_FREE(m-backends);
+   }
+
+   if (nwrap_pw_global.cache != NULL) {
+   struct nwrap_cache *c = nwrap_pw_global.cache;
+
+   

[SCM] NSS Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  6169a63 tests: Add missing includes for test_nwrap_disabled.
  from  83948bc nwrap: Add a destructor to free resources.

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


- Log -
commit 6169a63754ea383ac3053cfeefdc70a6837ce30e
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 10:47:25 2013 +0100

tests: Add missing includes for test_nwrap_disabled.

This should fix the build on FreeBSD.

---

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


Changeset truncated at 500 lines:

diff --git a/tests/test_nwrap_disabled.c b/tests/test_nwrap_disabled.c
index fff7041..a64cee4 100644
--- a/tests/test_nwrap_disabled.c
+++ b/tests/test_nwrap_disabled.c
@@ -6,6 +6,9 @@
 #include cmocka.h
 
 #include sys/types.h
+#include sys/socket.h
+#include arpa/inet.h
+#include netinet/in.h
 #include netdb.h
 #include pwd.h
 #include grp.h


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  21bce5e cmake: Add a valgrind suppression file.
   via  f6545a3 nwrap: Don't call close on a fd of -1.
   via  75ac11b nwrap: Fix loading the system libraries.
  from  6169a63 tests: Add missing includes for test_nwrap_disabled.

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


- Log -
commit 21bce5e006babe632e7587cad903a922bb4ef5ce
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:33:29 2013 +0100

cmake: Add a valgrind suppression file.

commit f6545a35c447dbd94efe6374ac55a41d92b787b1
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:32:50 2013 +0100

nwrap: Don't call close on a fd of -1.

valgrind complains about it.

commit 75ac11b6f109d438e2b0c08d534c2069caa5d06b
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:21:31 2013 +0100

nwrap: Fix loading the system libraries.

Thanks metze!

---

Summary of changes:
 src/nss_wrapper.c   |   21 -
 tests/valgrind.supp |   15 +++
 2 files changed, 27 insertions(+), 9 deletions(-)
 create mode 100644 tests/valgrind.supp


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 6b50c68..829453e 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -565,6 +565,7 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
switch (lib) {
case NWRAP_LIBNSL:
 #ifdef HAVE_LIBNSL
+   handle = nwrap_main_global-libc-nsl_handle;
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -574,14 +575,13 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
}
 
nwrap_main_global-libc-nsl_handle = handle;
-   } else {
-   handle = nwrap_main_global-libc-nsl_handle;
}
break;
 #endif
/* FALL TROUGH */
case NWRAP_LIBSOCKET:
 #ifdef HAVE_LIBSOCKET
+   handle = nwrap_main_global-libc-sock_handle;
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -591,13 +591,12 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
}
 
nwrap_main_global-libc-sock_handle = handle;
-   } else {
-   handle = nwrap_main_global-libc-sock_handle;
}
break;
 #endif
/* FALL TROUGH */
case NWRAP_LIBC:
+   handle = nwrap_main_global-libc-handle;
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -607,8 +606,6 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
}
 
nwrap_main_global-libc-handle = handle;
-   } else {
-   handle = nwrap_main_global-libc-handle;
}
break;
}
@@ -4184,7 +4181,9 @@ void nwrap_destructor(void)
struct nwrap_cache *c = nwrap_pw_global.cache;
 
nwrap_files_cache_unload(c);
-   close(c-fd);
+   if (c-fd  0) {
+   close(c-fd);
+   }
 
SAFE_FREE(nwrap_pw_global.list);
nwrap_pw_global.num = 0;
@@ -4194,7 +4193,9 @@ void nwrap_destructor(void)
struct nwrap_cache *c = nwrap_gr_global.cache;
 
nwrap_files_cache_unload(c);
-   close(c-fd);
+   if (c-fd  0) {
+   close(c-fd);
+   }
 
SAFE_FREE(nwrap_gr_global.list);
nwrap_pw_global.num = 0;
@@ -4204,7 +4205,9 @@ void nwrap_destructor(void)
struct nwrap_cache *c = nwrap_he_global.cache;
 
nwrap_files_cache_unload(c);
-   close(c-fd);
+   if (c-fd  0) {
+   close(c-fd);
+   }
 
SAFE_FREE(nwrap_he_global.list);
nwrap_he_global.num = 0;
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
new file mode 100644
index 000..95c980b
--- /dev/null
+++ b/tests/valgrind.supp
@@ -0,0 +1,15 @@
+### GLIBC
+
+{
+   glibc_dlopen_worker_alloc
+   Memcheck:Leak
+   fun:*alloc
+   ...
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.2.5
+}


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  6cf4553 nwrap: Fix fd checks.
  from  21bce5e cmake: Add a valgrind suppression file.

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


- Log -
commit 6cf45534f1d6c6d888d62b551cc7883ac0d2e1cc
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 15:53:42 2013 +0100

nwrap: Fix fd checks.

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 829453e..087dbdd 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -4181,7 +4181,7 @@ void nwrap_destructor(void)
struct nwrap_cache *c = nwrap_pw_global.cache;
 
nwrap_files_cache_unload(c);
-   if (c-fd  0) {
+   if (c-fd = 0) {
close(c-fd);
}
 
@@ -4193,7 +4193,7 @@ void nwrap_destructor(void)
struct nwrap_cache *c = nwrap_gr_global.cache;
 
nwrap_files_cache_unload(c);
-   if (c-fd  0) {
+   if (c-fd = 0) {
close(c-fd);
}
 
@@ -4205,7 +4205,7 @@ void nwrap_destructor(void)
struct nwrap_cache *c = nwrap_he_global.cache;
 
nwrap_files_cache_unload(c);
-   if (c-fd  0) {
+   if (c-fd = 0) {
close(c-fd);
}
 


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-19 Thread Andreas Schneider
The branch, master has been updated
   via  6d9789c nwrap: Fix function loading on Solaris.
  from  a5bea85 tests: Load nss_wrapper for test_nwrap_disabled().

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


- Log -
commit 6d9789c9357e971a0ae2820563637e22df02cb83
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 10:16:06 2013 +0100

nwrap: Fix function loading on Solaris.

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 7083dcd..cd04a79 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -663,7 +663,7 @@ static int libc_getpwnam_r(const char *name,
 #ifdef HAVE___POSIX_GETPWNAM_R
if (nwrap_main_global-libc-fns-_libc_getpwnam_r == NULL) {
*(void **) (nwrap_main_global-libc-fns-_libc_getpwnam_r) =
-   _nwrap_load_lib_function(lib, __posix_getpwnam_r);
+   _nwrap_load_lib_function(NWRAP_LIBC, 
__posix_getpwnam_r);
}
 #else
nwrap_load_lib_function(NWRAP_LIBC, getpwnam_r);
@@ -694,7 +694,7 @@ static int libc_getpwuid_r(uid_t uid,
 #ifdef HAVE___POSIX_GETPWUID_R
if (nwrap_main_global-libc-fns-_libc_getpwuid_r == NULL) {
*(void **) (nwrap_main_global-libc-fns-_libc_getpwuid_r) =
-   _nwrap_load_lib_function(lib, __posix_getpwuid_r);
+   _nwrap_load_lib_function(NWRAP_LIBC, 
__posix_getpwuid_r);
}
 #else
nwrap_load_lib_function(NWRAP_LIBC, getpwuid_r);
@@ -777,7 +777,10 @@ static int libc_getgrnam_r(const char *name,
   struct group **result)
 {
 #ifdef HAVE___POSIX_GETGRNAM_R
-   nwrap_load_lib_function(NWRAP_LIBC, __posix_getgrnam_r);
+   if (nwrap_main_global-libc-fns-_libc_getgrnam_r == NULL) {
+   *(void **) (nwrap_main_global-libc-fns-_libc_getgrnam_r) =
+   _nwrap_load_lib_function(NWRAP_LIBC, 
__posix_getgrnam_r);
+   }
 #else
nwrap_load_lib_function(NWRAP_LIBC, getgrnam_r);
 #endif
@@ -805,7 +808,10 @@ static int libc_getgrgid_r(gid_t gid,
   struct group **result)
 {
 #ifdef HAVE___POSIX_GETGRGID_R
-   nwrap_load_lib_function(NWRAP_LIBC, __posix_getgrgid_r);
+   if (nwrap_main_global-libc-fns-_libc_getgrgid_r == NULL) {
+   *(void **) (nwrap_main_global-libc-fns-_libc_getgrgid_r) =
+   _nwrap_load_lib_function(NWRAP_LIBC, 
__posix_getgrgid_r);
+   }
 #else
nwrap_load_lib_function(NWRAP_LIBC, getgrgid_r);
 #endif


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-19 Thread Andreas Schneider
The branch, master has been updated
   via  cd1a113 nwrap: Zero the allocated libc memory.
  from  6d9789c nwrap: Fix function loading on Solaris.

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


- Log -
commit cd1a1130ae609fe3c9f449d56a2ce7f5fb94d39b
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 11:18:40 2013 +0100

nwrap: Zero the allocated libc memory.

If not then this leads to setfaults cause the libc handle is pointing to
random memory.

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index cd04a79..7ceff25 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -128,6 +128,8 @@ typedef nss_status_t NSS_STATUS;
 #define PRINTF_ATTRIBUTE(a,b)
 #endif /* __GNUC__ */
 
+#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, 
sizeof(*(x))); } while(0)
+
 enum nwrap_dbglvl_e {
NWRAP_LOG_ERROR = 0,
NWRAP_LOG_WARN,
@@ -1141,12 +1143,14 @@ static void nwrap_libc_init(struct nwrap_main *r)
printf(Failed to allocate memory for libc);
exit(-1);
}
+   ZERO_STRUCTP(r-libc);
 
r-libc-fns = malloc(sizeof(struct nwrap_libc_fns));
if (r-libc-fns == NULL) {
printf(Failed to allocate memory for libc functions);
exit(-1);
}
+   ZERO_STRUCTP(r-libc-fns);
 }
 
 static void nwrap_backend_init(struct nwrap_main *r)


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-19 Thread Andreas Schneider
The branch, master has been updated
   via  c472118 nwrap: Rename FN_NAME to FN_PREFIX.
  from  cd1a113 nwrap: Zero the allocated libc memory.

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


- Log -
commit c4721187bbcb4ab90660d1e7bb30e9014e1eb9c4
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 12:50:19 2013 +0100

nwrap: Rename FN_NAME to FN_PREFIX.

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 7ceff25..3e6d072 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -1156,7 +1156,7 @@ static void nwrap_libc_init(struct nwrap_main *r)
 static void nwrap_backend_init(struct nwrap_main *r)
 {
const char *module_so_path = getenv(NSS_WRAPPER_MODULE_SO_PATH);
-   const char *module_fn_name = getenv(NSS_WRAPPER_MODULE_FN_NAME);
+   const char *module_fn_name = getenv(NSS_WRAPPER_MODULE_FN_PREFIX);
 
r-num_backends = 0;
r-backends = NULL;


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-19 Thread Andreas Schneider
The branch, master has been updated
   via  8327732 tests: Add a dummy nss module and load it.
  from  c472118 nwrap: Rename FN_NAME to FN_PREFIX.

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


- Log -
commit 83277324c9430b929e0270489aca79522bd3f732
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 15:01:55 2013 +0100

tests: Add a dummy nss module and load it.

---

Summary of changes:
 tests/CMakeLists.txt |9 +++-
 tests/nss_nwrap.c|  131 ++
 2 files changed, 139 insertions(+), 1 deletions(-)
 create mode 100644 tests/nss_nwrap.c


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index df76bb2..34d718f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -8,13 +8,20 @@ include_directories(
 
 set(TESTSUITE_LIBRARIES ${NWRAP_REQUIRED_LIBRARIES} ${CMOCKA_LIBRARY})
 
+add_library(nss_nwrap SHARED nss_nwrap.c)
+
 set(HOMEDIR ${CMAKE_CURRENT_BINARY_DIR})
 
 configure_file(passwd.in ${CMAKE_CURRENT_BINARY_DIR}/passwd @ONLY)
 configure_file(group.in ${CMAKE_CURRENT_BINARY_DIR}/group @ONLY)
 configure_file(hosts.in ${CMAKE_CURRENT_BINARY_DIR}/hosts @ONLY)
 
-set(TEST_ENVIRONMENT 
LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libnss_wrapper.so;NSS_WRAPPER_PASSWD=${CMAKE_CURRENT_BINARY_DIR}/passwd;NSS_WRAPPER_GROUP=${CMAKE_CURRENT_BINARY_DIR}/group;NSS_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/hosts)
+set(TEST_ENVIRONMENT LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libnss_wrapper.so)
+list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_PASSWD=${CMAKE_CURRENT_BINARY_DIR}/passwd)
+list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_GROUP=${CMAKE_CURRENT_BINARY_DIR}/group)
+list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/hosts)
+list(APPEND TEST_ENVIRONMENT 
NSS_WRAPPER_SO_PATH=${CMAKE_CURRENT_BINARY_DIR}/libnss_nwrap.so)
+list(APPEND TEST_ENVIRONMENT NSS_WRAPPER_SO_PREFIX=nwrap)
 
 set(NWRAP_TESTS testsuite test_getaddrinfo test_getnameinfo 
test_gethostby_name_addr)
 
diff --git a/tests/nss_nwrap.c b/tests/nss_nwrap.c
new file mode 100644
index 000..5c59022
--- /dev/null
+++ b/tests/nss_nwrap.c
@@ -0,0 +1,131 @@
+#include nss.h
+#include pwd.h
+#include grp.h
+
+typedef enum nss_status NSS_STATUS;
+
+NSS_STATUS _nss_nwrap_setpwent(void);
+NSS_STATUS _nss_nwrap_endpwent(void);
+NSS_STATUS _nss_nwrap_getpwent_r(struct passwd *result, char *buffer,
+size_t buflen, int *errnop);
+NSS_STATUS _nss_nwrap_getpwuid_r(uid_t uid, struct passwd *result,
+char *buffer, size_t buflen, int *errnop);
+NSS_STATUS _nss_nwrap_getpwnam_r(const char *name, struct passwd *result,
+  char *buffer, size_t buflen, int *errnop);
+NSS_STATUS _nss_nwrap_setgrent(void);
+NSS_STATUS _nss_nwrap_endgrent(void);
+NSS_STATUS _nss_nwrap_getgrent_r(struct group *result, char *buffer,
+size_t buflen, int *errnop);
+NSS_STATUS _nss_nwrap_getgrnam_r(const char *name, struct group *result,
+char *buffer, size_t buflen, int *errnop);
+NSS_STATUS _nss_nwrap_getgrgid_r(gid_t gid, struct group *result, char *buffer,
+size_t buflen, int *errnop);
+NSS_STATUS _nss_nwrap_initgroups_dyn(char *user, gid_t group, long int *start,
+long int *size, gid_t **groups,
+long int limit, int *errnop);
+
+NSS_STATUS _nss_nwrap_setpwent(void)
+{
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_endpwent(void)
+{
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_getpwent_r(struct passwd *result, char *buffer,
+size_t buflen, int *errnop)
+{
+   (void) result;
+   (void) buffer;
+   (void) buflen;
+   (void) errnop;
+
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_getpwuid_r(uid_t uid, struct passwd *result,
+char *buffer, size_t buflen, int *errnop)
+{
+   (void) uid;
+   (void) result;
+   (void) buffer;
+   (void) buflen;
+   (void) errnop;
+
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_getpwnam_r(const char *name, struct passwd *result,
+char *buffer, size_t buflen, int *errnop)
+{
+   (void) name;
+   (void) result;
+   (void) buffer;
+   (void) buflen;
+   (void) errnop;
+
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_setgrent(void)
+{
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_endgrent(void)
+{
+   return NSS_STATUS_UNAVAIL;
+}
+
+NSS_STATUS _nss_nwrap_getgrent_r(struct group *result, char *buffer,
+size_t buflen, int *errnop)
+{
+   (void) result;
+   

[SCM] NSS Wrapper Repository - branch master updated

2013-12-18 Thread Andreas Schneider
The branch, master has been updated
   via  bb76afd nwrap: Fix loading posix functions on Solaris.
   via  2d783c6 nwrap: Remove copy and paste obsolete line.
  from  c7a1361 nwrap: Remove obsolete nwrap_libc_fn().

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


- Log -
commit bb76afd6f4a41a8ec9dc95e403d82b77471d09ad
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 09:40:14 2013 +0100

nwrap: Fix loading posix functions on Solaris.

commit 2d783c62cf75777030d90c0e2ef8028c0a8a68c1
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 09:36:18 2013 +0100

nwrap: Remove copy and paste obsolete line.

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 1f7ae3b..e412299 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -576,7 +576,6 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
handle = dlopen(soname, flags);
}
 
-   swrap.libsocket_handle = handle;
nwrap_main_global-libc-sock_handle = handle;
} else {
handle = nwrap_main_global-libc-sock_handle;
@@ -662,7 +661,10 @@ static int libc_getpwnam_r(const char *name,
   struct passwd **result)
 {
 #ifdef HAVE___POSIX_GETPWNAM_R
-   nwrap_load_lib_function(NWRAP_LIBC, __posix_getpwnam_r);
+   if (nwrap_main_global-libc-fns-_libc_getpwnam_r == NULL) {
+   *(void **) (nwrap_main_global-libc-fns-_libc_getpwnam_r) =
+   _nwrap_load_lib_function(lib, __posix_getpwnam_r);
+   }
 #else
nwrap_load_lib_function(NWRAP_LIBC, getpwnam_r);
 #endif
@@ -690,9 +692,12 @@ static int libc_getpwuid_r(uid_t uid,
   struct passwd **result)
 {
 #ifdef HAVE___POSIX_GETPWUID_R
-   nwrap_load_lib_function(NWRAP_LIBC, __posix_getpwuid_r);
+   if (nwrap_main_global-libc-fns-_libc_getpwuid_r == NULL) {
+   *(void **) (nwrap_main_global-libc-fns-_libc_getpwuid_r) =
+   _nwrap_load_lib_function(lib, __posix_getpwuid_r);
+   }
 #else
-   nwrap_load_lib_function(NWRAP_LIBC, getpwuid);
+   nwrap_load_lib_function(NWRAP_LIBC, getpwuid_r);
 #endif
 
return nwrap_main_global-libc-fns-_libc_getpwuid_r(uid,


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-18 Thread Andreas Schneider
The branch, master has been updated
   via  42c96a9 nwrap: Only compile nwrap_getgrouplist if supported.
  from  bb76afd nwrap: Fix loading posix functions on Solaris.

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


- Log -
commit 42c96a9393db2ee0ffe9d7a8671f303bc55b473d
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 18 09:42:17 2013 +0100

nwrap: Only compile nwrap_getgrouplist if supported.

---

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


Changeset truncated at 500 lines:

diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index e412299..7083dcd 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -3481,6 +3481,7 @@ void endgrent(void)
  *   GETGROUPLIST
  ***/
 
+#ifdef HAVE_GETGROUPLIST
 static int nwrap_getgrouplist(const char *user, gid_t group,
  gid_t *groups, int *ngroups)
 {
@@ -3556,7 +3557,6 @@ static int nwrap_getgrouplist(const char *user, gid_t 
group,
return count;
 }
 
-#ifdef HAVE_GETGROUPLIST
 int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups)
 {
if (!nwrap_enabled()) {


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-18 Thread Andreas Schneider
The branch, master has been updated
   via  a5bea85 tests: Load nss_wrapper for test_nwrap_disabled().
  from  42c96a9 nwrap: Only compile nwrap_getgrouplist if supported.

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


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

tests: Load nss_wrapper for test_nwrap_disabled().

We want to test the direct libc calls inside nss_wrapper.

---

Summary of changes:
 tests/CMakeLists.txt |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 2f40998..df76bb2 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -29,3 +29,8 @@ endforeach()
 
 # Test nwrap without wrapping so the libc functions are called
 add_cmocka_test(test_nwrap_disabled test_nwrap_disabled.c 
${TESTSUITE_LIBRARIES})
+set_property(
+TEST
+test_nwrap_disabled
+PROPERTY
+ENVIRONMENT LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libnss_wrapper.so)


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-17 Thread Andreas Schneider
The branch, master has been updated
   via  c7a1361 nwrap: Remove obsolete nwrap_libc_fn().
   via  774e09c nwrap: Add libc_getnameinfo().
   via  da31d1c tests: Add getaddrinfo libsocket test.
   via  4f43a3c nwrap: Add libc_getaddrinfo().
   via  b68508d nwrap: Add libc_gethostbyaddr_r().
   via  b7ac818 nwrap: Add libc_gethostbyname_r().
   via  8f57370 tests: Add gethostname libnsl test.
   via  3ad5684 nwrap: Add libc_gethostname().
   via  62cfb80 nwrap: Add libc_gethostbyaddr().
   via  1ccea54 nwrap: Add libc_gethostbyname().
   via  afd7c5e tests: Add libnsl hostent test.
   via  0ae6477 nwrap: Add libc_gethostent().
   via  04a3892 nwrap: Add libc_sethostent().
   via  8d45afe nwrap: Add libc_getgrouplist().
   via  a4c9907 nwrap: Add libc_entgrent().
   via  220f276 nwrap: Add libc_getgrent_r().
   via  c72bd3f nwrap: Add libc_getgrent().
   via  68e38fe nwrap: Add libc_setgrent().
   via  b3f2164 nwrap: Add libc_getgrgid_r().
   via  dfabe52 nwrap: Add libc_getgrgid().
   via  9a9f8c5 nwrap: Add libc_getgrnam_r().
   via  db29481 tests: Add test to check if libc functions are loaded 
correctly.
   via  bde38cd cmake: Simplify test calling.
   via  40e587c nwrap: Add libc_getgrnam().
   via  330a6a8 nwrap: Add libc_initgroups().
   via  5b3d912 nwrap: Add libc_endpwent().
   via  42676e2 nwrap: Add libc_getpwent_r().
   via  4223f18 nwrap: Add libc_getpwent().
   via  c0fec19 nwrap: Add libc_setpwent().
   via  5125cce nwrap: Add libc_getpwuid_r().
   via  e95234d nwrap: Add libc_getpwuid().
   via  e5dabbd nwrap: Add libc_getpwnam_r().
   via  e2ff29e nwrap: Add libc_getpwnam().
   via  d14acdd nwrap: Add nwrap_load_lib_function().
   via  0015233 nwrap: Add nwrap_load_lib_handle().
   via  7c0801b Add more directories and definitons to .clang_complete.
  from  fa30df7 cmake: Set _FORTIFY_SOURCE only for optimized builds.

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


- Log -
commit c7a1361b173f29c35ca399a2075a68f026ed6dbf
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:45:14 2013 +0100

nwrap: Remove obsolete nwrap_libc_fn().

commit 774e09c88d59c9dd7e2fc6acb34f8ee07d4c3574
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:44:41 2013 +0100

nwrap: Add libc_getnameinfo().

commit da31d1c3f96a32c433790c94b732734aae2e4fff
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:40:52 2013 +0100

tests: Add getaddrinfo libsocket test.

commit 4f43a3c9f0312f121ac86ebce46593644e9257f6
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:40:41 2013 +0100

nwrap: Add libc_getaddrinfo().

commit b68508de14d098fb02e2649b2a9be819d4e672f5
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:33:54 2013 +0100

nwrap: Add libc_gethostbyaddr_r().

commit b7ac8181eaa22ac23be09329b1fbb8d40dcd5dd4
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:31:54 2013 +0100

nwrap: Add libc_gethostbyname_r().

commit 8f5737012ed36c7c03ae23854cb00c06067e418e
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:26:44 2013 +0100

tests: Add gethostname libnsl test.

commit 3ad5684aea931235f2812732707b7e554e69fb19
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:24:02 2013 +0100

nwrap: Add libc_gethostname().

commit 62cfb8008afb72dbb26fdace3f7b2ca8acb233e8
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:22:22 2013 +0100

nwrap: Add libc_gethostbyaddr().

commit 1ccea5429ae99a1662412041a30c9333d7720dd6
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:20:04 2013 +0100

nwrap: Add libc_gethostbyname().

commit afd7c5e9c5d7d895a7bcd7f9e4ec7c6ea39f13da
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:17:42 2013 +0100

tests: Add libnsl hostent test.

commit 0ae6477f61db7b82cc00aaa4b581c61fcd924460
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:17:25 2013 +0100

nwrap: Add libc_gethostent().

commit 04a3892a3d7522a0af29a135baaaf630bb405ad4
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:11:57 2013 +0100

nwrap: Add libc_sethostent().

commit 8d45afe13552a587b651f56ecb41ef7c74698693
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:09:56 2013 +0100

nwrap: Add libc_getgrouplist().

commit a4c9907ec0f9379cf1ef02cf00947b806c031abb
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:07:48 2013 +0100

nwrap: Add libc_entgrent().

commit 220f2766e2ff2bfa08ea4fc1208b9ba4802729e9
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:06:34 2013 +0100

nwrap: Add libc_getgrent_r().

commit c72bd3f7916a7677c7718eca227112513646c39e
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 12:02:43 2013 +0100

nwrap: Add libc_getgrent().

commit 

[SCM] NSS Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  20f4de9 cmake: Check for getnameinfo on older distributions.
   via  93adc03 Add .gitignore.
  from  7e63f09 nwrap: Try to fix some compile warning.

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


- Log -
commit 20f4de9ddc490caf8df57eb01240527a54b0
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 16:44:13 2013 +0100

cmake: Check for getnameinfo on older distributions.

This should fix the build on CentOS 5.5.

commit 93adc03b15c39b8537a9ccdf4f0033009f64fb89
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 16:43:43 2013 +0100

Add .gitignore.

---

Summary of changes:
 .gitignore|9 +
 ConfigureChecks.cmake |6 ++
 config.h.cmake|1 +
 src/nss_wrapper.c |5 +
 4 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore


Changeset truncated at 500 lines:

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..8fd1310
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+*.a
+*.o
+.*
+*.swp
+*~$
+build
+obj
+cscope.*
+tags
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index ef689b8..8c7539a 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -177,6 +177,12 @@ check_prototype_definition(getnameinfo
 unistd.h;netdb.h
 HAVE_LINUX_GETNAMEINFO)
 
+check_prototype_definition(getnameinfo
+int getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, 
socklen_t __hostlen, char *serv, socklen_t servlen, unsigned int flags)
+-1
+unistd.h;netdb.h
+HAVE_LINUX_GETNAMEINFO_UNSIGNED)
+
 # STRUCT MEMBERS
 check_struct_has_member(struct sockaddr sa_len sys/socket.h netinet/in.h 
HAVE_STRUCT_SOCKADDR_SA_LEN)
 
diff --git a/config.h.cmake b/config.h.cmake
index c1523ae..1fd9281 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -73,6 +73,7 @@
 #cmakedefine HAVE_SOLARIS_GETHOSTNAME 1
 #cmakedefine HAVE_BSD_SETGRENT 1
 #cmakedefine HAVE_LINUX_GETNAMEINFO 1
+#cmakedefine HAVE_LINUX_GETNAMEINFO_UNSIGNED 1
 
 #cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1
 #cmakedefine HAVE_IPV6 1
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 546fa10..c00e5cb 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -3745,6 +3745,11 @@ int getnameinfo(const struct sockaddr *sa, socklen_t 
salen,
char *host, socklen_t hostlen,
char *serv, socklen_t servlen,
int flags)
+#elif defined(HAVE_LINUX_GETNAMEINFO_UNSIGNED)
+int getnameinfo(const struct sockaddr *sa, socklen_t salen,
+   char *host, socklen_t hostlen,
+   char *serv, socklen_t servlen,
+   unsigned int flags)
 #else
 int getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  008f270 tests: Use AF_INET6 for testing.
  from  20f4de9 cmake: Check for getnameinfo on older distributions.

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


- Log -
commit 008f2703feea994f9578a504fb733ef41da170a3
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 16:49:38 2013 +0100

tests: Use AF_INET6 for testing.

---

Summary of changes:
 tests/test_getaddrinfo.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index 71b08cd..4825e77 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -274,7 +274,7 @@ static void test_nwrap_getaddrinfo_null(void **state)
(void) state; /* unused */
 
memset(hints, 0, sizeof(struct addrinfo));
-   hints.ai_family = AF_UNSPEC;
+   hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 17;
hints.ai_flags = AI_ADDRCONFIG;


-- 
NSS Wrapper Repository


[SCM] NSS Wrapper Repository - branch master updated

2013-12-04 Thread Andreas Schneider
The branch, master has been updated
   via  fa30df7 cmake: Set _FORTIFY_SOURCE only for optimized builds.
  from  008f270 tests: Use AF_INET6 for testing.

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


- Log -
commit fa30df7c002410e6530d88602cc11244fec37c88
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed Dec 4 17:40:27 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()


-- 
NSS Wrapper Repository