libgpo: remove unrequired references to ads_struct.
[samba.git] / libgpo / gpo_util.c
index cfb4512aefc2cf32146cd15242ea3590ca40d6ee..ea08f58f84bdb2e50f1c1020806efdaea880af39 100644 (file)
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
-#define TALLOC_DEPRECATED 1
+
 #include "includes.h"
 #include "system/filesys.h"
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "../librpc/gen_ndr/ndr_security.h"
 #include "../libgpo/gpo.h"
 #include "../libcli/security/security.h"
-#undef strdup
+#include "registry.h"
+#include "libgpo/gpo_proto.h"
 
 #if 0
 #define DEFAULT_DOMAIN_POLICY "Default Domain Policy"
@@ -442,8 +443,7 @@ static bool gpo_get_gp_ext_from_gpo(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
-ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
-                            TALLOC_CTX *mem_ctx,
+ADS_STATUS gpo_process_a_gpo(TALLOC_CTX *mem_ctx,
                             const struct security_token *token,
                             struct registry_key *root_key,
                             struct GROUP_POLICY_OBJECT *gpo,
@@ -484,7 +484,7 @@ ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
                        continue;
                }
 
-               ntstatus = gpext_process_extension(ads, mem_ctx,
+               ntstatus = gpext_process_extension(mem_ctx,
                                                   flags, token, root_key, gpo,
                                                   gp_ext->extensions_guid[i],
                                                   gp_ext->snapins_guid[i]);
@@ -499,8 +499,7 @@ ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
 /****************************************************************
 ****************************************************************/
 
-static ADS_STATUS gpo_process_gpo_list_by_ext(ADS_STRUCT *ads,
-                                             TALLOC_CTX *mem_ctx,
+static ADS_STATUS gpo_process_gpo_list_by_ext(TALLOC_CTX *mem_ctx,
                                              const struct security_token *token,
                                              struct registry_key *root_key,
                                              struct GROUP_POLICY_OBJECT *gpo_list,
@@ -521,7 +520,7 @@ static ADS_STATUS gpo_process_gpo_list_by_ext(ADS_STRUCT *ads,
                 * extension, otherwise we cannot store the e.g. the *list* of
                 * logon-scripts correctly (for more then one GPO) */
 
-               status = gpo_process_a_gpo(ads, mem_ctx, token, root_key,
+               status = gpo_process_a_gpo(mem_ctx, token, root_key,
                                           gpo, extensions_guid, flags);
 
                if (!ADS_ERR_OK(status)) {
@@ -537,8 +536,7 @@ static ADS_STATUS gpo_process_gpo_list_by_ext(ADS_STRUCT *ads,
 /****************************************************************
 ****************************************************************/
 
-ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
-                               TALLOC_CTX *mem_ctx,
+ADS_STATUS gpo_process_gpo_list(TALLOC_CTX *mem_ctx,
                                const struct security_token *token,
                                struct GROUP_POLICY_OBJECT *gpo_list,
                                const char *extensions_guid_filter,
@@ -549,9 +547,8 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
        struct gp_extension *gp_ext = NULL;
        struct registry_key *root_key = NULL;
        struct gp_registry_context *reg_ctx = NULL;
-#if 0
        WERROR werr;
-#endif
+
        status = ADS_ERROR_NT(init_gp_extensions(mem_ctx));
        if (!ADS_ERR_OK(status)) {
                return status;
@@ -561,8 +558,7 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
        if (!gp_ext_list) {
                return ADS_ERROR_NT(NT_STATUS_DLL_INIT_FAILED);
        }
-/* FIXME Needs to be replaced with new patchfile_preg calls */
-#if 0
+
        /* get the key here */
        if (flags & GPO_LIST_FLAG_MACHINE) {
                werr = gp_init_reg_ctx(mem_ctx, KEY_HKLM, REG_KEY_WRITE,
@@ -577,7 +573,6 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
                talloc_free(reg_ctx);
                return ADS_ERROR_NT(werror_to_ntstatus(werr));
        }
-#endif
 
        root_key = reg_ctx->curr_key;
 
@@ -601,7 +596,7 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
                        gp_ext->name, guid_str));
 
 
-               status = gpo_process_gpo_list_by_ext(ads, mem_ctx, token,
+               status = gpo_process_gpo_list_by_ext(mem_ctx, token,
                                                     root_key, gpo_list,
                                                     guid_str, flags);
                if (!ADS_ERR_OK(status)) {
@@ -626,7 +621,6 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
 NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
                           TALLOC_CTX *mem_ctx,
                            const char *cache_dir,
-                           struct loadparm_context *lp_ctx,
                           uint32_t flags,
                           struct GROUP_POLICY_OBJECT *gpo)
 {
@@ -666,7 +660,7 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
 
                DEBUG(1,("check_refresh_gpo: need to refresh GPO\n"));
 
-               result = gpo_fetch_files(mem_ctx, ads, lp_ctx, cache_dir, gpo);
+               result = gpo_fetch_files(mem_ctx, ads, cache_dir, gpo);
                if (!NT_STATUS_IS_OK(result)) {
                        goto out;
                }
@@ -713,7 +707,6 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
 NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
                                TALLOC_CTX *mem_ctx,
                                const char *cache_dir,
-                                struct loadparm_context *lp_ctx,
                                uint32_t flags,
                                struct GROUP_POLICY_OBJECT *gpo_list)
 {
@@ -726,7 +719,7 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
 
        for (gpo = gpo_list; gpo; gpo = gpo->next) {
 
-               result = check_refresh_gpo(ads, mem_ctx, cache_dir, lp_ctx, flags, gpo);
+               result = check_refresh_gpo(ads, mem_ctx, cache_dir, flags, gpo);
                if (!NT_STATUS_IS_OK(result)) {
                        goto out;
                }
@@ -764,24 +757,29 @@ char *gpo_flag_str(TALLOC_CTX *ctx, uint32_t flags)
                return NULL;
        }
 
+       str = talloc_strdup(ctx, "");
+       if (!str) {
+               return NULL;
+       }
+
        if (flags & GPO_INFO_FLAG_SLOWLINK)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_SLOWLINK ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_SLOWLINK ");
        if (flags & GPO_INFO_FLAG_VERBOSE)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_VERBOSE ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_VERBOSE ");
        if (flags & GPO_INFO_FLAG_SAFEMODE_BOOT)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_SAFEMODE_BOOT ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_SAFEMODE_BOOT ");
        if (flags & GPO_INFO_FLAG_NOCHANGES)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_NOCHANGES ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_NOCHANGES ");
        if (flags & GPO_INFO_FLAG_MACHINE)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_MACHINE ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_MACHINE ");
        if (flags & GPO_INFO_FLAG_LOGRSOP_TRANSITION)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_LOGRSOP_TRANSITION ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_LOGRSOP_TRANSITION ");
        if (flags & GPO_INFO_FLAG_LINKTRANSITION)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_LINKTRANSITION ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_LINKTRANSITION ");
        if (flags & GPO_INFO_FLAG_FORCED_REFRESH)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_FORCED_REFRESH ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_FORCED_REFRESH ");
        if (flags & GPO_INFO_FLAG_BACKGROUND)
-               str = talloc_append_string(ctx, str, "GPO_INFO_FLAG_BACKGROUND ");
+               str = talloc_strdup_append(str, "GPO_INFO_FLAG_BACKGROUND ");
 
        return str;
 }
@@ -834,7 +832,6 @@ NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx,
 
 ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads,
                                TALLOC_CTX *mem_ctx,
-                               struct loadparm_context *lp_ctx,
                                const char *dn,
                                struct security_token **token)
 {