summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c39
-rw-r--r--source3/smbd/open.c12
2 files changed, 42 insertions, 9 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index fe5e5eccf2..8958878433 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -22,6 +22,8 @@
#include "includes.h"
+extern struct current_user current_user;
+
/****************************************************************************
Run a file if it is a magic script.
****************************************************************************/
@@ -172,7 +174,23 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
"entry for file %s\n", fsp->fsp_name));
}
- delete_file = (lck->delete_on_close | lck->initial_delete_on_close);
+ if (fsp->initial_delete_on_close && (lck->delete_token == NULL)) {
+ BOOL became_user = False;
+
+ /* Initial delete on close was set and no one else
+ * wrote a real delete on close. */
+
+ if (current_user.vuid != fsp->vuid) {
+ become_user(conn, fsp->vuid);
+ became_user = True;
+ }
+ set_delete_on_close_lck(lck, True, &current_user.ut);
+ if (became_user) {
+ unbecome_user();
+ }
+ }
+
+ delete_file = lck->delete_on_close;
if (delete_file) {
int i;
@@ -402,7 +420,24 @@ static int close_directory(files_struct *fsp, enum file_close_type close_type)
DEBUG(0, ("close_directory: Could not delete share entry for %s\n", fsp->fsp_name));
}
- delete_dir = (lck->delete_on_close | lck->initial_delete_on_close);
+ if (fsp->initial_delete_on_close) {
+ BOOL became_user = False;
+
+ /* Initial delete on close was set - for
+ * directories we don't care if anyone else
+ * wrote a real delete on close. */
+
+ if (current_user.vuid != fsp->vuid) {
+ become_user(fsp->conn, fsp->vuid);
+ became_user = True;
+ }
+ set_delete_on_close_lck(lck, True, &current_user.ut);
+ if (became_user) {
+ unbecome_user();
+ }
+ }
+
+ delete_dir = lck->delete_on_close;
if (delete_dir) {
int i;
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index c0638c0039..a5a8eacda0 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1761,10 +1761,8 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
return status;
}
/* Note that here we set the *inital* delete on close flag,
- not the regular one. */
- set_delete_on_close_token(lck, &current_user.ut);
- lck->initial_delete_on_close = True;
- lck->modified = True;
+ not the regular one. The magic gets handled in close. */
+ fsp->initial_delete_on_close = True;
}
/* Files should be initially set as archive */
@@ -2117,9 +2115,9 @@ NTSTATUS open_directory(connection_struct *conn,
}
if (NT_STATUS_IS_OK(status)) {
- set_delete_on_close_token(lck, &current_user.ut);
- lck->initial_delete_on_close = True;
- lck->modified = True;
+ /* Note that here we set the *inital* delete on close flag,
+ not the regular one. The magic gets handled in close. */
+ fsp->initial_delete_on_close = True;
}
}