From a59149b86a36cd8b51ad5ae11b4d2b0714bb5e9c Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Mon, 13 Jun 2005 20:42:21 +0000
Subject: r7550: Steal the correct error return for invalid TID on NTcreateX
 from Samba4 (thanks tridge !). Jeremy. (This used to be commit
 0288823aacdbec6ba99e944c9f06f051e55c64b8)

---
 source3/smbd/process.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index afde2e94a9..0373cd471c 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -936,8 +936,14 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
 			change_to_root_user();
 
 		/* does this protocol need a valid tree connection? */
-		if ((flags & AS_USER) && !conn)
-			return ERROR_DOS(ERRSRV, ERRinvnid);
+		if ((flags & AS_USER) && !conn) {
+			/* Amazingly, the error code depends on the command (from Samba4). */
+			if (type == SMBntcreateX) {
+				return ERROR_NT(NT_STATUS_INVALID_HANDLE);
+			} else {
+				return ERROR_DOS(ERRSRV, ERRinvnid);
+			}
+		}
 
 
 		/* does this protocol need to be run as the connected user? */
-- 
cgit