summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-01-17 17:23:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:14 -0500
commit8139c1e6f2cf154dad0c0c3fbf8c4fac960bdfe0 (patch)
treebcc8c9325922090519fab856ccd4281a0be699ee /source4/lib
parente88285db2df8790c5ee9f42285fa2c27c9b155ed (diff)
downloadsamba-8139c1e6f2cf154dad0c0c3fbf8c4fac960bdfe0.tar.gz
samba-8139c1e6f2cf154dad0c0c3fbf8c4fac960bdfe0.tar.bz2
samba-8139c1e6f2cf154dad0c0c3fbf8c4fac960bdfe0.zip
r12983: - fix using a DIRSYNC cookie from the command line
- also w2k doesn't work correct with max_attrs = 0, so we should use a high number, with this I'm getting the same results from w2k and w2k3 metze (This used to be commit ce9f086c3c1a65bf1b4c843ec44e8817d9361182)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index 6c1071318e..df895350ee 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -82,10 +82,17 @@ static struct ldb_control **parse_controls(void *mem_ctx, char **control_strings
ret = sscanf(p, "%d:%d:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie);
if ((ret < 3) || (crit < 0) || (crit > 1) || (flags < 0) || (max_attrs < 0)) {
- fprintf(stderr, "invalid paged_results control syntax\n");
+ fprintf(stderr, "invalid dirsync control syntax\n");
return NULL;
}
+ /* w2k3 seems to ignore the parameter,
+ * but w2k sends a wrong cookie when this value is to small
+ * this would cause looping forever, while getting
+ * the same data and same cookie forever
+ */
+ if (max_attrs == 0) max_attrs = 0x0FFFFFFF;
+
ctrl[i] = talloc(ctrl, struct ldb_control);
ctrl[i]->oid = LDB_CONTROL_DIRSYNC_OID;
ctrl[i]->critical = crit;
@@ -93,9 +100,8 @@ static struct ldb_control **parse_controls(void *mem_ctx, char **control_strings
control->flags = flags;
control->max_attributes = max_attrs;
if (*cookie) {
- ldb_base64_decode(cookie);
- control->cookie = talloc_strdup(control, cookie);
- control->cookie_len = strlen(cookie);
+ control->cookie_len = ldb_base64_decode(cookie);
+ control->cookie = talloc_memdup(control, cookie, control->cookie_len);
} else {
control->cookie = NULL;
control->cookie_len = 0;
@@ -332,7 +338,7 @@ static int handle_controls_reply(struct ldb_control **reply, struct ldb_control
req_control->cookie_len = rep_control->cookie_len;
cookie = ldb_base64_encode(req_control, rep_control->cookie, rep_control->cookie_len);
- fprintf(stderr, "Debug: The cookie returned was: %s\n", cookie);
+ printf("# DIRSYNC cookie returned was:\n# %s\n", cookie);
ret = 1;