From 7d7c594644d9b374e522f208b1f0bd5ab8abb9ab Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Mar 2002 03:00:39 +0000 Subject: Removed HAVE_LIBDL from most places (except system.c). Added checks for dlopen & friends into configure.in. This should help building on *BSD where dl*** calls are in libc. Jeremy (This used to be commit ac1baba35d7a399bf800ced49a4384e39955e3eb) --- source3/configure | 20 +-- source3/configure.in | 2 +- source3/include/config.h.in | 12 ++ source3/lib/system.c | 8 +- source3/passdb/pdb_plugin.c | 12 -- source3/smbd/conn.c | 2 - source3/smbd/vfs.c | 422 ++++++++++++++++++++------------------------ 7 files changed, 221 insertions(+), 257 deletions(-) diff --git a/source3/configure b/source3/configure index 5d4b975c45..22650c1da7 100755 --- a/source3/configure +++ b/source3/configure @@ -2617,12 +2617,12 @@ else #line 2618 "configure" #include "confdefs.h" #include -int main() +main() { FILE *f=fopen("conftestval", "w"); - if (!f) return(1); + if (!f) exit(1); fprintf(f, "%d\n", sizeof(int)); - return(0); + exit(0); } EOF if { (eval echo configure:2629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null @@ -2656,12 +2656,12 @@ else #line 2657 "configure" #include "confdefs.h" #include -int main() +main() { FILE *f=fopen("conftestval", "w"); - if (!f) return(1); + if (!f) exit(1); fprintf(f, "%d\n", sizeof(long)); - return(0); + exit(0); } EOF if { (eval echo configure:2668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null @@ -2695,12 +2695,12 @@ else #line 2696 "configure" #include "confdefs.h" #include -int main() +main() { FILE *f=fopen("conftestval", "w"); - if (!f) return(1); + if (!f) exit(1); fprintf(f, "%d\n", sizeof(short)); - return(0); + exit(0); } EOF if { (eval echo configure:2707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null @@ -5175,7 +5175,7 @@ else RUNPROG="" fi -for ac_func in waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64 +for ac_func in dlopen dlclose dlsym dlerror waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64 do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:5182: checking for $ac_func" >&5 diff --git a/source3/configure.in b/source3/configure.in index 59df6e8099..6ca9cccfee 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -584,7 +584,7 @@ else RUNPROG="" fi -AC_CHECK_FUNCS(waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64) +AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64) AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid) AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid) AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent) diff --git a/source3/include/config.h.in b/source3/include/config.h.in index cebd9ee346..0500e05b7e 100644 --- a/source3/include/config.h.in +++ b/source3/include/config.h.in @@ -505,6 +505,18 @@ /* Define if you have the crypt16 function. */ #undef HAVE_CRYPT16 +/* Define if you have the dlclose function. */ +#undef HAVE_DLCLOSE + +/* Define if you have the dlerror function. */ +#undef HAVE_DLERROR + +/* Define if you have the dlopen function. */ +#undef HAVE_DLOPEN + +/* Define if you have the dlsym function. */ +#undef HAVE_DLSYM + /* Define if you have the dup2 function. */ #undef HAVE_DUP2 diff --git a/source3/lib/system.c b/source3/lib/system.c index b911c29d93..2a0889b356 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -1171,7 +1171,7 @@ int sys_pclose(int fd) void *sys_dlopen(const char *name, int flags) { -#ifdef HAVE_LIBDL +#if defined(HAVE_LIBDL) || defined(HAVE_DLOPEN) return dlopen(name, flags); #else return NULL; @@ -1180,7 +1180,7 @@ void *sys_dlopen(const char *name, int flags) void *sys_dlsym(void *handle, char *symbol) { -#ifdef HAVE_LIBDL +#if defined(HAVE_LIBDL) || defined(HAVE_DLSYM) return dlsym(handle, symbol); #else return NULL; @@ -1189,7 +1189,7 @@ void *sys_dlsym(void *handle, char *symbol) int sys_dlclose (void *handle) { -#ifdef HAVE_LIBDL +#if defined(HAVE_LIBDL) || defined(HAVE_DLCLOSE) return dlclose(handle); #else return 0; @@ -1198,7 +1198,7 @@ int sys_dlclose (void *handle) const char *sys_dlerror(void) { -#ifdef HAVE_LIBDL +#if defined(HAVE_LIBDL) || defined(HAVE_DLERROR) return dlerror(); #else return NULL; diff --git a/source3/passdb/pdb_plugin.c b/source3/passdb/pdb_plugin.c index 95fa9078ae..1de61abd5f 100644 --- a/source3/passdb/pdb_plugin.c +++ b/source3/passdb/pdb_plugin.c @@ -21,8 +21,6 @@ #include "includes.h" -#ifdef HAVE_LIBDL - NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location) { void * dl_handle; @@ -59,13 +57,3 @@ NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con DEBUG(5, ("Starting sam plugin %s with location %s\n", plugin_name, plugin_location)); return plugin_init(pdb_context, pdb_method, plugin_location); } - -#else - -NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location) -{ - DEBUG(0, ("pdb_init_plugin: No libdl present - cannot use passdb loadable modules\n")); - return NT_STATUS_UNSUCCESSFUL; -} - -#endif diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index 55b2d28272..f552d4a224 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -164,12 +164,10 @@ void conn_free(connection_struct *conn) { /* Free vfs_connection_struct */ -#ifdef HAVE_LIBDL if (conn->dl_handle != NULL) { /* Close dlopen() handle */ dlclose(conn->dl_handle); } -#endif /* HAVE_LIBDL */ DLIST_REMOVE(Connections, conn); diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 6416d8e73e..4e2e353ed8 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -119,50 +119,47 @@ struct vfs_ops default_vfs_ops = { static BOOL vfs_init_default(connection_struct *conn) { - DEBUG(3, ("Initialising default vfs hooks\n")); + DEBUG(3, ("Initialising default vfs hooks\n")); - memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops)); - return True; + memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops)); + return True; } /**************************************************************************** initialise custom vfs hooks ****************************************************************************/ -#ifdef HAVE_LIBDL static BOOL vfs_init_custom(connection_struct *conn) { int vfs_version = -1; - struct vfs_ops *ops, *(*init_fptr)(int *, struct vfs_ops *); + struct vfs_ops *ops, *(*init_fptr)(int *, struct vfs_ops *); - DEBUG(3, ("Initialising custom vfs hooks from %s\n", - lp_vfsobj(SNUM(conn)))); + DEBUG(3, ("Initialising custom vfs hooks from %s\n", lp_vfsobj(SNUM(conn)))); - /* Open object file */ + /* Open object file */ - if ((conn->dl_handle = sys_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 */ + /* Get handle on vfs_init() symbol */ - init_fptr = (struct vfs_ops *(*)(int *, struct vfs_ops *))sys_dlsym(conn->dl_handle, "vfs_init"); + init_fptr = (struct vfs_ops *(*)(int *, struct vfs_ops *))sys_dlsym(conn->dl_handle, "vfs_init"); - if (init_fptr == NULL) { - DEBUG(0, ("No vfs_init() symbol found in %s\n", - lp_vfsobj(SNUM(conn)))); + if (init_fptr == NULL) { + DEBUG(0, ("No vfs_init() symbol found in %s\n", lp_vfsobj(SNUM(conn)))); return False; - } + } - /* Initialise vfs_ops structure */ + /* Initialise vfs_ops structure */ conn->vfs_ops = default_vfs_ops; - if ((ops = init_fptr(&vfs_version, &default_vfs_ops)) == NULL) { - DEBUG(0, ("vfs_init function from %s failed\n", lp_vfsobj(SNUM(conn)))); + if ((ops = init_fptr(&vfs_version, &default_vfs_ops)) == NULL) { + DEBUG(0, ("vfs_init function from %s failed\n", lp_vfsobj(SNUM(conn)))); return False; - } + } if (vfs_version != SMB_VFS_INTERFACE_VERSION) { DEBUG(0, ("vfs_init returned wrong interface version info (was %d, should be %d)\n", @@ -174,9 +171,8 @@ static BOOL vfs_init_custom(connection_struct *conn) memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops)); } - return True; + return True; } -#endif /***************************************************************** Generic VFS init. @@ -185,7 +181,6 @@ static BOOL vfs_init_custom(connection_struct *conn) BOOL smbd_vfs_init(connection_struct *conn) { if (*lp_vfsobj(SNUM(conn))) { -#ifdef HAVE_LIBDL /* Loadable object file */ @@ -195,10 +190,6 @@ BOOL smbd_vfs_init(connection_struct *conn) } return True; -#else - DEBUG(0, ("smbd_vfs_init: No libdl present - cannot use VFS objects\n")); - return False; -#endif } /* Normal share - initialise with disk access functions */ @@ -305,7 +296,7 @@ ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count) while (total < byte_count) { ssize_t ret = fsp->conn->vfs_ops.read(fsp, fsp->fd, buf + total, - byte_count - total); + byte_count - total); if (ret == 0) return total; if (ret == -1) { @@ -571,12 +562,11 @@ int vfs_ChDir(connection_struct *conn, char *path) /* number of list structures for a caching GetWd function. */ #define MAX_GETWDCACHE (50) -struct -{ - SMB_DEV_T dev; /* These *must* be compatible with the types returned in a stat() call. */ - SMB_INO_T inode; /* These *must* be compatible with the types returned in a stat() call. */ - char *dos_path; /* The pathname in DOS format. */ - BOOL valid; +struct { + SMB_DEV_T dev; /* These *must* be compatible with the types returned in a stat() call. */ + SMB_INO_T inode; /* These *must* be compatible with the types returned in a stat() call. */ + char *dos_path; /* The pathname in DOS format. */ + BOOL valid; } ino_list[MAX_GETWDCACHE]; extern BOOL use_getwd_cache; @@ -612,98 +602,86 @@ static void array_promote(char *array,int elsize,int element) char *vfs_GetWd(connection_struct *conn, char *path) { - pstring s; - static BOOL getwd_cache_init = False; - SMB_STRUCT_STAT st, st2; - int i; - - *s = 0; - - if (!use_getwd_cache) - return(vfs_getwd(conn,path)); - - /* init the cache */ - if (!getwd_cache_init) - { - getwd_cache_init = True; - for (i=0;i