summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-01-09 11:07:45 -0800
committerTim Prouty <tprouty@samba.org>2009-01-09 11:45:31 -0800
commitf2269e6cc85ffcd38134df2e430c4c0fabde17f8 (patch)
tree4c509d89863c2368152a8607e698487686794218
parent6dde84553c1f4d14f075982377f5af97ff5abc44 (diff)
downloadsamba-f2269e6cc85ffcd38134df2e430c4c0fabde17f8.tar.gz
samba-f2269e6cc85ffcd38134df2e430c4c0fabde17f8.tar.bz2
samba-f2269e6cc85ffcd38134df2e430c4c0fabde17f8.zip
s3: Fix open path to delete streams depending on the create disposition
The new create disposition test in smbtorture RAW-STREAMS verifies this fix.
-rw-r--r--source3/smbd/open.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 52e31dfc23..7d23b92359 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1330,6 +1330,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
bool def_acl = False;
bool posix_open = False;
bool new_file_created = False;
+ bool clear_ads = false;
struct file_id id;
NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED;
mode_t new_unx_mode = (mode_t)0;
@@ -1461,12 +1462,14 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
/* If file exists replace/overwrite. If file doesn't
* exist create. */
flags2 |= (O_CREAT | O_TRUNC);
+ clear_ads = true;
break;
case FILE_OVERWRITE_IF:
/* If file exists replace/overwrite. If file doesn't
* exist create. */
flags2 |= (O_CREAT | O_TRUNC);
+ clear_ads = true;
break;
case FILE_OPEN:
@@ -1491,6 +1494,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
flags2 |= O_TRUNC;
+ clear_ads = true;
break;
case FILE_CREATE:
@@ -1925,6 +1929,16 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
SMB_ASSERT(lck != NULL);
+ /* Delete streams if create_disposition requires it */
+ if (file_existed && clear_ads) {
+ status = delete_all_streams(conn, fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(lck);
+ fd_close(fsp);
+ return status;
+ }
+ }
+
/* note that we ignore failure for the following. It is
basically a hack for NFS, and NFS will never set one of
these only read them. Nobody but Samba can ever set a deny