The branch, master has been updated
       via  26ccb6d s4-dsdb: cope with failed searches in the linked attributes 
callback
       via  e395b5b s3-torture: a very simple test for convert_string_error()
      from  6a9043d s3: Fix a typo

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


- Log -----------------------------------------------------------------
commit 26ccb6d5ed88638dd3643632157771320cd8042a
Author: Andrew Tridgell <[email protected]>
Date:   Thu Mar 31 15:16:51 2011 +1100

    s4-dsdb: cope with failed searches in the linked attributes callback
    
    This fixes a bug where we try to add an empty backlink because the
    search for the forward link failed.
    
    Autobuild-User: Andrew Tridgell <[email protected]>
    Autobuild-Date: Thu Mar 31 13:37:36 CEST 2011 on sn-devel-104

commit e395b5bd3c8290ad400ed1389d3bd0ee0b28056f
Author: Andrew Tridgell <[email protected]>
Date:   Wed Mar 30 17:30:08 2011 +1100

    s3-torture: a very simple test for convert_string_error()
    
    this is a very simple test based on the example volker gave in
    1e50f9a5. A more sophisticated test will also be worthwhile, but this
    at least gives us a basic test while changes are being made

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

Summary of changes:
 source3/selftest/tests.py                          |    2 +-
 source3/torture/torture.c                          |   98 ++++++++++++++++++++
 source4/dsdb/samdb/ldb_modules/linked_attributes.c |   31 +++---
 3 files changed, 114 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 19ea34a..cf6f8a7 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -59,7 +59,7 @@ tests=[ "FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", 
"LOCK5", "LOCK6", "LOCK7",
         "TCON2", "IOCTL", "CHKPATH", "FDSESS", "LOCAL-SUBSTITUTE", "CHAIN1",
         "GETADDRINFO", "POSIX", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
         "LOCAL-BASE64", "LOCAL-GENCACHE", "POSIX-APPEND",
-        "LOCAL-string_to_sid" ]
+        "LOCAL-string_to_sid", "LOCAL-CONVERT-STRING" ]
 
 for t in tests:
     plantestsuite("samba3.smbtorture_s3.plain(dc).%s" % t, "dc", 
[os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, 
'//$SERVER_IP/tmp', '$USERNAME', '$PASSWORD', "", "-l $LOCAL_PATH"])
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 175c217..87b03b4 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -7259,6 +7259,103 @@ static bool run_local_rbtree(int dummy)
        return ret;
 }
 
+
+/*
+  local test for character set functions
+
+  This is a very simple test for the functionality in convert_string_error()
+ */
+static bool run_local_convert_string(int dummy)
+{
+       TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+       const char *test_strings[2] = { "March", "M\303\244rz" };
+       char dst[7];
+       int i;
+
+       for (i=0; i<2; i++) {
+               const char *str = test_strings[i];
+               int len = strlen(str);
+               size_t converted_size;
+               bool ret;
+
+               memset(dst, 'X', sizeof(dst));
+
+               /* first try with real source length */
+               ret = convert_string_error(CH_UNIX, CH_UTF8,
+                                          str, len,
+                                          dst, sizeof(dst),
+                                          &converted_size);
+               if (ret != true) {
+                       d_fprintf(stderr, "Failed to convert '%s' to 
CH_DISPLAY\n", str);
+                       goto failed;
+               }
+
+               if (converted_size != len) {
+                       d_fprintf(stderr, "Converted size of '%s' should be %d 
- got %d\n",
+                                 str, len, (int)converted_size);
+                       goto failed;
+               }
+
+               if (strncmp(str, dst, converted_size) != 0) {
+                       d_fprintf(stderr, "Expected '%s' to match '%s'\n", str, 
dst);
+                       goto failed;
+               }
+
+               if (strlen(str) != converted_size) {
+                       d_fprintf(stderr, "Expected '%s' length %d - got %d\n", 
str,
+                                 (int)strlen(str), (int)converted_size);
+                       goto failed;
+               }
+
+               if (dst[converted_size] != 'X') {
+                       d_fprintf(stderr, "Expected no termination of '%s'\n", 
dst);
+                       goto failed;
+               }
+
+               /* now with srclen==-1, this causes the nul to be
+                * converted too */
+               ret = convert_string_error(CH_UNIX, CH_UTF8,
+                                          str, -1,
+                                          dst, sizeof(dst),
+                                          &converted_size);
+               if (ret != true) {
+                       d_fprintf(stderr, "Failed to convert '%s' to 
CH_DISPLAY\n", str);
+                       goto failed;
+               }
+
+               if (converted_size != len+1) {
+                       d_fprintf(stderr, "Converted size of '%s' should be %d 
- got %d\n",
+                                 str, len, (int)converted_size);
+                       goto failed;
+               }
+
+               if (strncmp(str, dst, converted_size) != 0) {
+                       d_fprintf(stderr, "Expected '%s' to match '%s'\n", str, 
dst);
+                       goto failed;
+               }
+
+               if (len+1 != converted_size) {
+                       d_fprintf(stderr, "Expected '%s' length %d - got %d\n", 
str,
+                                 len+1, (int)converted_size);
+                       goto failed;
+               }
+
+               if (dst[converted_size] != 'X') {
+                       d_fprintf(stderr, "Expected no termination of '%s'\n", 
dst);
+                       goto failed;
+               }
+
+       }
+
+
+       TALLOC_FREE(tmp_ctx);
+       return true;
+failed:
+       TALLOC_FREE(tmp_ctx);
+       return false;
+}
+
+
 struct talloc_dict_test {
        int content;
 };
@@ -8176,6 +8273,7 @@ static struct {
        { "LOCAL-binary_to_sid", run_local_binary_to_sid, 0},
        { "LOCAL-DBTRANS", run_local_dbtrans, 0},
        { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0},
+       { "LOCAL-CONVERT-STRING", run_local_convert_string, 0},
        {NULL, NULL, 0}};
 
 
diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c 
b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
index 393f00f..6948800 100644
--- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c
+++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
@@ -45,7 +45,6 @@ struct la_op_store {
        enum la_op {LA_OP_ADD, LA_OP_DEL} op;
        struct GUID guid;
        char *name;
-       char *value;
 };
 
 struct replace_context {
@@ -59,8 +58,7 @@ struct la_context {
        const struct dsdb_schema *schema;
        struct ldb_module *module;
        struct ldb_request *req;
-       struct ldb_dn *add_dn;
-       struct ldb_dn *del_dn;
+       struct ldb_dn *mod_dn;
        struct replace_context *rc;
        struct la_op_store *ops;
        struct ldb_extended *op_response;
@@ -319,7 +317,7 @@ static int la_mod_search_callback(struct ldb_request *req, 
struct ldb_reply *are
                                                LDB_ERR_OPERATIONS_ERROR);
                }
 
-               ac->add_dn = ac->del_dn = talloc_steal(ac, ares->message->dn);
+               ac->mod_dn = talloc_steal(ac, ares->message->dn);
 
                /* We don't populate 'rc' for ADD - it can't be deleting 
elements anyway */
                for (i = 0; rc && i < rc->num_elements; i++) {
@@ -572,9 +570,9 @@ static int linked_attributes_modify(struct ldb_module 
*module, struct ldb_reques
 
                /* We need to figure out our own extended DN, to fill in as the 
backlink target */
                if (ret == LDB_SUCCESS) {
-                       ret = ldb_request_add_control(search_req,
-                                                     
LDB_CONTROL_EXTENDED_DN_OID,
-                                                     false, NULL);
+                       ret = dsdb_request_add_controls(search_req,
+                                                       
DSDB_SEARCH_SHOW_DELETED |
+                                                       
DSDB_SEARCH_SHOW_EXTENDED_DN);
                }
                if (ret == LDB_SUCCESS) {
                        talloc_steal(search_req, attrs);
@@ -867,9 +865,9 @@ static int la_add_callback(struct ldb_request *req, struct 
ldb_reply *ares)
                LDB_REQ_SET_LOCATION(search_req);
 
                if (ret == LDB_SUCCESS) {
-                       ret = ldb_request_add_control(search_req,
-                                                     
LDB_CONTROL_EXTENDED_DN_OID,
-                                                     false, NULL);
+                       ret = dsdb_request_add_controls(search_req,
+                                                       
DSDB_SEARCH_SHOW_DELETED |
+                                                       
DSDB_SEARCH_SHOW_EXTENDED_DN);
                }
                if (ret != LDB_SUCCESS) {
                        return ldb_module_done(ac->req, NULL, NULL,
@@ -941,6 +939,11 @@ static int la_do_op_request(struct ldb_module *module, 
struct la_context *ac, st
        struct ldb_context *ldb;
        int ret;
 
+       if (ac->mod_dn == NULL) {
+               /* we didn't find the DN that we searched for */
+               return LDB_SUCCESS;
+       }
+
        ldb = ldb_module_get_ctx(ac->module);
 
        /* Create the modify request */
@@ -969,11 +972,7 @@ static int la_do_op_request(struct ldb_module *module, 
struct la_context *ac, st
                return ldb_oom(ldb);
        }
        ret_el->num_values = 1;
-       if (op->op == LA_OP_ADD) {
-               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_get_extended_linearized(new_msg, ac->del_dn, 1));
-       }
+       ret_el->values[0] = 
data_blob_string_const(ldb_dn_get_extended_linearized(new_msg, ac->mod_dn, 1));
 
        /* a backlink should never be single valued. Unfortunately the
           exchange schema has a attribute
@@ -996,7 +995,7 @@ static int la_do_op_request(struct ldb_module *module, 
struct la_context *ac, st
 
        ret = dsdb_module_modify(module, new_msg, DSDB_FLAG_NEXT_MODULE, 
ac->req);
        if (ret != LDB_SUCCESS) {
-               ldb_debug(ldb, LDB_DEBUG_WARNING, "Failed to apply linked 
attribute change '%s'\n%s\n",
+               ldb_debug(ldb, LDB_DEBUG_WARNING, __location__ ": failed to 
apply linked attribute change '%s'\n%s\n",
                          ldb_errstring(ldb),
                          ldb_ldif_message_string(ldb, op, 
LDB_CHANGETYPE_MODIFY, new_msg));
        }


-- 
Samba Shared Repository

Reply via email to