diff options
author | Volker Lendecke <vl@samba.org> | 2012-09-02 13:06:22 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-09-04 15:15:00 -0700 |
commit | f67a6c463cbe14dfaaeb8a6255cfb587eea1b5a2 (patch) | |
tree | 2d0d175090e1d2cdcac4d3d3e6ac7733f1834709 /source3/smbd | |
parent | 0d869327edaede4f573cd607a14538d92160a286 (diff) | |
download | samba-f67a6c463cbe14dfaaeb8a6255cfb587eea1b5a2.tar.gz samba-f67a6c463cbe14dfaaeb8a6255cfb587eea1b5a2.tar.bz2 samba-f67a6c463cbe14dfaaeb8a6255cfb587eea1b5a2.zip |
s3: Factor out calculation of clear_ads
Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/open.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index dc775dceab..e801a7873d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1778,6 +1778,22 @@ bool is_deferred_open_async(const void *ptr) return state->async_open; } +static bool clear_ads(uint32_t create_disposition) +{ + bool ret = false; + + switch (create_disposition) { + case FILE_SUPERSEDE: + case FILE_OVERWRITE_IF: + case FILE_OVERWRITE: + ret = true; + break; + default: + break; + } + return ret; +} + /**************************************************************************** Open a file with a share mode. Passed in an already created files_struct *. ****************************************************************************/ @@ -1802,7 +1818,6 @@ 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; NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED; mode_t new_unx_mode = (mode_t)0; mode_t unx_mode = (mode_t)0; @@ -1943,14 +1958,12 @@ 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: @@ -1977,7 +1990,6 @@ 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: @@ -2494,7 +2506,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, SMB_ASSERT(lck != NULL); /* Delete streams if create_disposition requires it */ - if (!new_file_created && clear_ads && + if (!new_file_created && clear_ads(create_disposition) && !is_ntfs_stream_smb_fname(smb_fname)) { status = delete_all_streams(conn, smb_fname->base_name); if (!NT_STATUS_IS_OK(status)) { |