heimdal: Fix a warning
[kai/samba-autobuild/.git] / libgpo / gpo_util.c
index b654d4ad58400d3d81760a69e42f922d59d217db..e90b9a3f244e7317335785e2ea890e12631283e0 100644 (file)
@@ -25,6 +25,7 @@
 #include "../libcli/security/security.h"
 #include "registry.h"
 #include "libgpo/gpo_proto.h"
+#include "libgpo/gpext/gpext.h"
 
 #if 0
 #define DEFAULT_DOMAIN_POLICY "Default Domain Policy"
@@ -427,7 +428,8 @@ bool gpo_get_gp_ext_from_gpo(TALLOC_CTX *mem_ctx,
 
 NTSTATUS gpo_process_gpo_list(TALLOC_CTX *mem_ctx,
                              const struct security_token *token,
-                             struct GROUP_POLICY_OBJECT *gpo_list,
+                             const struct GROUP_POLICY_OBJECT *deleted_gpo_list,
+                             const struct GROUP_POLICY_OBJECT *changed_gpo_list,
                              const char *extensions_guid_filter,
                              uint32_t flags)
 {
@@ -455,8 +457,8 @@ NTSTATUS gpo_process_gpo_list(TALLOC_CTX *mem_ctx,
 
        status = gpext_process_extension(mem_ctx,
                                         flags, token, root_key,
-                                        NULL,
-                                        gpo_list,
+                                        deleted_gpo_list,
+                                        changed_gpo_list,
                                         extensions_guid_filter);
        talloc_free(reg_ctx);
        talloc_free(root_key);
@@ -475,7 +477,7 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
                           TALLOC_CTX *mem_ctx,
                            const char *cache_dir,
                           uint32_t flags,
-                          struct GROUP_POLICY_OBJECT *gpo)
+                          const struct GROUP_POLICY_OBJECT *gpo)
 {
        NTSTATUS result;
        char *server = NULL;
@@ -561,10 +563,10 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
                                TALLOC_CTX *mem_ctx,
                                const char *cache_dir,
                                uint32_t flags,
-                               struct GROUP_POLICY_OBJECT *gpo_list)
+                               const struct GROUP_POLICY_OBJECT *gpo_list)
 {
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-       struct GROUP_POLICY_OBJECT *gpo;
+       const struct GROUP_POLICY_OBJECT *gpo;
 
        if (!gpo_list) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -591,7 +593,7 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
 
 NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx,
                            const char *cache_dir,
-                          struct GROUP_POLICY_OBJECT *gpo,
+                          const struct GROUP_POLICY_OBJECT *gpo,
                           char **unix_path)
 {
        char *server, *share, *nt_path;
@@ -724,34 +726,64 @@ NTSTATUS gpo_copy(TALLOC_CTX *mem_ctx,
        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);
+       if (gpo->ds_path == NULL) {
+               TALLOC_FREE(gpo);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        gpo->file_sys_path      = talloc_strdup(gpo, gpo_src->file_sys_path);
-       NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, gpo);
+       if (gpo->file_sys_path == NULL) {
+               TALLOC_FREE(gpo);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        gpo->display_name       = talloc_strdup(gpo, gpo_src->display_name);
-       NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, gpo);
+       if (gpo->display_name == NULL) {
+               TALLOC_FREE(gpo);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        gpo->name               = talloc_strdup(gpo, gpo_src->name);
-       NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->name, gpo);
+       if (gpo->name == NULL) {
+               TALLOC_FREE(gpo);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        gpo->link               = talloc_strdup(gpo, gpo_src->link);
-       NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->link, gpo);
+       if (gpo->link == NULL) {
+               TALLOC_FREE(gpo);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        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->user_extensions == NULL) {
+                       TALLOC_FREE(gpo);
+                       return NT_STATUS_NO_MEMORY;
+               }
        }
 
        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);
+               if (gpo->machine_extensions == NULL) {
+                       TALLOC_FREE(gpo);
+                       return NT_STATUS_NO_MEMORY;
+               }
        }
 
-       gpo->security_descriptor = dup_sec_desc(gpo, gpo_src->security_descriptor);
-       NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->security_descriptor, gpo);
+       if (gpo_src->security_descriptor == NULL) {
+               /* existing SD assumed */
+               TALLOC_FREE(gpo);
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+       gpo->security_descriptor = security_descriptor_copy(gpo,
+                                               gpo_src->security_descriptor);
+       if (gpo->security_descriptor == NULL) {
+               TALLOC_FREE(gpo);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        gpo->next = gpo->prev = NULL;