summaryrefslogtreecommitdiffstats
path: root/examples/libsmbclient/smbwrapper/wrapper.c
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-01-11 18:22:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:06:04 -0500
commit673c3564885fdb57e8f99d64401ee81152134e54 (patch)
treedafef7e582d5a6d278bc0fc6b80edfb3de1e8a26 /examples/libsmbclient/smbwrapper/wrapper.c
parent19563e67447366364c75dbf79fff48a972669d40 (diff)
downloadsamba-673c3564885fdb57e8f99d64401ee81152134e54.tar.gz
samba-673c3564885fdb57e8f99d64401ee81152134e54.tar.xz
samba-673c3564885fdb57e8f99d64401ee81152134e54.zip
r12852: r12150@cabra: derrell | 2006-01-11 13:21:14 -0500
Although RTLD_NEXT was not working properly a number of years ago, it seems to be now. Replace dlopen(/lib/libc...) with direct use of RTLD_NEXT (This used to be commit 2b4866500640891fcb1ca7b24997df17f1b077cc)
Diffstat (limited to 'examples/libsmbclient/smbwrapper/wrapper.c')
-rw-r--r--examples/libsmbclient/smbwrapper/wrapper.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/examples/libsmbclient/smbwrapper/wrapper.c b/examples/libsmbclient/smbwrapper/wrapper.c
index 12904c30737..e6f764c16d8 100644
--- a/examples/libsmbclient/smbwrapper/wrapper.c
+++ b/examples/libsmbclient/smbwrapper/wrapper.c
@@ -62,7 +62,14 @@
#include <dirent.h>
#include <signal.h>
#include <stdarg.h>
+#ifdef __USE_GNU
+# define SMBW_USE_GNU
+#endif
+#define __USE_GNU /* need this to have RTLD_NEXT defined */
#include <dlfcn.h>
+#ifndef SMBW_USE_GNU
+# undef __USE_GNU
+#endif
#include <errno.h>
#include "libsmbclient.h"
#include "bsd-strlfunc.h"
@@ -131,7 +138,6 @@ void smbw_initialize(void)
static void initialize(void)
{
- void *lib = NULL;
int saved_errno;
#if SMBW_DEBUG & 0x1
char *error;
@@ -144,26 +150,18 @@ static void initialize(void)
}
initialized = 1;
- if ((lib = dlopen("/lib/libc.so.6", RTLD_NOW | RTLD_GLOBAL)) == NULL) {
-#ifdef RTLD_NEXT
- lib = RTLD_NEXT;
-#else
- exit(1);
-#endif
- }
-
#if SMBW_DEBUG & 0x1
-# define GETSYM(symname, symstring) \
- if ((smbw_libc.symname = dlsym(lib, symstring)) == NULL) { \
- if (smbw_libc.write != NULL && \
- (error = dlerror()) != NULL) { \
- (* smbw_libc.write)(1, error, strlen(error)); \
- (* smbw_libc.write)(1, "\n", 1); \
- } \
+# define GETSYM(symname, symstring) \
+ if ((smbw_libc.symname = dlsym(RTLD_NEXT, symstring)) == NULL) { \
+ if (smbw_libc.write != NULL && \
+ (error = dlerror()) != NULL) { \
+ (* smbw_libc.write)(1, error, strlen(error)); \
+ (* smbw_libc.write)(1, "\n", 1); \
+ } \
}
#else
# define GETSYM(symname, symstring) \
- smbw_libc.symname = dlsym(lib, symstring);
+ smbw_libc.symname = dlsym(RTLD_NEXT, symstring);
#endif
/*
@@ -265,19 +263,6 @@ static void initialize(void)
GETSYM(_select, "_select");
GETSYM(__select, "__select");
-#ifdef RTLD_NEXT
- if (lib != RTLD_NEXT) {
- dlclose(lib);
- }
-#else
- dlclose(lib);
-#endif
-
- /* Ensure that the C library is immediately available */
- if ((lib = dlopen("/lib/libc.so.6", RTLD_NOW | RTLD_GLOBAL)) == NULL) {
- exit(1);
- }
-
#if SMBW_DEBUG & 4
{
if ((debugFd =