r4166: More small API fixes, keep registry structs as small as possible.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 13 Dec 2004 00:45:29 +0000 (00:45 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:21 +0000 (13:07 -0500)
Implement DelValue in the RPC server
(This used to be commit f6b9ec89af934e837069fb26c0e3491fc78ebc12)

source4/include/registry.h
source4/lib/registry/common/reg_interface.c
source4/lib/registry/reg_backend_dir.c
source4/lib/registry/reg_backend_ldb.c
source4/lib/registry/reg_backend_rpc.c
source4/lib/registry/reg_backend_w95.c
source4/lib/registry/tools/regpatch.c
source4/lib/registry/tools/regshell.c
source4/rpc_server/winreg/rpc_winreg.c

index 345d6fac4381428c7d8e40fd6a053716b818b36f..5865636836d6a15f556906020ef04330a58b3a41 100644 (file)
@@ -75,10 +75,8 @@ struct registry_key {
   const char *path;              /* Full path to the key */
   char *class_name; /* Name of key class */
   NTTIME last_mod; /* Time last modified                 */
-  SEC_DESC *security;
   struct registry_hive *hive;
   void *backend_data;
-  int ref;
 };
 
 struct registry_value {
@@ -86,10 +84,6 @@ struct registry_value {
   unsigned int data_type;
   int data_len;
   void *data_blk;    /* Might want a separate block */
-  struct registry_hive *hive;
-  struct registry_key *parent;
-  void *backend_data;
-  int ref;
 };
 
 /* FIXME */
@@ -142,7 +136,7 @@ struct hive_operations {
 
        /* Value management */
        WERROR (*set_value)(struct registry_key *, const char *name, int type, void *data, int len); 
-       WERROR (*del_value)(struct registry_value *);
+       WERROR (*del_value)(struct registry_key *, const char *valname);
 };
 
 struct registry_hive {
index ee140e150fb030fc6f39c1187dd5061501f7059f..79bb0b765cbf6cfced5a55ee4648d3a41f2fff5e 100644 (file)
@@ -281,8 +281,6 @@ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx, struct registry_key *key,
                return WERR_NOT_SUPPORTED;
        }
        
-       (*val)->parent = key;
-       (*val)->hive = key->hive;
        return WERR_OK;
 }
 
@@ -408,9 +406,6 @@ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx, struct registry_key *key,
        if(!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
                return error;
        
-       (*val)->parent = key;
-       (*val)->hive = key->hive;
-       
        return WERR_OK;
 }
 
@@ -447,7 +442,7 @@ WERROR reg_key_del_recursive(struct registry_key *key)
                }
 
                if(W_ERROR_IS_OK(error)) {
-                       error = reg_del_value(val);
+                       error = reg_del_value(key, val->name);
                        if(!W_ERROR_IS_OK(error)) {
                                talloc_destroy(mem_ctx);
                                return error;
@@ -564,13 +559,13 @@ WERROR reg_val_set(struct registry_key *key, const char *value, int type, void *
 
 
 
-WERROR reg_del_value(struct registry_value *val)
+WERROR reg_del_value(struct registry_key *key, const char *valname)
 {
        WERROR ret = WERR_OK;
-       if(!val->hive->functions->del_value)
+       if(!key->hive->functions->del_value)
                return WERR_NOT_SUPPORTED;
 
-       ret = val->hive->functions->del_value(val);
+       ret = key->hive->functions->del_value(key, valname);
 
        if(!W_ERROR_IS_OK(ret)) return ret;
 
index c004be5a064ebbcbae1fd8e093898de8a3b84c41..89f92805854210f91a5560b1e0bcf2ac82101196 100644 (file)
@@ -120,27 +120,13 @@ static WERROR reg_dir_open(struct registry_hive *h, struct registry_key **key)
        return WERR_OK;
 }
 
-static WERROR reg_dir_set_value(struct registry_key *p, const char *name, int type, void *data, int len)
-{
-       /* FIXME */
-       return WERR_NOT_SUPPORTED;
-}
-
-static WERROR reg_dir_del_value(struct registry_value *v)
-{
-       /* FIXME*/
-       return WERR_NOT_SUPPORTED;
-}
-
 static struct hive_operations reg_backend_dir = {
        .name = "dir",
        .open_hive = reg_dir_open,
        .open_key = reg_dir_open_key,
        .add_key = reg_dir_add_key,
        .del_key = reg_dir_del_key,
-       .get_subkey_by_index = reg_dir_key_by_index,
-       .set_value = reg_dir_set_value,
-       .del_value = reg_dir_del_value,
+       .get_subkey_by_index = reg_dir_key_by_index
 };
 
 NTSTATUS registry_dir_init(void)
index e84850763453d255d91414673340951de76285ba..ec8a6d9de3ae7ba0fb541eeb655252042c724c08 100644 (file)
@@ -144,7 +144,7 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct registry_key *k, i
        
        *value = talloc_p(mem_ctx, struct registry_value);
        (*value)->name = talloc_strdup(mem_ctx, el->values[0].data);
-       (*value)->backend_data = talloc_strdup(mem_ctx, kd->values[idx]->dn);
+       /* FIXME */
 
        return WERR_OK;
 }
index 78c45f636547687d235bad3c2e2cfb4a410ec41d..16516d25b70feac7c1c3aeaa7d26a7c07cfd1149 100644 (file)
@@ -218,7 +218,6 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx, struct registry_key *p
        if(NT_STATUS_IS_OK(status) && 
           W_ERROR_IS_OK(r.out.result) && r.out.length) {
                *value = talloc_p(mem_ctx, struct registry_value);
-               (*value)->parent = parent;
                (*value)->name = talloc_strdup(mem_ctx, r.out.name_out.name);
                (*value)->data_type = type;
                (*value)->data_len = *r.out.length;
index a94ad86c2ceb6eb330a3181d1c5ed3514710cdb5..957039dea3f80b98bb11003174ba1503bb7c46e9 100644 (file)
@@ -332,7 +332,6 @@ static WERROR w95_get_value_by_id(TALLOC_CTX *mem_ctx, struct registry_key *k, i
        }
 
        *value = talloc_p(mem_ctx, struct registry_value);
-       (*value)->backend_data = curval;
        (*value)->name = talloc_strndup(mem_ctx, (char *)curval+sizeof(RGDB_VALUE), curval->name_len);
                
        (*value)->data_len = curval->data_len;
index a4a4649c9620c6f8a701289940738df9ca3c4526..18589a9285e78a93bbc15b63012f9b67a01de233 100644 (file)
@@ -701,13 +701,9 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd
 
                  while (cmd->val_count) {
                          VAL_SPEC_LIST *val = cmd->val_spec_list;
-                         struct registry_value *reg_val = NULL;
 
                          if (val->type == REG_DELETE) {
-                                 error = reg_key_get_value_by_name( mem_ctx, tmp, val->name, &reg_val);
-                                 if(W_ERROR_IS_OK(error)) {
-                                         error = reg_del_value(reg_val);
-                                 }
+                                 error = reg_del_value(tmp, val->name);
                                  if(!W_ERROR_IS_OK(error)) {
                                        DEBUG(0, ("Error removing value '%s'\n", val->name));
                                  }
index 47d84c1f623f4f683ef99c40b6cd3bbcd9ab5719..0a097088699f87ec8728394a8c641470d112bdf1 100644 (file)
@@ -142,18 +142,12 @@ static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_key *
 
 static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv)
 { 
-       struct registry_value *val;
        if(argc < 2) {
                fprintf(stderr, "Usage: rmval <valuename>\n");
                return NULL;
        }
 
-       if(!W_ERROR_IS_OK(reg_key_get_value_by_name(mem_ctx, cur, argv[1], &val))) {
-               fprintf(stderr, "No such value '%s'\n", argv[1]);
-               return NULL;
-       }
-
-       if(!W_ERROR_IS_OK(reg_del_value(val))) {
+       if(!W_ERROR_IS_OK(reg_del_value(cur, argv[1]))) {
                fprintf(stderr, "Error deleting value '%s'\n", argv[1]);
        } else {
                fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]);
index 478c6c1d86d5cb9fc0d3bcf91f3d5a7850e9f750..41147c089d0828ee367257ab54e679a16a41d8d7 100644 (file)
@@ -149,16 +149,14 @@ static WERROR winreg_DeleteValue(struct dcesrv_call_state *dce_call, TALLOC_CTX
                       struct winreg_DeleteValue *r)
 {
        struct dcesrv_handle *h;
-       struct registry_value *value;
+       struct registry_key *key;
 
-       h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGVAL);
+       h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
        DCESRV_CHECK_HANDLE(h);
 
-       value = h->data;
+       key = h->data;
        
-       /* FIXME */
-
-       return WERR_NOT_SUPPORTED;
+       return reg_del_value(key, r->in.value.name);
 }