summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-03-19 02:32:39 +0000
committerJeremy Allison <jra@samba.org>2002-03-19 02:32:39 +0000
commitffadd471b9664018b3010ab5d74e6d05b8886e66 (patch)
treeeaf1c0c83d1f11f2eb6f68d1201f745722f33dfe
parentcdc9931bb2f53272159b04ef7b1b057ce837ed4b (diff)
downloadsamba-ffadd471b9664018b3010ab5d74e6d05b8886e66.tar.gz
samba-ffadd471b9664018b3010ab5d74e6d05b8886e66.tar.bz2
samba-ffadd471b9664018b3010ab5d74e6d05b8886e66.zip
Sync up vfs changes from 2.2.x.
Jeremy. (This used to be commit ad1e858d8e72adf924ff435eab8da3e60842e2e6)
-rwxr-xr-xsource3/configure6
-rw-r--r--source3/configure.in2
-rw-r--r--source3/include/config.h.in3
-rw-r--r--source3/include/smb.h1
-rw-r--r--source3/include/vfs.h6
-rw-r--r--source3/lib/system.c15
-rw-r--r--source3/param/loadparm.c3
-rw-r--r--source3/smbd/reply.c2
-rw-r--r--source3/smbd/vfs-wrap.c166
-rw-r--r--source3/smbd/vfs.c52
10 files changed, 68 insertions, 188 deletions
diff --git a/source3/configure b/source3/configure
index fb5ac068d5..a542e3dc18 100755
--- a/source3/configure
+++ b/source3/configure
@@ -5395,7 +5395,7 @@ else
fi
done
-for ac_func in initgroups select poll rdchk getgrnam getgrent pathconf
+for ac_func in initgroups select poll rdchk getgrnam getgrent pathconf realpath
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:5402: checking for $ac_func" >&5
@@ -13447,12 +13447,12 @@ case "$host_os" in
;;
*solaris*)
HAVE_WINBIND=yes
- WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris"
+ WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
WINBIND_NSS_EXTRA_LIBS="-lsocket"
;;
*hpux11*)
HAVE_WINBIND=yes
- WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris"
+ WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
;;
*)
HAVE_WINBIND=no
diff --git a/source3/configure.in b/source3/configure.in
index 76250e3050..3610b37b25 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -588,7 +588,7 @@ AC_CHECK_FUNCS(waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod
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)
-AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
+AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
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)
diff --git a/source3/include/config.h.in b/source3/include/config.h.in
index 310ef32b2f..cebd9ee346 100644
--- a/source3/include/config.h.in
+++ b/source3/include/config.h.in
@@ -676,6 +676,9 @@
/* Define if you have the readlink function. */
#undef HAVE_READLINK
+/* Define if you have the realpath function. */
+#undef HAVE_REALPATH
+
/* Define if you have the rename function. */
#undef HAVE_RENAME
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 303b1f5efa..02645f35d3 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -449,6 +449,7 @@ typedef struct connection_struct
struct vfs_ops vfs_ops; /* Filesystem operations */
/* Handle on dlopen() call */
void *dl_handle;
+ void *vfs_private;
char *user; /* name of user who *opened* this connection */
uid_t uid; /* uid of user who *opened* this connection */
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index da601b937b..bbbe2cb8b2 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
VFS structures and parameters
Copyright (C) Tim Potter 1999
@@ -55,7 +56,7 @@ struct vfs_ops {
int (*connect)(struct connection_struct *conn, const char *service, const char *user);
void (*disconnect)(struct connection_struct *conn);
SMB_BIG_UINT (*disk_free)(struct connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize,
- SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
+ SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
/* Directory operations */
@@ -91,6 +92,7 @@ struct vfs_ops {
int (*readlink)(struct connection_struct *conn, const char *path, char *buf, size_t bufsiz);
int (*link)(struct connection_struct *conn, const char *oldpath, const char *newpath);
int (*mknod)(struct connection_struct *conn, const char *path, mode_t mode, SMB_DEV_T dev);
+ char *(*realpath)(struct connection_struct *conn, const char *path, char *resolved_path);
/* NT ACL operations. */
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 631c02633f..b911c29d93 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -255,6 +255,21 @@ int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev)
}
/*******************************************************************
+ Wrapper for realpath.
+********************************************************************/
+
+char *sys_realpath(const char *path, char *resolved_path)
+{
+#if defined(HAVE_REALPATH)
+ return realpath(path, resolved_path);
+#else
+ /* As realpath is not a system call we can't return ENOSYS. */
+ errno = EINVAL;
+ return NULL;
+#endif
+}
+
+/*******************************************************************
The wait() calls vary between systems
********************************************************************/
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 12dedc7a01..7e9224dcd4 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1047,7 +1047,7 @@ static struct parm_struct parm_table[] = {
{"hide local users", P_BOOL, P_GLOBAL, &Globals.bHideLocalUsers, NULL,
NULL, 0},
- {"VFS options", P_SEP, P_SEPARATOR},
+ {"VFS module options", P_SEP, P_SEPARATOR},
{"vfs object", P_STRING, P_LOCAL, &sDefault.szVfsObjectFile, handle_vfs_object, NULL, FLAG_SHARE},
{"vfs options", P_STRING, P_LOCAL, &sDefault.szVfsOptions, NULL, NULL, FLAG_SHARE},
@@ -1700,6 +1700,7 @@ FN_LOCAL_LIST(lp_writelist, writelist)
FN_LOCAL_LIST(lp_printer_admin, printer_admin)
FN_LOCAL_STRING(lp_fstype, fstype)
FN_LOCAL_STRING(lp_vfsobj, szVfsObjectFile)
+FN_LOCAL_STRING(lp_vfs_options, szVfsOptions)
static FN_LOCAL_STRING(lp_volume, volume)
FN_LOCAL_STRING(lp_mangled_map, szMangledMap)
FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 1b7db5f0a7..0af2ea3716 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1261,7 +1261,7 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
p = strrchr_m(name,'/');
if (!p) {
- pstrcpy(directory,"./");
+ pstrcpy(directory,".");
pstrcpy(mask,name);
} else {
*p = 0;
diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c
index 73b070d3f8..1d94e18e5b 100644
--- a/source3/smbd/vfs-wrap.c
+++ b/source3/smbd/vfs-wrap.c
@@ -22,8 +22,6 @@
/* Check for NULL pointer parameters in vfswrap_* functions */
-#define VFS_CHECK_NULL
-
/* We don't want to have NULL function pointers lying around. Someone
is sure to try and execute them. These stubs are used to prevent
this possibility. */
@@ -44,14 +42,6 @@ SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, const char *path, BOOL s
{
SMB_BIG_UINT result;
-#ifdef VFS_CHECK_NULL
- if ((path == NULL) || (bsize == NULL) || (dfree == NULL) ||
- (dsize == NULL)) {
-
- smb_panic("NULL pointer passed to vfswrap_disk_free() function\n");
- }
-#endif
-
result = sys_disk_free(path, small_query, bsize, dfree, dsize);
return result;
}
@@ -63,13 +53,6 @@ DIR *vfswrap_opendir(connection_struct *conn, const char *fname)
DIR *result;
START_PROFILE(syscall_opendir);
-
-#ifdef VFS_CHECK_NULL
- if (fname == NULL) {
- smb_panic("NULL pointer passed to vfswrap_opendir()\n");
- }
-#endif
-
result = opendir(fname);
END_PROFILE(syscall_opendir);
return result;
@@ -80,13 +63,6 @@ struct dirent *vfswrap_readdir(connection_struct *conn, DIR *dirp)
struct dirent *result;
START_PROFILE(syscall_readdir);
-
-#ifdef VFS_CHECK_NULL
- if (dirp == NULL) {
- smb_panic("NULL pointer passed to vfswrap_readdir()\n");
- }
-#endif
-
result = readdir(dirp);
END_PROFILE(syscall_readdir);
return result;
@@ -99,12 +75,6 @@ int vfswrap_mkdir(connection_struct *conn, const char *path, mode_t mode)
START_PROFILE(syscall_mkdir);
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_mkdir()\n");
- }
-#endif
-
if (lp_inherit_acls(SNUM(conn)) && (has_dacl = directory_has_default_acl(conn, parent_dirname(path))))
mode = 0777;
@@ -134,13 +104,6 @@ int vfswrap_rmdir(connection_struct *conn, const char *path)
int result;
START_PROFILE(syscall_rmdir);
-
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_rmdir()\n");
- }
-#endif
-
result = rmdir(path);
END_PROFILE(syscall_rmdir);
return result;
@@ -151,13 +114,6 @@ int vfswrap_closedir(connection_struct *conn, DIR *dirp)
int result;
START_PROFILE(syscall_closedir);
-
-#ifdef VFS_CHECK_NULL
- if (dirp == NULL) {
- smb_panic("NULL pointer passed to vfswrap_closedir()\n");
- }
-#endif
-
result = closedir(dirp);
END_PROFILE(syscall_closedir);
return result;
@@ -170,13 +126,6 @@ int vfswrap_open(connection_struct *conn, const char *fname, int flags, mode_t m
int result;
START_PROFILE(syscall_open);
-
-#ifdef VFS_CHECK_NULL
- if (fname == NULL) {
- smb_panic("NULL pointer passed to vfswrap_open()\n");
- }
-#endif
-
result = sys_open(fname, flags, mode);
END_PROFILE(syscall_open);
return result;
@@ -198,13 +147,6 @@ ssize_t vfswrap_read(files_struct *fsp, int fd, void *data, size_t n)
ssize_t result;
START_PROFILE_BYTES(syscall_read, n);
-
-#ifdef VFS_CHECK_NULL
- if (data == NULL) {
- smb_panic("NULL pointer passed to vfswrap_read()\n");
- }
-#endif
-
result = read(fd, data, n);
END_PROFILE(syscall_read);
return result;
@@ -215,13 +157,6 @@ ssize_t vfswrap_write(files_struct *fsp, int fd, const void *data, size_t n)
ssize_t result;
START_PROFILE_BYTES(syscall_write, n);
-
-#ifdef VFS_CHECK_NULL
- if (data == NULL) {
- smb_panic("NULL pointer passed to vfswrap_write()\n");
- }
-#endif
-
result = write(fd, data, n);
END_PROFILE(syscall_write);
return result;
@@ -256,13 +191,6 @@ int vfswrap_rename(connection_struct *conn, const char *old, const char *new)
int result;
START_PROFILE(syscall_rename);
-
-#ifdef VFS_CHECK_NULL
- if ((old == NULL) || (new == NULL)) {
- smb_panic("NULL pointer passed to vfswrap_rename()\n");
- }
-#endif
-
result = rename(old, new);
END_PROFILE(syscall_rename);
return result;
@@ -288,13 +216,6 @@ int vfswrap_stat(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sb
int result;
START_PROFILE(syscall_stat);
-
-#ifdef VFS_CHECK_NULL
- if ((fname == NULL) || (sbuf == NULL)) {
- smb_panic("NULL pointer passed to vfswrap_stat()\n");
- }
-#endif
-
result = sys_stat(fname, sbuf);
END_PROFILE(syscall_stat);
return result;
@@ -305,13 +226,6 @@ int vfswrap_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
int result;
START_PROFILE(syscall_fstat);
-
-#ifdef VFS_CHECK_NULL
- if (sbuf == NULL) {
- smb_panic("NULL pointer passed to vfswrap_fstat()\n");
- }
-#endif
-
result = sys_fstat(fd, sbuf);
END_PROFILE(syscall_fstat);
return result;
@@ -322,13 +236,6 @@ int vfswrap_lstat(connection_struct *conn, const char *path, SMB_STRUCT_STAT *sb
int result;
START_PROFILE(syscall_lstat);
-
-#ifdef VFS_CHECK_NULL
- if ((path == NULL) || (sbuf == NULL)) {
- smb_panic("NULL pointer passed to vfswrap_lstat()\n");
- }
-#endif
-
result = sys_lstat(path, sbuf);
END_PROFILE(syscall_lstat);
return result;
@@ -339,13 +246,6 @@ int vfswrap_unlink(connection_struct *conn, const char *path)
int result;
START_PROFILE(syscall_unlink);
-
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_unlink()\n");
- }
-#endif
-
result = unlink(path);
END_PROFILE(syscall_unlink);
return result;
@@ -357,12 +257,6 @@ int vfswrap_chmod(connection_struct *conn, const char *path, mode_t mode)
START_PROFILE(syscall_chmod);
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_chmod()\n");
- }
-#endif
-
/*
* We need to do this due to the fact that the default POSIX ACL
* chmod modifies the ACL *mask* for the group owner, not the
@@ -418,13 +312,6 @@ int vfswrap_chown(connection_struct *conn, const char *path, uid_t uid, gid_t gi
int result;
START_PROFILE(syscall_chown);
-
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_chown()\n");
- }
-#endif
-
result = sys_chown(path, uid, gid);
END_PROFILE(syscall_chown);
return result;
@@ -446,13 +333,6 @@ int vfswrap_chdir(connection_struct *conn, const char *path)
int result;
START_PROFILE(syscall_chdir);
-
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_chdir()\n");
- }
-#endif
-
result = chdir(path);
END_PROFILE(syscall_chdir);
return result;
@@ -463,13 +343,6 @@ char *vfswrap_getwd(connection_struct *conn, char *path)
char *result;
START_PROFILE(syscall_getwd);
-
-#ifdef VFS_CHECK_NULL
- if (path == NULL) {
- smb_panic("NULL pointer passed to vfswrap_getwd()\n");
- }
-#endif
-
result = sys_getwd(path);
END_PROFILE(syscall_getwd);
return result;
@@ -480,13 +353,6 @@ int vfswrap_utime(connection_struct *conn, const char *path, struct utimbuf *tim
int result;
START_PROFILE(syscall_utime);
-
-#ifdef VFS_CHECK_NULL
- if ((path == NULL) || (times == NULL)) {
- smb_panic("NULL pointer passed to vfswrap_utime()\n");
- }
-#endif
-
result = utime(path, times);
END_PROFILE(syscall_utime);
return result;
@@ -642,12 +508,6 @@ int vfswrap_symlink(connection_struct *conn, const char *oldpath, const char *ne
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;
@@ -658,12 +518,6 @@ int vfswrap_readlink(connection_struct *conn, const char *path, char *buf, size_
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;
@@ -674,11 +528,6 @@ int vfswrap_link(connection_struct *conn, const char *oldpath, const char *newpa
int result;
START_PROFILE(syscall_link);
-
-#ifdef VFS_CHECK_NULL
- if ((oldpath == NULL) || (newpath == NULL))
- smb_panic("NULL pointer passed to vfswrap_link()\n");
-#endif
result = sys_link(oldpath, newpath);
END_PROFILE(syscall_link);
return result;
@@ -689,16 +538,21 @@ int vfswrap_mknod(connection_struct *conn, const char *pathname, mode_t mode, SM
int result;
START_PROFILE(syscall_mknod);
-
-#ifdef VFS_CHECK_NULL
- if (pathname == NULL)
- smb_panic("NULL pointer passed to vfswrap_mknod()\n");
-#endif
result = sys_mknod(pathname, mode, dev);
END_PROFILE(syscall_mknod);
return result;
}
+char *vfswrap_realpath(connection_struct *conn, const char *path, char *resolved_path)
+{
+ char *result;
+
+ START_PROFILE(syscall_realpath);
+ result = sys_realpath(path, resolved_path);
+ END_PROFILE(syscall_realpath);
+ return result;
+}
+
size_t vfswrap_fget_nt_acl(files_struct *fsp, int fd, SEC_DESC **ppdesc)
{
size_t result;
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 8d7ee2b075..6416d8e73e 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
VFS initialisation and support functions
Copyright (C) Tim Potter 1999
@@ -31,7 +32,7 @@ struct vfs_syminfo {
very important. They must be in the same order as defined in
vfs.h. Change at your own peril. */
-static struct vfs_ops default_vfs_ops = {
+struct vfs_ops default_vfs_ops = {
/* Disk operations */
@@ -73,6 +74,7 @@ static struct vfs_ops default_vfs_ops = {
vfswrap_readlink,
vfswrap_link,
vfswrap_mknod,
+ vfswrap_realpath,
vfswrap_fget_nt_acl,
vfswrap_get_nt_acl,
@@ -131,46 +133,48 @@ static BOOL vfs_init_default(connection_struct *conn)
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) {
- DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)), sys_dlerror()));
+ 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) {
+ if (init_fptr == NULL) {
DEBUG(0, ("No vfs_init() symbol found in %s\n",
- lp_vfsobj(SNUM(conn))));
+ 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, &conn->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",
- vfs_version, SMB_VFS_INTERFACE_VERSION ));
+ vfs_version, SMB_VFS_INTERFACE_VERSION ));
return False;
}
-
+
if (ops != &conn->vfs_ops) {
memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops));
}
- return True;
+ return True;
}
#endif
@@ -276,7 +280,7 @@ BOOL vfs_object_exist(connection_struct *conn,const char *fname,SMB_STRUCT_STAT
Check if a file exists in the vfs.
********************************************************************/
-BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf)
+BOOL vfs_file_exist(connection_struct *conn, const char *fname,SMB_STRUCT_STAT *sbuf)
{
SMB_STRUCT_STAT st;