s4:registry - move some common constraint checks to the "local" backend
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Tue, 29 Jun 2010 14:10:32 +0000 (16:10 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 1 Jul 2010 13:48:06 +0000 (15:48 +0200)
They should also be enforced when we don't use "ldb".

source4/lib/registry/ldb.c
source4/lib/registry/local.c

index b4eae9a341cf5999379685f6ac2d3a2ae3fcdad7..122f565813fe0f4897a9ea06083dd997ac8c2f82 100644 (file)
@@ -466,10 +466,6 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
        const char *res_name;
        uint32_t idx;
 
-       if (name == NULL) {
-               return WERR_INVALID_PARAM;
-       }
-
        /* the default value was requested, give it back */
        if (name[0] == '\0') {
                return ldb_get_default_value(mem_ctx, k, NULL, data_type, data);
@@ -503,10 +499,6 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
        struct ldb_key_data *kd = talloc_get_type(h, struct ldb_key_data);
        struct ldb_context *c = kd->ldb;
 
-       if (name == NULL) {
-               return WERR_INVALID_PARAM;
-       }
-
        ldb_path = reg_path_to_ldb(mem_ctx, h, name, NULL);
        W_ERROR_HAVE_NO_MEMORY(ldb_path);
 
@@ -593,10 +585,6 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
        struct ldb_key_data *newkd;
        int ret;
 
-       if (name == NULL) {
-               return WERR_INVALID_PARAM;
-       }
-
        ldb_path = reg_path_to_ldb(mem_ctx, parent, name, NULL);
        W_ERROR_HAVE_NO_MEMORY(ldb_path);
 
@@ -649,10 +637,6 @@ static WERROR ldb_del_value(TALLOC_CTX *mem_ctx, struct hive_key *key,
        struct ldb_message *msg;
        struct ldb_dn *childdn;
 
-       if (child == NULL) {
-               return WERR_INVALID_PARAM;
-       }
-
        if (child[0] == '\0') {
                /* default value */
                msg = talloc_zero(mem_ctx, struct ldb_message);
@@ -709,10 +693,6 @@ static WERROR ldb_del_key(TALLOC_CTX *mem_ctx, const struct hive_key *key,
        WERROR werr;
        struct hive_key *hk;
 
-       if (name == NULL) {
-               return WERR_INVALID_PARAM;
-       }
-
        /* Verify key exists by opening it */
        werr = ldb_open_key(mem_ctx, key, name, &hk);
        if (!W_ERROR_IS_OK(werr)) {
@@ -816,10 +796,6 @@ static WERROR ldb_set_value(struct hive_key *parent,
        int ret;
        TALLOC_CTX *mem_ctx = talloc_init("ldb_set_value");
 
-       if (name == NULL) {
-               return WERR_INVALID_PARAM;
-       }
-
        msg = reg_ldb_pack_value(kd->ldb, mem_ctx, name, type, data);
        W_ERROR_HAVE_NO_MEMORY(msg);
 
index 30785185393cf1c43bfa89f40b9193a29c627752..98791743aec5cfceed69ac601c9976fbc46478f3 100644 (file)
@@ -80,6 +80,10 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx,
        const char **elements = NULL;
        int el;
 
+       if (path == NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        orig = talloc_strdup(mem_ctx, path);
        W_ERROR_HAVE_NO_MEMORY(orig);
        curbegin = orig;
@@ -180,6 +184,10 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx,
        const char **elements = NULL;
        int el;
 
+       if (path == NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        orig = talloc_strdup(mem_ctx, path);
        W_ERROR_HAVE_NO_MEMORY(orig);
        curbegin = orig;
@@ -240,6 +248,10 @@ static WERROR local_set_value(struct registry_key *key, const char *name,
 {
        struct local_key *local = (struct local_key *)key;
 
+       if (name == NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        return hive_key_set_value(local->hive_key, name, type, data);
 }
 
@@ -249,6 +261,10 @@ static WERROR local_get_value(TALLOC_CTX *mem_ctx,
 {
        const struct local_key *local = (const struct local_key *)key;
 
+       if (name == NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        return hive_get_value(mem_ctx, local->hive_key, name, type, data);
 }
 
@@ -269,6 +285,10 @@ static WERROR local_delete_key(TALLOC_CTX *mem_ctx, struct registry_key *key,
 {
        const struct local_key *local = (const struct local_key *)key;
 
+       if (name == NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        return hive_key_del(mem_ctx, local->hive_key, name);
 }
 
@@ -277,6 +297,10 @@ static WERROR local_delete_value(TALLOC_CTX *mem_ctx, struct registry_key *key,
 {
        const struct local_key *local = (const struct local_key *)key;
 
+       if (name == NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        return hive_key_del_value(mem_ctx, local->hive_key, name);
 }