svn commit: samba r24498 - in branches/SAMBA_3_2/source/smbd: .

jra at samba.org jra at samba.org
Thu Aug 16 17:42:35 GMT 2007


Author: jra
Date: 2007-08-16 17:42:34 +0000 (Thu, 16 Aug 2007)
New Revision: 24498

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

Log:
More extra code into a function, reply_openerror.
Jeremy.

Modified:
   branches/SAMBA_3_2/source/smbd/error.c
   branches/SAMBA_3_2/source/smbd/nttrans.c
   branches/SAMBA_3_2/source/smbd/reply.c
   branches/SAMBA_3_2/source/smbd/trans2.c


Changeset:
Modified: branches/SAMBA_3_2/source/smbd/error.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/error.c	2007-08-16 15:44:13 UTC (rev 24497)
+++ branches/SAMBA_3_2/source/smbd/error.c	2007-08-16 17:42:34 UTC (rev 24498)
@@ -179,3 +179,20 @@
 	error_packet_set((char *)req->outbuf, eclass, ecode, ntstatus,
 			 line, file);
 }
+
+void reply_openerror(struct smb_request *req, NTSTATUS status)
+{
+	if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		/*
+		 * We hit an existing file, and if we're returning DOS
+		 * error codes OBJECT_NAME_COLLISION would map to
+		 * ERRDOS/183, we need to return ERRDOS/80, see bug
+		 * 4852.
+		 */
+		reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
+			ERRDOS, ERRfilexists);
+	} else {
+		reply_nterror(req, status);
+	}
+}
+

Modified: branches/SAMBA_3_2/source/smbd/nttrans.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/nttrans.c	2007-08-16 15:44:13 UTC (rev 24497)
+++ branches/SAMBA_3_2/source/smbd/nttrans.c	2007-08-16 17:42:34 UTC (rev 24498)
@@ -816,51 +816,50 @@
 					oplock_request,
 					&info, &fsp);
 
-		if (!NT_STATUS_IS_OK(status)) { 
-			/* We cheat here. There are two cases we
-			 * care about. One is a directory rename,
-			 * where the NT client will attempt to
-			 * open the source directory for
-			 * DELETE access. Note that when the
-			 * NT client does this it does *not*
-			 * set the directory bit in the
-			 * request packet. This is translated
-			 * into a read/write open
-			 * request. POSIX states that any open
-			 * for write request on a directory
-			 * will generate an EISDIR error, so
-			 * we can catch this here and open a
-			 * pseudo handle that is flagged as a
-			 * directory. The second is an open
-			 * for a permissions read only, which
-			 * we handle in the open_file_stat case. JRA.
-			 */
+		/* We cheat here. There are two cases we
+		 * care about. One is a directory rename,
+		 * where the NT client will attempt to
+		 * open the source directory for
+		 * DELETE access. Note that when the
+		 * NT client does this it does *not*
+		 * set the directory bit in the
+		 * request packet. This is translated
+		 * into a read/write open
+		 * request. POSIX states that any open
+		 * for write request on a directory
+		 * will generate an EISDIR error, so
+		 * we can catch this here and open a
+		 * pseudo handle that is flagged as a
+		 * directory. The second is an open
+		 * for a permissions read only, which
+		 * we handle in the open_file_stat case. JRA.
+		 */
 
-			if (NT_STATUS_EQUAL(status,
-					    NT_STATUS_FILE_IS_A_DIRECTORY)) {
+		if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
 
-				/*
-				 * Fail the open if it was explicitly a non-directory file.
-				 */
+			/*
+			 * Fail the open if it was explicitly a non-directory
+			 * file.
+			 */
 
-				if (create_options & FILE_NON_DIRECTORY_FILE) {
-					TALLOC_FREE(case_state);
-					reply_force_nterror(req, NT_STATUS_FILE_IS_A_DIRECTORY);
-					END_PROFILE(SMBntcreateX);
-					return;
-				}
+			if (create_options & FILE_NON_DIRECTORY_FILE) {
+				TALLOC_FREE(case_state);
+				reply_force_nterror(req,
+						NT_STATUS_FILE_IS_A_DIRECTORY);
+				END_PROFILE(SMBntcreateX);
+				return;
+			}
 
-				oplock_request = 0;
-				status = open_directory(conn, req, fname,
-							&sbuf,
-							access_mask,
-							share_access,
-							create_disposition,
-							create_options,
-							file_attributes,
-							&info, &fsp);
+			oplock_request = 0;
+			status = open_directory(conn, req, fname,
+						&sbuf,
+						access_mask,
+						share_access,
+						create_disposition,
+						create_options,
+						file_attributes,
+						&info, &fsp);
 
-			}
 		}
 	}
 
@@ -872,18 +871,7 @@
 			/* We have re-scheduled this call. */
 			return;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-			return;
-		}
-		reply_nterror(req, status);
+		reply_openerror(req, status);
 		return;
 	}
 
@@ -1532,12 +1520,6 @@
 					create_options,
 					file_attributes,
 					&info, &fsp);
-		if(!NT_STATUS_IS_OK(status)) {
-			TALLOC_FREE(case_state);
-			reply_nterror(req, status);
-			return;
-		}
-
 	} else {
 
 		/*
@@ -1553,48 +1535,43 @@
 					oplock_request,
 					&info, &fsp);
 
-		if (!NT_STATUS_IS_OK(status)) { 
-			if (NT_STATUS_EQUAL(status,
-					    NT_STATUS_FILE_IS_A_DIRECTORY)) {
+		if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
 
-				/*
-				 * Fail the open if it was explicitly a non-directory file.
-				 */
+			/*
+			 * Fail the open if it was explicitly a non-directory file.
+			 */
 
-				if (create_options & FILE_NON_DIRECTORY_FILE) {
-					TALLOC_FREE(case_state);
-					reply_force_nterror(
-						req,
-						NT_STATUS_FILE_IS_A_DIRECTORY);
-					return;
-				}
-	
-				oplock_request = 0;
-				status = open_directory(conn, req, fname,
-							&sbuf,
-							access_mask,
-							share_access,
-							create_disposition,
-							create_options,
-							file_attributes,
-							&info, &fsp);
-				if(!NT_STATUS_IS_OK(status)) {
-					TALLOC_FREE(case_state);
-					reply_nterror(req, status);
-					return;
-				}
-			} else {
+			if (create_options & FILE_NON_DIRECTORY_FILE) {
 				TALLOC_FREE(case_state);
-				if (open_was_deferred(req->mid)) {
-					/* We have re-scheduled this call. */
-					return;
-				}
-				reply_nterror(req, status);
+				reply_force_nterror(
+					req,
+					NT_STATUS_FILE_IS_A_DIRECTORY);
 				return;
 			}
-		} 
+
+			oplock_request = 0;
+			status = open_directory(conn, req, fname,
+						&sbuf,
+						access_mask,
+						share_access,
+						create_disposition,
+						create_options,
+						file_attributes,
+						&info, &fsp);
+		}
 	}
 
+	TALLOC_FREE(case_state);
+
+	if(!NT_STATUS_IS_OK(status)) {
+		if (open_was_deferred(req->mid)) {
+			/* We have re-scheduled this call. */
+			return;
+		}
+		reply_openerror(req, status);
+		return;
+	}
+
 	/*
 	 * According to the MS documentation, the only time the security
 	 * descriptor is applied to the opened file is iff we *created* the

Modified: branches/SAMBA_3_2/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/reply.c	2007-08-16 15:44:13 UTC (rev 24497)
+++ branches/SAMBA_3_2/source/smbd/reply.c	2007-08-16 17:42:34 UTC (rev 24498)
@@ -1556,18 +1556,7 @@
 			/* We have re-scheduled this call. */
 			return;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
-					ERRDOS, ERRfilexists);
-			return;
-		}
-		reply_nterror(req, status);
+		reply_openerror(req, status);
 		return;
 	}
 
@@ -1723,25 +1712,14 @@
 			smb_attr,
 			oplock_request,
 			&smb_action, &fsp);
-      
+
 	if (!NT_STATUS_IS_OK(status)) {
 		END_PROFILE(SMBopenX);
 		if (open_was_deferred(req->mid)) {
 			/* We have re-scheduled this call. */
 			return;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
-					ERRDOS, ERRfilexists);
-			return;
-		}
-		reply_nterror(req, status);
+		reply_openerror(req, status);
 		return;
 	}
 
@@ -2087,18 +2065,7 @@
 			/* We have re-scheduled this call. */
 			return;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
-					ERRDOS, ERRfilexists);
-			return;
-		}
-		reply_nterror(req, status);
+		reply_openerror(req, status);
 		return;
 	}
 
@@ -4678,7 +4645,7 @@
 		END_PROFILE(SMBmkdir);
 		return;
 	}
-  
+
 	status = create_directory(conn, directory);
 
 	DEBUG(5, ("create_directory returned %s\n", nt_errstr(status)));

Modified: branches/SAMBA_3_2/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/trans2.c	2007-08-16 15:44:13 UTC (rev 24497)
+++ branches/SAMBA_3_2/source/smbd/trans2.c	2007-08-16 17:42:34 UTC (rev 24498)
@@ -913,18 +913,7 @@
 			/* We have re-scheduled this call. */
 			return;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			/*
-			 * We hit an existing file, and if we're returning DOS
-			 * error codes OBJECT_NAME_COLLISION would map to
-			 * ERRDOS/183, we need to return ERRDOS/80, see bug
-			 * 4852.
-			 */
-			reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION,
-				ERRDOS, ERRfilexists);
-			return;
-		}
-		reply_nterror(req, status);
+		reply_openerror(req, status);
 		return;
 	}
 
@@ -6515,18 +6504,9 @@
 					ERRSRV, ERRbadpath);
 			return;
 		}
-		if (info_level == SMB_POSIX_PATH_OPEN &&
-			NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-				/*
-				 * We hit an existing file, and if we're returning DOS
-				 * error codes OBJECT_NAME_COLLISION would map to
-				 * ERRDOS/183, we need to return ERRDOS/80, see bug
-				 * 4852.
-				 */
-				reply_botherror(req,
-					NT_STATUS_OBJECT_NAME_COLLISION,
-					ERRDOS, ERRfilexists);
-				return;
+		if (info_level == SMB_POSIX_PATH_OPEN) {
+			reply_openerror(req, status);
+			return;
 		}
 
 		reply_nterror(req, status);



More information about the samba-cvs mailing list