diff options
author | Jeremy Allison <jra@samba.org> | 2002-03-27 03:00:39 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-03-27 03:00:39 +0000 |
commit | 7d7c594644d9b374e522f208b1f0bd5ab8abb9ab (patch) | |
tree | c197c1ed507014055f027cf0ace873e11ac3caca | |
parent | 1a06eeb6dae9b148a6e70470660e51a42def2399 (diff) | |
download | samba-7d7c594644d9b374e522f208b1f0bd5ab8abb9ab.tar.gz samba-7d7c594644d9b374e522f208b1f0bd5ab8abb9ab.tar.bz2 samba-7d7c594644d9b374e522f208b1f0bd5ab8abb9ab.zip |
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)
-rwxr-xr-x | source3/configure | 20 | ||||
-rw-r--r-- | source3/configure.in | 2 | ||||
-rw-r--r-- | source3/include/config.h.in | 12 | ||||
-rw-r--r-- | source3/lib/system.c | 8 | ||||
-rw-r--r-- | source3/passdb/pdb_plugin.c | 12 | ||||
-rw-r--r-- | source3/smbd/conn.c | 2 | ||||
-rw-r--r-- | 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 <stdio.h> -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 <stdio.h> -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 <stdio.h> -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<MAX_GETWDCACHE;i++) - { - string_set(&ino_list[i].dos_path,""); - ino_list[i].valid = False; - } - } - - /* Get the inode of the current directory, if this doesn't work we're - in trouble :-) */ - - if (vfs_stat(conn, ".",&st) == -1) - { - DEBUG(0,("Very strange, couldn't stat \".\" path=%s\n", path)); - return(vfs_getwd(conn,path)); - } - - - for (i=0; i<MAX_GETWDCACHE; i++) - if (ino_list[i].valid) - { - - /* If we have found an entry with a matching inode and dev number - then find the inode number for the directory in the cached string. - If this agrees with that returned by the stat for the current - directory then all is o.k. (but make sure it is a directory all - the same...) */ - - if (st.st_ino == ino_list[i].inode && - st.st_dev == ino_list[i].dev) - { - if (vfs_stat(conn,ino_list[i].dos_path,&st2) == 0) - { - if (st.st_ino == st2.st_ino && - st.st_dev == st2.st_dev && - (st2.st_mode & S_IFMT) == S_IFDIR) - { - pstrcpy (path, ino_list[i].dos_path); - - /* promote it for future use */ - array_promote((char *)&ino_list[0],sizeof(ino_list[0]),i); - return (path); - } - else - { - /* If the inode is different then something's changed, - scrub the entry and start from scratch. */ - ino_list[i].valid = False; - } - } - } - } + 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<MAX_GETWDCACHE;i++) { + string_set(&ino_list[i].dos_path,""); + ino_list[i].valid = False; + } + } + + /* Get the inode of the current directory, if this doesn't work we're + in trouble :-) */ + if (vfs_stat(conn, ".",&st) == -1) { + DEBUG(0,("Very strange, couldn't stat \".\" path=%s\n", path)); + return(vfs_getwd(conn,path)); + } - /* We don't have the information to hand so rely on traditional methods. - The very slow getcwd, which spawns a process on some systems, or the - not quite so bad getwd. */ - if (!vfs_getwd(conn,s)) - { - DEBUG(0,("vfs_GetWd: vfs_getwd call failed, errno %s\n",strerror(errno))); - return (NULL); - } + for (i=0; i<MAX_GETWDCACHE; i++) { + if (ino_list[i].valid) { + + /* If we have found an entry with a matching inode and dev number + then find the inode number for the directory in the cached string. + If this agrees with that returned by the stat for the current + directory then all is o.k. (but make sure it is a directory all + the same...) */ + + if (st.st_ino == ino_list[i].inode && st.st_dev == ino_list[i].dev) { + if (vfs_stat(conn,ino_list[i].dos_path,&st2) == 0) { + if (st.st_ino == st2.st_ino && st.st_dev == st2.st_dev && + (st2.st_mode & S_IFMT) == S_IFDIR) { + pstrcpy (path, ino_list[i].dos_path); + + /* promote it for future use */ + array_promote((char *)&ino_list[0],sizeof(ino_list[0]),i); + return (path); + } else { + /* If the inode is different then something's changed, + scrub the entry and start from scratch. */ + ino_list[i].valid = False; + } + } + } + } + } - pstrcpy(path,s); + /* We don't have the information to hand so rely on traditional methods. + The very slow getcwd, which spawns a process on some systems, or the + not quite so bad getwd. */ - DEBUG(5,("vfs_GetWd %s, inode %.0f, dev %.0f\n",s,(double)st.st_ino,(double)st.st_dev)); + if (!vfs_getwd(conn,s)) { + DEBUG(0,("vfs_GetWd: vfs_getwd call failed, errno %s\n",strerror(errno))); + return (NULL); + } - /* add it to the cache */ - i = MAX_GETWDCACHE - 1; - string_set(&ino_list[i].dos_path,s); - ino_list[i].dev = st.st_dev; - ino_list[i].inode = st.st_ino; - ino_list[i].valid = True; + pstrcpy(path,s); - /* put it at the top of the list */ - array_promote((char *)&ino_list[0],sizeof(ino_list[0]),i); + DEBUG(5,("vfs_GetWd %s, inode %.0f, dev %.0f\n",s,(double)st.st_ino,(double)st.st_dev)); - return (path); + /* add it to the cache */ + i = MAX_GETWDCACHE - 1; + string_set(&ino_list[i].dos_path,s); + ino_list[i].dev = st.st_dev; + ino_list[i].inode = st.st_ino; + ino_list[i].valid = True; + + /* put it at the top of the list */ + array_promote((char *)&ino_list[0],sizeof(ino_list[0]),i); + + return (path); } /******************************************************************* @@ -716,121 +694,109 @@ char *vfs_GetWd(connection_struct *conn, char *path) BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks) { #ifndef REDUCE_PATHS - return True; + return True; #else - pstring dir2; - pstring wd; - pstring base_name; - pstring newname; - char *p=NULL; - BOOL relative = (*s != '/'); - - *dir2 = *wd = *base_name = *newname = 0; - - if (widelinks) - { - unix_clean_name(s); - /* can't have a leading .. */ - if (strncmp(s,"..",2) == 0 && (s[2]==0 || s[2]=='/')) - { - DEBUG(3,("Illegal file name? (%s)\n",s)); - return(False); - } + pstring dir2; + pstring wd; + pstring base_name; + pstring newname; + char *p=NULL; + BOOL relative = (*s != '/'); + + *dir2 = *wd = *base_name = *newname = 0; + + if (widelinks) { + unix_clean_name(s); + /* can't have a leading .. */ + if (strncmp(s,"..",2) == 0 && (s[2]==0 || s[2]=='/')) { + DEBUG(3,("Illegal file name? (%s)\n",s)); + return(False); + } - if (strlen(s) == 0) - pstrcpy(s,"./"); - - return(True); - } - - DEBUG(3,("reduce_name [%s] [%s]\n",s,dir)); - - /* remove any double slashes */ - all_string_sub(s,"//","/",0); - - pstrcpy(base_name,s); - p = strrchr_m(base_name,'/'); - - if (!p) - return(True); - - if (!vfs_GetWd(conn,wd)) - { - DEBUG(0,("couldn't vfs_GetWd for %s %s\n",s,dir)); - return(False); - } - - if (vfs_ChDir(conn,dir) != 0) - { - DEBUG(0,("couldn't vfs_ChDir to %s\n",dir)); - return(False); - } - - if (!vfs_GetWd(conn,dir2)) - { - DEBUG(0,("couldn't vfs_GetWd for %s\n",dir)); - vfs_ChDir(conn,wd); - return(False); - } - - if (p && (p != base_name)) - { - *p = 0; - if (strcmp(p+1,".")==0) - p[1]=0; - if (strcmp(p+1,"..")==0) - *p = '/'; - } - - if (vfs_ChDir(conn,base_name) != 0) - { - vfs_ChDir(conn,wd); - DEBUG(3,("couldn't vfs_ChDir for %s %s basename=%s\n",s,dir,base_name)); - return(False); - } - - if (!vfs_GetWd(conn,newname)) - { - vfs_ChDir(conn,wd); - DEBUG(2,("couldn't get vfs_GetWd for %s %s\n",s,dir2)); - return(False); - } - - if (p && (p != base_name)) - { - pstrcat(newname,"/"); - pstrcat(newname,p+1); - } - - { - size_t l = strlen(dir2); - if (dir2[l-1] == '/') - l--; - - if (strncmp(newname,dir2,l) != 0) - { - vfs_ChDir(conn,wd); - DEBUG(2,("Bad access attempt? s=%s dir=%s newname=%s l=%d\n",s,dir2,newname,(int)l)); - return(False); - } + if (strlen(s) == 0) + pstrcpy(s,"./"); - if (relative) - { - if (newname[l] == '/') - pstrcpy(s,newname + l + 1); - else - pstrcpy(s,newname+l); - } - else - pstrcpy(s,newname); - } + return(True); + } + + DEBUG(3,("reduce_name [%s] [%s]\n",s,dir)); + + /* remove any double slashes */ + all_string_sub(s,"//","/",0); + + pstrcpy(base_name,s); + p = strrchr_m(base_name,'/'); + + if (!p) + return(True); + + if (!vfs_GetWd(conn,wd)) { + DEBUG(0,("couldn't vfs_GetWd for %s %s\n",s,dir)); + return(False); + } + + if (vfs_ChDir(conn,dir) != 0) { + DEBUG(0,("couldn't vfs_ChDir to %s\n",dir)); + return(False); + } + + if (!vfs_GetWd(conn,dir2)) { + DEBUG(0,("couldn't vfs_GetWd for %s\n",dir)); + vfs_ChDir(conn,wd); + return(False); + } + + if (p && (p != base_name)) { + *p = 0; + if (strcmp(p+1,".")==0) + p[1]=0; + if (strcmp(p+1,"..")==0) + *p = '/'; + } + + if (vfs_ChDir(conn,base_name) != 0) { + vfs_ChDir(conn,wd); + DEBUG(3,("couldn't vfs_ChDir for %s %s basename=%s\n",s,dir,base_name)); + return(False); + } + + if (!vfs_GetWd(conn,newname)) { + vfs_ChDir(conn,wd); + DEBUG(2,("couldn't get vfs_GetWd for %s %s\n",s,dir2)); + return(False); + } + + if (p && (p != base_name)) { + pstrcat(newname,"/"); + pstrcat(newname,p+1); + } + + { + size_t l = strlen(dir2); + if (dir2[l-1] == '/') + l--; + + if (strncmp(newname,dir2,l) != 0) { + vfs_ChDir(conn,wd); + DEBUG(2,("Bad access attempt? s=%s dir=%s newname=%s l=%d\n",s,dir2,newname,(int)l)); + return(False); + } + + if (relative) { + if (newname[l] == '/') + pstrcpy(s,newname + l + 1); + else + pstrcpy(s,newname+l); + } else + pstrcpy(s,newname); + } - vfs_ChDir(conn,wd); + vfs_ChDir(conn,wd); - if (strlen(s) == 0) - pstrcpy(s,"./"); + if (strlen(s) == 0) + pstrcpy(s,"./"); - DEBUG(3,("reduced to %s\n",s)); - return(True); + DEBUG(3,("reduced to %s\n",s)); + return(True); #endif } |