summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-12-01 14:25:20 -0800
committerJeremy Allison <jra@samba.org>2008-12-01 14:25:20 -0800
commita8004a4ef5713a2005ae6ead1d510f30080ecb6f (patch)
treea3723f5de7b1f1721af073c51d4ff5de7c5db5fd
parente6a2ce970bf24a1ff588ee2f492e47b88145992f (diff)
downloadsamba-a8004a4ef5713a2005ae6ead1d510f30080ecb6f.tar.gz
samba-a8004a4ef5713a2005ae6ead1d510f30080ecb6f.tar.bz2
samba-a8004a4ef5713a2005ae6ead1d510f30080ecb6f.zip
s3:streams_xattr: recheck fsp->fsp_name after a rename
metze
-rw-r--r--source3/modules/vfs_streams_xattr.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index e96f616e31..6530a1813b 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/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)) {