summaryrefslogtreecommitdiff
path: root/source3/rpc_server/samr
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-09-26 11:30:05 -0400
committerAndreas Schneider <asn@cryptomilk.org>2011-09-26 18:25:26 +0200
commitf7419172f03089276cab71c41419a5c57508d42e (patch)
tree1fb9960270a0395fe6e3220d3caeeaad2e0d0cb6 /source3/rpc_server/samr
parent0ff0b37f43d6a3ad52b1c954bc8f921222424c0d (diff)
downloadsamba-f7419172f03089276cab71c41419a5c57508d42e.tar.gz
samba-f7419172f03089276cab71c41419a5c57508d42e.tar.bz2
samba-f7419172f03089276cab71c41419a5c57508d42e.zip
s3-passdb: Cleanup use of fstring and move to talloc.
Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/rpc_server/samr')
-rw-r--r--source3/rpc_server/samr/srv_samr_nt.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c
index 016d426bfe..9cd08873dd 100644
--- a/source3/rpc_server/samr/srv_samr_nt.c
+++ b/source3/rpc_server/samr/srv_samr_nt.c
@@ -1564,7 +1564,7 @@ NTSTATUS _samr_QueryAliasInfo(struct pipes_struct *p,
struct samr_QueryAliasInfo *r)
{
struct samr_alias_info *ainfo;
- struct acct_info info;
+ struct acct_info *info;
NTSTATUS status;
union samr_AliasInfo *alias_info = NULL;
const char *alias_name = NULL;
@@ -1584,16 +1584,23 @@ NTSTATUS _samr_QueryAliasInfo(struct pipes_struct *p,
return NT_STATUS_NO_MEMORY;
}
+ info = talloc_zero(p->mem_ctx, struct acct_info);
+ if (!info) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
become_root();
- status = pdb_get_aliasinfo(&ainfo->sid, &info);
+ status = pdb_get_aliasinfo(&ainfo->sid, info);
unbecome_root();
- if ( !NT_STATUS_IS_OK(status))
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(info);
return status;
+ }
- /* FIXME: info contains fstrings */
- alias_name = talloc_strdup(r, info.acct_name);
- alias_description = talloc_strdup(r, info.acct_desc);
+ alias_name = talloc_steal(r, info->acct_name);
+ alias_description = talloc_steal(r, info->acct_desc);
+ TALLOC_FREE(info);
switch (r->in.level) {
case ALIASINFOALL:
@@ -6112,7 +6119,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
struct samr_SetAliasInfo *r)
{
struct samr_alias_info *ainfo;
- struct acct_info info;
+ struct acct_info *info;
NTSTATUS status;
ainfo = policy_handle_find(p, r->in.alias_handle,
@@ -6122,10 +6129,15 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
return status;
}
+ info = talloc_zero(p->mem_ctx, struct acct_info);
+ if (!info) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
/* get the current group information */
become_root();
- status = pdb_get_aliasinfo( &ainfo->sid, &info );
+ status = pdb_get_aliasinfo(&ainfo->sid, info);
unbecome_root();
if ( !NT_STATUS_IS_OK(status))
@@ -6153,26 +6165,36 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
/* If the name is the same just reply "ok". Yes this
doesn't allow you to change the case of a group name. */
- if ( strequal( r->in.info->name.string, info.acct_name ) )
+ if (strequal(r->in.info->name.string, info->acct_name)) {
return NT_STATUS_OK;
+ }
- fstrcpy( info.acct_name, r->in.info->name.string);
+ talloc_free(info->acct_name);
+ info->acct_name = talloc_strdup(info, r->in.info->name.string);
+ if (!info->acct_name) {
+ return NT_STATUS_NO_MEMORY;
+ }
/* make sure the name doesn't already exist as a user
or local group */
- fstr_sprintf( group_name, "%s\\%s", lp_netbios_name(), info.acct_name );
+ fstr_sprintf(group_name, "%s\\%s",
+ lp_netbios_name(), info->acct_name);
status = can_create( p->mem_ctx, group_name );
if ( !NT_STATUS_IS_OK( status ) )
return status;
break;
}
case ALIASINFODESCRIPTION:
+ TALLOC_FREE(info->acct_desc);
if (r->in.info->description.string) {
- fstrcpy(info.acct_desc,
- r->in.info->description.string);
+ info->acct_desc = talloc_strdup(info,
+ r->in.info->description.string);
} else {
- fstrcpy( info.acct_desc, "" );
+ info->acct_desc = talloc_strdup(info, "");
+ }
+ if (!info->acct_desc) {
+ return NT_STATUS_NO_MEMORY;
}
break;
default:
@@ -6182,7 +6204,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
/******** BEGIN SeAddUsers BLOCK *********/
become_root();
- status = pdb_set_aliasinfo( &ainfo->sid, &info );
+ status = pdb_set_aliasinfo(&ainfo->sid, info);
unbecome_root();
/******** End SeAddUsers BLOCK *********/