summaryrefslogtreecommitdiff
path: root/source3/rpc_parse
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-03-26 06:52:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:20 -0500
commit0aa89db9471330fd02db395c2eb387ac2dfef54f (patch)
treec4cf899e4aeb15bc926c2e4e470ee32f14b2bba4 /source3/rpc_parse
parent404fa5636ddae8caa0a46bb68b796d23ec3f5a0e (diff)
downloadsamba-0aa89db9471330fd02db395c2eb387ac2dfef54f.tar.gz
samba-0aa89db9471330fd02db395c2eb387ac2dfef54f.tar.bz2
samba-0aa89db9471330fd02db395c2eb387ac2dfef54f.zip
r6071: * clean up UNISTR2_ARRAY ( really just an array of UNISTR4 + count )
* add some backwards compatibility to 'net rpc rights list' * verify privilege name in 'net rpc rights privileges <name>' in order to give back better error messages. (This used to be commit 0e29dc8aa384dfa6d2495beb8a9ffb5371e60a13)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_lsa.c28
-rw-r--r--source3/rpc_parse/parse_misc.c142
-rw-r--r--source3/rpc_parse/parse_svcctl.c2
3 files changed, 96 insertions, 76 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index d0b9b20a3b..649cb7845a 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -2322,7 +2322,9 @@ NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *r_u, PRIVILEGE_SET *pr
}
if ( num_priv ) {
- if ( !init_unistr2_array( &r_u->rights, num_priv, privname_array ) )
+ r_u->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
+
+ if ( !init_unistr4_array( r_u->rights, num_priv, privname_array ) )
return NT_STATUS_NO_MEMORY;
r_u->count = num_priv;
@@ -2364,7 +2366,7 @@ BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, pr
if(!prs_uint32("count ", ps, depth, &r_c->count))
return False;
- if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth))
+ if ( !prs_pointer("rights", ps, depth, (void**)&r_c->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
if(!prs_align(ps))
@@ -2380,17 +2382,17 @@ BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, pr
/*******************************************************************
Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
********************************************************************/
-void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q,
- POLICY_HND *hnd,
- DOM_SID *sid,
- uint32 count,
- const char **rights)
+void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *q_q, POLICY_HND *hnd,
+ DOM_SID *sid, uint32 count, const char **rights )
{
DEBUG(5, ("init_q_add_acct_rights\n"));
q_q->pol = *hnd;
init_dom_sid2(&q_q->sid, sid);
- init_unistr2_array(&q_q->rights, count, rights);
+
+ q_q->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
+ init_unistr4_array( q_q->rights, count, rights );
+
q_q->count = count;
}
@@ -2412,7 +2414,7 @@ BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_
if(!prs_uint32("count", ps, depth, &q_q->count))
return False;
- if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
+ if ( !prs_pointer("rights", ps, depth, (void**)&q_q->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
return True;
@@ -2446,10 +2448,14 @@ void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q,
DEBUG(5, ("init_q_remove_acct_rights\n"));
q_q->pol = *hnd;
+
init_dom_sid2(&q_q->sid, sid);
+
q_q->removeall = removeall;
- init_unistr2_array(&q_q->rights, count, rights);
q_q->count = count;
+
+ q_q->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY );
+ init_unistr4_array( q_q->rights, count, rights );
}
@@ -2473,7 +2479,7 @@ BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q
if(!prs_uint32("count", ps, depth, &q_q->count))
return False;
- if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
+ if ( !prs_pointer("rights", ps, depth, (void**)&q_q->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
return True;
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 76c6438d59..57f44f9f85 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -1114,7 +1114,6 @@ BOOL smb_io_unistr2(const char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *
BOOL prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4)
{
-
if ( !prs_uint16("length", ps, depth, &uni4->length ))
return False;
if ( !prs_uint16("size", ps, depth, &uni4->size ))
@@ -1126,33 +1125,97 @@ BOOL prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4)
return True;
}
+/*******************************************************************
+ now read/write UNISTR4 header
+********************************************************************/
+
+BOOL prs_unistr4_hdr(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4)
+{
+ prs_debug(ps, depth, desc, "prs_unistr4_hdr");
+ depth++;
+
+ if ( !prs_uint16("length", ps, depth, &uni4->length) )
+ return False;
+ if ( !prs_uint16("size", ps, depth, &uni4->size) )
+ return False;
+ if ( !prs_io_unistr2_p(desc, ps, depth, &uni4->string) )
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ now read/write UNISTR4 string
+********************************************************************/
+
+BOOL prs_unistr4_str(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4)
+{
+ prs_debug(ps, depth, desc, "prs_unistr4_str");
+ depth++;
+
+ if ( !prs_io_unistr2(desc, ps, depth, uni4->string) )
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a UNISTR2_ARRAY structure.
+********************************************************************/
+
+BOOL prs_unistr4_array(const char *desc, prs_struct *ps, int depth, UNISTR4_ARRAY *array )
+{
+ unsigned int i;
+
+ prs_debug(ps, depth, desc, "prs_unistr4_array");
+ depth++;
+
+ if(!prs_uint32("count", ps, depth, &array->count))
+ return False;
+
+ if ( array->count == 0 )
+ return True;
+
+ if (UNMARSHALLING(ps)) {
+ if ( !(array->strings = TALLOC_ZERO_ARRAY( get_talloc_ctx(), UNISTR4, array->count)) )
+ return False;
+ }
+
+ /* write the headers and then the actual string buffer */
+
+ for ( i=0; i<array->count; i++ ) {
+ if ( !prs_unistr4_hdr( "string", ps, depth, &array->strings[i]) )
+ return False;
+ }
+
+ for (i=0;i<array->count;i++) {
+ if ( !prs_unistr4_str("string", ps, depth, &array->strings[i]) )
+ return False;
+ }
+
+ return True;
+}
/********************************************************************
initialise a UNISTR_ARRAY from a char**
********************************************************************/
-BOOL init_unistr2_array(UNISTR2_ARRAY *array,
- uint32 count, const char **strings)
+BOOL init_unistr4_array( UNISTR4_ARRAY *array, uint32 count, const char **strings )
{
unsigned int i;
array->count = count;
- array->ref_id = count?1:0;
- if (array->count == 0) {
+
+ if ( array->count == 0 )
return True;
- }
- array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR2_ARRAY_EL, count );
- if (!array->strings) {
+ /* allocate memory for the array of UNISTR4 objects */
+
+ if ( !(array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR4, count )) )
return False;
- }
- for (i=0;i<count;i++) {
- init_unistr2(&array->strings[i].string, strings[i], UNI_FLAGS_NONE);
- array->strings[i].size = array->strings[i].string.uni_max_len*2;
- array->strings[i].length = array->strings[i].size;
- array->strings[i].ref_id = 1;
- }
+ for ( i=0; i<count; i++ )
+ init_unistr4( &array->strings[i], strings[i], STR_TERMINATE );
return True;
}
@@ -1205,55 +1268,6 @@ BOOL smb_io_account_lockout_str(const char *desc, LOCKOUT_STRING *account_lockou
}
/*******************************************************************
- Reads or writes a UNISTR2_ARRAY structure.
-********************************************************************/
-BOOL smb_io_unistr2_array(const char *desc, UNISTR2_ARRAY *array, prs_struct *ps, int depth)
-{
- unsigned int i;
-
- prs_debug(ps, depth, desc, "smb_io_unistr2_array");
- depth++;
-
- if(!prs_uint32("ref_id", ps, depth, &array->ref_id))
- return False;
-
- if (! array->ref_id) {
- return True;
- }
-
- if(!prs_uint32("count", ps, depth, &array->count))
- return False;
-
- if (array->count == 0) {
- return True;
- }
-
- if (UNMARSHALLING(ps)) {
- array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR2_ARRAY_EL, array->count );
- }
- if (! array->strings) {
- return False;
- }
-
- for (i=0;i<array->count;i++) {
- if(!prs_uint16("length", ps, depth, &array->strings[i].length))
- return False;
- if(!prs_uint16("size", ps, depth, &array->strings[i].size))
- return False;
- if(!prs_uint32("ref_id", ps, depth, &array->strings[i].ref_id))
- return False;
- }
-
- for (i=0;i<array->count;i++) {
- if (! smb_io_unistr2("string", &array->strings[i].string, array->strings[i].ref_id, ps, depth))
- return False;
- }
-
- return True;
-}
-
-
-/*******************************************************************
Inits a DOM_RID2 structure.
********************************************************************/
diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c
index acebcf34c6..1c41a18b99 100644
--- a/source3/rpc_parse/parse_svcctl.c
+++ b/source3/rpc_parse/parse_svcctl.c
@@ -481,7 +481,7 @@ BOOL svcctl_io_q_start_service(const char *desc, SVCCTL_Q_START_SERVICE *q_u, pr
if(!prs_uint32("parmcount", ps, depth, &q_u->parmcount))
return False;
- if(!smb_io_unistr2_array("parameters", &q_u->parameters, ps, depth))
+ if ( !prs_pointer("rights", ps, depth, (void**)&q_u->parameters, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
return True;