[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Fri Dec 18 03:03:55 MST 2009
The branch, master has been updated
via 19cdcde... s4-dsdb: stop warnings about unknown struct GUID in prototypes
via cb841c3... s4-ldb: fixed a valgrind error in ldbtest
via 5d7805b... s4-dsdb: greatly simplify the subtree_delete module
via b3c69e7... s4-dsdb: declare ldb_dn_update_components()
via 82bf0d8... s4-dsdb: added ldb_dn_update_components()
via db76e65... s4-dsdb: fixed the sort in dsdb_find_nc_root()
via f392ae5... s4-ldb: display msDS-OptionalFeatureGUID as a GUID
via 811b405... s4-scripts: add a enablerecyclebin script
via 20869a0... s4-ldb: canonicalise the message on ldb_add
from 7cb858e... s4-dsdb: Add a test for adding, deleting, and appending a posixAccount objectClass to a user
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 19cdcdec096f5d1e3be2707d546715912e3db122
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Dec 18 14:57:57 2009 +1100
s4-dsdb: stop warnings about unknown struct GUID in prototypes
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit cb841c363a3f78689b0bea12d359a4f0855164dd
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Dec 18 13:07:48 2009 +1100
s4-ldb: fixed a valgrind error in ldbtest
we were using msg->dn after the ldb it contained had been freed
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit 5d7805b07f1417e79325c5fd51c0c621f609b6df
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 17 23:01:13 2009 +1100
s4-dsdb: greatly simplify the subtree_delete module
We can use dsdb_module_search() to make this much simpler
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit b3c69e76ec9dbcffe363e3bdfcd7ed3c76b48220
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 17 23:04:00 2009 +1100
s4-dsdb: declare ldb_dn_update_components()
commit 82bf0d8bc6b4fa43f015b700a97f68f3d479eb36
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 17 23:03:41 2009 +1100
s4-dsdb: added ldb_dn_update_components()
This is used to udpate just the DN components of a ldb_dn, leaving the
other extended fields alone. It is needed to prevent linked attribute
updates from removing other extended components.
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit db76e6531825e66d4859106b583d9f7be8ae0a3a
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 17 23:50:05 2009 +1100
s4-dsdb: fixed the sort in dsdb_find_nc_root()
commit f392ae5169150dc939e0cea9732a6d0ef0ab860a
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Dec 18 11:43:21 2009 +1100
s4-ldb: display msDS-OptionalFeatureGUID as a GUID
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit 811b4054f95dca3c61a32b99627394ba40f9c1fc
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Dec 18 11:44:20 2009 +1100
s4-scripts: add a enablerecyclebin script
This can be used to enable the recyclebin on a windows box. Once we
properly implement this feature in samba we will use this to enable
the feature on ourselves as well.
commit 20869a0bf0758936b31dc648db7c1ee435dadc34
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 17 14:20:35 2009 +1100
s4-ldb: canonicalise the message on ldb_add
This canonicalise avoids a problem with an add that has multiple
elements with the same el->name. That is allowed by MS servers, and by
ldb, but it breaks things like the tdb backend and the repl_meta_data
RPMD handling.
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source4/dsdb/common/util.c | 7 +-
source4/dsdb/samdb/ldb_modules/subtree_delete.c | 137 ++++-------------------
source4/dsdb/samdb/ldb_modules/util.h | 1 +
source4/lib/ldb-samba/ldif_handlers.c | 1 +
source4/lib/ldb/common/ldb.c | 9 ++
source4/lib/ldb/common/ldb_dn.c | 23 ++++
source4/lib/ldb/include/ldb.h | 1 +
source4/lib/ldb/tools/ldbtest.c | 2 +
source4/scripting/bin/enablerecyclebin | 54 +++++++++
9 files changed, 117 insertions(+), 118 deletions(-)
create mode 100755 source4/scripting/bin/enablerecyclebin
Changeset truncated at 500 lines:
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 8ba734c..61d065b 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -2781,6 +2781,11 @@ int dsdb_wellknown_dn(struct ldb_context *samdb, TALLOC_CTX *mem_ctx,
}
+static int dsdb_dn_compare_ptrs(struct ldb_dn **dn1, struct ldb_dn **dn2)
+{
+ return ldb_dn_compare(*dn1, *dn2);
+}
+
/*
find a NC root given a DN within the NC
*/
@@ -2830,7 +2835,7 @@ int dsdb_find_nc_root(struct ldb_context *samdb, TALLOC_CTX *mem_ctx, struct ldb
}
}
- qsort(nc_dns, el->num_values, sizeof(nc_dns[0]), (comparison_fn_t)ldb_dn_compare);
+ qsort(nc_dns, el->num_values, sizeof(nc_dns[0]), (comparison_fn_t)dsdb_dn_compare_ptrs);
for (i=0; i<el->num_values; i++) {
if (ldb_dn_compare_base(nc_dns[i], dn) == 0) {
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index e1ce9c1..34f5cca 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -2,6 +2,7 @@
ldb database library
Copyright (C) Andrew Bartlett <abartlet at samba.org> 2006-2007
+ Copyright (C) Andrew Tridgell <tridge at samba.org> 2009
Copyright (C) Stefan Metzmacher <metze at samba.org> 2007
Copyright (C) Simo Sorce <idra at samba.org> 2008
@@ -30,137 +31,39 @@
*/
#include "ldb_module.h"
+#include "dsdb/samdb/ldb_modules/util.h"
-struct subtree_delete_context {
- struct ldb_module *module;
- struct ldb_request *req;
-
- int num_children;
-};
-
-static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module,
- struct ldb_request *req)
-{
- struct ldb_context *ldb;
- struct subtree_delete_context *ac;
-
- ldb = ldb_module_get_ctx(module);
-
- ac = talloc_zero(req, struct subtree_delete_context);
- if (ac == NULL) {
- ldb_oom(ldb);
- return NULL;
- }
-
- ac->module = module;
- ac->req = req;
-
- ac->num_children = 0;
-
- return ac;
-}
-
-static int subtree_delete_search_callback(struct ldb_request *req,
- struct ldb_reply *ares)
-{
- struct ldb_context *ldb;
- struct subtree_delete_context *ac;
- int ret;
-
- ac = talloc_get_type(req->context, struct subtree_delete_context);
- ldb = ldb_module_get_ctx(ac->module);
-
- if (!ares) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
- }
- if (ares->error != LDB_SUCCESS) {
- return ldb_module_done(ac->req, ares->controls,
- ares->response, ares->error);
- }
-
- switch (ares->type) {
- case LDB_REPLY_ENTRY:
- /* count entry */
- ++(ac->num_children);
-
- talloc_free(ares);
- ret = LDB_SUCCESS;
- break;
-
- case LDB_REPLY_REFERRAL:
- /* ignore */
- talloc_free(ares);
- ret = LDB_SUCCESS;
- break;
-
- case LDB_REPLY_DONE:
- talloc_free(ares);
-
- if (ac->num_children > 0) {
- ldb_asprintf_errstring(ldb,
- "Cannot delete %s, not a leaf node "
- "(has %d children)\n",
- ldb_dn_get_linearized(ac->req->op.del.dn),
- ac->num_children);
- return ldb_module_done(ac->req, NULL, NULL,
- LDB_ERR_NOT_ALLOWED_ON_NON_LEAF);
- }
-
- /* ok no children, let the original request through */
- ret = ldb_next_request(ac->module, ac->req);
- break;
- }
-
-done:
- if (ret != LDB_SUCCESS) {
- return ldb_module_done(ac->req, NULL, NULL, ret);
- }
-
- return LDB_SUCCESS;
-}
static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_context *ldb;
- static const char * const attrs[2] = { "distinguishedName", NULL };
- struct ldb_request *search_req;
- struct subtree_delete_context *ac;
+ static const char * const attrs[] = { NULL };
int ret;
+ struct ldb_result *res = NULL;
- if (ldb_dn_is_special(req->op.rename.olddn)) {
+ if (ldb_dn_is_special(req->op.del.dn)) {
/* do not manipulate our control entries */
return ldb_next_request(module, req);
}
- ldb = ldb_module_get_ctx(module);
-
- /* This gets complex: We need to:
- - Do a search for all entires under this entry
- - Wait for these results to appear
- - In the callback for each result, count the children (if any)
- - return an error if there are any
- */
-
- ac = subdel_ctx_init(module, req);
- if (!ac) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- /* we do not really need to find all descendents,
- * if there is even one single direct child, that's
- * enough to bail out */
- ret = ldb_build_search_req(&search_req, ldb, ac,
- req->op.del.dn, LDB_SCOPE_ONELEVEL,
- "(objectClass=*)", attrs,
- req->controls,
- ac, subtree_delete_search_callback,
- req);
+ /* see if we have any children */
+ ret = dsdb_module_search(module, req, &res, req->op.del.dn, LDB_SCOPE_ONELEVEL, attrs,
+ DSDB_SEARCH_SHOW_DELETED, NULL);
if (ret != LDB_SUCCESS) {
+ talloc_free(res);
return ret;
}
+ if (res->count > 0) {
+ ldb_asprintf_errstring(ldb_module_get_ctx(module),
+ "Cannot delete %s, not a leaf node "
+ "(has %d children)\n",
+ ldb_dn_get_linearized(req->op.del.dn),
+ res->count);
+ talloc_free(res);
+ return LDB_ERR_NOT_ALLOWED_ON_NON_LEAF;
+ }
+ talloc_free(res);
- return ldb_next_request(module, search_req);
+ return ldb_next_request(module, req);
}
const struct ldb_module_ops ldb_subtree_delete_module_ops = {
diff --git a/source4/dsdb/samdb/ldb_modules/util.h b/source4/dsdb/samdb/ldb_modules/util.h
index 41ec873..41ed883 100644
--- a/source4/dsdb/samdb/ldb_modules/util.h
+++ b/source4/dsdb/samdb/ldb_modules/util.h
@@ -20,6 +20,7 @@
*/
struct dsdb_schema; /* predeclare schema struct */
+struct GUID;
#include "dsdb/samdb/ldb_modules/util_proto.h"
#define DSDB_SEARCH_SEARCH_ALL_PARTITIONS 0x0001
diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c
index 6d54d1e..5f709e6 100644
--- a/source4/lib/ldb-samba/ldif_handlers.c
+++ b/source4/lib/ldb-samba/ldif_handlers.c
@@ -892,6 +892,7 @@ static const struct {
{ "fRSVersionGUID", LDB_SYNTAX_SAMBA_GUID },
{ "fRSReplicaSetGUID", LDB_SYNTAX_SAMBA_GUID },
{ "netbootGUID", LDB_SYNTAX_SAMBA_GUID },
+ { "msDS-OptionalFeatureGUID", LDB_SYNTAX_SAMBA_GUID },
{ "objectCategory", LDB_SYNTAX_SAMBA_OBJECT_CATEGORY },
{ "prefixMap", LDB_SYNTAX_SAMBA_PREFIX_MAP },
{ "repsFrom", LDB_SYNTAX_SAMBA_REPSFROMTO },
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 91429c2..94fd6cd 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -779,6 +779,15 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
ret = module->ops->search(module, req);
break;
case LDB_ADD:
+ /* we have to canonicalise here, as so many places
+ * in modules and backends assume we don't have two
+ * elements with the same name */
+ req->op.add.message = ldb_msg_canonicalize(ldb, req->op.add.message);
+ if (!req->op.add.message) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ talloc_steal(req, req->op.add.message);
FIRST_OP(ldb, add);
ret = module->ops->add(module, req);
break;
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index f11ccf3..79953c6 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -2001,3 +2001,26 @@ bool ldb_dn_is_null(struct ldb_dn *dn)
return false;
}
+/*
+ this updates dn->components, taking the components from ref_dn.
+ This is used by code that wants to update the DN path of a DN
+ while not impacting on the extended DN components
+ */
+int ldb_dn_update_components(struct ldb_dn *dn, const struct ldb_dn *ref_dn)
+{
+ dn->components = talloc_realloc(dn, dn->components,
+ struct ldb_dn_component, ref_dn->comp_num);
+ if (!dn->components) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ memcpy(dn->components, ref_dn->components,
+ sizeof(struct ldb_dn_component)*ref_dn->comp_num);
+ dn->comp_num = ref_dn->comp_num;
+
+ talloc_free(dn->linearized);
+ talloc_free(dn->ext_linearized);
+ dn->ext_linearized = NULL;
+ dn->linearized = NULL;
+
+ return LDB_SUCCESS;
+}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index cf55f0a..81ec9ee 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -1683,6 +1683,7 @@ bool ldb_dn_is_valid(struct ldb_dn *dn);
bool ldb_dn_is_special(struct ldb_dn *dn);
bool ldb_dn_check_special(struct ldb_dn *dn, const char *check);
bool ldb_dn_is_null(struct ldb_dn *dn);
+int ldb_dn_update_components(struct ldb_dn *dn, const struct ldb_dn *ref_dn);
/**
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 6af0ee9..adc6ec8 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -354,6 +354,8 @@ static void start_test_index(struct ldb_context **ldb)
}
basedn = ldb_dn_new(*ldb, *ldb, options->basedn);
+ msg->dn = basedn;
+ ldb_dn_add_child_fmt(msg->dn, "cn=test");
ret = ldb_search(*ldb, *ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, "uid=test");
if (ret != LDB_SUCCESS) {
diff --git a/source4/scripting/bin/enablerecyclebin b/source4/scripting/bin/enablerecyclebin
new file mode 100755
index 0000000..d02e90b
--- /dev/null
+++ b/source4/scripting/bin/enablerecyclebin
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+#
+# enabled the Recycle Bin optional feature
+#
+import base64
+import optparse
+import os
+import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
+import samba
+from samba import getopt as options, Ldb
+from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError
+import sys
+import ldb
+
+parser = optparse.OptionParser("enablerecyclebin <URL>")
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+credopts = options.CredentialsOptions(parser)
+parser.add_option_group(credopts)
+parser.add_option_group(options.VersionOptions(parser))
+
+opts, args = parser.parse_args()
+opts.dump_all = True
+
+if len(args) != 1:
+ parser.print_usage()
+ sys.exit(1)
+
+url = args[0]
+
+lp_ctx = sambaopts.get_loadparm()
+
+creds = credopts.get_credentials(lp_ctx)
+sam_ldb = Ldb(url, credentials=creds, lp=lp_ctx)
+
+# get the rootDSE
+res = sam_ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
+rootDse = res[0]
+
+configbase=rootDse["configurationNamingContext"]
+
+# enable the feature
+msg = ldb.Message()
+msg.dn = ldb.Dn(sam_ldb, "")
+msg["enableOptionalFeature"] = ldb.MessageElement(
+ "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
+ ldb.FLAG_MOD_ADD, "enableOptionalFeature")
+res = sam_ldb.modify(msg)
+
+print "Recycle Bin feature enabled"
--
Samba Shared Repository
More information about the samba-cvs
mailing list