[SCM] NSS Wrapper Repository - branch master updated
Michael Adam
obnox at samba.org
Tue Oct 6 20:18:29 UTC 2015
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 <asn at samba.org>
Date: Tue Oct 6 10:53:00 2015 +0200
tests: Only run shadow test when shadow.h is available
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit d2de6c71699c0a2700b2829d296136f619e333eb
Author: Andreas Schneider <asn at samba.org>
Date: Tue Oct 6 10:34:20 2015 +0200
nwrap: Check for setspent and getspnam functions
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 03dc910bd3c21b34021a6e0836faa2412eb5ea0e
Author: Andreas Schneider <asn at samba.org>
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 <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
-----------------------------------------------------------------------
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 <pwd.h>
#include <grp.h>
+#ifdef HAVE_SHADOW_H
#include <shadow.h>
+#endif /* HAVE_SHADOW_H */
#include <netdb.h>
#include <arpa/inet.h>
@@ -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 = &nwrap_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 +1340,7 @@ bool nss_wrapper_shadow_enabled(void)
return true;
}
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
bool nss_wrapper_hosts_enabled(void)
{
@@ -1721,6 +1729,7 @@ static int nwrap_pw_copy_r(const struct passwd *src, struct passwd *dst,
return 0;
}
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
static bool nwrap_sp_parse_line(struct nwrap_cache *nwrap, char *line)
{
struct nwrap_sp *nwrap_sp;
@@ -2011,6 +2020,7 @@ static void nwrap_sp_unload(struct nwrap_cache *nwrap)
nwrap_sp->num = 0;
nwrap_sp->idx = 0;
}
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
/*
* the caller has to call nwrap_unload() on failure
@@ -2537,6 +2547,10 @@ static void nwrap_files_endpwent(struct nwrap_backend *b)
}
/* shadow */
+
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
+
+#ifdef HAVE_SETSPENT
static void nwrap_files_setspent(void)
{
nwrap_sp_global.idx = 0;
@@ -2568,6 +2582,7 @@ static void nwrap_files_endspent(void)
{
nwrap_sp_global.idx = 0;
}
+#endif /* HAVE_SETSPENT */
static struct spwd *nwrap_files_getspnam(const char *name)
{
@@ -2593,6 +2608,7 @@ static struct spwd *nwrap_files_getspnam(const char *name)
errno = ENOENT;
return NULL;
}
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
/* misc functions */
static int nwrap_files_initgroups(struct nwrap_backend *b,
@@ -4071,6 +4087,9 @@ int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups)
* SHADOW
**********************************************************/
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
+
+#ifdef HAVE_SETSPENT
static void nwrap_setspent(void)
{
nwrap_files_setspent();
@@ -4112,6 +4131,7 @@ void endspent(void)
nwrap_endspent();
}
+#endif /* HAVE_SETSPENT */
static struct spwd *nwrap_getspnam(const char *name)
{
@@ -4127,6 +4147,8 @@ struct spwd *getspnam(const char *name)
return nwrap_getspnam(name);
}
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
+
/**********************************************************
* NETDB
**********************************************************/
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 38bb835..ac2548e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -30,8 +30,11 @@ set(NWRAP_TESTS
test_getaddrinfo
test_getnameinfo
test_gethostby_name_addr
- test_gethostent
- test_shadow)
+ test_gethostent)
+
+if (HAVE_SHADOW_H)
+ list(APPEND NWRAP_TESTS test_shadow)
+endif (HAVE_SHADOW_H)
foreach(_NWRAP_TEST ${NWRAP_TESTS})
add_cmocka_test(${_NWRAP_TEST} ${_NWRAP_TEST}.c ${TESTSUITE_LIBRARIES})
@@ -42,8 +45,10 @@ foreach(_NWRAP_TEST ${NWRAP_TESTS})
ENVIRONMENT ${TEST_ENVIRONMENT})
endforeach()
-# This is needed to check the hash in tests/shadow.in
-target_link_libraries(test_shadow crypt)
+if (HAVE_SHADOW_H)
+ # This is needed to check the hash in tests/shadow.in
+ target_link_libraries(test_shadow crypt)
+endif (HAVE_SHADOW_H)
# Test nwrap without wrapping so the libc functions are called
add_cmocka_test(test_nwrap_disabled test_nwrap_disabled.c ${TESTSUITE_LIBRARIES})
--
NSS Wrapper Repository
More information about the samba-cvs
mailing list