Rename ldb_dn_extended_linearized to ldb_dn_get_extended_linearized
authorAndrew Bartlett <abartlet@samba.org>
Thu, 11 Dec 2008 04:03:16 +0000 (15:03 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 11 Dec 2008 04:03:16 +0000 (15:03 +1100)
source4/dsdb/samdb/ldb_modules/extended_dn_out.c
source4/dsdb/samdb/ldb_modules/extended_dn_store.c
source4/dsdb/samdb/ldb_modules/linked_attributes.c
source4/ldap_server/ldap_backend.c
source4/lib/ldb/common/ldb_dn.c
source4/lib/ldb/common/ldb_ldif.c
source4/lib/ldb/include/ldb.h
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/torture/ldb/ldb.c

index 9c178f2..1b38168 100644 (file)
@@ -140,7 +140,7 @@ static int inject_extended_dn_out(struct ldb_reply *ares,
        if (val) {
                ldb_msg_remove_attr(ares->message, "distinguishedName");
                ret = ldb_msg_add_steal_string(ares->message, "distinguishedName", 
-                                              ldb_dn_extended_linearized(ares->message, ares->message->dn, type));
+                                              ldb_dn_get_extended_linearized(ares->message, ares->message->dn, type));
                if (ret != LDB_SUCCESS) {
                        ldb_oom(ldb);
                        return LDB_ERR_OPERATIONS_ERROR;
@@ -315,8 +315,8 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares)
                                                      ldb_dn_get_linearized(dn));
                        } else {
                                dn_str = talloc_steal(msg->elements[i].values, 
-                                                     ldb_dn_extended_linearized(msg->elements[i].values, 
-                                                                                dn, ac->extended_type));
+                                                     ldb_dn_get_extended_linearized(msg->elements[i].values, 
+                                                                                    dn, ac->extended_type));
                        }
                        msg->elements[i].values[j] = data_blob_string_const(dn_str);
                        talloc_free(dn);
index a49ce84..f497b29 100644 (file)
@@ -159,8 +159,8 @@ static int extended_replace_dn(struct ldb_request *req, struct ldb_reply *ares)
                struct ldb_dn *dn = ares->message->dn;
 
                *os->replace_dn = data_blob_string_const(
-                       ldb_dn_extended_linearized(os->mem_ctx, 
-                                                  dn, 1));
+                       ldb_dn_get_extended_linearized(os->mem_ctx, 
+                                                      dn, 1));
                if (os->replace_dn->data == NULL) {
                        return ldb_module_done(os->ac->req, NULL, NULL,
                                                LDB_ERR_OPERATIONS_ERROR);
index 49e91cb..a3318cc 100644 (file)
@@ -791,9 +791,9 @@ static int la_do_mod_request(struct la_context *ac)
        }
        ret_el->num_values = 1;
        if (ac->ops->op == LA_OP_ADD) {
-               ret_el->values[0] = data_blob_string_const(ldb_dn_extended_linearized(new_msg, ac->add_dn, 1));
+               ret_el->values[0] = data_blob_string_const(ldb_dn_get_extended_linearized(new_msg, ac->add_dn, 1));
        } else {
-               ret_el->values[0] = data_blob_string_const(ldb_dn_extended_linearized(new_msg, ac->del_dn, 1));
+               ret_el->values[0] = data_blob_string_const(ldb_dn_get_extended_linearized(new_msg, ac->del_dn, 1));
        }
 
 #if 0
index 4cdfeaf..a091c1d 100644 (file)
@@ -281,7 +281,7 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
                        talloc_steal(ent_r, res->msgs[i]);
                        
                        ent = &ent_r->msg->r.SearchResultEntry;
-                       ent->dn = ldb_dn_extended_linearized(ent_r, res->msgs[i]->dn, extended_type);
+                       ent->dn = ldb_dn_get_extended_linearized(ent_r, res->msgs[i]->dn, extended_type);
                        ent->num_attributes = 0;
                        ent->attributes = NULL;
                        if (res->msgs[i]->num_elements == 0) {
index 23069ca..13c01f4 100644 (file)
@@ -708,7 +708,7 @@ const char *ldb_dn_get_linearized(struct ldb_dn *dn)
        return dn->linearized;
 }
 
-char *ldb_dn_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode)
+char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode)
 {
        const char *linearized = ldb_dn_get_linearized(dn);
        char *p;
index 92af72c..619c10e 100644 (file)
@@ -284,7 +284,7 @@ int ldb_ldif_write(struct ldb_context *ldb,
        mem_ctx = talloc_named_const(NULL, 0, "ldb_ldif_write");
 
        msg = ldif->msg;
-       p = ldb_dn_extended_linearized(mem_ctx, msg->dn, 1);
+       p = ldb_dn_get_extended_linearized(mem_ctx, msg->dn, 1);
        ret = fprintf_fn(private_data, "dn: %s\n", p);
        talloc_free(p);
        CHECK_RET;
index 9399a01..e2ec869 100644 (file)
@@ -1439,15 +1439,82 @@ int ldb_base64_decode(char *s);
 
 /* The following definitions come from lib/ldb/common/ldb_dn.c  */
 
+/**
+  Get the linear form of a DN (without any extended components)
+  
+  \param dn The DN to linearize
+*/
+
+const char *ldb_dn_get_linearized(struct ldb_dn *dn);
+
+/**
+  Allocate a copy of the linear form of a DN (without any extended components) onto the supplied memory context 
+  
+  \param dn The DN to linearize
+  \param mem_ctx TALLOC context to return result on
+*/
+
+char *ldb_dn_alloc_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn);
+
+/**
+  Get the linear form of a DN (with any extended components)
+  
+  \param mem_ctx TALLOC context to return result on
+  \param dn The DN to linearize
+  \param mode Style of extended DN to return (0 is HEX representation of binary form, 1 is a string form)
+*/
+char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode);
+const struct ldb_val *ldb_dn_get_extended_component(struct ldb_dn *dn, const char *name);
+int ldb_dn_set_extended_component(struct ldb_dn *dn, const char *name, const struct ldb_val *val);
+
+void ldb_dn_remove_extended_components(struct ldb_dn *dn);
+bool ldb_dn_has_extended(struct ldb_dn *dn);
+
+int ldb_dn_extended_add_syntax(struct ldb_context *ldb, 
+                              unsigned flags,
+                              const struct ldb_dn_extended_syntax *syntax);
+
+/** 
+  Allocate a new DN from a string
+
+  \param mem_ctx TALLOC context to return resulting ldb_dn structure on
+  \param dn The new DN 
+
+  \note The DN will not be parsed at this time.  Use ldb_dn_validate to tell if the DN is syntacticly correct
+*/
+
 struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn);
+/** 
+  Allocate a new DN from a printf style format string and arguments
+
+  \param mem_ctx TALLOC context to return resulting ldb_dn structure on
+  \param new_fms The new DN as a format string (plus arguments)
+
+  \note The DN will not be parsed at this time.  Use ldb_dn_validate to tell if the DN is syntacticly correct
+*/
+
 struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4);
+/** 
+  Allocate a new DN from a struct ldb_val (useful to avoid buffer overrun)
+
+  \param mem_ctx TALLOC context to return resulting ldb_dn structure on
+  \param dn The new DN 
+
+  \note The DN will not be parsed at this time.  Use ldb_dn_validate to tell if the DN is syntacticly correct
+*/
+
 struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn);
+
+/**
+  Determine if this DN is syntactically valid 
+
+  \param dn The DN to validate
+*/
+
 bool ldb_dn_validate(struct ldb_dn *dn);
 
 char *ldb_dn_escape_value(TALLOC_CTX *mem_ctx, struct ldb_val value);
-const char *ldb_dn_get_linearized(struct ldb_dn *dn);
 const char *ldb_dn_get_casefold(struct ldb_dn *dn);
-char *ldb_dn_alloc_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn);
 char *ldb_dn_alloc_casefold(TALLOC_CTX *mem_ctx, struct ldb_dn *dn);
 
 int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn);
@@ -1754,15 +1821,5 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque
    \return array of ldb_control elements
 */
 struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char **control_strings);
-char *ldb_dn_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode);
-const struct ldb_val *ldb_dn_get_extended_component(struct ldb_dn *dn, const char *name);
-int ldb_dn_set_extended_component(struct ldb_dn *dn, const char *name, const struct ldb_val *val);
-
-void ldb_dn_remove_extended_components(struct ldb_dn *dn);
-bool ldb_dn_has_extended(struct ldb_dn *dn);
-
-int ldb_dn_extended_add_syntax(struct ldb_context *ldb, 
-                              unsigned flags,
-                              const struct ldb_dn_extended_syntax *syntax);
 
 #endif
index 002983d..ae79bdf 100644 (file)
@@ -428,7 +428,7 @@ static int ildb_search(struct ildb_context *ac)
        if (req->op.search.base == NULL) {
                msg->r.SearchRequest.basedn = talloc_strdup(msg, "");
        } else {
-               msg->r.SearchRequest.basedn  = ldb_dn_extended_linearized(msg, req->op.search.base, 0);
+               msg->r.SearchRequest.basedn  = ldb_dn_get_extended_linearized(msg, req->op.search.base, 0);
        }
        if (msg->r.SearchRequest.basedn == NULL) {
                ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN");
@@ -473,7 +473,7 @@ static int ildb_add(struct ildb_context *ac)
 
        msg->type = LDAP_TAG_AddRequest;
 
-       msg->r.AddRequest.dn = ldb_dn_extended_linearized(msg, req->op.add.message->dn, 0);
+       msg->r.AddRequest.dn = ldb_dn_get_extended_linearized(msg, req->op.add.message->dn, 0);
        if (msg->r.AddRequest.dn == NULL) {
                talloc_free(msg);
                return LDB_ERR_INVALID_DN_SYNTAX;
@@ -516,7 +516,7 @@ static int ildb_modify(struct ildb_context *ac)
 
        msg->type = LDAP_TAG_ModifyRequest;
 
-       msg->r.ModifyRequest.dn = ldb_dn_extended_linearized(msg, req->op.mod.message->dn, 0);
+       msg->r.ModifyRequest.dn = ldb_dn_get_extended_linearized(msg, req->op.mod.message->dn, 0);
        if (msg->r.ModifyRequest.dn == NULL) {
                talloc_free(msg);
                return LDB_ERR_INVALID_DN_SYNTAX;
@@ -557,7 +557,7 @@ static int ildb_delete(struct ildb_context *ac)
 
        msg->type = LDAP_TAG_DelRequest;
 
-       msg->r.DelRequest.dn = ldb_dn_extended_linearized(msg, req->op.del.dn, 0);
+       msg->r.DelRequest.dn = ldb_dn_get_extended_linearized(msg, req->op.del.dn, 0);
        if (msg->r.DelRequest.dn == NULL) {
                talloc_free(msg);
                return LDB_ERR_INVALID_DN_SYNTAX;
@@ -580,7 +580,7 @@ static int ildb_rename(struct ildb_context *ac)
        }
 
        msg->type = LDAP_TAG_ModifyDNRequest;
-       msg->r.ModifyDNRequest.dn = ldb_dn_extended_linearized(msg, req->op.rename.olddn, 0);
+       msg->r.ModifyDNRequest.dn = ldb_dn_get_extended_linearized(msg, req->op.rename.olddn, 0);
        if (msg->r.ModifyDNRequest.dn == NULL) {
                talloc_free(msg);
                return LDB_ERR_INVALID_DN_SYNTAX;
index f67ce1e..d161325 100644 (file)
@@ -371,12 +371,12 @@ static bool torture_ldb_dn_extended(struct torture_context *torture)
        torture_assert_data_blob_equal(torture, *ldb_dn_get_component_val(dn, 0), data_blob_string_const("admin"), 
                                 "componet zero incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 1),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
                                 talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s", 
                                                 guid, sid, dn_str),
                                 "Clear extended linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 0),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
                                 talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s", 
                                                 hex_guid, hex_sid, dn_str),
                                 "HEX extended linearized DN incorrect");
@@ -410,12 +410,12 @@ static bool torture_ldb_dn_extended(struct torture_context *torture)
        torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "cn=users,dc=samba,dc=org", 
                                 "linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 1),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
                                 talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s", 
                                                 guid, sid, "cn=users,dc=samba,dc=org"),
                                 "Clear extended linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 0),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
                                 talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s", 
                                                 hex_guid, hex_sid, "cn=users,dc=samba,dc=org"),
                                 "HEX extended linearized DN incorrect");
@@ -448,12 +448,12 @@ static bool torture_ldb_dn_extended(struct torture_context *torture)
        torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "", 
                                 "linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 1),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
                                 talloc_asprintf(mem_ctx, "<GUID=%s>", 
                                                 guid),
                                 "Clear extended linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 0),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
                                 talloc_asprintf(mem_ctx, "<GUID=%s>", 
                                                 hex_guid),
                                 "HEX extended linearized DN incorrect");
@@ -508,12 +508,12 @@ static bool torture_ldb_dn_extended(struct torture_context *torture)
        torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "", 
                                 "linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 1),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
                                 talloc_asprintf(mem_ctx, "<SID=%s>", 
                                                 sid),
                                 "Clear extended linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 0),
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
                                 talloc_asprintf(mem_ctx, "<SID=%s>", 
                                                 hex_sid),
                                 "HEX extended linearized DN incorrect");
@@ -586,7 +586,7 @@ static bool torture_ldb_dn(struct torture_context *torture)
        torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "dc=samba,dc=org", 
                                 "linearized DN incorrect");
 
-       torture_assert_str_equal(torture, ldb_dn_extended_linearized(mem_ctx, dn, 0), "dc=samba,dc=org", 
+       torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0), "dc=samba,dc=org", 
                                 "extended linearized DN incorrect");
 
        /* Check child DN comparisons */