r10026: Move registry header file to lib/registry
authorJelmer Vernooij <jelmer@samba.org>
Sun, 4 Sep 2005 14:47:19 +0000 (14:47 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:36:30 +0000 (13:36 -0500)
Add support for showing security descriptor in regshell
Add support for saving files in NT4 registry backend
(This used to be commit 47cecd4726e6568f1aafb404646d2664f630a9bb)

source4/gtk/tools/gregedit.c
source4/lib/registry/common/reg_interface.c
source4/lib/registry/common/reg_util.c
source4/lib/registry/reg_backend_nt4.c
source4/lib/registry/registry.h [moved from source4/include/registry.h with 98% similarity]
source4/lib/registry/tools/regdiff.c
source4/lib/registry/tools/regpatch.c
source4/lib/registry/tools/regshell.c
source4/lib/registry/tools/regtree.c
source4/rpc_server/winreg/rpc_winreg.c

index 26aedf2084e16dd76e7b064d6990aaf575041d4f..c574b5246b78839f3df3f35fcf2f8cb7ea2d7a2f 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "dynconfig.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "gtk/common/select.h"
 #include "gtk/common/gtk-smb.h"
index ddd4ecbe9316abe0044e4811faededf8a757aa40..74f158b02788cdca1163698d670de5c59ff70acb 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "includes.h"
 #include "dlinklist.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 
 /* List of available backends */
 static struct reg_init_function_entry *backends = NULL;
index a0d4db6f57740f7f6c53929b1707cf7a510af676..ae30839cca29b6132b618ada9ab6b92129909b95 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "librpc/gen_ndr/winreg.h"
 
 static const struct {
index cf67abb3225ae0bd17d93b492880717102109aac..4fc458dee4ba6b420679025bea635b89dd2c616a 100644 (file)
@@ -376,7 +376,11 @@ static struct registry_key *regf_get_key (TALLOC_CTX *ctx, struct regf_data *reg
 
        ret->name = talloc_steal(ret, nk->key_name);
        ret->last_mod = nk->last_change;
-       ret->class_name = NULL; /* FIXME: get somehow using clsname_offset */
+
+       if (nk->clsname_offset != -1) {
+               DATA_BLOB data = hbin_get(regf, nk->clsname_offset);
+               ret->class_name = talloc_strndup(ret, (char*)data.data, nk->clsname_length);
+       }
        ret->backend_data = nk;
 
        return ret;
@@ -581,6 +585,30 @@ static WERROR regf_add_key (TALLOC_CTX *ctx, struct registry_key *parent, const
        return WERR_OK;
 }
 
+static WERROR regf_set_value (struct registry_key *key, const char *name, uint32_t type, DATA_BLOB data)
+{
+       /* FIXME */
+
+       return WERR_NOT_SUPPORTED;
+}
+
+static WERROR regf_save(struct registry_hive *hive, const char *location)
+{
+       struct regf_data *regf = hive->backend_data;
+       struct tdr_push *push = talloc_zero(regf, struct tdr_push);
+       int i;
+
+       tdr_push_regf_hdr(push, regf->header);
+
+       for (i = 0; regf->hbins[i]; i++) {
+               tdr_push_hbin_block(push, regf->hbins[i]);
+       }
+
+       file_save(location, push->data.data, push->data.length);
+
+       return WERR_OK;
+}
+
 static WERROR nt_open_hive (struct registry_hive *h, struct registry_key **key)
 {
        struct regf_data *regf;
@@ -676,6 +704,8 @@ static struct hive_operations reg_backend_nt4 = {
        .get_value_by_index = regf_get_value,
        .key_get_sec_desc = regf_get_sec_desc,
        .add_key = regf_add_key,
+       .set_value = regf_set_value,
+       .save_hive = regf_save,
 };
 
 NTSTATUS registry_nt4_init(void)
similarity index 98%
rename from source4/include/registry.h
rename to source4/lib/registry/registry.h
index 06442514f0cfcf2dc1318fdcd4c87264756f9ebe..f9e8a7698c2f8a621ab2f142741d54b61880a3f0 100644 (file)
@@ -80,6 +80,7 @@ struct hive_operations {
 
        /* Implement this one */
        WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
+       WERROR (*save_hive) (struct registry_hive *, const char *location);
 
        /* Or this one */
        WERROR (*open_key) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
index 307ec3793e3ecaf20f3db82276fe3453d2b683ab..3d8201330eaab40b22b9995e2565b447340d3da3 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "dynconfig.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 
 static void writediff(struct registry_key *oldkey, struct registry_key *newkey, FILE *out)
index 5f7d4376d40707c2787fac38b20f330d2c17d075..887f53df37db77e1f8286ece7388a68ece700c44 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "includes.h"
 #include "dynconfig.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "system/filesys.h"
 #include "librpc/gen_ndr/winreg.h"
index 496b9dc7e5fcfefcc430ed8590a7c29c07ebbfcd..08da5ae2fd9978a351654e8e51b0dca933836d9d 100644 (file)
 
 #include "includes.h"
 #include "dynconfig.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "system/time.h"
+#include "librpc/gen_ndr/ndr_security.h"
 
 /* 
  * ck/cd - change key
  * mkkey/mkdir - make key
  * ch - change hive
  * info - show key info
+ * save - save hive
  * help
  * exit
  */
 
 static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv)
 {
+       struct security_descriptor *sec_desc = NULL;
        time_t last_mod;
+       WERROR error;
+       
        printf("Name: %s\n", cur->name);
        printf("Full path: %s\n", cur->path);
        printf("Key Class: %s\n", cur->class_name);
        last_mod = nt_time_to_unix(cur->last_mod);
        printf("Time Last Modified: %s\n", ctime(&last_mod));
-       /* FIXME: Security info */
+
+       error = reg_get_sec_desc(mem_ctx, cur, &sec_desc);
+       if (!W_ERROR_IS_OK(error)) {
+               printf("Error getting security descriptor\n");
+       } else {
+               ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "Security", sec_desc);
+       }
+       talloc_free(sec_desc);
        return cur;
 }
 
index 38dffed85dfb60601c40dc9c8d353f9e322ece61..c24e66412f4ddb9c7b22970b99a51e310d54d16a 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "dynconfig.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 
 static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
index ba11b071481a3a27f0cb2a4107ad5b681e39adb1..df92dfcff8ca87253687768a747256c02c24e128 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "includes.h"
 #include "rpc_server/dcerpc_server.h"
-#include "registry.h"
+#include "lib/registry/registry.h"
 #include "librpc/gen_ndr/ndr_winreg.h"
 #include "rpc_server/common/common.h"