diff options
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 16dbfb3e96..d7ab19c58b 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 9a19fbe9b5..ff7eb9383e 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 */ |