libgpo: add gpo_copy().
authorGünther Deschner <gd@samba.org>
Thu, 19 Dec 2013 12:27:45 +0000 (13:27 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 7 Jan 2014 15:59:38 +0000 (16:59 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
libgpo/gpo.h
libgpo/gpo_util.c

index 2e247e5652431871e47881738acc6749b998f6ed..f32b7399986c4f3434b9d91f97f3bee357361602 100644 (file)
@@ -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"
 
index 32d3aa2be3721f4a8392b5ebb627c79274e8cc48..88ebdc0d40187ef3b969a3b873f1523ae8cda844 100644 (file)
@@ -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;
+}