diff options
author | Günther Deschner <gd@samba.org> | 2013-12-19 13:27:45 +0100 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2014-01-07 16:59:38 +0100 |
commit | 288e883fb0612ffbbcf17c5bf8341872153a3092 (patch) | |
tree | 87cb9ac6b3cc8decbb958d72096658fd62587422 /libgpo | |
parent | 57498dc569eb07403134f88f2872102f15a297c2 (diff) | |
download | samba-288e883fb0612ffbbcf17c5bf8341872153a3092.tar.gz |
libgpo: add gpo_copy().
Guenther
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'libgpo')
-rw-r--r-- | libgpo/gpo.h | 3 | ||||
-rw-r--r-- | libgpo/gpo_util.c | 52 |
2 files changed, 55 insertions, 0 deletions
diff --git a/libgpo/gpo.h b/libgpo/gpo.h index 2e247e56524..f32b7399986 100644 --- a/libgpo/gpo.h +++ b/libgpo/gpo.h @@ -260,6 +260,9 @@ bool gpo_get_gp_ext_from_gpo(TALLOC_CTX *mem_ctx, uint32_t flags, const struct GROUP_POLICY_OBJECT *gpo, struct GP_EXT **gp_ext); +NTSTATUS gpo_copy(TALLOC_CTX *mem_ctx, + const struct GROUP_POLICY_OBJECT *gpo_src, + struct GROUP_POLICY_OBJECT **gpo_dst); #include "../libgpo/gpext/gpext.h" diff --git a/libgpo/gpo_util.c b/libgpo/gpo_util.c index 32d3aa2be37..88ebdc0d401 100644 --- a/libgpo/gpo_util.c +++ b/libgpo/gpo_util.c @@ -836,3 +836,55 @@ ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, return ADS_ERROR_NT(NT_STATUS_NOT_SUPPORTED); #endif } + +/**************************************************************** +****************************************************************/ + +NTSTATUS gpo_copy(TALLOC_CTX *mem_ctx, + const struct GROUP_POLICY_OBJECT *gpo_src, + struct GROUP_POLICY_OBJECT **gpo_dst) +{ + struct GROUP_POLICY_OBJECT *gpo; + + gpo = talloc_zero(mem_ctx, struct GROUP_POLICY_OBJECT); + NT_STATUS_HAVE_NO_MEMORY(gpo); + + gpo->options = gpo_src->options; + gpo->version = gpo_src->version; + + gpo->ds_path = talloc_strdup(gpo, gpo_src->ds_path); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->ds_path, gpo); + + gpo->file_sys_path = talloc_strdup(gpo, gpo_src->file_sys_path); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, gpo); + + gpo->display_name = talloc_strdup(gpo, gpo_src->display_name); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, gpo); + + gpo->name = talloc_strdup(gpo, gpo_src->name); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->name, gpo); + + gpo->link = talloc_strdup(gpo, gpo_src->link); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->link, gpo); + + gpo->link_type = gpo_src->link_type; + + if (gpo_src->user_extensions) { + gpo->user_extensions = talloc_strdup(gpo, gpo_src->user_extensions); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->user_extensions, gpo); + } + + if (gpo_src->machine_extensions) { + gpo->machine_extensions = talloc_strdup(gpo, gpo_src->machine_extensions); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->machine_extensions, gpo); + } + + gpo->security_descriptor = dup_sec_desc(gpo, gpo_src->security_descriptor); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->security_descriptor, gpo); + + gpo->next = gpo->prev = NULL; + + *gpo_dst = gpo; + + return NT_STATUS_OK; +} |