1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

Added sys_dlopen/sys_dlsym/sys_dlclose.

Jeremy.
(This used to be commit 49f0e7e7143f82bce9dfd8b06e9e515bc0869ab7)
This commit is contained in:
Jeremy Allison 2001-03-19 07:08:02 +00:00
parent 62711a9ceb
commit c7a953a318
5 changed files with 52 additions and 5 deletions

View 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 */

View 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 */

View 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
}

View 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()));

View 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",