mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Ensured all the system calls in msdfs.c go through the vfs layer.
Added vfs calls to symlink() and readlink() with appropriate configure checks. Jeremy.
This commit is contained in:
2
source/configure
vendored
2
source/configure
vendored
@ -5792,7 +5792,7 @@ else
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_func in srandom random srand rand setenv usleep strcasecmp fcvt fcvtl
|
||||
for ac_func in srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:5799: checking for $ac_func" >&5
|
||||
|
@ -497,7 +497,7 @@ AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
|
||||
AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
|
||||
AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
|
||||
AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
|
||||
AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl)
|
||||
AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
|
||||
|
||||
# syscall() is needed for smbwrapper.
|
||||
AC_CHECK_FUNCS(syscall)
|
||||
|
@ -628,6 +628,9 @@
|
||||
/* Define if you have the readdir64 function. */
|
||||
#undef HAVE_READDIR64
|
||||
|
||||
/* Define if you have the readlink function. */
|
||||
#undef HAVE_READLINK
|
||||
|
||||
/* Define if you have the rename function. */
|
||||
#undef HAVE_RENAME
|
||||
|
||||
@ -706,6 +709,9 @@
|
||||
/* Define if you have the strtoul function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
/* Define if you have the symlink function. */
|
||||
#undef HAVE_SYMLINK
|
||||
|
||||
/* Define if you have the syscall function. */
|
||||
#undef HAVE_SYSCALL
|
||||
|
||||
|
@ -86,6 +86,8 @@ struct vfs_ops {
|
||||
int (*utime)(struct connection_struct *conn, char *path, struct utimbuf *times);
|
||||
int (*ftruncate)(struct files_struct *fsp, int fd, SMB_OFF_T offset);
|
||||
BOOL (*lock)(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
|
||||
int (*symlink)(struct connection_struct *conn, const char *oldpath, const char *newpath);
|
||||
int (*readlink)(struct connection_struct *conn, const char *path, char *buf, size_t bufsiz);
|
||||
|
||||
/* NT ACL operations. */
|
||||
|
||||
|
@ -264,6 +264,34 @@ char *sys_getwd(char *s)
|
||||
return wd;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
system wrapper for symlink
|
||||
********************************************************************/
|
||||
|
||||
int sys_symlink(const char *oldpath, const char *newpath)
|
||||
{
|
||||
#ifndef HAVE_SYMLINK
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#else
|
||||
return symlink(oldpath, newpath);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
system wrapper for readlink
|
||||
********************************************************************/
|
||||
|
||||
int sys_readlink(const char *path, char *buf, size_t bufsiz)
|
||||
{
|
||||
#ifndef HAVE_READLINK
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#else
|
||||
return readlink(path, buf, bufsiz);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
chown isn't used much but OS/2 doesn't have it
|
||||
********************************************************************/
|
||||
|
1022
source/msdfs/msdfs.c
1022
source/msdfs/msdfs.c
File diff suppressed because it is too large
Load Diff
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
********************************************************************/
|
||||
|
Reference in New Issue
Block a user