The branch, master has been updated
       via  872d233... s4:regtree - fix counter variables to be "unsigned"
       via  61761cb... s4:registry - "LDB backend" - "reg_ldb_unpack_value"
       via  7b54964... s4:registry - "LDB backend" - "reg_key_get_info"
       via  773faa5... s4:registry - "LDB backend" - "ldb_get_default_value"
       via  b7f129f... s4:registry - "LDB backend" - make the key argument 
"const" of ldb_get_default_value
       via  ea621ef... s4:registry - "LDB backend" - fix indentation
      from  56940a2... Fix an uninitialized variable

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 872d2330a4d0d2608993fab9e9c0b0c3aa3921f8
Author: Matthias Dieter Wallnöfer <mwallnoe...@yahoo.de>
Date:   Sun Mar 21 23:41:50 2010 +0100

    s4:regtree - fix counter variables to be "unsigned"

commit 61761cbac8f609c9ee7c6d391739c50bd4844340
Author: Matthias Dieter Wallnöfer <mwallnoe...@yahoo.de>
Date:   Sun Mar 21 23:36:09 2010 +0100

    s4:registry - "LDB backend" - "reg_ldb_unpack_value"
    
    When the name isn't found it is the default value. Call it "" to be 
consistent.

commit 7b54964a253b031ba0351fecbfc271a68b76c25b
Author: Matthias Dieter Wallnöfer <mwallnoe...@yahoo.de>
Date:   Sun Mar 21 22:01:06 2010 +0100

    s4:registry - "LDB backend" - "reg_key_get_info"
    
    Consider also the default value (if it exists) as value. That means:
    - count it when setting "num_values"
    - take also his buffer length as a candidate for the maximum value buffer 
length
    
    This is what Windows does.

commit 773faa50632b8cee0008fe5d2c277c924b121756
Author: Matthias Dieter Wallnöfer <mwallnoe...@yahoo.de>
Date:   Sun Mar 21 22:57:31 2010 +0100

    s4:registry - "LDB backend" - "ldb_get_default_value"
    
    There exist also key objects (the hives) which don't contain a "key" entry 
at
    all. This prevented to display their default value (my fault).

commit b7f129f5c4686ac22940a09f306c813ce4212aef
Author: Matthias Dieter Wallnöfer <mwallnoe...@yahoo.de>
Date:   Sun Mar 21 22:02:19 2010 +0100

    s4:registry - "LDB backend" - make the key argument "const" of 
ldb_get_default_value

commit ea621efee79721afff8238c94ee8c95045820d0b
Author: Matthias Dieter Wallnöfer <mwallnoe...@yahoo.de>
Date:   Sun Mar 21 21:51:06 2010 +0100

    s4:registry - "LDB backend" - fix indentation

-----------------------------------------------------------------------

Summary of changes:
 source4/lib/registry/ldb.c           |   42 ++++++++++++++++++++++++++++-----
 source4/lib/registry/tools/regtree.c |    7 +++--
 2 files changed, 39 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 46b340d..7ceaa5b 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -48,7 +48,7 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
        if (name != NULL) {
                *name = talloc_strdup(mem_ctx,
                                      ldb_msg_find_attr_as_string(msg, "value",
-                                     NULL));
+                                     ""));
        }
 
        value_type = ldb_msg_find_attr_as_uint(msg, "type", 0);
@@ -486,9 +486,10 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
        return WERR_OK;
 }
 
-static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
-                                 const char **name, uint32_t *data_type,
-                                  DATA_BLOB *data)
+static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx,
+                                   const struct hive_key *k,
+                                   const char **name, uint32_t *data_type,
+                                   DATA_BLOB *data)
 {
        struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
        struct ldb_context *c = kd->ldb;
@@ -496,7 +497,7 @@ static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx, 
struct hive_key *k,
        struct ldb_result *res;
        int ret;
 
-       ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_BASE, attrs, 
"(key=*)");
+       ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_BASE, attrs, 
"(dn=*)");
 
        if (ret != LDB_SUCCESS) {
                DEBUG(0, ("Error getting default value for '%s': %s\n",
@@ -507,8 +508,10 @@ static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx, 
struct hive_key *k,
        if (res->count == 0 || res->msgs[0]->num_elements == 0)
                return WERR_BADFILE;
 
-       reg_ldb_unpack_value(mem_ctx,
-                res->msgs[0], name, data_type, data);
+       if ((data_type != NULL) && (data != NULL)) {
+               reg_ldb_unpack_value(mem_ctx, res->msgs[0], name, data_type,
+                                    data);
+       }
 
        talloc_free(res);
 
@@ -954,6 +957,9 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
                               uint32_t *max_valbufsize)
 {
        struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data);
+       uint32_t default_value_type = REG_NONE;
+       DATA_BLOB default_value = { NULL, 0 };
+       WERROR werr;
 
        /* Initialization */
        if (classname != NULL)
@@ -971,6 +977,16 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
        if (max_valbufsize != NULL)
                *max_valbufsize = 0;
 
+       /* We need this to get the default value (if it exists) for counting
+        * the values under the key and for finding out the longest value buffer
+        * size. If no default value exists the DATA_BLOB "default_value" will
+        * remain { NULL, 0 }. */
+       werr = ldb_get_default_value(mem_ctx, key, NULL, &default_value_type,
+                                    &default_value);
+       if ((!W_ERROR_IS_OK(werr)) && (!W_ERROR_EQUAL(werr, WERR_BADFILE))) {
+               return werr;
+       }
+
        if (kd->subkeys == NULL) {
                W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
        }
@@ -984,6 +1000,10 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
        }
        if (num_values != NULL) {
                *num_values = kd->value_count;
+               /* also consider the default value if it exists */
+               if (default_value.data != NULL) {
+                       ++(*num_values);
+               }
        }
 
 
@@ -1005,6 +1025,12 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
                struct ldb_message_element *el;
                W_ERROR_NOT_OK_RETURN(cache_values(kd));
 
+               /* also consider the default value if it exists */
+               if ((max_valbufsize != NULL) && (default_value.data != NULL)) {
+                               *max_valbufsize = MAX(*max_valbufsize,
+                                                     default_value.length);
+               }
+
                for (i = 0; i < kd->value_count; i++) {
                        if (max_valnamelen != NULL) {
                                el = ldb_msg_find_element(kd->values[i], 
"value");
@@ -1028,6 +1054,8 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
                }
        }
 
+       talloc_free(default_value.data);
+
        return WERR_OK;
 }
 
diff --git a/source4/lib/registry/tools/regtree.c 
b/source4/lib/registry/tools/regtree.c
index 7215828..3a7026b 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -33,7 +33,7 @@
  * @param fullpath Whether the full pat hshould be printed or just the last bit
  * @param novals Whether values should not be printed
  */
-static void print_tree(int level, struct registry_key *p,
+static void print_tree(unsigned int level, struct registry_key *p,
                       const char *name,
                       bool fullpath, bool novals)
 {
@@ -78,7 +78,7 @@ static void print_tree(int level, struct registry_key *p,
                for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(
                        mem_ctx, p, i, &valuename, &valuetype, &valuedata));
                        i++) {
-                       int j;
+                       unsigned int j;
                        for(j = 0; j < level+1; j++) putchar(' ');
                        printf("%s\n",  reg_val_description(mem_ctx,
                                lp_iconv_convenience(cmdline_lp_ctx), valuename,
@@ -101,7 +101,8 @@ static void print_tree(int level, struct registry_key *p,
 
 int main(int argc, char **argv)
 {
-       int opt, i;
+       int opt;
+       unsigned int i;
        const char *file = NULL;
        const char *remote = NULL;
        poptContext pc;


-- 
Samba Shared Repository

Reply via email to