[SCM] NSS Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Dec 17 04:46:13 MST 2013


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 <asn at samba.org>
Date:   Tue Dec 17 12:45:14 2013 +0100

    nwrap: Remove obsolete nwrap_libc_fn().

commit 774e09c88d59c9dd7e2fc6acb34f8ee07d4c3574
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:44:41 2013 +0100

    nwrap: Add libc_getnameinfo().

commit da31d1c3f96a32c433790c94b732734aae2e4fff
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:40:52 2013 +0100

    tests: Add getaddrinfo libsocket test.

commit 4f43a3c9f0312f121ac86ebce46593644e9257f6
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:40:41 2013 +0100

    nwrap: Add libc_getaddrinfo().

commit b68508de14d098fb02e2649b2a9be819d4e672f5
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:33:54 2013 +0100

    nwrap: Add libc_gethostbyaddr_r().

commit b7ac8181eaa22ac23be09329b1fbb8d40dcd5dd4
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:31:54 2013 +0100

    nwrap: Add libc_gethostbyname_r().

commit 8f5737012ed36c7c03ae23854cb00c06067e418e
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:26:44 2013 +0100

    tests: Add gethostname libnsl test.

commit 3ad5684aea931235f2812732707b7e554e69fb19
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:24:02 2013 +0100

    nwrap: Add libc_gethostname().

commit 62cfb8008afb72dbb26fdace3f7b2ca8acb233e8
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:22:22 2013 +0100

    nwrap: Add libc_gethostbyaddr().

commit 1ccea5429ae99a1662412041a30c9333d7720dd6
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:20:04 2013 +0100

    nwrap: Add libc_gethostbyname().

commit afd7c5e9c5d7d895a7bcd7f9e4ec7c6ea39f13da
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:17:42 2013 +0100

    tests: Add libnsl hostent test.

commit 0ae6477f61db7b82cc00aaa4b581c61fcd924460
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:17:25 2013 +0100

    nwrap: Add libc_gethostent().

commit 04a3892a3d7522a0af29a135baaaf630bb405ad4
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:11:57 2013 +0100

    nwrap: Add libc_sethostent().

commit 8d45afe13552a587b651f56ecb41ef7c74698693
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:09:56 2013 +0100

    nwrap: Add libc_getgrouplist().

commit a4c9907ec0f9379cf1ef02cf00947b806c031abb
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:07:48 2013 +0100

    nwrap: Add libc_entgrent().

commit 220f2766e2ff2bfa08ea4fc1208b9ba4802729e9
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:06:34 2013 +0100

    nwrap: Add libc_getgrent_r().

commit c72bd3f7916a7677c7718eca227112513646c39e
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:02:43 2013 +0100

    nwrap: Add libc_getgrent().

commit 68e38fe90b9e250933bb928d66df940bf7cbd706
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 12:01:42 2013 +0100

    nwrap: Add libc_setgrent().

commit b3f216484c6e93c38f11ecb77a49c56cfc27b4e0
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:59:45 2013 +0100

    nwrap: Add libc_getgrgid_r().

commit dfabe527d40288e2e2d55996b65f472a18b86817
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:57:10 2013 +0100

    nwrap: Add libc_getgrgid().

commit 9a9f8c53ee2239fc31c9df71d2535fcae702bc57
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:55:55 2013 +0100

    nwrap: Add libc_getgrnam_r().

commit db29481e0246130a878c0a2d6ecfe5acbf2f443f
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:52:12 2013 +0100

    tests: Add test to check if libc functions are loaded correctly.

commit bde38cdaabc6b059131f5eea1d60b19ee68fb9dd
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:45:43 2013 +0100

    cmake: Simplify test calling.

commit 40e587c816bf26e3660e7ddc4066a76bb6c58cc4
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:40:18 2013 +0100

    nwrap: Add libc_getgrnam().

commit 330a6a81b60c41c6148f737f218fe7409eb68049
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:38:48 2013 +0100

    nwrap: Add libc_initgroups().

commit 5b3d912fb7846e280c4ebc6c3b59e4e64eb8157b
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:36:18 2013 +0100

    nwrap: Add libc_endpwent().

commit 42676e2965c48f7703e6a8c2e3e49c7de0859317
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:33:03 2013 +0100

    nwrap: Add libc_getpwent_r().

commit 4223f1817c3bf0cb019eb50a1a1dcead163655d8
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:27:31 2013 +0100

    nwrap: Add libc_getpwent().

commit c0fec19ec7cbe51f5c5aae512a54cd3ff9d38522
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:26:01 2013 +0100

    nwrap: Add libc_setpwent().

commit 5125ccecce6aded81ab1aa2d58c582ac1f31c0eb
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:23:12 2013 +0100

    nwrap: Add libc_getpwuid_r().

commit e95234d7238a8dfa5fd14191946d108f2c24182e
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:17:20 2013 +0100

    nwrap: Add libc_getpwuid().

commit e5dabbd3077d60aadd86ce28f3a88e74b05bf592
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:14:34 2013 +0100

    nwrap: Add libc_getpwnam_r().

commit e2ff29ea1afe4a4b09679f2eaf1ae6c834adbb62
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:09:45 2013 +0100

    nwrap: Add libc_getpwnam().

commit d14acddbc0f759df9a117eb3dc819626b87f7c5b
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 11:03:18 2013 +0100

    nwrap: Add nwrap_load_lib_function().

commit 0015233fd0b83d7372ad8cc5825b13b80999fd2d
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 10:54:52 2013 +0100

    nwrap: Add nwrap_load_lib_handle().

commit 7c0801b07707af5353ee40cee9be7504d173a3a8
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 17 10:54:07 2013 +0100

    Add more directories and definitons to .clang_complete.

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

Summary of changes:
 .clang_complete             |    4 +
 src/nss_wrapper.c           |  768 ++++++++++++++++++++++++++++++-------------
 tests/CMakeLists.txt        |   40 +--
 tests/test_nwrap_disabled.c |  106 ++++++
 4 files changed, 667 insertions(+), 251 deletions(-)
 create mode 100644 tests/test_nwrap_disabled.c


Changeset truncated at 500 lines:

diff --git a/.clang_complete b/.clang_complete
index 44adc4f..8ea074a 100644
--- a/.clang_complete
+++ b/.clang_complete
@@ -1 +1,5 @@
 -DHAVE_IPV6
+-DHAVE_LIBNSL
+-DHAVE_LIBSOCKET
+-Isrc
+-Iobj
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index c00e5cb..1f7ae3b 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -503,9 +503,504 @@ struct nwrap_he {
 struct nwrap_cache __nwrap_cache_he;
 struct nwrap_he nwrap_he_global;
 
+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);
 
+/*********************************************************
+ * NWRAP LIBC LOADER FUNCTIONS
+ *********************************************************/
+
+enum nwrap_lib {
+    NWRAP_LIBC,
+    NWRAP_LIBNSL,
+    NWRAP_LIBSOCKET,
+};
+
+#ifndef NDEBUG
+static const char *nwrap_str_lib(enum nwrap_lib lib)
+{
+	switch (lib) {
+	case NWRAP_LIBC:
+		return "libc";
+	case NWRAP_LIBNSL:
+		return "libnsl";
+	case NWRAP_LIBSOCKET:
+		return "libsocket";
+	}
+
+	/* Compiler would warn us about unhandled enum value if we get here */
+	return "unknown";
+}
+#endif
+
+static void *nwrap_load_lib_handle(enum nwrap_lib lib)
+{
+	int flags = RTLD_LAZY;
+	void *handle = NULL;
+	int i;
+
+#ifdef HAVE_APPLE
+	return RTLD_NEXT;
+#endif
+
+#ifdef RTLD_DEEPBIND
+	flags |= RTLD_DEEPBIND;
+#endif
+
+	switch (lib) {
+	case NWRAP_LIBNSL:
+#ifdef HAVE_LIBNSL
+		if (handle == NULL) {
+			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+				char soname[256] = {0};
+
+				snprintf(soname, sizeof(soname), "libnsl.so.%d", i);
+				handle = dlopen(soname, flags);
+			}
+
+			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
+		if (handle == NULL) {
+			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+				char soname[256] = {0};
+
+				snprintf(soname, sizeof(soname), "libsocket.so.%d", i);
+				handle = dlopen(soname, flags);
+			}
+
+			swrap.libsocket_handle = handle;
+			nwrap_main_global->libc->sock_handle = handle;
+		} else {
+			handle = nwrap_main_global->libc->sock_handle;
+		}
+		break;
+#endif
+		/* FALL TROUGH */
+	case NWRAP_LIBC:
+		if (handle == NULL) {
+			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+				char soname[256] = {0};
+
+				snprintf(soname, sizeof(soname), "libc.so.%d", i);
+				handle = dlopen(soname, flags);
+			}
+
+			nwrap_main_global->libc->handle = handle;
+		} else {
+			handle = nwrap_main_global->libc->handle;
+		}
+		break;
+	}
+
+	if (handle == NULL) {
+		NWRAP_LOG(NWRAP_LOG_ERROR,
+			  "Failed to dlopen library: %s\n",
+			  dlerror());
+		exit(-1);
+	}
+
+	return handle;
+}
+
+static void *_nwrap_load_lib_function(enum nwrap_lib lib, const char *fn_name)
+{
+	void *handle;
+	void *func;
+
+	nwrap_init();
+
+	handle = nwrap_load_lib_handle(lib);
+
+	func = dlsym(handle, fn_name);
+	if (func == NULL) {
+		NWRAP_LOG(NWRAP_LOG_ERROR,
+				"Failed to find %s: %s\n",
+				fn_name, dlerror());
+		exit(-1);
+	}
+
+	NWRAP_LOG(NWRAP_LOG_TRACE,
+			"Loaded %s from %s",
+			fn_name, nwrap_str_lib(lib));
+	return func;
+}
+
+#define nwrap_load_lib_function(lib, fn_name) \
+	if (nwrap_main_global->libc->fns->_libc_##fn_name == NULL) { \
+		*(void **) (&nwrap_main_global->libc->fns->_libc_##fn_name) = \
+			_nwrap_load_lib_function(lib, #fn_name); \
+	}
+
+/*
+ * IMPORTANT
+ *
+ * Functions expeciall from libc need to be loaded individually, you can't load
+ * all at once or gdb will segfault at startup. The same applies to valgrind and
+ * has probably something todo with with the linker.
+ * So we need load each function at the point it is called the first time.
+ */
+static struct passwd *libc_getpwnam(const char *name)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getpwnam);
+
+	return nwrap_main_global->libc->fns->_libc_getpwnam(name);
+}
+
+#ifdef HAVE_GETPWNAM_R
+static int libc_getpwnam_r(const char *name,
+			   struct passwd *pwd,
+			   char *buf,
+			   size_t buflen,
+			   struct passwd **result)
+{
+#ifdef HAVE___POSIX_GETPWNAM_R
+	nwrap_load_lib_function(NWRAP_LIBC, __posix_getpwnam_r);
+#else
+	nwrap_load_lib_function(NWRAP_LIBC, getpwnam_r);
+#endif
+
+	return nwrap_main_global->libc->fns->_libc_getpwnam_r(name,
+							      pwd,
+							      buf,
+							      buflen,
+							      result);
+}
+#endif
+
+static struct passwd *libc_getpwuid(uid_t uid)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getpwuid);
+
+	return nwrap_main_global->libc->fns->_libc_getpwuid(uid);
+}
+
+#ifdef HAVE_GETPWUID_R
+static int libc_getpwuid_r(uid_t uid,
+			   struct passwd *pwd,
+			   char *buf,
+			   size_t buflen,
+			   struct passwd **result)
+{
+#ifdef HAVE___POSIX_GETPWUID_R
+	nwrap_load_lib_function(NWRAP_LIBC, __posix_getpwuid_r);
+#else
+	nwrap_load_lib_function(NWRAP_LIBC, getpwuid);
+#endif
+
+	return nwrap_main_global->libc->fns->_libc_getpwuid_r(uid,
+							      pwd,
+							      buf,
+							      buflen,
+							      result);
+}
+#endif
+
+static void libc_setpwent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, setpwent);
+
+	nwrap_main_global->libc->fns->_libc_setpwent();
+}
+
+static struct passwd *libc_getpwent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getpwent);
+
+	return nwrap_main_global->libc->fns->_libc_getpwent();
+}
+
+#ifdef HAVE_SOLARIS_GETPWENT_R
+static struct passwd *libc_getpwent_r(struct passwd *pwdst,
+				      char *buf,
+				      int buflen)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getpwent_r);
+
+	return nwrap_main_global->libc->fns->_libc_getpwent_r(pwdst,
+							      buf,
+							      buflen);
+}
+#else /* HAVE_SOLARIS_GETPWENT_R */
+static int libc_getpwent_r(struct passwd *pwdst,
+			   char *buf,
+			   size_t buflen,
+			   struct passwd **pwdstp)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getpwent_r);
+
+	return nwrap_main_global->libc->fns->_libc_getpwent_r(pwdst,
+							      buf,
+							      buflen,
+							      pwdstp);
+}
+#endif /* HAVE_SOLARIS_GETPWENT_R */
+
+static void libc_endpwent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, endpwent);
+
+	nwrap_main_global->libc->fns->_libc_endpwent();
+}
+
+static int libc_initgroups(const char *user, gid_t gid)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, initgroups);
+
+	return nwrap_main_global->libc->fns->_libc_initgroups(user, gid);
+}
+
+static struct group *libc_getgrnam(const char *name)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getgrnam);
+
+	return nwrap_main_global->libc->fns->_libc_getgrnam(name);
+}
+
+#ifdef HAVE_GETGRNAM_R
+static int libc_getgrnam_r(const char *name,
+			   struct group *grp,
+			   char *buf,
+			   size_t buflen,
+			   struct group **result)
+{
+#ifdef HAVE___POSIX_GETGRNAM_R
+	nwrap_load_lib_function(NWRAP_LIBC, __posix_getgrnam_r);
+#else
+	nwrap_load_lib_function(NWRAP_LIBC, getgrnam_r);
+#endif
+
+	return nwrap_main_global->libc->fns->_libc_getgrnam_r(name,
+							      grp,
+							      buf,
+							      buflen,
+							      result);
+}
+#endif
+
+static struct group *libc_getgrgid(gid_t gid)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getgrgid);
+
+	return nwrap_main_global->libc->fns->_libc_getgrgid(gid);
+}
+
+#ifdef HAVE_GETGRGID_R
+static int libc_getgrgid_r(gid_t gid,
+			   struct group *grp,
+			   char *buf,
+			   size_t buflen,
+			   struct group **result)
+{
+#ifdef HAVE___POSIX_GETGRGID_R
+	nwrap_load_lib_function(NWRAP_LIBC, __posix_getgrgid_r);
+#else
+	nwrap_load_lib_function(NWRAP_LIBC, getgrgid_r);
+#endif
+
+	return nwrap_main_global->libc->fns->_libc_getgrgid_r(gid,
+							      grp,
+							      buf,
+							      buflen,
+							      result);
+}
+#endif
+
+static void libc_setgrent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, setgrent);
+
+	nwrap_main_global->libc->fns->_libc_setgrent();
+}
+
+static struct group *libc_getgrent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getgrent);
+
+	return nwrap_main_global->libc->fns->_libc_getgrent();
+}
+
+#ifdef HAVE_GETGRENT_R
+#ifdef HAVE_SOLARIS_GETGRENT_R
+static struct group *libc_getgrent_r(struct group *group,
+				     char *buf,
+				     size_t buflen)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getgrent_r);
+
+	return nwrap_main_global->libc->fns->_libc_getgrent_r(group,
+							      buf,
+							      buflen);
+}
+#else /* !HAVE_SOLARIS_GETGRENT_R */
+static int libc_getgrent_r(struct group *group,
+			   char *buf,
+			   size_t buflen,
+			   struct group **result)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getgrent_r);
+
+	return nwrap_main_global->libc->fns->_libc_getgrent_r(group,
+							      buf,
+							      buflen,
+							      result);
+}
+#endif /* HAVE_SOLARIS_GETGRENT_R */
+#endif /* HAVE_GETGRENT_R */
+
+static void libc_endgrent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, endgrent);
+
+	nwrap_main_global->libc->fns->_libc_endgrent();
+}
+
+#ifdef HAVE_GETGROUPLIST
+static int libc_getgrouplist(const char *user,
+			     gid_t group,
+			     gid_t *groups,
+			     int *ngroups)
+{
+	nwrap_load_lib_function(NWRAP_LIBC, getgrouplist);
+
+	return nwrap_main_global->libc->fns->_libc_getgrouplist(user,
+								group,
+								groups,
+								ngroups);
+}
+#endif
+
+static void libc_sethostent(int stayopen)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, sethostent);
+
+	nwrap_main_global->libc->fns->_libc_sethostent(stayopen);
+}
+
+static struct hostent *libc_gethostent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, gethostent);
+
+	return nwrap_main_global->libc->fns->_libc_gethostent();
+}
+
+static void libc_endhostent(void)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, endhostent);
+
+	nwrap_main_global->libc->fns->_libc_endhostent();
+}
+
+static struct hostent *libc_gethostbyname(const char *name)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname);
+
+	return nwrap_main_global->libc->fns->_libc_gethostbyname(name);
+}
+
+static struct hostent *libc_gethostbyaddr(const void *addr,
+					  socklen_t len,
+					  int type)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyaddr);
+
+	return nwrap_main_global->libc->fns->_libc_gethostbyaddr(addr,
+								 len,
+								 type);
+}
+
+static int libc_gethostname(char *name, size_t len)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, gethostname);
+
+	return nwrap_main_global->libc->fns->_libc_gethostname(name, len);
+}
+
+#ifdef HAVE_GETHOSTBYNAME_R
+static int libc_gethostbyname_r(const char *name,
+				struct hostent *ret,
+				char *buf,
+				size_t buflen,
+				struct hostent **result,
+				int *h_errnop)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname_r);
+
+	return nwrap_main_global->libc->fns->_libc_gethostbyname_r(name,
+								   ret,
+								   buf,
+								   buflen,
+								   result,
+								   h_errnop);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+static int libc_gethostbyaddr_r(const void *addr,
+				socklen_t len,
+				int type,
+				struct hostent *ret,
+				char *buf,
+				size_t buflen,
+				struct hostent **result,
+				int *h_errnop)
+{
+	nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyaddr_r);
+
+	return nwrap_main_global->libc->fns->_libc_gethostbyaddr_r(addr,
+								   len,
+								   type,
+								   ret,
+								   buf,
+								   buflen,
+								   result,
+								   h_errnop);
+}
+#endif
+
+static int libc_getaddrinfo(const char *node,
+			    const char *service,
+			    const struct addrinfo *hints,
+			    struct addrinfo **res)
+{
+	nwrap_load_lib_function(NWRAP_LIBSOCKET, getaddrinfo);
+
+	return nwrap_main_global->libc->fns->_libc_getaddrinfo(node,
+							       service,
+							       hints,
+							       res);
+}
+
+static int libc_getnameinfo(const struct sockaddr *sa,
+			    socklen_t salen,
+			    char *host,
+			    size_t hostlen,
+			    char *serv,
+			    size_t servlen,
+			    int flags)


-- 
NSS Wrapper Repository


More information about the samba-cvs mailing list