summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-11-18 01:36:02 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-11-18 01:36:02 +0100
commit1c07c30d31b4b588b59b845bdb5f85a0ba19f762 (patch)
treefe6e815464ae0ab1397567150978e04ea4fb3d46 /librpc
parentab55ecb881bfabe427ecb874d2dff2b5c2a7e84a (diff)
parent9ea794417e8bad3da4236f4071a0d8a23612ac8a (diff)
downloadsamba-1c07c30d31b4b588b59b845bdb5f85a0ba19f762.tar.gz
samba-1c07c30d31b4b588b59b845bdb5f85a0ba19f762.tar.bz2
samba-1c07c30d31b4b588b59b845bdb5f85a0ba19f762.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'librpc')
-rw-r--r--librpc/idl/ntsvcs.idl2
-rw-r--r--librpc/idl/svcctl.idl44
-rw-r--r--librpc/ndr/libndr.h2
-rw-r--r--librpc/ndr/uuid.c82
-rw-r--r--librpc/rpc/binding.c4
5 files changed, 105 insertions, 29 deletions
diff --git a/librpc/idl/ntsvcs.idl b/librpc/idl/ntsvcs.idl
index d50243534e..be7fcdff13 100644
--- a/librpc/idl/ntsvcs.idl
+++ b/librpc/idl/ntsvcs.idl
@@ -70,7 +70,7 @@ interface ntsvcs
/******************/
/* Function: 0x0a */
- [todo] WERROR PNP_GetDeviceList(
+ WERROR PNP_GetDeviceList(
[in,unique] [string,charset(UTF16)] uint16 *filter,
[out,ref] [size_is(*length),length_is(*length)] uint16 *buffer,
[in,out,ref] uint32 *length,
diff --git a/librpc/idl/svcctl.idl b/librpc/idl/svcctl.idl
index fa8e10988c..4b88f5e5f4 100644
--- a/librpc/idl/svcctl.idl
+++ b/librpc/idl/svcctl.idl
@@ -89,13 +89,19 @@ import "misc.idl", "security.idl";
/*****************/
/* Function 0x01 */
- typedef enum {
- FIXME=1
+ /* Service Controls */
+
+ typedef [v1_enum] enum {
+ SVCCTL_CONTROL_STOP = 0x00000001,
+ SVCCTL_CONTROL_PAUSE = 0x00000002,
+ SVCCTL_CONTROL_CONTINUE = 0x00000003,
+ SVCCTL_CONTROL_INTERROGATE = 0x00000004,
+ SVCCTL_CONTROL_SHUTDOWN = 0x00000005
} SERVICE_CONTROL;
WERROR svcctl_ControlService(
[in,ref] policy_handle *handle,
- [in] uint32 control,
+ [in] SERVICE_CONTROL control,
[out,ref] SERVICE_STATUS *service_status
);
@@ -218,10 +224,10 @@ import "misc.idl", "security.idl";
[in,ref] policy_handle *handle,
[in] uint32 type,
[in] uint32 state,
- [in] uint32 buf_size,
- [out,size_is(buf_size)] uint8 service[*],
- [out,ref] uint32 *bytes_needed,
- [out,ref] uint32 *services_returned,
+ [out,ref,size_is(buf_size)] uint8 *service,
+ [in] [range(0,262144)] uint32 buf_size,
+ [out,ref] [range(0,262144)] uint32 *bytes_needed,
+ [out,ref] [range(0,262144)] uint32 *services_returned,
[in,out,unique] uint32 *resume_handle
);
@@ -535,9 +541,9 @@ import "misc.idl", "security.idl";
WERROR svcctl_QueryServiceConfig2W(
[in,ref] policy_handle *handle,
[in] uint32 info_level,
- [out] uint8 buffer[buf_size],
- [in] uint32 buf_size,
- [out,ref] uint32 *bytes_needed
+ [out,ref,size_is(buf_size)] uint8 *buffer,
+ [in] [range(0,8192)] uint32 buf_size,
+ [out,ref] [range(0,8192)] uint32 *bytes_needed
);
/*****************/
@@ -545,9 +551,9 @@ import "misc.idl", "security.idl";
WERROR svcctl_QueryServiceStatusEx(
[in,ref] policy_handle *handle,
[in] uint32 info_level,
- [out] uint8 buffer[buf_size],
- [in] uint32 buf_size,
- [out,ref] uint32 *bytes_needed
+ [out,ref,size_is(buf_size)] uint8 *buffer,
+ [in] [range(0,8192)] uint32 buf_size,
+ [out,ref] [range(0,8192)] uint32 *bytes_needed
);
/*****************/
@@ -572,12 +578,12 @@ import "misc.idl", "security.idl";
[in] uint32 info_level,
[in] uint32 type,
[in] uint32 state,
- [out] uint8 services[buf_size],
- [in] uint32 buf_size,
- [out,ref] uint32 *bytes_needed,
- [out,ref] uint32 *service_returned,
- [in,out,unique] uint32 *resume_handle,
- [out,ref] [string,charset(UTF16)] uint16 **group_name
+ [out,ref,size_is(buf_size)] uint8 *services,
+ [in] [range(0,262144)] uint32 buf_size,
+ [out,ref] [range(0,262144)] uint32 *bytes_needed,
+ [out,ref] [range(0,262144)] uint32 *service_returned,
+ [in,out,unique] [range(0,262144)] uint32 *resume_handle,
+ [in,unique] [string,charset(UTF16)] uint16 *group_name
);
/*****************/
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 127f6734e3..eafaf688af 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -511,6 +511,7 @@ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const ch
/* GUIDs */
bool GUID_equal(const struct GUID *u1, const struct GUID *u2);
+NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid);
NTSTATUS GUID_from_string(const char *s, struct GUID *guid);
NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid);
struct GUID GUID_zero(void);
@@ -518,6 +519,7 @@ bool GUID_all_zero(const struct GUID *u);
int GUID_compare(const struct GUID *u1, const struct GUID *u2);
char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);
char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid);
+char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid);
char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);
struct GUID GUID_random(void);
diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c
index 1e6ee0a3db..aa24ac4494 100644
--- a/librpc/ndr/uuid.c
+++ b/librpc/ndr/uuid.c
@@ -23,33 +23,66 @@
#include "includes.h"
#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/ndr_misc.h"
/**
build a GUID from a string
*/
-_PUBLIC_ NTSTATUS GUID_from_string(const char *s, struct GUID *guid)
+_PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
{
NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
uint32_t time_low;
uint32_t time_mid, time_hi_and_version;
uint32_t clock_seq[2];
uint32_t node[6];
+ uint8_t buf16[16];
+ DATA_BLOB blob16 = data_blob_const(buf16, sizeof(buf16));
int i;
- if (s == NULL) {
+ if (s->data == NULL) {
return NT_STATUS_INVALID_PARAMETER;
}
- if (11 == sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ if (s->length == 36 &&
+ 11 == sscanf((const char *)s->data,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
&time_low, &time_mid, &time_hi_and_version,
&clock_seq[0], &clock_seq[1],
&node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
status = NT_STATUS_OK;
- } else if (11 == sscanf(s, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
- &time_low, &time_mid, &time_hi_and_version,
- &clock_seq[0], &clock_seq[1],
- &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
+ } else if (s->length == 38
+ && 11 == sscanf((const char *)s->data,
+ "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ &time_low, &time_mid, &time_hi_and_version,
+ &clock_seq[0], &clock_seq[1],
+ &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
status = NT_STATUS_OK;
+ } else if (s->length == 32) {
+ size_t rlen = strhex_to_str((char *)blob16.data, blob16.length,
+ (const char *)s->data, s->length);
+ if (rlen == blob16.length) {
+ /* goto the ndr_pull_struct_blob() path */
+ status = NT_STATUS_OK;
+ s = &blob16;
+ }
+ }
+
+ if (s->length == 16) {
+ enum ndr_err_code ndr_err;
+ struct GUID guid2;
+ TALLOC_CTX *mem_ctx;
+
+ mem_ctx = talloc_new(NULL);
+ NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
+
+ ndr_err = ndr_pull_struct_blob(s, mem_ctx, NULL, &guid2,
+ (ndr_pull_flags_fn_t)ndr_pull_GUID);
+ talloc_free(mem_ctx);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ *guid = guid2;
+ return NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(status)) {
@@ -71,6 +104,16 @@ _PUBLIC_ NTSTATUS GUID_from_string(const char *s, struct GUID *guid)
/**
build a GUID from a string
*/
+_PUBLIC_ NTSTATUS GUID_from_string(const char *s, struct GUID *guid)
+{
+ DATA_BLOB blob = data_blob_string_const(s);
+ return GUID_from_data_blob(&blob, guid);
+ return NT_STATUS_OK;
+}
+
+/**
+ build a GUID from a string
+*/
_PUBLIC_ NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid)
{
NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
@@ -208,6 +251,31 @@ _PUBLIC_ char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid)
return ret;
}
+_PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
+{
+ char *ret;
+ DATA_BLOB guid_blob;
+ enum ndr_err_code ndr_err;
+ TALLOC_CTX *tmp_mem;
+
+ tmp_mem = talloc_new(mem_ctx);
+ if (!tmp_mem) {
+ return NULL;
+ }
+ ndr_err = ndr_push_struct_blob(&guid_blob, tmp_mem,
+ NULL,
+ guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(tmp_mem);
+ return NULL;
+ }
+
+ ret = data_blob_hex_string(mem_ctx, &guid_blob);
+ talloc_free(tmp_mem);
+ return ret;
+}
+
_PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid)
{
return talloc_asprintf(mem_ctx,
diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c
index b755431034..a660989d19 100644
--- a/librpc/rpc/binding.c
+++ b/librpc/rpc/binding.c
@@ -251,8 +251,8 @@ _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struc
if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */
NTSTATUS status;
-
- status = GUID_from_string(s, &b->object.uuid);
+ DATA_BLOB blob = data_blob(s, 36);
+ status = GUID_from_data_blob(&blob, &b->object.uuid);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(0, ("Failed parsing UUID\n"));