summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/rpc_samr.h64
-rw-r--r--source3/rpc_client/cli_samr.c2
-rw-r--r--source3/rpc_parse/parse_samr.c87
-rw-r--r--source3/rpc_server/srv_samr_nt.c27
-rw-r--r--source3/utils/net_rpc.c7
5 files changed, 75 insertions, 112 deletions
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h
index 6559127df1..adf4101880 100644
--- a/source3/include/rpc_samr.h
+++ b/source3/include/rpc_samr.h
@@ -1180,74 +1180,52 @@ typedef struct r_samr_create_dom_alias_info
} SAMR_R_CREATE_DOM_ALIAS;
-/* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
-typedef struct q_samr_query_alias_info
-{
- POLICY_HND pol; /* policy handle */
- uint16 switch_level; /* 0x0003 seen */
+/********************************************************/
-} SAMR_Q_QUERY_ALIASINFO;
-
-typedef struct samr_alias_info1
-{
- UNIHDR hdr_acct_name;
- UNIHDR hdr_acct_desc;
+typedef struct {
+ UNISTR4 name;
+ UNISTR4 description;
uint32 num_member;
- UNISTR2 uni_acct_name;
- UNISTR2 uni_acct_desc;
-
} ALIAS_INFO1;
-typedef struct samr_alias_info3
-{
- UNIHDR hdr_acct_desc;
- UNISTR2 uni_acct_desc;
-
+typedef struct {
+ UNISTR4 description;
} ALIAS_INFO3;
-/* ALIAS_INFO_CTR */
-typedef struct alias_info_ctr
-{
- uint16 switch_value1;
- uint16 switch_value2;
+typedef struct {
+ POLICY_HND pol; /* policy handle */
+ uint16 level; /* 0x0003 seen */
+} SAMR_Q_QUERY_ALIASINFO;
- union
- {
+typedef struct {
+ uint16 level;
+ union {
ALIAS_INFO1 info1;
ALIAS_INFO3 info3;
-
} alias;
-
} ALIAS_INFO_CTR;
-/* SAMR_R_QUERY_ALIASINFO - SAM alias info */
-typedef struct r_samr_query_aliasinfo_info
-{
- uint32 ptr;
- ALIAS_INFO_CTR ctr;
-
+typedef struct {
+ ALIAS_INFO_CTR *ctr;
NTSTATUS status;
-
} SAMR_R_QUERY_ALIASINFO;
-/* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
-typedef struct q_samr_set_alias_info
-{
+/********************************************************/
+
+typedef struct {
POLICY_HND alias_pol; /* policy handle */
ALIAS_INFO_CTR ctr;
-
} SAMR_Q_SET_ALIASINFO;
-/* SAMR_R_SET_ALIASINFO - SAM alias info */
-typedef struct r_samr_set_aliasinfo_info
-{
+typedef struct {
NTSTATUS status;
-
} SAMR_R_SET_ALIASINFO;
+/********************************************************/
+
/* SAMR_Q_QUERY_USERGROUPS - */
typedef struct q_samr_query_usergroup_info
{
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 75751dbcbd..45f9bd67a5 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -1357,7 +1357,7 @@ NTSTATUS cli_samr_query_alias_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
goto done;
}
- *ctr = r.ctr;
+ *ctr = *r.ctr;
done:
prs_mem_free(&qbuf);
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index d3f709c352..ba8b367a42 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -3472,13 +3472,9 @@ void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member
{
DEBUG(5, ("init_samr_alias_info1\n"));
- init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
- init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
-
- al1->num_member=num_member;
-
- init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
+ init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
+ al1->num_member = num_member;
+ init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
}
/*******************************************************************
@@ -3497,22 +3493,20 @@ BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
if(!prs_align(ps))
return False;
- if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
+ if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
return False;
- if(!prs_uint32("num_member", ps, depth, &al1->num_member))
+ if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
return False;
- if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
+ if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
return False;
- if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
- al1->hdr_acct_name.buffer, ps, depth))
+ if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
return False;
-
- if(!prs_align(ps))
+ if ( !prs_align(ps) )
return False;
-
- if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
- al1->hdr_acct_desc.buffer, ps, depth))
+ if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
+ return False;
+ if ( !prs_align(ps) )
return False;
return True;
@@ -3526,15 +3520,14 @@ void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
{
DEBUG(5, ("init_samr_alias_info3\n"));
- init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
+ init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
+BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
prs_struct *ps, int depth)
{
if (al3 == NULL)
@@ -3546,10 +3539,7 @@ BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
if(!prs_align(ps))
return False;
- if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
- al3->hdr_acct_desc.buffer, ps, depth))
+ if (!prs_unistr4("description", ps, depth, &al3->description))
return False;
return True;
@@ -3559,21 +3549,20 @@ BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
reads or writes a structure.
********************************************************************/
-BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
- prs_struct *ps, int depth)
+BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
{
- if (ctr == NULL)
+ if ( !ctr )
return False;
prs_debug(ps, depth, desc, "samr_alias_info_ctr");
depth++;
- if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
- return False;
- if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
+ if ( !prs_uint16("level", ps, depth, &ctr->level) )
return False;
- switch (ctr->switch_value1) {
+ if(!prs_align(ps))
+ return False;
+ switch (ctr->level) {
case 1:
if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
return False;
@@ -3595,22 +3584,22 @@ inits a SAMR_Q_QUERY_ALIASINFO structure.
********************************************************************/
void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
- POLICY_HND *pol, uint16 switch_level)
+ POLICY_HND *pol, uint32 switch_level)
{
DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
q_e->pol = *pol;
- q_e->switch_level = switch_level;
+ q_e->level = switch_level;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
+BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ if ( !in )
return False;
prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
@@ -3619,10 +3608,10 @@ BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
+ if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
return False;
- if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
+ if ( !prs_uint16("level", ps, depth, &in->level) )
return False;
return True;
@@ -3632,24 +3621,23 @@ BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
inits a SAMR_R_QUERY_ALIASINFO structure.
********************************************************************/
-void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
+void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
ALIAS_INFO_CTR * ctr, NTSTATUS status)
{
DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
- r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
- r_u->ctr = *ctr;
- r_u->status = status;
+ out->ctr = ctr;
+ out->status = status;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
+BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ if ( !out )
return False;
prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
@@ -3658,17 +3646,12 @@ BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
if(!prs_align(ps))
return False;
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
+ if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
return False;
-
- if (r_u->ptr != 0) {
- if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
- return False;
- }
-
if(!prs_align(ps))
return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+
+ if(!prs_ntstatus("status", ps, depth, &out->status))
return False;
return True;
@@ -3705,7 +3688,7 @@ BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
return False;
- if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
+ if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
return False;
return True;
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 040d4e7dea..54012d57a9 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -985,17 +985,18 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM
if ( !ret )
return NT_STATUS_NO_SUCH_ALIAS;
- switch (q_u->switch_level) {
+ if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) )
+ return NT_STATUS_NO_MEMORY;
+
+
+ switch (q_u->level ) {
case 1:
- r_u->ptr = 1;
- r_u->ctr.switch_value1 = 1;
- init_samr_alias_info1(&r_u->ctr.alias.info1,
- info.acct_name, 1, info.acct_desc);
+ r_u->ctr->level = 1;
+ init_samr_alias_info1(&r_u->ctr->alias.info1, info.acct_name, 1, info.acct_desc);
break;
case 3:
- r_u->ptr = 1;
- r_u->ctr.switch_value1 = 3;
- init_samr_alias_info3(&r_u->ctr.alias.info3, info.acct_desc);
+ r_u->ctr->level = 3;
+ init_samr_alias_info3(&r_u->ctr->alias.info3, info.acct_desc);
break;
default:
return NT_STATUS_INVALID_INFO_CLASS;
@@ -3984,11 +3985,13 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_
ctr=&q_u->ctr;
- switch (ctr->switch_value1) {
+ switch (ctr->level) {
case 3:
- unistr2_to_ascii(info.acct_desc,
- &(ctr->alias.info3.uni_acct_desc),
- sizeof(info.acct_desc)-1);
+ if ( ctr->alias.info3.description.string ) {
+ unistr2_to_ascii( info.acct_desc,
+ ctr->alias.info3.description.string,
+ sizeof(info.acct_desc)-1 );
+ }
break;
default:
return NT_STATUS_INVALID_INFO_CLASS;
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 6e884c24df..e982186835 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -1459,8 +1459,7 @@ rpc_alias_add_internals(const DOM_SID *domain_sid, const char *domain_name,
/* We've got a comment to set */
- alias_info.switch_value1 = 3;
- alias_info.switch_value2 = 3;
+ alias_info.level = 3;
init_samr_alias_info3(&alias_info.alias.info3, opt_comment);
result = cli_samr_set_aliasinfo(cli, mem_ctx, &alias_pol, &alias_info);
@@ -2026,7 +2025,7 @@ rpc_group_list_internals(const DOM_SID *domain_sid, const char *domain_name,
(NT_STATUS_IS_OK(cli_samr_close(cli, mem_ctx,
&alias_pol)))) {
description = unistr2_tdup(mem_ctx,
- &ctr.alias.info3.uni_acct_desc);
+ ctr.alias.info3.description.string);
}
}
@@ -2081,7 +2080,7 @@ rpc_group_list_internals(const DOM_SID *domain_sid, const char *domain_name,
(NT_STATUS_IS_OK(cli_samr_close(cli, mem_ctx,
&alias_pol)))) {
description = unistr2_tdup(mem_ctx,
- &ctr.alias.info3.uni_acct_desc);
+ ctr.alias.info3.description.string);
}
}