NT status/error codes instead of DOS error codes - bug 3.0.0

Jeremy Allison jra at samba.org
Mon Dec 1 02:08:41 GMT 2003


On Sun, Nov 30, 2003 at 01:12:40PM -0800, John Kleven wrote:
> K -- attached is trace of the problem from ethereal,
> plus a copy of logs in /var/log/samba.  I ran smbd
> with debug level 10.
> 
> It is weird because if an error actually occurs during
> sending packets (i.e., bad password or invalid share,
> etc) then smbd WILL return a DOS error code.  But for
> succesful responses it always returns NT status code.
> 
> BTW, it might be 'ok' for smbd to return an NT status
> code "success" to the negotiate protocol response
> because at that point, the client (my code) has not
> been able to even send the capabilities int yet.  But
> after the session setup w/ the capabilities, it should
> be illegal to return the NT status code - i think.

Ok, can you try this patch please ? I think this will
fix it.

Jeremy.
-------------- next part --------------
? client_oplocks.txt
? security_server_segfault.patch
? lib/smbldap.c.mod
Index: smbd/process.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/process.c,v
retrieving revision 1.92.2.27
diff -u -r1.92.2.27 process.c
--- smbd/process.c	5 Nov 2003 00:16:01 -0000	1.92.2.27
+++ smbd/process.c	1 Dec 2003 02:07:32 -0000
@@ -924,11 +924,17 @@
 	return(smb_messages[type].name);
 }
 
-
 /****************************************************************************
- Helper function for contruct_reply.
+ Helper functions for contruct_reply.
 ****************************************************************************/
 
+static uint32 common_flags2 = FLAGS2_LONG_PATH_COMPONENTS|FLAGS2_EXTENDED_SECURITY;
+
+void add_to_common_flags2(uint32 v)
+{
+	common_flags2 |= v;
+}
+
 void construct_reply_common(char *inbuf,char *outbuf)
 {
 	memset(outbuf,'\0',smb_size);
@@ -941,9 +947,8 @@
 	SCVAL(outbuf,smb_reh,0);
 	SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); 
 	SSVAL(outbuf,smb_flg2,
-	      (SVAL(inbuf,smb_flg2) & FLAGS2_UNICODE_STRINGS) |
-	      FLAGS2_LONG_PATH_COMPONENTS |
-	      FLAGS2_32_BIT_ERROR_CODES | FLAGS2_EXTENDED_SECURITY);
+		(SVAL(inbuf,smb_flg2) & FLAGS2_UNICODE_STRINGS) |
+		common_flags2);
 
 	SSVAL(outbuf,smb_err,SMB_SUCCESS);
 	SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid));
Index: smbd/sesssetup.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/sesssetup.c,v
retrieving revision 1.50.2.39
diff -u -r1.50.2.39 sesssetup.c
--- smbd/sesssetup.c	22 Nov 2003 13:19:38 -0000	1.50.2.39
+++ smbd/sesssetup.c	1 Dec 2003 02:07:33 -0000
@@ -472,6 +472,11 @@
 
 	if (global_client_caps == 0) {
 		global_client_caps = IVAL(inbuf,smb_vwv10);
+
+		if (global_client_caps & CAP_STATUS32) {
+			add_to_common_flags2(FLAGS2_32_BIT_ERROR_CODES);
+		}
+
 	}
 		
 	p = (uint8 *)smb_buf(inbuf);
@@ -615,17 +620,22 @@
 		enum remote_arch_types ra_type = get_remote_arch();
 		char *p = smb_buf(inbuf);    
 
-		if(global_client_caps == 0)
+		if(global_client_caps == 0) {
 			global_client_caps = IVAL(inbuf,smb_vwv11);
 		
-		/* client_caps is used as final determination if client is NT or Win95. 
-		   This is needed to return the correct error codes in some
-		   circumstances.
-		*/
-		
-		if(ra_type == RA_WINNT || ra_type == RA_WIN2K || ra_type == RA_WIN95) {
-			if(!(global_client_caps & (CAP_NT_SMBS | CAP_STATUS32))) {
-				set_remote_arch( RA_WIN95);
+			if (global_client_caps & CAP_STATUS32) {
+				add_to_common_flags2(FLAGS2_32_BIT_ERROR_CODES);
+			}
+
+			/* client_caps is used as final determination if client is NT or Win95. 
+			   This is needed to return the correct error codes in some
+			   circumstances.
+			*/
+		
+			if(ra_type == RA_WINNT || ra_type == RA_WIN2K || ra_type == RA_WIN95) {
+				if(!(global_client_caps & (CAP_NT_SMBS | CAP_STATUS32))) {
+					set_remote_arch( RA_WIN95);
+				}
 			}
 		}
 
@@ -686,7 +696,7 @@
 			ra_lanman_string( native_lanman );
 
 	}
-	
+
 	if (SVAL(inbuf,smb_vwv4) == 0) {
 		setup_new_vc_session();
 	}


More information about the samba-technical mailing list