svn commit: samba r5524 - in branches/SAMBA_3_0/source/smbd: .

jra at samba.org jra at samba.org
Wed Feb 23 23:39:54 GMT 2005


Author: jra
Date: 2005-02-23 23:39:51 +0000 (Wed, 23 Feb 2005)
New Revision: 5524

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5524

Log:
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.

Modified:
   branches/SAMBA_3_0/source/smbd/nttrans.c
   branches/SAMBA_3_0/source/smbd/reply.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/nttrans.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/nttrans.c	2005-02-23 23:39:40 UTC (rev 5523)
+++ branches/SAMBA_3_0/source/smbd/nttrans.c	2005-02-23 23:39:51 UTC (rev 5524)
@@ -793,7 +793,8 @@
 		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);

Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c	2005-02-23 23:39:40 UTC (rev 5523)
+++ branches/SAMBA_3_0/source/smbd/reply.c	2005-02-23 23:39:51 UTC (rev 5524)
@@ -1520,29 +1520,34 @@
 	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;
-	}
+	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. */
 
-	/* We need a better way to return NT status codes from open... */
-	unix_ERR_class = 0;
-	unix_ERR_code = 0;
+		/* 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);
+		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;
+		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;
 }
 



More information about the samba-cvs mailing list