svn commit: samba r24753 - in branches/SAMBA_4_0: .
source/librpc/rpc source/librpc/tests
jelmer at samba.org
jelmer at samba.org
Tue Aug 28 17:45:59 GMT 2007
Author: jelmer
Date: 2007-08-28 17:45:57 +0000 (Tue, 28 Aug 2007)
New Revision: 24753
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24753
Log:
Allow host name in binding string without transport.
Modified:
branches/SAMBA_4_0/
branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
branches/SAMBA_4_0/source/librpc/tests/binding_string.c
Changeset:
Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h 2007-08-28 16:39:03 UTC (rev 24752)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h 2007-08-28 17:45:57 UTC (rev 24753)
@@ -28,9 +28,9 @@
#include "librpc/ndr/libndr.h"
enum dcerpc_transport_t {
- NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, NCACN_VNS_SPP,
- NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, NCADG_UNIX_DGRAM,
- NCACN_HTTP, NCADG_IPX, NCACN_SPX };
+ NCA_UNKNOWN, NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC,
+ NCACN_VNS_SPP, NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM,
+ NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX };
/*
this defines a generic security context for signed/sealed dcerpc pipes.
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c 2007-08-28 16:39:03 UTC (rev 24752)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c 2007-08-28 17:45:57 UTC (rev 24753)
@@ -235,24 +235,31 @@
{
char *s = talloc_strdup(mem_ctx, "");
int i;
- const char *t_name=NULL;
+ const char *t_name = NULL;
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- if (transports[i].transport == b->transport) {
- t_name = transports[i].name;
+ if (b->transport != NCA_UNKNOWN) {
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == b->transport) {
+ t_name = transports[i].name;
+ }
}
+ if (!t_name) {
+ return NULL;
+ }
}
- if (!t_name) {
- return NULL;
- }
if (!GUID_all_zero(&b->object.uuid)) {
s = talloc_asprintf(s, "%s@",
GUID_string(mem_ctx, &b->object.uuid));
}
- s = talloc_asprintf_append(s, "%s:", t_name);
- if (!s) return NULL;
+ if (t_name != NULL) {
+ s = talloc_asprintf_append(s, "%s:", t_name);
+ if (s == NULL)
+ return NULL;
+ } else {
+ s = NULL;
+ }
if (b->host) {
s = talloc_asprintf_append(s, "%s", b->host);
@@ -323,27 +330,29 @@
b->object.if_version = 0;
p = strchr(s, ':');
- if (!p) {
- return NT_STATUS_INVALID_PARAMETER;
- }
- type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
- if (!type) {
- return NT_STATUS_NO_MEMORY;
- }
+ if (p == NULL) {
+ b->transport = NCA_UNKNOWN;
+ } else {
+ type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
+ if (!type) {
+ return NT_STATUS_NO_MEMORY;
+ }
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- if (strcasecmp(type, transports[i].name) == 0) {
- b->transport = transports[i].transport;
- break;
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (strcasecmp(type, transports[i].name) == 0) {
+ b->transport = transports[i].transport;
+ break;
+ }
}
+
+ if (i==ARRAY_SIZE(transports)) {
+ DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ s = p+1;
}
- if (i==ARRAY_SIZE(transports)) {
- DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- s = p+1;
p = strchr(s, '[');
if (p) {
Modified: branches/SAMBA_4_0/source/librpc/tests/binding_string.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/tests/binding_string.c 2007-08-28 16:39:03 UTC (rev 24752)
+++ branches/SAMBA_4_0/source/librpc/tests/binding_string.c 2007-08-28 17:45:57 UTC (rev 24753)
@@ -95,6 +95,27 @@
"ncacn_unix_stream:[/tmp/epmapper,sign]",
};
+static bool test_no_transport(struct torture_context *tctx)
+{
+ const char *binding = "somehost";
+ struct dcerpc_binding *b;
+ const char *s;
+
+ /* Parse */
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, binding, &b),
+ "Error parsing binding string");
+
+ torture_assert(tctx, b->transport == NCA_UNKNOWN, "invalid transport");
+
+ s = dcerpc_binding_string(tctx, b);
+ torture_assert(tctx, s != NULL, "Error converting binding back to string");
+
+ torture_assert_casestr_equal(tctx, binding, s,
+ "Mismatch while comparing original and regenerated binding strings");
+
+ return true;
+}
+
struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx)
{
int i;
@@ -106,5 +127,7 @@
test_BindingString, test_strings[i]);
}
+ torture_suite_add_simple_test(suite, "no transport", test_no_transport);
+
return suite;
}
More information about the samba-cvs
mailing list