r9387: regedit uses "New Key #nn" for newly created keys, which conflicts with the...
authorAndrew Tridgell <tridge@samba.org>
Thu, 18 Aug 2005 11:15:15 +0000 (11:15 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:33:31 +0000 (13:33 -0500)
DN rules in ldb. Escape the DN components to cope.

Simo, sorry for making a change in ldb_dn.c while you have changes
pending. Please feel free to revert these and switch reg_backend_ldb.c
to use the new dn construction code.
(This used to be commit 136ecf5cb23758558b4119b08047fc273be8b0f8)

source4/lib/ldb/common/ldb_dn.c
source4/lib/ldb/include/ldb.h
source4/lib/registry/reg_backend_ldb.c

index 5dcb540fa137748416abf91bc35904d89aff15a9..d13238cc170c0949e2a6f008e3f131cbb30b004d 100644 (file)
@@ -56,7 +56,7 @@ static int ldb_dn_is_valid_attribute_name(const char *name)
        return 1;
 }
 
-static char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value)
+char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value)
 {
        const char *p, *s, *src;
        char *d, *dst;
index 7399b8ffe7232b8da8a36ddc3b5b0e0290818d10..fdf5dc8d91940ec05f4a5b444bc00e69ed0b5cd2 100644 (file)
@@ -342,6 +342,7 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb,
 
 int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2);
 int ldb_attr_cmp(const char *dn1, const char *dn2);
+char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
 
 /* case-fold a DN */
 char *ldb_dn_fold(void * mem_ctx,
index 784d8ac6fa4667ddab93eb70a82ac6766d9e7263..114614597f6ad7a8e82e01a07371f6813ae34f90 100644 (file)
@@ -126,12 +126,24 @@ static char *reg_path_to_ldb(TALLOC_CTX *mem_ctx, struct registry_key *from, con
        while(mypath) {
                char *keyname;
                begin = strrchr(mypath, '\\');
+               struct ldb_val val;
+               char *key;
 
-               if(begin) keyname = begin + 1;
+               if (begin) keyname = begin + 1;
                else keyname = mypath;
 
-               if(strlen(keyname))
-                       ret = talloc_asprintf_append(ret, "key=%s,", keyname);
+               val.data = keyname;
+               val.length = strlen(keyname);
+               
+               key = ldb_dn_escape_value(mem_ctx, val);
+               if (key == NULL) {
+                       return NULL;
+               }
+
+               if (strlen(key))
+                       ret = talloc_asprintf_append(ret, "key=%s,", key);
+
+               talloc_free(key);
                        
                if(begin) {
                        *begin = '\0';