summaryrefslogtreecommitdiffstats
path: root/source3/rpc_parse
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-04-06 22:27:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:30 -0500
commitb137b7cc4720ca9d99eab2bb198be1b112c2e24c (patch)
tree357cbbc9122d1766d2532ffe60aa463686f57c81 /source3/rpc_parse
parent978ca8486031e43754a3c23757f361bf3a85f335 (diff)
downloadsamba-b137b7cc4720ca9d99eab2bb198be1b112c2e24c.tar.gz
samba-b137b7cc4720ca9d99eab2bb198be1b112c2e24c.tar.xz
samba-b137b7cc4720ca9d99eab2bb198be1b112c2e24c.zip
r6228: remove BUFHDR2 and clean up LsaEnumTrustedDomains()
Tested client and server code. (This used to be commit efb3ac4c69c72c0fa01c558951fa357893562bce)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_lsa.c136
-rw-r--r--source3/rpc_parse/parse_misc.c69
-rw-r--r--source3/rpc_parse/parse_reg.c2
3 files changed, 106 insertions, 101 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index 649cb7845a..ab3d3fcfe8 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -6,6 +6,7 @@
* Copyright (C) Paul Ashton 1997,
* Copyright (C) Andrew Bartlett 2002,
* Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
+ * Copyright (C) Gerald )Jerry) Carter 2005
*
* 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
@@ -516,100 +517,99 @@ void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 en
DEBUG(5, ("init_r_enum_trust_dom\n"));
- r_e->enum_context = enum_context;
- r_e->num_domains = num_domains;
- r_e->ptr_enum_domains = 0;
- r_e->num_domains2 = num_domains;
-
- if (num_domains != 0) {
+ r_e->enum_context = enum_context;
+ r_e->count = num_domains;
+
+ if ( num_domains != 0 ) {
- /*
- * allocating empty arrays of unicode headers, strings
- * and sids of enumerated trusted domains
- */
- if (!(r_e->hdr_domain_name = TALLOC_ARRAY(ctx,UNIHDR2,num_domains))) {
- r_e->status = NT_STATUS_NO_MEMORY;
- return;
- }
+ /* allocate container memory */
- if (!(r_e->uni_domain_name = TALLOC_ARRAY(ctx,UNISTR2,num_domains))) {
- r_e->status = NT_STATUS_NO_MEMORY;
- return;
- }
-
- if (!(r_e->domain_sid = TALLOC_ARRAY(ctx,DOM_SID2,num_domains))) {
+ r_e->domlist = TALLOC_P( ctx, DOMAIN_LIST );
+ r_e->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO, r_e->count );
+
+ if ( !r_e->domlist || !r_e->domlist->domains ) {
r_e->status = NT_STATUS_NO_MEMORY;
return;
}
+
+ r_e->domlist->count = r_e->count;
+
+ /* initialize the list of domains and their sid */
+
+ for (i = 0; i < num_domains; i++) {
+ if ( !(r_e->domlist->domains[i].sid = TALLOC_P(ctx, DOM_SID2)) ) {
+ r_e->status = NT_STATUS_NO_MEMORY;
+ return;
+ }
- for (i = 0; i < num_domains; i++) {
-
- /* don't know what actually is this for */
- r_e->ptr_enum_domains = 1;
-
- init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid);
-
- init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name);
- init_uni_hdr2(&r_e->hdr_domain_name[i], &r_e->uni_domain_name[i]);
-
- };
+ init_dom_sid2(r_e->domlist->domains[i].sid, &(td[i])->sid);
+ init_unistr4_w(ctx, &r_e->domlist->domains[i].name, (td[i])->name);
+ }
}
}
/*******************************************************************
- Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
********************************************************************/
-BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
- prs_struct *ps, int depth)
+BOOL lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist )
{
- prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
+ int i;
+
+ prs_debug(ps, depth, desc, "lsa_io_domain_list");
depth++;
- if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context))
- return False;
- if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains))
- return False;
- if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains))
+ if(!prs_uint32("count", ps, depth, &domlist->count))
return False;
- if (r_e->ptr_enum_domains) {
- int i, num_domains;
+ if ( domlist->count == 0 )
+ return True;
+
+ if ( UNMARSHALLING(ps) ) {
+ if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) )
+ return False;
+ }
+
+ /* headers */
+
+ for ( i=0; i<domlist->count; i++ ) {
+ if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) )
+ return False;
+ if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) )
+ return False;
+ }
- if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2))
+ /* data */
+
+ for ( i=0; i<domlist->count; i++ ) {
+ if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) )
return False;
+ if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) )
+ return False;
+ }
+
+ return True;
+}
- num_domains = r_e->num_domains2;
+/*******************************************************************
+ Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
+********************************************************************/
- if (UNMARSHALLING(ps)) {
- if (!(r_e->hdr_domain_name = PRS_ALLOC_MEM(ps,UNIHDR2,num_domains)))
- return False;
+BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
+ depth++;
- if (!(r_e->uni_domain_name = PRS_ALLOC_MEM(ps,UNISTR2,num_domains)))
- return False;
+ if(!prs_uint32("enum_context", ps, depth, &r_e->enum_context))
+ return False;
- if (!(r_e->domain_sid = PRS_ALLOC_MEM(ps,DOM_SID2,num_domains)))
- return False;
- }
+ if(!prs_uint32("count", ps, depth, &r_e->count))
+ return False;
- for (i = 0; i < num_domains; i++) {
- if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps,
- depth))
- return False;
- }
+ if ( !prs_pointer("trusted_domains", ps, depth, (void**)&r_e->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
+ return False;
- for (i = 0; i < num_domains; i++) {
- if(!smb_io_unistr2 ("", &r_e->uni_domain_name[i],
- r_e->hdr_domain_name[i].buffer,
- ps, depth))
- return False;
- if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps,
- depth))
- return False;
- }
- }
-
if(!prs_ntstatus("status", ps, depth, &r_e->status))
return False;
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 57f44f9f85..858366d4ad 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -4,6 +4,7 @@
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
* Copyright (C) Paul Ashton 1997.
+ * Copyright (C) Gerald (Jerry) Carter 2005
*
* 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
@@ -280,6 +281,33 @@ void init_dom_sid2(DOM_SID2 *sid2, const DOM_SID *sid)
Reads or writes a DOM_SID2 structure.
********************************************************************/
+BOOL smb_io_dom_sid2_p(const char *desc, prs_struct *ps, int depth, DOM_SID2 **sid2)
+{
+ uint32 data_p;
+
+ /* caputure the pointer value to stream */
+
+ data_p = (uint32) *sid2;
+
+ if ( !prs_uint32("dom_sid2_p", ps, depth, &data_p ))
+ return False;
+
+ /* we're done if there is no data */
+
+ if ( !data_p )
+ return True;
+
+ if (UNMARSHALLING(ps)) {
+ if ( !(*sid2 = PRS_ALLOC_MEM(ps, DOM_SID2, 1)) )
+ return False;
+ }
+
+ return True;
+}
+/*******************************************************************
+ Reads or writes a DOM_SID2 structure.
+********************************************************************/
+
BOOL smb_io_dom_sid2(const char *desc, DOM_SID2 *sid, prs_struct *ps, int depth)
{
if (sid == NULL)
@@ -485,39 +513,6 @@ BOOL smb_io_hdrbuf(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth)
}
/*******************************************************************
-creates a UNIHDR2 structure.
-********************************************************************/
-
-void init_uni_hdr2(UNIHDR2 *hdr, UNISTR2 *str2)
-{
- init_uni_hdr(&hdr->unihdr, str2);
- hdr->buffer = (str2->uni_str_len > 0) ? 1 : 0;
-}
-
-/*******************************************************************
- Reads or writes a UNIHDR2 structure.
-********************************************************************/
-
-BOOL smb_io_unihdr2(const char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth)
-{
- if (hdr2 == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "smb_io_unihdr2");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unihdr("hdr", &hdr2->unihdr, ps, depth))
- return False;
- if(!prs_uint32("buffer", ps, depth, &hdr2->buffer))
- return False;
-
- return True;
-}
-
-/*******************************************************************
Inits a UNISTR structure.
********************************************************************/
@@ -913,6 +908,14 @@ void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags)
uni4->size = 2 * (uni4->string->uni_max_len);
}
+void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf )
+{
+ uni4->string = TALLOC_P( ctx, UNISTR2 );
+ init_unistr2_w( ctx, uni4->string, buf );
+
+ uni4->length = 2 * (uni4->string->uni_str_len);
+ uni4->size = 2 * (uni4->string->uni_max_len);
+}
/**
* Inits a UNISTR2 structure.
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index 09e19bf701..e76c536cee 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -271,8 +271,10 @@ BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *q_u,
ps, depth))
return False;
+#if 0
if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2))
return False;
+#endif
return True;
}