summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-02-01 04:14:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:06:20 -0500
commit86c9bac4c31df1606e3758ec42672506dde26cc6 (patch)
tree1b0c707e273f3d44adb2ea3c4e87090d1cc99313 /source3/smbd
parent0e551cd5a2f468ad297f1bfbccbc9f91579dc794 (diff)
downloadsamba-86c9bac4c31df1606e3758ec42672506dde26cc6.tar.gz
samba-86c9bac4c31df1606e3758ec42672506dde26cc6.tar.bz2
samba-86c9bac4c31df1606e3758ec42672506dde26cc6.zip
r13274: Fix for bug #3467. Not a show stopper.
jason qian <jason@infrant.com> was a *fantastic* help in tracking this down. Jeremy. (This used to be commit 9f4a9c70fa232047868e5d8a3f132a2dd6bfee82)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c4
-rw-r--r--source3/smbd/open.c46
2 files changed, 24 insertions, 26 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index c0d87b1b21..d284c82f44 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -209,7 +209,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
DEBUG(0, ("close_file: Could not delete share entry for file %s\n", fsp->fsp_name));
}
- delete_file = lck->delete_on_close;
+ delete_file = (lck->delete_on_close | lck->initial_delete_on_close);
if (delete_file) {
int i;
@@ -345,7 +345,7 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
DEBUG(0, ("close_directory: Could not delete share entry for %s\n", fsp->fsp_name));
}
- delete_dir = lck->delete_on_close;
+ delete_dir = (lck->delete_on_close | lck->initial_delete_on_close);
talloc_free(lck);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 0ccac592d6..dd2731c897 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1660,32 +1660,28 @@ files_struct *open_file_ntcreate(connection_struct *conn,
}
set_share_mode(lck, fsp, 0, fsp->oplock_type);
- if (create_options & FILE_DELETE_ON_CLOSE) {
- uint32 dosattr= existing_dos_attributes;
- NTSTATUS result;
-
- if (info == FILE_WAS_OVERWRITTEN || info == FILE_WAS_CREATED ||
+ if (info == FILE_WAS_OVERWRITTEN || info == FILE_WAS_CREATED ||
info == FILE_WAS_SUPERSEDED) {
- dosattr = new_dos_attributes;
- }
-
- result = can_set_delete_on_close(fsp, True, dosattr);
- if (!NT_STATUS_IS_OK(result)) {
- /* Remember to delete the mode we just added. */
- del_share_mode(lck, fsp);
- talloc_free(lck);
- fd_close(conn,fsp);
- file_free(fsp);
- set_saved_ntstatus(result);
- return NULL;
+ /* Handle strange delete on close create semantics. */
+ if (create_options & FILE_DELETE_ON_CLOSE) {
+ NTSTATUS result = can_set_delete_on_close(fsp, True, new_dos_attributes);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ /* Remember to delete the mode we just added. */
+ del_share_mode(lck, fsp);
+ talloc_free(lck);
+ fd_close(conn,fsp);
+ file_free(fsp);
+ set_saved_ntstatus(result);
+ return NULL;
+ }
+ /* Note that here we set the *inital* delete on close flag,
+ not the regular one. */
+ lck->initial_delete_on_close = True;
+ lck->modified = True;
}
- lck->delete_on_close = True;
- lck->modified = True;
- }
- if (info == FILE_WAS_OVERWRITTEN || info == FILE_WAS_CREATED ||
- info == FILE_WAS_SUPERSEDED) {
/* Files should be initially set as archive */
if (lp_map_archive(SNUM(conn)) ||
lp_store_dos_attributes(SNUM(conn))) {
@@ -1976,7 +1972,9 @@ files_struct *open_directory(connection_struct *conn,
set_share_mode(lck, fsp, 0, NO_OPLOCK);
- if (create_options & FILE_DELETE_ON_CLOSE) {
+ if ((create_options & FILE_DELETE_ON_CLOSE) &&
+ (info == FILE_WAS_OVERWRITTEN || info == FILE_WAS_CREATED ||
+ info == FILE_WAS_SUPERSEDED)) {
status = can_set_delete_on_close(fsp, True, 0);
if (!NT_STATUS_IS_OK(status)) {
set_saved_ntstatus(status);
@@ -1985,7 +1983,7 @@ files_struct *open_directory(connection_struct *conn,
return NULL;
}
- lck->delete_on_close = True;
+ lck->initial_delete_on_close = True;
lck->modified = True;
}