svn commit: samba r6173 - in trunk/source/smbd: .

jra at samba.org jra at samba.org
Sat Apr 2 00:13:28 GMT 2005


Author: jra
Date: 2005-04-02 00:13:27 +0000 (Sat, 02 Apr 2005)
New Revision: 6173

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

Log:
Fixup T2 open call - we were returning 2 bytes short.
Jeremy.

Modified:
   trunk/source/smbd/open.c
   trunk/source/smbd/reply.c
   trunk/source/smbd/trans2.c


Changeset:
Modified: trunk/source/smbd/open.c
===================================================================
--- trunk/source/smbd/open.c	2005-04-01 23:11:28 UTC (rev 6172)
+++ trunk/source/smbd/open.c	2005-04-02 00:13:27 UTC (rev 6173)
@@ -1098,23 +1098,6 @@
 		return print_fsp_open(conn, fname);
 	}
 
-	switch(ofun) {
-		case FILE_EXISTS_OPEN:
-		case FILE_EXISTS_TRUNCATE:
-		case FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST:
-		case FILE_EXISTS_OPEN | FILE_CREATE_IF_NOT_EXIST:
-		case FILE_EXISTS_TRUNCATE | FILE_CREATE_IF_NOT_EXIST:
-			break; /* These are ok. */
-		default:
-			if (GET_OPEN_MODE(share_mode) == DOS_OPEN_EXEC) {
-				ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
-				break;
-			}
-			/* Cause caller to force dos errors. */
-			set_saved_error_triple(ERRDOS, ERRbadaccess, NT_STATUS_INVALID);
-			return NULL;
-	}
-
 	DEBUG(10,("open_file_shared: fname = %s, dos_attrs = %x, share_mode = %x, ofun = %x, mode = %o, oplock request = %d\n",
 		fname, new_dos_mode, share_mode, ofun, (int)mode,  oplock_request ));
 

Modified: trunk/source/smbd/reply.c
===================================================================
--- trunk/source/smbd/reply.c	2005-04-01 23:11:28 UTC (rev 6172)
+++ trunk/source/smbd/reply.c	2005-04-02 00:13:27 UTC (rev 6173)
@@ -1295,7 +1295,17 @@
 		END_PROFILE(SMBopenX);
 		return ERROR_NT(NT_STATUS_OBJECT_PATH_NOT_FOUND);
 	}
-    
+
+	/* Strange open mode mapping. */
+	if (smb_ofun == 0) {
+		if (GET_OPEN_MODE(smb_mode) == DOS_OPEN_EXEC) {
+			smb_ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
+		} else {
+			END_PROFILE(SMBopenX);
+			return ERROR_FORCE_DOS(ERRDOS, ERRbadaccess);
+		}
+	}
+
 	fsp = open_file_shared(conn,fname,&sbuf,smb_mode,smb_ofun,(uint32)smb_attr,
 			oplock_request, &rmode,&smb_action);
       

Modified: trunk/source/smbd/trans2.c
===================================================================
--- trunk/source/smbd/trans2.c	2005-04-01 23:11:28 UTC (rev 6172)
+++ trunk/source/smbd/trans2.c	2005-04-02 00:13:27 UTC (rev 6173)
@@ -732,6 +732,7 @@
 	files_struct *fsp;
 	TALLOC_CTX *ctx = NULL;
 	struct ea_list *ea_list = NULL;
+	uint16 flags = 0;
 	NTSTATUS status;
 
 	/*
@@ -742,11 +743,12 @@
 		return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 	}
 
+	flags = SVAL(params, 0);
 	open_mode = SVAL(params, 2);
 	open_attr = SVAL(params,6);
-        oplock_request = (SVAL(params,0) & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
+        oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
         if (oplock_request) {
-                oplock_request |= (SVAL(params,0) & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
+                oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
         }
 
 #if 0
@@ -780,6 +782,16 @@
 		return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
 	}
 
+	/* Strange open mode mapping. */
+	if (open_ofun == 0) {
+		if (GET_OPEN_MODE(open_mode) == DOS_OPEN_EXEC) {
+			open_ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
+		} else {
+			END_PROFILE(SMBopenX);
+			return ERROR_FORCE_DOS(ERRDOS, ERRbadaccess);
+		}
+	}
+
 	/* Any data in this call is an EA list. */
 	if (total_data && !lp_ea_support(SNUM(conn))) {
 		return ERROR_NT(NT_STATUS_EAS_NOT_SUPPORTED);
@@ -839,21 +851,22 @@
 	}
 
 	/* Realloc the size of parameters and data we will return */
-	params = SMB_REALLOC(*pparams, 28);
+	params = SMB_REALLOC(*pparams, 30);
 	if( params == NULL ) {
 		return ERROR_NT(NT_STATUS_NO_MEMORY);
 	}
 	*pparams = params;
 
-	memset((char *)params,'\0',28);
+	memset((char *)params,'\0',30);
 	SSVAL(params,0,fsp->fnum);
 	SSVAL(params,2,fmode);
 	put_dos_date2(params,4, mtime);
 	SIVAL(params,8, (uint32)size);
 	SSVAL(params,12,rmode);
 
-	if (oplock_request && lp_fake_oplocks(SNUM(conn)))
+	if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
 		smb_action |= EXTENDED_OPLOCK_GRANTED;
+	}
 
 	SSVAL(params,18,smb_action);
 
@@ -861,9 +874,13 @@
 	 * WARNING - this may need to be changed if SMB_INO_T <> 4 bytes.
 	 */
 	SIVAL(params,20,inode);
- 
+	if (flags & 8) {
+		uint32 ea_size = estimate_ea_size(conn, fsp, fname);
+		SIVAL(params, 26, ea_size);
+	}
+
 	/* Send the required number of replies */
-	send_trans2_replies(outbuf, bufsize, params, 28, *ppdata, 0);
+	send_trans2_replies(outbuf, bufsize, params, 30, *ppdata, 0);
 
 	return -1;
 }



More information about the samba-cvs mailing list