Added sys_dlopen/sys_dlsym/sys_dlclose.
authorJeremy Allison <jra@samba.org>
Mon, 19 Mar 2001 07:08:02 +0000 (07:08 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 19 Mar 2001 07:08:02 +0000 (07:08 +0000)
Jeremy.
(This used to be commit 49f0e7e7143f82bce9dfd8b06e9e515bc0869ab7)

source3/include/includes.h
source3/include/proto.h
source3/lib/system.c
source3/passdb/passdb.c
source3/smbd/vfs.c

index f81a5e33624355ba726bb59781754d8aca314f59..f4dcbde62e0bd887b3e4b8fa19c2b12bb4ed695a 100644 (file)
@@ -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 */
 
index 2b79371acc12acf51e54b3059f6f7695358e6bae..04480cd8a163396597fd008c5b353d63c40c9693 100644 (file)
@@ -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  */
 
index 38b2e79ac624d0f0d0465b60f02eacf96076e187..91f4f8a333b5f875c7165fd72fc13aff74928252 100644 (file)
@@ -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
+}
index 404163c67bea530a6b03da88d65b4378fd2c44f2..2b318eca53920987fbc918acd9744a6858c11762 100644 (file)
@@ -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()));
index b8aa290cab965fc2b2d32e6d3548d31b92167dcc..b41e1f27fd4527032f7bb066366b1ef7497d3da9 100644 (file)
@@ -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",