s3-libgpo: move group policy protos to where they belong.
[sfrench/samba-autobuild/.git] / source3 / libgpo / gpext / registry.c
index 6cad8c796cd32aaa91183fdf80389c842fd87272..d7018556d85f1cd2ed7f983d08ca9392e4e27d57 100644 (file)
@@ -18,6 +18,9 @@
  */
 
 #include "includes.h"
  */
 
 #include "includes.h"
+#include "../libgpo/gpo_ini.h"
+#include "../libgpo/gpo.h"
+#include "libgpo/gpo_proto.h"
 
 #define GP_EXT_NAME "registry"
 
 
 #define GP_EXT_NAME "registry"
 
@@ -258,6 +261,7 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
        char *key = NULL;
        char *value = NULL;
        enum gp_reg_action action = GP_REG_ACTION_NONE;
        char *key = NULL;
        char *value = NULL;
        enum gp_reg_action action = GP_REG_ACTION_NONE;
+       size_t converted_size;
 
        ZERO_STRUCTP(*reg_entry);
 
 
        ZERO_STRUCTP(*reg_entry);
 
@@ -268,12 +272,16 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
        if (strlen_w((const smb_ucs2_t *)file_entry->key.buffer) <= 0)
                return false;
 
        if (strlen_w((const smb_ucs2_t *)file_entry->key.buffer) <= 0)
                return false;
 
-       if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer))
+       if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer,
+                             &converted_size))
+       {
                return false;
                return false;
+       }
 
 
-       if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0) {
-               if (!pull_ucs2_talloc(mem_ctx, &value,
-                                     file_entry->value.buffer))
+       if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0 &&
+           !pull_ucs2_talloc(mem_ctx, &value, file_entry->value.buffer,
+                             &converted_size))
+       {
                        return false;
        }
 
                        return false;
        }
 
@@ -294,9 +302,13 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
                case REG_NONE:
                        break;
                case REG_SZ:
                case REG_NONE:
                        break;
                case REG_SZ:
-                       data->v.sz.len = pull_ucs2_talloc(mem_ctx,
-                                       &data->v.sz.str,
-                                       (const smb_ucs2_t *)file_entry->data);
+                       if (!pull_ucs2_talloc(mem_ctx, &data->v.sz.str,
+                                             (const smb_ucs2_t *)
+                                             file_entry->data,
+                                             &data->v.sz.len)) {
+                               data->v.sz.len = -1;
+                       }
+
                        break;
                case REG_DWORD_BIG_ENDIAN:
                case REG_EXPAND_SZ:
                        break;
                case REG_DWORD_BIG_ENDIAN:
                case REG_EXPAND_SZ:
@@ -401,7 +413,7 @@ static NTSTATUS reg_parse_registry(TALLOC_CTX *mem_ctx,
                return status;
        }
 
                return status;
        }
 
-       buf = (uint16 *)file_load(real_filename, &n, 0);
+       buf = (uint16 *)file_load(real_filename, &n, 0, NULL);
        if (!buf) {
                TALLOC_FREE(reg_file);
                return NT_STATUS_CANNOT_LOAD_REGISTRY_FILE;
        if (!buf) {
                TALLOC_FREE(reg_file);
                return NT_STATUS_CANNOT_LOAD_REGISTRY_FILE;
@@ -446,7 +458,7 @@ static NTSTATUS reg_parse_registry(TALLOC_CTX *mem_ctx,
        status = NT_STATUS_OK;
 
  out:
        status = NT_STATUS_OK;
 
  out:
-       SAFE_FREE(buf);
+       TALLOC_FREE(buf);
        prs_mem_free(&ps);
 
        return status;
        prs_mem_free(&ps);
 
        return status;
@@ -493,7 +505,7 @@ static WERROR reg_apply_registry(TALLOC_CTX *mem_ctx,
                                                token, flags);
                if (!W_ERROR_IS_OK(werr)) {
                        DEBUG(0,("failed to apply registry: %s\n",
                                                token, flags);
                if (!W_ERROR_IS_OK(werr)) {
                        DEBUG(0,("failed to apply registry: %s\n",
-                               dos_errstr(werr)));
+                               win_errstr(werr)));
                        goto done;
                }
        }
                        goto done;
                }
        }
@@ -525,7 +537,7 @@ static NTSTATUS registry_process_group_policy(ADS_STRUCT *ads,
        debug_gpext_header(0, "registry_process_group_policy", flags, gpo,
                           extension_guid, snapin_guid);
 
        debug_gpext_header(0, "registry_process_group_policy", flags, gpo,
                           extension_guid, snapin_guid);
 
-       status = gpo_get_unix_path(mem_ctx, gpo, &unix_path);
+       status = gpo_get_unix_path(mem_ctx, cache_path(GPO_CACHE_DIR), gpo, &unix_path);
        NT_STATUS_NOT_OK_RETURN(status);
 
        status = reg_parse_registry(mem_ctx,
        NT_STATUS_NOT_OK_RETURN(status);
 
        status = reg_parse_registry(mem_ctx,
@@ -545,7 +557,7 @@ static NTSTATUS registry_process_group_policy(ADS_STRUCT *ads,
                                  entries, num_entries);
        if (!W_ERROR_IS_OK(werr)) {
                DEBUG(0,("failed to apply registry: %s\n",
                                  entries, num_entries);
        if (!W_ERROR_IS_OK(werr)) {
                DEBUG(0,("failed to apply registry: %s\n",
-                       dos_errstr(werr)));
+                       win_errstr(werr)));
                return werror_to_ntstatus(werr);
        }
 
                return werror_to_ntstatus(werr);
        }