libgpo: remove ads reference from dump calls and make them take const structs.
authorGünther Deschner <gd@samba.org>
Wed, 18 Dec 2013 14:45:58 +0000 (15:45 +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_ldap.c
libgpo/gpo_util.c
source3/utils/net_ads_gpo.c

index 40ecd34b6e95f03f4f5417684b30d8f55de6ac20..91ce006cd0972f1d4e2029a5cb526fb9f0410ad7 100644 (file)
@@ -228,15 +228,11 @@ const char *cse_gpo_guid_string_to_name(const char *guid);
 const char *cse_gpo_name_to_guid_string(const char *name);
 const char *cse_snapin_gpo_guid_string_to_name(const char *guid);
 void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel);
-void dump_gpo(ADS_STRUCT *ads,
-             TALLOC_CTX *mem_ctx,
-             struct GROUP_POLICY_OBJECT *gpo,
+void dump_gpo(const struct GROUP_POLICY_OBJECT *gpo,
              int debuglevel);
-void dump_gpo_list(ADS_STRUCT *ads,
-                  TALLOC_CTX *mem_ctx,
-                  struct GROUP_POLICY_OBJECT *gpo_list,
+void dump_gpo_list(const struct GROUP_POLICY_OBJECT *gpo_list,
                   int debuglevel);
-void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link);
+void dump_gplink(const struct GP_LINK *gp_link);
 NTSTATUS gpo_process_a_gpo(TALLOC_CTX *mem_ctx,
                           const struct security_token *token,
                           struct registry_key *root_key,
index d46c48f8f3e52e7121a5ecd49ea4808eb7d8d142..f797c2f8ad535e6160fd857eaf4f87f22669f602 100644 (file)
@@ -756,7 +756,7 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
                if (ADS_ERR_OK(status)) {
 
                        if (DEBUGLEVEL >= 100) {
-                               dump_gplink(ads, mem_ctx, &gp_link);
+                               dump_gplink(&gp_link);
                        }
 
                        status = add_gplink_to_gpo_list(ads, mem_ctx, gpo_list,
@@ -794,7 +794,7 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
                        if (ADS_ERR_OK(status)) {
 
                                if (DEBUGLEVEL >= 100) {
-                                       dump_gplink(ads, mem_ctx, &gp_link);
+                                       dump_gplink(&gp_link);
                                }
 
                                /* block inheritance from now on */
@@ -840,7 +840,7 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
                        if (ADS_ERR_OK(status)) {
 
                                if (DEBUGLEVEL >= 100) {
-                                       dump_gplink(ads, mem_ctx, &gp_link);
+                                       dump_gplink(&gp_link);
                                }
 
                                /* block inheritance from now on */
index 8689f2c4cd760145db6401b38aa966e5ca1841f6..9cba41099bbad9f6c946e6691cbb9f1d894199c6 100644 (file)
@@ -228,15 +228,14 @@ void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel)
 /****************************************************************
 ****************************************************************/
 
-void dump_gpo(ADS_STRUCT *ads,
-             TALLOC_CTX *mem_ctx,
-             struct GROUP_POLICY_OBJECT *gpo,
+void dump_gpo(const struct GROUP_POLICY_OBJECT *gpo,
              int debuglevel)
 {
        int lvl = debuglevel;
+       TALLOC_CTX *frame = talloc_stackframe();
 
        if (gpo == NULL) {
-               return;
+               goto out;
        }
 
        DEBUG(lvl,("---------------------\n\n"));
@@ -300,9 +299,9 @@ void dump_gpo(ADS_STRUCT *ads,
 
                struct GP_EXT *gp_ext = NULL;
 
-               if (!ads_parse_gp_ext(mem_ctx, gpo->machine_extensions,
+               if (!ads_parse_gp_ext(frame, gpo->machine_extensions,
                                      &gp_ext)) {
-                       return;
+                       goto out;
                }
                dump_gp_ext(gp_ext, lvl);
        }
@@ -313,9 +312,9 @@ void dump_gpo(ADS_STRUCT *ads,
 
                struct GP_EXT *gp_ext = NULL;
 
-               if (!ads_parse_gp_ext(mem_ctx, gpo->user_extensions,
+               if (!ads_parse_gp_ext(frame, gpo->user_extensions,
                                      &gp_ext)) {
-                       return;
+                       goto out;
                }
                dump_gp_ext(gp_ext, lvl);
        }
@@ -324,29 +323,28 @@ void dump_gpo(ADS_STRUCT *ads,
 
                NDR_PRINT_DEBUG(security_descriptor, gpo->security_descriptor);
        }
+ out:
+       talloc_free(frame);
 }
 
 /****************************************************************
 ****************************************************************/
 
-void dump_gpo_list(ADS_STRUCT *ads,
-                  TALLOC_CTX *mem_ctx,
-                  struct GROUP_POLICY_OBJECT *gpo_list,
+void dump_gpo_list(const struct GROUP_POLICY_OBJECT *gpo_list,
                   int debuglevel)
 {
-       struct GROUP_POLICY_OBJECT *gpo = NULL;
+       const struct GROUP_POLICY_OBJECT *gpo = NULL;
 
        for (gpo = gpo_list; gpo; gpo = gpo->next) {
-               dump_gpo(ads, mem_ctx, gpo, debuglevel);
+               dump_gpo(gpo, debuglevel);
        }
 }
 
 /****************************************************************
 ****************************************************************/
 
-void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link)
+void dump_gplink(const struct GP_LINK *gp_link)
 {
-       ADS_STATUS status;
        int i;
        int lvl = 10;
 
@@ -386,22 +384,6 @@ void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link)
                        DEBUGADD(lvl,("GPO_LINK_OPT_DISABLED"));
                }
                DEBUGADD(lvl,("\n"));
-
-               if (ads != NULL && mem_ctx != NULL) {
-
-                       struct GROUP_POLICY_OBJECT gpo;
-
-                       status = ads_get_gpo(ads, mem_ctx,
-                                            gp_link->link_names[i],
-                                            NULL, NULL, &gpo);
-                       if (!ADS_ERR_OK(status)) {
-                               DEBUG(lvl,("get gpo for %s failed: %s\n",
-                                       gp_link->link_names[i],
-                                       ads_errstr(status)));
-                               return;
-                       }
-                       dump_gpo(ads, mem_ctx, &gpo, lvl);
-               }
        }
 }
 
index 0a698da0d041f15a9f3a0b37eb5b48bb38f35cff..b9b0a1422967d0cc6117a87bb722f424dadc0ad7 100644 (file)
@@ -127,7 +127,7 @@ static int net_ads_gpo_refresh(struct net_context *c, int argc, const char **arg
 
                for (gpo = gpo_list; gpo; gpo = gpo->next) {
 
-                       dump_gpo(ads, mem_ctx, gpo, 0);
+                       dump_gpo(gpo, 0);
 #if 0
                char *server, *share, *nt_path, *unix_path;
 
@@ -172,7 +172,7 @@ static int net_ads_gpo_refresh(struct net_context *c, int argc, const char **arg
 
                for (gpo = read_list; gpo; gpo = gpo->next) {
 
-                       dump_gpo(ads, mem_ctx, gpo, 0);
+                       dump_gpo(gpo, 0);
 
 #if 0
                char *server, *share, *nt_path, *unix_path;
@@ -278,7 +278,7 @@ static int net_ads_gpo_list_all(struct net_context *c, int argc, const char **ar
                        goto out;
                }
 
-               dump_gpo(ads, mem_ctx, &gpo, 0);
+               dump_gpo(&gpo, 0);
        }
 
 out:
@@ -350,7 +350,7 @@ static int net_ads_gpo_list(struct net_context *c, int argc, const char **argv)
                goto out;
        }
 
-       dump_gpo_list(ads, mem_ctx, gpo_list, 0);
+       dump_gpo_list(gpo_list, 0);
 
 out:
        ads_msgfree(ads, res);
@@ -480,7 +480,7 @@ static int net_ads_gpo_link_get(struct net_context *c, int argc, const char **ar
                goto out;
        }
 
-       dump_gplink(ads, mem_ctx, &gp_link);
+       dump_gplink(&gp_link);
 
 out:
        talloc_destroy(mem_ctx);
@@ -615,7 +615,7 @@ static int net_ads_gpo_get_gpo(struct net_context *c, int argc, const char **arg
                goto out;
        }
 
-       dump_gpo(ads, mem_ctx, &gpo, 1);
+       dump_gpo(&gpo, 1);
 
 out:
        talloc_destroy(mem_ctx);