svn commit: samba r19993 - in branches: SAMBA_3_0/source/smbd SAMBA_3_0_24/source/smbd

jra at samba.org jra at samba.org
Fri Dec 1 23:46:08 GMT 2006


Author: jra
Date: 2006-12-01 23:46:07 +0000 (Fri, 01 Dec 2006)
New Revision: 19993

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

Log:
Fix the problem with Linux clients requesting O_WRONLY
on write-only files. Jim please check. Should not affect
Windows clients - I ensured all the relevent Samba4 
torture tests still pass.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/open.c
   branches/SAMBA_3_0_24/source/smbd/open.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/open.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/open.c	2006-12-01 20:45:43 UTC (rev 19992)
+++ branches/SAMBA_3_0/source/smbd/open.c	2006-12-01 23:46:07 UTC (rev 19993)
@@ -1105,7 +1105,6 @@
 	uint32 open_access_mask = access_mask;
 	NTSTATUS status;
 	int ret_flock;
-	
 
 	if (conn->printer) {
 		/* 
@@ -1300,7 +1299,15 @@
 	 */
 
 	if (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) {
-		flags = O_RDWR;
+		/* DENY_DOS opens are always underlying read-write on the
+		   file handle, no matter what the requested access mask
+		    says. */
+		if ((create_options & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
+			access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|FILE_READ_EA|FILE_EXECUTE)) {
+			flags = O_RDWR;
+		} else {
+			flags = O_WRONLY;
+		}
 	} else {
 		flags = O_RDONLY;
 	}
@@ -1448,11 +1455,13 @@
 
 			if (flags & O_RDWR) {
 				can_access_mask = FILE_READ_DATA|FILE_WRITE_DATA;
+			} else if (flags & O_WRONLY) {
+				can_access_mask = FILE_WRITE_DATA;
 			} else {
 				can_access_mask = FILE_READ_DATA;
 			}
 
-			if (((flags & O_RDWR) && !CAN_WRITE(conn)) ||
+			if (((can_access_mask & FILE_WRITE_DATA) && !CAN_WRITE(conn)) ||
 			    !can_access_file(conn,fname,psbuf,can_access_mask)) {
 				can_access = False;
 			}

Modified: branches/SAMBA_3_0_24/source/smbd/open.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/open.c	2006-12-01 20:45:43 UTC (rev 19992)
+++ branches/SAMBA_3_0_24/source/smbd/open.c	2006-12-01 23:46:07 UTC (rev 19993)
@@ -1105,7 +1105,6 @@
 	uint32 open_access_mask = access_mask;
 	NTSTATUS status;
 	int ret_flock;
-	
 
 	if (conn->printer) {
 		/* 
@@ -1300,7 +1299,15 @@
 	 */
 
 	if (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) {
-		flags = O_RDWR;
+		/* DENY_DOS opens are always underlying read-write on the
+		   file handle, no matter what the requested access mask
+		    says. */
+		if ((create_options & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
+			access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|FILE_READ_EA|FILE_EXECUTE)) {
+			flags = O_RDWR;
+		} else {
+			flags = O_WRONLY;
+		}
 	} else {
 		flags = O_RDONLY;
 	}
@@ -1448,11 +1455,13 @@
 
 			if (flags & O_RDWR) {
 				can_access_mask = FILE_READ_DATA|FILE_WRITE_DATA;
+			} else if (flags & O_WRONLY) {
+				can_access_mask = FILE_WRITE_DATA;
 			} else {
 				can_access_mask = FILE_READ_DATA;
 			}
 
-			if (((flags & O_RDWR) && !CAN_WRITE(conn)) ||
+			if (((can_access_mask & FILE_WRITE_DATA) && !CAN_WRITE(conn)) ||
 			    !can_access_file(conn,fname,psbuf,can_access_mask)) {
 				can_access = False;
 			}



More information about the samba-cvs mailing list