diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-20 03:09:19 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-20 03:09:19 +0000 |
commit | 308cc429eb7c07d94609f2818e9d81239cb4cbb9 (patch) | |
tree | 84c059b23956750a4ca196fb0faebb4c889f4718 /source4/librpc/ndr | |
parent | cde87e39c68f599026cc350c37c0cafe0e7ebcb6 (diff) | |
download | samba-308cc429eb7c07d94609f2818e9d81239cb4cbb9.tar.gz samba-308cc429eb7c07d94609f2818e9d81239cb4cbb9.tar.bz2 samba-308cc429eb7c07d94609f2818e9d81239cb4cbb9.zip |
added samr_LookupNames() and test code
(This used to be commit f8397cbc8554b721093b8ae6ac6fb26d0ee9a7cf)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r-- | source4/librpc/ndr/libndr.h | 3 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 1 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 10 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_misc.c | 4 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.c | 65 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.h | 15 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 2 |
7 files changed, 66 insertions, 34 deletions
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index 96322ed654..df058abc68 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -65,6 +65,9 @@ struct ndr_push { uint32 offset; TALLOC_CTX *mem_ctx; + /* this is used to ensure we generate unique reference IDs */ + uint32 ptr_count; + /* this points at a list of offsets to the structures being processed. The first element in the list is the current structure */ struct ndr_ofs_list *ofs_list; diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index a78f135d92..56e0e5f0ed 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -151,6 +151,7 @@ struct ndr_push *ndr_push_init(void) return NULL; } ndr->offset = 0; + ndr->ptr_count = 0; return ndr; } diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index fcf64b6790..0cb4456399 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -308,7 +308,15 @@ NTSTATUS ndr_push_length4_end(struct ndr_push *ndr, struct ndr_push_save *save) */ NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) { - return ndr_push_uint32(ndr, p?0xaabbccdd:0); + uint32 ptr = 0; + if (p) { + /* we do this to ensure that we generate unique ref ids, + which means we can handle the case where a MS programmer + forgot to mark a pointer as unique */ + ndr->ptr_count++; + ptr = 0xaabbcc00 + ndr->ptr_count; + } + return ndr_push_uint32(ndr, ptr); } /* diff --git a/source4/librpc/ndr/ndr_misc.c b/source4/librpc/ndr/ndr_misc.c index 65e198ce96..31f501e614 100644 --- a/source4/librpc/ndr/ndr_misc.c +++ b/source4/librpc/ndr/ndr_misc.c @@ -138,10 +138,6 @@ done: NTSTATUS ndr_pull_security_descriptor(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor *r) { - uint32 _ptr_owner_sid; - uint32 _ptr_group_sid; - uint32 _ptr_sacl; - uint32 _ptr_dacl; NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); diff --git a/source4/librpc/ndr/ndr_samr.c b/source4/librpc/ndr/ndr_samr.c index c319e4cac7..9297a2781b 100644 --- a/source4/librpc/ndr/ndr_samr.c +++ b/source4/librpc/ndr/ndr_samr.c @@ -176,8 +176,16 @@ NTSTATUS ndr_push_samr_GetAliasMembership(struct ndr_push *ndr, struct samr_GetA return NT_STATUS_OK; } -NTSTATUS ndr_push_samr_LOOKUP_NAMES(struct ndr_push *ndr, struct samr_LOOKUP_NAMES *r) +NTSTATUS ndr_push_samr_LookupNames(struct ndr_push *ndr, struct samr_LookupNames *r) { + NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, r->in.num_names)); + if (r->in.names) { + NDR_CHECK(ndr_push_uint32(ndr, 1000)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, r->in.num_names)); + NDR_CHECK(ndr_push_array(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.names, sizeof(r->in.names[0]), r->in.num_names, (ndr_push_flags_fn_t)ndr_push_samr_Name)); + } return NT_STATUS_OK; } @@ -1110,23 +1118,23 @@ NTSTATUS ndr_pull_samr_EnumDomainAliases(struct ndr_pull *ndr, struct samr_EnumD return NT_STATUS_OK; } -NTSTATUS ndr_pull_samr_Rids(struct ndr_pull *ndr, int ndr_flags, struct samr_Rids *r) +NTSTATUS ndr_pull_samr_Ids(struct ndr_pull *ndr, int ndr_flags, struct samr_Ids *r) { - uint32 _ptr_rids; + uint32 _ptr_ids; NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); - NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_rids)); - if (_ptr_rids) { - NDR_ALLOC(ndr, r->rids); + NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_ids)); + if (_ptr_ids) { + NDR_ALLOC(ndr, r->ids); } else { - r->rids = NULL; + r->ids = NULL; } ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; - if (r->rids) { + if (r->ids) { { uint32 _array_size; NDR_CHECK(ndr_pull_uint32(ndr, &_array_size)); @@ -1134,8 +1142,8 @@ buffers: return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should be %u", _array_size, r->count); } } - NDR_ALLOC_N_SIZE(ndr, r->rids, r->count, sizeof(r->rids[0])); - NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->rids, r->count)); + NDR_ALLOC_N_SIZE(ndr, r->ids, r->count, sizeof(r->ids[0])); + NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->ids, r->count)); } done: return NT_STATUS_OK; @@ -1151,15 +1159,17 @@ NTSTATUS ndr_pull_samr_GetAliasMembership(struct ndr_pull *ndr, struct samr_GetA r->out.rids = NULL; } if (r->out.rids) { - NDR_CHECK(ndr_pull_samr_Rids(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.rids)); + NDR_CHECK(ndr_pull_samr_Ids(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.rids)); } NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; } -NTSTATUS ndr_pull_samr_LOOKUP_NAMES(struct ndr_pull *ndr, struct samr_LOOKUP_NAMES *r) +NTSTATUS ndr_pull_samr_LookupNames(struct ndr_pull *ndr, struct samr_LookupNames *r) { + NDR_CHECK(ndr_pull_samr_Ids(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.rids)); + NDR_CHECK(ndr_pull_samr_Ids(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.types)); NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; @@ -3099,15 +3109,15 @@ void ndr_print_samr_Sids(struct ndr_print *ndr, const char *name, struct samr_Si ndr->depth--; } -void ndr_print_samr_Rids(struct ndr_print *ndr, const char *name, struct samr_Rids *r) +void ndr_print_samr_Ids(struct ndr_print *ndr, const char *name, struct samr_Ids *r) { - ndr_print_struct(ndr, name, "samr_Rids"); + ndr_print_struct(ndr, name, "samr_Ids"); ndr->depth++; ndr_print_uint32(ndr, "count", r->count); - ndr_print_ptr(ndr, "rids", r->rids); + ndr_print_ptr(ndr, "ids", r->ids); ndr->depth++; - if (r->rids) { - ndr_print_array_uint32(ndr, "rids", r->rids, r->count); + if (r->ids) { + ndr_print_array_uint32(ndr, "ids", r->ids, r->count); } ndr->depth--; ndr->depth--; @@ -3138,7 +3148,7 @@ void ndr_print_samr_GetAliasMembership(struct ndr_print *ndr, const char *name, ndr_print_ptr(ndr, "rids", r->out.rids); ndr->depth++; if (r->out.rids) { - ndr_print_samr_Rids(ndr, "rids", r->out.rids); + ndr_print_samr_Ids(ndr, "rids", r->out.rids); } ndr->depth--; ndr_print_NTSTATUS(ndr, "result", &r->out.result); @@ -3147,18 +3157,29 @@ void ndr_print_samr_GetAliasMembership(struct ndr_print *ndr, const char *name, ndr->depth--; } -void ndr_print_samr_LOOKUP_NAMES(struct ndr_print *ndr, const char *name, int flags, struct samr_LOOKUP_NAMES *r) +void ndr_print_samr_LookupNames(struct ndr_print *ndr, const char *name, int flags, struct samr_LookupNames *r) { - ndr_print_struct(ndr, name, "samr_LOOKUP_NAMES"); + ndr_print_struct(ndr, name, "samr_LookupNames"); ndr->depth++; if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "samr_LOOKUP_NAMES"); + ndr_print_struct(ndr, "in", "samr_LookupNames"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "num_names", r->in.num_names); + ndr_print_ptr(ndr, "names", r->in.names); + ndr->depth++; + ndr_print_array(ndr, "names", r->in.names, sizeof(r->in.names[0]), r->in.num_names, (ndr_print_fn_t)ndr_print_samr_Name); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "samr_LOOKUP_NAMES"); + ndr_print_struct(ndr, "out", "samr_LookupNames"); ndr->depth++; + ndr_print_samr_Ids(ndr, "rids", &r->out.rids); + ndr_print_samr_Ids(ndr, "types", &r->out.types); ndr_print_NTSTATUS(ndr, "result", &r->out.result); ndr->depth--; } diff --git a/source4/librpc/ndr/ndr_samr.h b/source4/librpc/ndr/ndr_samr.h index 11ae381639..452822b15e 100644 --- a/source4/librpc/ndr/ndr_samr.h +++ b/source4/librpc/ndr/ndr_samr.h @@ -21,7 +21,7 @@ #define DCERPC_SAMR_CREATE_DOM_ALIAS 14 #define DCERPC_SAMR_ENUMDOMAINALIASES 15 #define DCERPC_SAMR_GETALIASMEMBERSHIP 16 -#define DCERPC_SAMR_LOOKUP_NAMES 17 +#define DCERPC_SAMR_LOOKUPNAMES 17 #define DCERPC_SAMR_LOOKUP_RIDS 18 #define DCERPC_SAMR_OPENGROUP 19 #define DCERPC_SAMR_QUERYGROUPINFO 20 @@ -404,9 +404,9 @@ struct samr_Sids { struct dom_sid2 *sids; }; -struct samr_Rids { +struct samr_Ids { uint32 count; - uint32 *rids; + uint32 *ids; }; struct samr_GetAliasMembership { @@ -416,17 +416,22 @@ struct samr_GetAliasMembership { } in; struct { - struct samr_Rids *rids; + struct samr_Ids *rids; NTSTATUS result; } out; }; -struct samr_LOOKUP_NAMES { +struct samr_LookupNames { struct { + struct policy_handle *handle; + uint32 num_names; + struct samr_Name *names; } in; struct { + struct samr_Ids rids; + struct samr_Ids types; NTSTATUS result; } out; diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index b0d4418af9..bed2ce25f5 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -1064,8 +1064,6 @@ done: NTSTATUS ndr_pull_spoolss_PrinterInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r) { - uint32 _ptr_devmode; - uint32 _ptr_secdesc; NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); |