summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/includes.h13
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/lib/system.c31
-rw-r--r--source3/passdb/passdb.c6
-rw-r--r--source3/smbd/vfs.c4
5 files changed, 52 insertions, 5 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h
index f81a5e3362..f4dcbde62e 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -945,5 +945,18 @@ extern int DEBUGLEVEL;
#define F_SETLKW 14
#endif
+/* Needed for sys_dlopen/sys_dlsym/sys_dlclose */
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+#ifndef RTLD_LAZY
+#define RTLD_LAZY 0
+#endif
+
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+
#endif /* _INCLUDES_H */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2b79371acc..04480cd8a1 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -333,6 +333,9 @@ pid_t sys_fork(void);
pid_t sys_getpid(void);
int sys_popen(const char *command);
int sys_pclose(int fd);
+void *sys_dlopen(const char *name, int flags);
+void *sys_dlsym(void *handle, char *symbol);
+int sys_dlclose (void *handle);
/*The following definitions come from lib/talloc.c */
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 38b2e79ac6..91f4f8a333 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1081,3 +1081,34 @@ int sys_pclose(int fd)
return -1;
return wstatus;
}
+
+/**************************************************************************
+ Wrappers for dlopen, dlsym, dlclose.
+****************************************************************************/
+
+void *sys_dlopen(const char *name, int flags)
+{
+#ifdef HAVE_LIBDL
+ return dlopen(name, flags);
+#else
+ return NULL;
+#endif
+}
+
+void *sys_dlsym(void *handle, char *symbol)
+{
+#ifdef HAVE_LIBDL
+ return dlsym(handle, symbol);
+#else
+ return NULL;
+#endif
+}
+
+int sys_dlclose (void *handle)
+{
+#ifdef HAVE_LIBDL
+ return dlclose(handle);
+#else
+ return 0;
+#endif
+}
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 404163c67b..2b318eca53 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -51,14 +51,14 @@ BOOL initialize_password_db(BOOL reload)
/* load another module? */
if (reload && pdb_handle)
{
- dlclose (pdb_handle);
+ sys_dlclose (pdb_handle);
pdb_handle = NULL;
}
/* do we have a module defined or use the default? */
if (strlen (modulename) != 0)
{
- if ((pdb_handle=dlopen (modulename, RTLD_LAZY)) == NULL)
+ if ((pdb_handle=sys_dlopen (modulename, RTLD_LAZY)) == NULL)
{
DEBUG(0,("initialize_password_db: ERROR - Unable to open passdb module \"%s\"!\n%s\n",
modulename, dlerror()));
@@ -71,7 +71,7 @@ BOOL initialize_password_db(BOOL reload)
to open. Let's try the default */
if (pdb_handle == NULL)
{
- if ((pdb_handle=dlopen ("libpdbfile.so", RTLD_LAZY)) == NULL)
+ if ((pdb_handle=sys_dlopen ("libpdbfile.so", RTLD_LAZY)) == NULL)
{
DEBUG(0,("initialize_password_db: ERROR - Unable to open \"libpdbfile.so\" passdb module! No user authentication possible!\n%s\n",
dlerror()));
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index b8aa290cab..b41e1f27fd 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -105,14 +105,14 @@ BOOL vfs_init_custom(connection_struct *conn)
/* Open object file */
- if ((conn->dl_handle = dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL)) == NULL) {
+ if ((conn->dl_handle = sys_dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL)) == NULL) {
DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)), dlerror()));
return False;
}
/* Get handle on vfs_init() symbol */
- init_fptr = (struct vfs_ops *(*)(int *))dlsym(conn->dl_handle, "vfs_init");
+ init_fptr = (struct vfs_ops *(*)(int *))sys_dlsym(conn->dl_handle, "vfs_init");
if (init_fptr == NULL) {
DEBUG(0, ("No vfs_init() symbol found in %s\n",