r14643: Merge dcerpc_errstr from Samba 4.
authorGünther Deschner <gd@samba.org>
Wed, 22 Mar 2006 14:41:07 +0000 (14:41 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:15:41 +0000 (11:15 -0500)
Might need to rework prs_dcerpc_status().

Guenther

source/Makefile.in
source/libsmb/dcerpc_err.c [new file with mode: 0644]
source/rpc_client/cli_pipe.c
source/rpc_parse/parse_prs.c
source/rpc_parse/parse_rpc.c

index 40d59e7cec347dcabdab32e433507e8e17461ae6..97348ff73589249a301ebe74057e80d5a9f0a251 100644 (file)
@@ -250,8 +250,9 @@ SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o
 LIBNMB_OBJ = libsmb/unexpected.o libsmb/namecache.o libsmb/nmblib.o \
             libsmb/namequery.o libsmb/conncache.o 
 
-LIBSAMBA_OBJ = libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o libsmb/ntlm_check.o \
-       libsmb/ntlmssp.o libsmb/ntlmssp_parse.o libsmb/ntlmssp_sign.o
+LIBSAMBA_OBJ = libsmb/nterr.o libsmb/dcerpc_err.o libsmb/smbdes.o \
+              libsmb/smbencrypt.o libsmb/ntlm_check.o \
+              libsmb/ntlmssp.o libsmb/ntlmssp_parse.o libsmb/ntlmssp_sign.o
 
 LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
             libsmb/clikrb5.o libsmb/clispnego.o libsmb/asn1.o \
diff --git a/source/libsmb/dcerpc_err.c b/source/libsmb/dcerpc_err.c
new file mode 100644 (file)
index 0000000..89db4aa
--- /dev/null
@@ -0,0 +1,110 @@
+/* 
+ *  Unix SMB/CIFS implementation.
+ *  Copyright (C) Stefan Metzmacher 2004
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+
+struct dcerpc_fault_table {
+       const char *errstr;
+       uint32_t faultcode;
+};
+
+static const struct dcerpc_fault_table dcerpc_faults[] =
+{
+       { "DCERPC_FAULT_OP_RNG_ERROR",          DCERPC_FAULT_OP_RNG_ERROR },
+       { "DCERPC_FAULT_UNK_IF",                DCERPC_FAULT_UNK_IF },
+       { "DCERPC_FAULT_NDR",                   DCERPC_FAULT_NDR },
+       { "DCERPC_FAULT_INVALID_TAG",           DCERPC_FAULT_INVALID_TAG },
+       { "DCERPC_FAULT_CONTEXT_MISMATCH",      DCERPC_FAULT_CONTEXT_MISMATCH },
+       { "DCERPC_FAULT_OTHER",                 DCERPC_FAULT_OTHER },
+       { "DCERPC_FAULT_ACCESS_DENIED",         DCERPC_FAULT_ACCESS_DENIED },
+
+       { NULL,                                 0}      
+};
+
+const char *dcerpc_errstr(uint32 fault_code)
+{
+       static pstring msg;
+       int idx = 0;
+
+       slprintf(msg, sizeof(msg), "DCERPC fault 0x%08x", fault_code);
+
+       while (dcerpc_faults[idx].errstr != NULL) {
+               if (dcerpc_faults[idx].faultcode == fault_code) {
+                       return dcerpc_faults[idx].errstr;
+               }
+               idx++;
+       }
+
+       return msg;
+}
+/* 
+ *  Unix SMB/CIFS implementation.
+ *  Copyright (C) Stefan Metzmacher 2004
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+
+struct dcerpc_fault_table {
+       const char *errstr;
+       uint32_t faultcode;
+};
+
+static const struct dcerpc_fault_table dcerpc_faults[] =
+{
+       { "DCERPC_FAULT_OP_RNG_ERROR",          DCERPC_FAULT_OP_RNG_ERROR },
+       { "DCERPC_FAULT_UNK_IF",                DCERPC_FAULT_UNK_IF },
+       { "DCERPC_FAULT_NDR",                   DCERPC_FAULT_NDR },
+       { "DCERPC_FAULT_INVALID_TAG",           DCERPC_FAULT_INVALID_TAG },
+       { "DCERPC_FAULT_CONTEXT_MISMATCH",      DCERPC_FAULT_CONTEXT_MISMATCH },
+       { "DCERPC_FAULT_OTHER",                 DCERPC_FAULT_OTHER },
+       { "DCERPC_FAULT_ACCESS_DENIED",         DCERPC_FAULT_ACCESS_DENIED },
+
+       { NULL,                                 0}      
+};
+
+const char *dcerpc_errstr(uint32 fault_code)
+{
+        static pstring msg;
+        int idx = 0;
+
+       slprintf(msg, sizeof(msg), "DCERPC fault 0x%08x", fault_code);
+
+       while (dcerpc_faults[idx].errstr != NULL) {
+               if (dcerpc_faults[idx].faultcode == fault_code) {
+                       return dcerpc_faults[idx].errstr;
+               }
+               idx++;
+       }
+
+       return msg;
+}
index afdf6f3d67c6748b84913333259cd0f34dde965e..37b1b2a671b065a618342dd735fb198ff7fe7595 100644 (file)
@@ -619,7 +619,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(struct rpc_pipe_client *cli, RPC_H
 
                        DEBUG(1, ("cli_pipe_validate_current_pdu: RPC fault code %s received from remote machine %s "
                                "pipe %s fnum 0x%x!\n",
-                               nt_errstr(fault_resp.status),
+                               dcerpc_errstr(NT_STATUS_V(fault_resp.status)),
                                cli->cli->desthost,
                                cli->pipe_name,
                                (unsigned int)cli->fnum));
index 474e93cc1f09d152dd80bede6c81a1a0b4ced816..f2b002c48cf5f5cc4daa20c063c43a46688df0cf 100644 (file)
@@ -767,6 +767,37 @@ BOOL prs_ntstatus(const char *name, prs_struct *ps, int depth, NTSTATUS *status)
        return True;
 }
 
+/*******************************************************************
+ Stream a DCE error code
+ ********************************************************************/
+
+BOOL prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *status)
+{
+       char *q = prs_mem_get(ps, sizeof(uint32));
+       if (q == NULL)
+               return False;
+
+       if (UNMARSHALLING(ps)) {
+               if (ps->bigendian_data)
+                       *status = NT_STATUS(RIVAL(q,0));
+               else
+                       *status = NT_STATUS(IVAL(q,0));
+       } else {
+               if (ps->bigendian_data)
+                       RSIVAL(q,0,NT_STATUS_V(*status));
+               else
+                       SIVAL(q,0,NT_STATUS_V(*status));
+       }
+
+       DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name, 
+                dcerpc_errstr(NT_STATUS_V(*status))));
+
+       ps->data_offset += sizeof(uint32);
+
+       return True;
+}
+
+
 /*******************************************************************
  Stream a WERROR
  ********************************************************************/
index 79dfc05e43cbd87aa6c0ae62572adff93a710e85..2d166c773b4d4cafa8221ca198dc5ac516d12ee1 100644 (file)
@@ -661,7 +661,7 @@ BOOL smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps,
        prs_debug(ps, depth, desc, "smb_io_rpc_hdr_fault");
        depth++;
 
-       if(!prs_ntstatus("status  ", ps, depth, &rpc->status))
+       if(!prs_dcerpc_status("status  ", ps, depth, &rpc->status))
                return False;
        if(!prs_uint32("reserved", ps, depth, &rpc->reserved))
                return False;