[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-3217-g6778837

Jeremy Allison jra at samba.org
Mon Dec 1 22:26:04 GMT 2008


The branch, v3-2-test has been updated
       via  67788371cef51009295d1f85daf7f0328225f1f9 (commit)
      from  c8b021ee740e67973b1d37eceadf7bab6c413cdd (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 67788371cef51009295d1f85daf7f0328225f1f9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Dec 1 14:25:04 2008 -0800

    s3:streams_xattr: recheck fsp->fsp_name after a rename
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source/modules/vfs_streams_xattr.c |   65 ++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/modules/vfs_streams_xattr.c b/source/modules/vfs_streams_xattr.c
index e96f616..6530a18 100644
--- a/source/modules/vfs_streams_xattr.c
+++ b/source/modules/vfs_streams_xattr.c
@@ -29,6 +29,9 @@
 struct stream_io {
 	char *base;
 	char *xattr_name;
+	void *fsp_name_ptr;
+	files_struct *fsp;
+	vfs_handle_struct *handle;
 };
 
 static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
@@ -85,6 +88,49 @@ static ssize_t get_xattr_size(connection_struct *conn,
 	return result;
 }
 
+static bool streams_xattr_recheck(struct stream_io *sio)
+{
+	NTSTATUS status;
+	char *base = NULL;
+	char *sname = NULL;
+	char *xattr_name = NULL;
+
+	if (sio->fsp->fsp_name == sio->fsp_name_ptr) {
+		return true;
+	}
+
+	status = split_ntfs_stream_name(talloc_tos(), sio->fsp->fsp_name,
+					&base, &sname);
+	if (!NT_STATUS_IS_OK(status)) {
+		return false;
+	}
+
+	if (sname == NULL) {
+		/* how can this happen */
+		errno = EINVAL;
+		return false;
+	}
+
+	xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
+				     SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
+	if (xattr_name == NULL) {
+		return false;
+	}
+
+	TALLOC_FREE(sio->xattr_name);
+	TALLOC_FREE(sio->base);
+	sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
+					xattr_name);
+	sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
+				  base);
+	sio->fsp_name_ptr = sio->fsp->fsp_name;
+
+	if ((sio->xattr_name == NULL) || (sio->base == NULL)) {
+		return false;
+	}
+
+	return true;
+}
 
 static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
 			       SMB_STRUCT_STAT *sbuf)
@@ -98,6 +144,10 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
 		return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
 	}
 
+	if (!streams_xattr_recheck(io)) {
+		return -1;
+	}
+
 	if (SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf) == -1) {
 		return -1;
 	}
@@ -365,6 +415,9 @@ static int streams_xattr_open(vfs_handle_struct *handle,  const char *fname,
 					xattr_name);
         sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
 				  base);
+	sio->fsp_name_ptr = fsp->fsp_name;
+	sio->handle = handle;
+	sio->fsp = fsp;
 
 	if ((sio->xattr_name == NULL) || (sio->base == NULL)) {
 		errno = ENOMEM;
@@ -739,6 +792,10 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
 		return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
 	}
 
+	if (!streams_xattr_recheck(sio)) {
+		return -1;
+	}
+
 	status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp,
 			      sio->base, sio->xattr_name, &ea);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -795,6 +852,10 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
 		return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
 	}
 
+	if (!streams_xattr_recheck(sio)) {
+		return -1;
+	}
+
 	status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp,
 			      sio->base, sio->xattr_name, &ea);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -835,6 +896,10 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
 		return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
 	}
 
+	if (!streams_xattr_recheck(sio)) {
+		return -1;
+	}
+
 	status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp,
 			      sio->base, sio->xattr_name, &ea);
 	if (!NT_STATUS_IS_OK(status)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list