summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-02-23 23:39:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:44 -0500
commite2cc3f48162d7dec35fb3f256c031979cfa531f8 (patch)
tree8bbad8c6ce99ab543ac9560d650c3fe42b3e7529 /source3
parent0a063991a7b2a2a6a7ce537f24be1205d29bc09d (diff)
downloadsamba-e2cc3f48162d7dec35fb3f256c031979cfa531f8.tar.gz
samba-e2cc3f48162d7dec35fb3f256c031979cfa531f8.tar.bz2
samba-e2cc3f48162d7dec35fb3f256c031979cfa531f8.zip
r5524: Don't do share mode checks on can_delete if open, the rest of the open
code will do this correctly. More for bug #2201. Jeremy. (This used to be commit faecf639efdecf949e91184d041489aa54e8664f)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/nttrans.c3
-rw-r--r--source3/smbd/reply.c43
2 files changed, 26 insertions, 20 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index f07fd8c25b..2bb2198574 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -793,7 +793,8 @@ create_options = 0x%x root_dir_fid = 0x%x\n", flags, desired_access, file_attrib
status = can_delete(conn, fname, file_attributes, bad_path, True);
/* We're only going to fail here if it's access denied, as that's the
only error we care about for "can we delete this ?" questions. */
- if (!NT_STATUS_IS_OK(status) && NT_STATUS_EQUAL(status,NT_STATUS_ACCESS_DENIED)) {
+ if (!NT_STATUS_IS_OK(status) && (NT_STATUS_EQUAL(status,NT_STATUS_ACCESS_DENIED) ||
+ NT_STATUS_EQUAL(status,NT_STATUS_CANNOT_DELETE))) {
restore_case_semantics(conn, file_attributes);
END_PROFILE(SMBntcreateX);
return ERROR_NT(status);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 68705a8aea..89183aed34 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1520,29 +1520,34 @@ NTSTATUS can_delete(connection_struct *conn, char *fname, int dirtype, BOOL bad_
if ((fmode & ~dirtype) & (aHIDDEN | aSYSTEM))
return NT_STATUS_NO_SUCH_FILE;
- if (check_is_at_open && !can_delete_file_in_directory(conn, fname)) {
- return NT_STATUS_ACCESS_DENIED;
- }
-
- /* We need a better way to return NT status codes from open... */
- unix_ERR_class = 0;
- unix_ERR_code = 0;
-
- fsp = open_file_shared1(conn, fname, &sbuf, DELETE_ACCESS, SET_DENY_MODE(DENY_ALL),
- (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &smb_action);
+ if (check_is_at_open) {
+ if (!can_delete_file_in_directory(conn, fname)) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+ } else {
+ /* On open checks the open itself will check the share mode, so
+ don't do it here as we'll get it wrong. */
- if (!fsp) {
- NTSTATUS ret = NT_STATUS_ACCESS_DENIED;
- if (!NT_STATUS_IS_OK(unix_ERR_ntstatus))
- ret = unix_ERR_ntstatus;
- else if (unix_ERR_class == ERRDOS && unix_ERR_code == ERRbadshare)
- ret = NT_STATUS_SHARING_VIOLATION;
+ /* We need a better way to return NT status codes from open... */
unix_ERR_class = 0;
unix_ERR_code = 0;
- unix_ERR_ntstatus = NT_STATUS_OK;
- return ret;
+
+ fsp = open_file_shared1(conn, fname, &sbuf, DELETE_ACCESS, SET_DENY_MODE(DENY_ALL),
+ (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &smb_action);
+
+ if (!fsp) {
+ NTSTATUS ret = NT_STATUS_ACCESS_DENIED;
+ if (!NT_STATUS_IS_OK(unix_ERR_ntstatus))
+ ret = unix_ERR_ntstatus;
+ else if (unix_ERR_class == ERRDOS && unix_ERR_code == ERRbadshare)
+ ret = NT_STATUS_SHARING_VIOLATION;
+ unix_ERR_class = 0;
+ unix_ERR_code = 0;
+ unix_ERR_ntstatus = NT_STATUS_OK;
+ return ret;
+ }
+ close_file(fsp,False);
}
- close_file(fsp,False);
return NT_STATUS_OK;
}