r549: added support for DOS error codes in NTSTATUS returns. This uses a
authorAndrew Tridgell <tridge@samba.org>
Fri, 7 May 2004 11:56:13 +0000 (11:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:47 +0000 (12:51 -0500)
range of NTSTATUS codes that are normally invalid to prevent conflicts
with real error codes.

use the new DOS facility to fix the ERRbaduid return that volker found

source/include/nt_status.h
source/smb_server/request.c
source/smb_server/smb_server.c

index 9747f73eb18a465133e6d9854e56bc274813fe24..d2cf1ceae4a5093584a050b0ebc1fb25c365b90a 100644 (file)
@@ -60,4 +60,12 @@ typedef uint32 WERROR;
 #define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
 #define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
 
+/* this defines special NTSTATUS codes to represent DOS errors.  I
+   have chosen this macro to produce status codes in the invalid
+   NTSTATUS range */
+#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
+#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
+#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
+#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
+
 #endif
index 065e63a8d2c3bb1fe3d4e9bb144cd92bc05e2894..964f4a2d706fabe070bdc2aa7c527c5b33c828c6 100644 (file)
@@ -310,8 +310,15 @@ void req_reply_error(struct request_context *req, NTSTATUS status)
                return;
        }
 
-       SIVAL(req->out.hdr, HDR_RCLS, NT_STATUS_V(status));
-       SSVAL(req->out.hdr, HDR_FLG2, SVAL(req->out.hdr, HDR_FLG2) | FLAGS2_32_BIT_ERROR_CODES);
+       if (NT_STATUS_IS_DOS(status)) {
+               /* its a encoded DOS error, using the reserved range */
+               SSVAL(req->out.hdr, HDR_RCLS, NT_STATUS_DOS_CLASS(status));
+               SSVAL(req->out.hdr, HDR_ERR,  NT_STATUS_DOS_CODE(status));
+               SSVAL(req->out.hdr, HDR_FLG2, SVAL(req->out.hdr, HDR_FLG2) & ~FLAGS2_32_BIT_ERROR_CODES);
+       } else {
+               SIVAL(req->out.hdr, HDR_RCLS, NT_STATUS_V(status));
+               SSVAL(req->out.hdr, HDR_FLG2, SVAL(req->out.hdr, HDR_FLG2) | FLAGS2_32_BIT_ERROR_CODES);
+       }
        
        req_send_reply(req);
 }
index 84209d86707131374cd384dd2dc7799deae93949..aceae08ad8581990e7457e3d866b3362bcc017f4 100644 (file)
@@ -480,6 +480,14 @@ static void switch_message(int type, struct request_context *req)
                return;
        }
 
+       /* see if the vuid is valid */
+       if ((flags & AS_USER) && !req->user_ctx->vuser) {
+               if (!(flags & AS_GUEST)) {
+                       req_reply_error(req, NT_STATUS_DOS(ERRSRV, ERRbaduid));
+                       return;
+               }
+       }
+
        /* does this protocol need to be run as the connected user? */
 #if HACK_REWRITE
        if ((flags & AS_USER) && !change_to_user(req->conn,session_tag)) {