diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/service.c | 26 | ||||
-rw-r--r-- | source3/smbd/vfs-wrap.c | 32 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 213 |
3 files changed, 145 insertions, 126 deletions
diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 61da72b2e9..0e2c0ff7a1 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -524,28 +524,10 @@ connection_struct *make_connection(char *service,char *user,char *password, int } /* Initialise VFS function pointers */ - if (*lp_vfsobj(SNUM(conn))) { - -#ifdef HAVE_LIBDL - - /* Loadable object file */ - - if (!vfs_init_custom(conn)) { - DEBUG(0, ("vfs_init failed\n")); - conn_free(conn); - return NULL; - } -#else - DEBUG(0, ("No libdl present - cannot use VFS objects\n")); - conn_free(conn); - return NULL; -#endif - - } else { - - /* Normal share - initialise with disk access functions */ - - vfs_init_default(conn); + if (!vfs_init(conn)) { + DEBUG(0, ("vfs_init failed for service %s\n", lp_servicename(SNUM(conn)))); + conn_free(conn); + return NULL; } /* execute any "root preexec = " line */ diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c index da8484e14e..a0b4966c59 100644 --- a/source3/smbd/vfs-wrap.c +++ b/source3/smbd/vfs-wrap.c @@ -558,6 +558,38 @@ BOOL vfswrap_lock(files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T return result; } +int vfswrap_symlink(connection_struct *conn, const char *oldpath, const char *newpath) +{ + int result; + + START_PROFILE(syscall_symlink); + +#ifdef VFS_CHECK_NULL + if ((oldpath == NULL) || (newpath == NULL)) + smb_panic("NULL pointer passed to vfswrap_symlink()\n"); +#endif + + result = sys_symlink(oldpath, newpath); + END_PROFILE(syscall_symlink); + return result; +} + +int vfswrap_readlink(connection_struct *conn, const char *path, char *buf, size_t bufsiz) +{ + int result; + + START_PROFILE(syscall_readlink); + +#ifdef VFS_CHECK_NULL + if ((path == NULL) || (buf == NULL)) + smb_panic("NULL pointer passed to vfswrap_readlink()\n"); +#endif + + result = sys_readlink(path, buf, bufsiz); + END_PROFILE(syscall_readlink); + return result; +} + size_t vfswrap_fget_nt_acl(files_struct *fsp, int fd, SEC_DESC **ppdesc) { return get_nt_acl(fsp, ppdesc); diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 713d58cdc8..ac00d00e9e 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -72,6 +72,9 @@ struct vfs_ops default_vfs_ops = { vfswrap_utime, vfswrap_ftruncate, vfswrap_lock, + vfswrap_symlink, + vfswrap_readlink, + vfswrap_fget_nt_acl, vfswrap_get_nt_acl, vfswrap_fset_nt_acl, @@ -89,7 +92,8 @@ struct vfs_ops default_vfs_ops = { /**************************************************************************** initialise default vfs hooks ****************************************************************************/ -int vfs_init_default(connection_struct *conn) + +static BOOL vfs_init_default(connection_struct *conn) { DEBUG(3, ("Initialising default vfs hooks\n")); @@ -102,7 +106,7 @@ int vfs_init_default(connection_struct *conn) ****************************************************************************/ #ifdef HAVE_LIBDL -BOOL vfs_init_custom(connection_struct *conn) +static BOOL vfs_init_custom(connection_struct *conn) { int vfs_version = -1; struct vfs_ops *ops, *(*init_fptr)(int *); @@ -146,145 +150,146 @@ BOOL vfs_init_custom(connection_struct *conn) memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops)); - if (conn->vfs_ops.connect == NULL) { - conn->vfs_ops.connect = default_vfs_ops.connect; - } + if (conn->vfs_ops.connect == NULL) + conn->vfs_ops.connect = default_vfs_ops.connect; - if (conn->vfs_ops.disconnect == NULL) { - conn->vfs_ops.disconnect = default_vfs_ops.disconnect; - } + if (conn->vfs_ops.disconnect == NULL) + conn->vfs_ops.disconnect = default_vfs_ops.disconnect; - if (conn->vfs_ops.disk_free == NULL) { - conn->vfs_ops.disk_free = default_vfs_ops.disk_free; - } + if (conn->vfs_ops.disk_free == NULL) + conn->vfs_ops.disk_free = default_vfs_ops.disk_free; - if (conn->vfs_ops.opendir == NULL) { - conn->vfs_ops.opendir = default_vfs_ops.opendir; - } + if (conn->vfs_ops.opendir == NULL) + conn->vfs_ops.opendir = default_vfs_ops.opendir; - if (conn->vfs_ops.readdir == NULL) { - conn->vfs_ops.readdir = default_vfs_ops.readdir; - } + if (conn->vfs_ops.readdir == NULL) + conn->vfs_ops.readdir = default_vfs_ops.readdir; - if (conn->vfs_ops.mkdir == NULL) { - conn->vfs_ops.mkdir = default_vfs_ops.mkdir; - } + if (conn->vfs_ops.mkdir == NULL) + conn->vfs_ops.mkdir = default_vfs_ops.mkdir; - if (conn->vfs_ops.rmdir == NULL) { - conn->vfs_ops.rmdir = default_vfs_ops.rmdir; - } + if (conn->vfs_ops.rmdir == NULL) + conn->vfs_ops.rmdir = default_vfs_ops.rmdir; - if (conn->vfs_ops.closedir == NULL) { - conn->vfs_ops.closedir = default_vfs_ops.closedir; - } + if (conn->vfs_ops.closedir == NULL) + conn->vfs_ops.closedir = default_vfs_ops.closedir; - if (conn->vfs_ops.open == NULL) { - conn->vfs_ops.open = default_vfs_ops.open; - } + if (conn->vfs_ops.open == NULL) + conn->vfs_ops.open = default_vfs_ops.open; - if (conn->vfs_ops.close == NULL) { - conn->vfs_ops.close = default_vfs_ops.close; - } + if (conn->vfs_ops.close == NULL) + conn->vfs_ops.close = default_vfs_ops.close; - if (conn->vfs_ops.read == NULL) { - conn->vfs_ops.read = default_vfs_ops.read; - } + if (conn->vfs_ops.read == NULL) + conn->vfs_ops.read = default_vfs_ops.read; - if (conn->vfs_ops.write == NULL) { - conn->vfs_ops.write = default_vfs_ops.write; - } + if (conn->vfs_ops.write == NULL) + conn->vfs_ops.write = default_vfs_ops.write; - if (conn->vfs_ops.lseek == NULL) { - conn->vfs_ops.lseek = default_vfs_ops.lseek; - } + if (conn->vfs_ops.lseek == NULL) + conn->vfs_ops.lseek = default_vfs_ops.lseek; - if (conn->vfs_ops.rename == NULL) { - conn->vfs_ops.rename = default_vfs_ops.rename; - } + if (conn->vfs_ops.rename == NULL) + conn->vfs_ops.rename = default_vfs_ops.rename; - if (conn->vfs_ops.fsync == NULL) { - conn->vfs_ops.fsync = default_vfs_ops.fsync; - } + if (conn->vfs_ops.fsync == NULL) + conn->vfs_ops.fsync = default_vfs_ops.fsync; - if (conn->vfs_ops.stat == NULL) { - conn->vfs_ops.stat = default_vfs_ops.stat; - } + if (conn->vfs_ops.stat == NULL) + conn->vfs_ops.stat = default_vfs_ops.stat; - if (conn->vfs_ops.fstat == NULL) { - conn->vfs_ops.fstat = default_vfs_ops.fstat; - } + if (conn->vfs_ops.fstat == NULL) + conn->vfs_ops.fstat = default_vfs_ops.fstat; - if (conn->vfs_ops.lstat == NULL) { - conn->vfs_ops.lstat = default_vfs_ops.lstat; - } + if (conn->vfs_ops.lstat == NULL) + conn->vfs_ops.lstat = default_vfs_ops.lstat; - if (conn->vfs_ops.unlink == NULL) { - conn->vfs_ops.unlink = default_vfs_ops.unlink; - } + if (conn->vfs_ops.unlink == NULL) + conn->vfs_ops.unlink = default_vfs_ops.unlink; - if (conn->vfs_ops.chmod == NULL) { - conn->vfs_ops.chmod = default_vfs_ops.chmod; - } + if (conn->vfs_ops.chmod == NULL) + conn->vfs_ops.chmod = default_vfs_ops.chmod; - if (conn->vfs_ops.fchmod == NULL) { - conn->vfs_ops.fchmod = default_vfs_ops.fchmod; - } + if (conn->vfs_ops.fchmod == NULL) + conn->vfs_ops.fchmod = default_vfs_ops.fchmod; - if (conn->vfs_ops.chown == NULL) { - conn->vfs_ops.chown = default_vfs_ops.chown; - } + if (conn->vfs_ops.chown == NULL) + conn->vfs_ops.chown = default_vfs_ops.chown; - if (conn->vfs_ops.fchown == NULL) { - conn->vfs_ops.fchown = default_vfs_ops.fchown; - } + if (conn->vfs_ops.fchown == NULL) + conn->vfs_ops.fchown = default_vfs_ops.fchown; - if (conn->vfs_ops.chdir == NULL) { - conn->vfs_ops.chdir = default_vfs_ops.chdir; - } + if (conn->vfs_ops.chdir == NULL) + conn->vfs_ops.chdir = default_vfs_ops.chdir; - if (conn->vfs_ops.getwd == NULL) { - conn->vfs_ops.getwd = default_vfs_ops.getwd; - } + if (conn->vfs_ops.getwd == NULL) + conn->vfs_ops.getwd = default_vfs_ops.getwd; - if (conn->vfs_ops.utime == NULL) { - conn->vfs_ops.utime = default_vfs_ops.utime; - } + if (conn->vfs_ops.utime == NULL) + conn->vfs_ops.utime = default_vfs_ops.utime; - if (conn->vfs_ops.ftruncate == NULL) { - conn->vfs_ops.ftruncate = default_vfs_ops.ftruncate; - } + if (conn->vfs_ops.ftruncate == NULL) + conn->vfs_ops.ftruncate = default_vfs_ops.ftruncate; - if (conn->vfs_ops.lock == NULL) { - conn->vfs_ops.lock = default_vfs_ops.lock; - } + if (conn->vfs_ops.lock == NULL) + conn->vfs_ops.lock = default_vfs_ops.lock; - if (conn->vfs_ops.fget_nt_acl == NULL) { - conn->vfs_ops.fget_nt_acl = default_vfs_ops.fget_nt_acl; - } + if (conn->vfs_ops.symlink == NULL) + conn->vfs_ops.symlink = default_vfs_ops.symlink; - if (conn->vfs_ops.get_nt_acl == NULL) { - conn->vfs_ops.get_nt_acl = default_vfs_ops.get_nt_acl; - } + if (conn->vfs_ops.readlink == NULL) + conn->vfs_ops.readlink = default_vfs_ops.readlink; - if (conn->vfs_ops.fset_nt_acl == NULL) { - conn->vfs_ops.fset_nt_acl = default_vfs_ops.fset_nt_acl; - } + if (conn->vfs_ops.fget_nt_acl == NULL) + conn->vfs_ops.fget_nt_acl = default_vfs_ops.fget_nt_acl; - if (conn->vfs_ops.set_nt_acl == NULL) { - conn->vfs_ops.set_nt_acl = default_vfs_ops.set_nt_acl; - } + if (conn->vfs_ops.get_nt_acl == NULL) + conn->vfs_ops.get_nt_acl = default_vfs_ops.get_nt_acl; - if (conn->vfs_ops.chmod_acl == NULL) { - conn->vfs_ops.chmod_acl = default_vfs_ops.chmod_acl; - } + if (conn->vfs_ops.fset_nt_acl == NULL) + conn->vfs_ops.fset_nt_acl = default_vfs_ops.fset_nt_acl; + + if (conn->vfs_ops.set_nt_acl == NULL) + conn->vfs_ops.set_nt_acl = default_vfs_ops.set_nt_acl; + + if (conn->vfs_ops.chmod_acl == NULL) + conn->vfs_ops.chmod_acl = default_vfs_ops.chmod_acl; + + if (conn->vfs_ops.fchmod_acl == NULL) + conn->vfs_ops.fchmod_acl = default_vfs_ops.fchmod_acl; - if (conn->vfs_ops.fchmod_acl == NULL) { - conn->vfs_ops.fchmod_acl = default_vfs_ops.fchmod_acl; - } return True; } #endif +/***************************************************************** + Generic VFS init. +******************************************************************/ + +BOOL vfs_init(connection_struct *conn) +{ + if (*lp_vfsobj(SNUM(conn))) { +#ifdef HAVE_LIBDL + + /* Loadable object file */ + + if (!vfs_init_custom(conn)) { + DEBUG(0, ("vfs_init: vfs_init_custom failed\n")); + return False; + } + + return True; +#else + DEBUG(0, ("vfs_init: No libdl present - cannot use VFS objects\n")); + return False; +#endif + } + + /* Normal share - initialise with disk access functions */ + + return vfs_init_default(conn); +} + /******************************************************************* Check if directory exists. ********************************************************************/ |