diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-05-27 02:40:59 -0400 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-05-28 00:55:27 +0200 |
commit | 6713f3d945f09a732e620641771d9ff403aca9ef (patch) | |
tree | d67129b51b84685fe8af3088b6119187ccb8c79d /source3 | |
parent | 605cfef56c23f39eba88545c43284b061e9755bd (diff) | |
download | samba-6713f3d945f09a732e620641771d9ff403aca9ef.tar.gz |
s3:auth add function to copy a netr_SamInfo3 structure
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/auth/server_info.c | 61 | ||||
-rw-r--r-- | source3/include/proto.h | 2 |
2 files changed, 63 insertions, 0 deletions
diff --git a/source3/auth/server_info.c b/source3/auth/server_info.c index 16dbfb3e962..d7ab19c58b4 100644 --- a/source3/auth/server_info.c +++ b/source3/auth/server_info.c @@ -507,3 +507,64 @@ NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +#undef RET_NOMEM + +#define RET_NOMEM(ptr) do { \ + if (!ptr) { \ + TALLOC_FREE(info3); \ + return NULL; \ + } } while(0) + +struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx, + struct netr_SamInfo3 *orig) +{ + struct netr_SamInfo3 *info3; + + info3 = talloc(mem_ctx, struct netr_SamInfo3); + if (!info3) return NULL; + + /* first copy all, then realloc pointers */ + info3->base = orig->base; + + info3->base.account_name.string = + talloc_strdup(info3, orig->base.account_name.string); + RET_NOMEM(info3->base.account_name.string); + info3->base.full_name.string = + talloc_strdup(info3, orig->base.full_name.string); + RET_NOMEM(info3->base.full_name.string); + info3->base.logon_script.string = + talloc_strdup(info3, orig->base.logon_script.string); + RET_NOMEM(info3->base.logon_script.string); + info3->base.profile_path.string = + talloc_strdup(info3, orig->base.profile_path.string); + RET_NOMEM(info3->base.profile_path.string); + info3->base.home_directory.string = + talloc_strdup(info3, orig->base.home_directory.string); + RET_NOMEM(info3->base.home_directory.string); + info3->base.home_drive.string = + talloc_strdup(info3, orig->base.home_drive.string); + RET_NOMEM(info3->base.home_drive.string); + + info3->base.groups.rids = + talloc_memdup(info3, orig->base.groups.rids, + (sizeof(struct samr_RidWithAttribute) * + orig->base.groups.count)); + RET_NOMEM(info3->base.groups.rids); + + info3->base.logon_server.string = + talloc_strdup(info3, orig->base.logon_server.string); + RET_NOMEM(info3->base.logon_server.string); + info3->base.domain.string = + talloc_strdup(info3, orig->base.domain.string); + RET_NOMEM(info3->base.domain.string); + + info3->base.domain_sid = sid_dup_talloc(info3, orig->base.domain_sid); + RET_NOMEM(info3->base.domain_sid); + + info3->sids = talloc_memdup(info3, orig->sids, + (sizeof(struct netr_SidAttr) * + orig->sidcount)); + RET_NOMEM(info3->sids); + + return info3; +} diff --git a/source3/include/proto.h b/source3/include/proto.h index 9a19fbe9b5e..ff7eb9383e2 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -182,6 +182,8 @@ NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx, struct samu *samu, const char *login_server, struct netr_SamInfo3 **_info3); +struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx, + struct netr_SamInfo3 *orig); /* The following definitions come from auth/auth_wbc.c */ |