summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-03-27 03:00:39 +0000
committerJeremy Allison <jra@samba.org>2002-03-27 03:00:39 +0000
commit7d7c594644d9b374e522f208b1f0bd5ab8abb9ab (patch)
treec197c1ed507014055f027cf0ace873e11ac3caca /source3/smbd
parent1a06eeb6dae9b148a6e70470660e51a42def2399 (diff)
downloadsamba-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)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/conn.c2
-rw-r--r--source3/smbd/vfs.c422
2 files changed, 194 insertions, 230 deletions
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
}