svn commit: samba r14643 - branches/SAMBA_3_0/source branches/SAMBA_3_0/source/libsmb branches/SAMBA_3_0/source/rpc_client branches/SAMBA_3_0/source/rpc_parse trunk/source trunk/source/libsmb trunk/source/rpc_client trunk/source/rpc_parse

gd at samba.org gd at samba.org
Wed Mar 22 14:41:08 GMT 2006


Author: gd
Date: 2006-03-22 14:41:07 +0000 (Wed, 22 Mar 2006)
New Revision: 14643

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

Log:
Merge dcerpc_errstr from Samba 4.

Might need to rework prs_dcerpc_status().

Guenther

Added:
   branches/SAMBA_3_0/source/libsmb/dcerpc_err.c
   trunk/source/libsmb/dcerpc_err.c
Modified:
   branches/SAMBA_3_0/source/Makefile.in
   branches/SAMBA_3_0/source/rpc_client/cli_pipe.c
   branches/SAMBA_3_0/source/rpc_parse/parse_prs.c
   branches/SAMBA_3_0/source/rpc_parse/parse_rpc.c
   trunk/source/Makefile.in
   trunk/source/rpc_client/cli_pipe.c
   trunk/source/rpc_parse/parse_prs.c
   trunk/source/rpc_parse/parse_rpc.c


Changeset:
Modified: branches/SAMBA_3_0/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0/source/Makefile.in	2006-03-22 14:33:06 UTC (rev 14642)
+++ branches/SAMBA_3_0/source/Makefile.in	2006-03-22 14:41:07 UTC (rev 14643)
@@ -250,8 +250,9 @@
 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 \

Added: branches/SAMBA_3_0/source/libsmb/dcerpc_err.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/dcerpc_err.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ branches/SAMBA_3_0/source/libsmb/dcerpc_err.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -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;
+}

Modified: branches/SAMBA_3_0/source/rpc_client/cli_pipe.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_client/cli_pipe.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ branches/SAMBA_3_0/source/rpc_client/cli_pipe.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -619,7 +619,7 @@
 
 			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));

Modified: branches/SAMBA_3_0/source/rpc_parse/parse_prs.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_parse/parse_prs.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ branches/SAMBA_3_0/source/rpc_parse/parse_prs.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -768,6 +768,37 @@
 }
 
 /*******************************************************************
+ 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
  ********************************************************************/
 

Modified: branches/SAMBA_3_0/source/rpc_parse/parse_rpc.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_parse/parse_rpc.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ branches/SAMBA_3_0/source/rpc_parse/parse_rpc.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -661,7 +661,7 @@
 	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;

Modified: trunk/source/Makefile.in
===================================================================
--- trunk/source/Makefile.in	2006-03-22 14:33:06 UTC (rev 14642)
+++ trunk/source/Makefile.in	2006-03-22 14:41:07 UTC (rev 14643)
@@ -250,8 +250,9 @@
 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 \

Added: trunk/source/libsmb/dcerpc_err.c
===================================================================
--- trunk/source/libsmb/dcerpc_err.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ trunk/source/libsmb/dcerpc_err.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -0,0 +1,55 @@
+/* 
+ *  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;
+}

Modified: trunk/source/rpc_client/cli_pipe.c
===================================================================
--- trunk/source/rpc_client/cli_pipe.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ trunk/source/rpc_client/cli_pipe.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -619,7 +619,7 @@
 
 			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));

Modified: trunk/source/rpc_parse/parse_prs.c
===================================================================
--- trunk/source/rpc_parse/parse_prs.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ trunk/source/rpc_parse/parse_prs.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -768,6 +768,37 @@
 }
 
 /*******************************************************************
+ 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
  ********************************************************************/
 

Modified: trunk/source/rpc_parse/parse_rpc.c
===================================================================
--- trunk/source/rpc_parse/parse_rpc.c	2006-03-22 14:33:06 UTC (rev 14642)
+++ trunk/source/rpc_parse/parse_rpc.c	2006-03-22 14:41:07 UTC (rev 14643)
@@ -672,7 +672,7 @@
 	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;



More information about the samba-cvs mailing list