static WERROR reg_apply_registry(TALLOC_CTX *mem_ctx, const struct security_token *token, struct registry_key *root_key, uint32_t flags, struct gp_registry_entry *entries, size_t num_entries) { struct gp_registry_context *reg_ctx = NULL; WERROR werr; size_t i; if (num_entries == 0) { return WERR_OK; } #if 0 if (flags & GPO_LIST_FLAG_MACHINE) { werr = gp_init_reg_ctx(mem_ctx, KEY_HKLM, REG_KEY_WRITE, get_system_token(), ®_ctx); } else { werr = gp_init_reg_ctx(mem_ctx, KEY_HKCU, REG_KEY_WRITE, token, ®_ctx); } W_ERROR_NOT_OK_RETURN(werr); #endif for (i=0; i<num_entries; i++) { /* FIXME: maybe we should check here if we attempt to go beyond * the 4 allowed reg keys */ werr = reg_apply_registry_entry(mem_ctx, root_key, reg_ctx, &(entries)[i], token, flags); if (!W_ERROR_IS_OK(werr)) { DEBUG(0,("failed to apply registry: %s\n", win_errstr(werr))); goto done; } } done: gp_free_reg_ctx(reg_ctx); return werr; }
static WERROR scripts_apply(TALLOC_CTX *mem_ctx, const struct security_token *token, struct registry_key *root_key, uint32_t flags, const char *section, const struct GROUP_POLICY_OBJECT *gpo, struct gp_registry_entry *entries, size_t num_entries) { struct gp_registry_context *reg_ctx = NULL; WERROR werr; size_t i; const char *keystr = NULL; int count = 0; if (num_entries == 0) { return WERR_OK; } #if 0 if (flags & GPO_INFO_FLAG_MACHINE) { struct security_token *tmp_token; tmp_token = registry_create_system_token(mem_ctx); W_ERROR_HAVE_NO_MEMORY(tmp_token); werr = gp_init_reg_ctx(mem_ctx, KEY_HKLM, REG_KEY_WRITE, tmp_token, ®_ctx); } else { werr = gp_init_reg_ctx(mem_ctx, KEY_HKCU, REG_KEY_WRITE, token, ®_ctx); } W_ERROR_NOT_OK_RETURN(werr); #endif keystr = talloc_asprintf(mem_ctx, "%s\\%s\\%d", KEY_GP_SCRIPTS, section, count++); W_ERROR_HAVE_NO_MEMORY(keystr); reg_deletekey_recursive(root_key, keystr); werr = gp_store_reg_subkey(mem_ctx, keystr, root_key, &root_key); if (!W_ERROR_IS_OK(werr)) { goto done; } werr = scripts_store_reg_gpovals(mem_ctx, root_key, gpo); if (!W_ERROR_IS_OK(werr)) { goto done; } for (i=0; i<num_entries; i++) { werr = reg_apply_registry_entry(mem_ctx, root_key, reg_ctx, &(entries)[i], token, flags); if (!W_ERROR_IS_OK(werr)) { DEBUG(0,("failed to apply registry: %s\n", win_errstr(werr))); goto done; } } done: gp_free_reg_ctx(reg_ctx); return werr; }