summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-08-28 17:45:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:03 -0500
commit53d10b44faa77293e380bd1cda6168acc05a5493 (patch)
tree58dc8d8a13c11494a1a237b4f6f9702240cd75ed /source4/librpc/rpc
parent18302e7030e568d23f13717cb006193490e4213d (diff)
downloadsamba-53d10b44faa77293e380bd1cda6168acc05a5493.tar.gz
samba-53d10b44faa77293e380bd1cda6168acc05a5493.tar.bz2
samba-53d10b44faa77293e380bd1cda6168acc05a5493.zip
r24753: Allow host name in binding string without transport.
(This used to be commit f7051d3a84486ed9d0a1689c10a693521ec63528)
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/dcerpc.h6
-rw-r--r--source4/librpc/rpc/dcerpc_util.c61
2 files changed, 38 insertions, 29 deletions
diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h
index 746f6b6d50..f075075c02 100644
--- a/source4/librpc/rpc/dcerpc.h
+++ b/source4/librpc/rpc/dcerpc.h
@@ -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.
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 66ce2bda85..e1fb4c1d86 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -235,15 +235,17 @@ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
{
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)) {
@@ -251,8 +253,13 @@ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
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 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_
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;
}
- }
- if (i==ARRAY_SIZE(transports)) {
- DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
- return NT_STATUS_INVALID_PARAMETER;
- }
- s = p+1;
+ s = p+1;
+ }
p = strchr(s, '[');
if (p) {