Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Fri, Oct 30, 2009 at 10:51:13PM +0100, Sumit Bose wrote: On Fri, Oct 30, 2009 at 05:42:10PM -0400, Simo Sorce wrote: On Fri, 2009-10-30 at 12:01 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 11:26:39PM +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 09:32:34PM +, Simo Sorce wrote: On Thu, 2009-10-29 at 19:40 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 01:39:21PM +0100, Sumit Bose wrote: Hi, this patch adds a recursive delete request to the sysdb API. It has the same interface as sysdb_delete_entry, but does not delete the entry, but its children. bye, Sumit This is a new version of the patch which tries to delete the entry AND all its children. It searches all objects with a subtree search, sorts the result so that the ones with the most components come first and finally loops over the results and deletes them. Comments inline. + +subreq = sysdb_search_entry_send(state, ev, handle, dn, LDB_SCOPE_SUBTREE, + distinguishedName=*, NULL); Please use (objectclass=*) as filter to catch all entries. I would prefer to stay with distinguishedName, because it is auto-generated and always present. Also please set attrs. Passing NULL, means you will retrieve all attributes wasting a lot of memory unnecessarily. You are interested only in the entries msg-dn, so you probably do not want any attribute returned at all. ah, I thought NULL means nothing, now I pass { NULL } [..] +static int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} Please move this function in sysdb.c, it's a generic function that can be used by multiple functions and here just interrupts reading the program flow. done +static void sysdb_delete_recursive_loop(struct tevent_req *subreq) [...] I think you should split the this function into a function that receives the results of sysdb_search_entry_recv() and then another one that sets the loop. If necessary use the trick I used in sdap_cli_connect to do continuation functions (see the sdap_cli_*_step functions). done The rest looks good to me. Thanks for reviewing. bye, Sumit sorry, this new patch fixes a compiler warning. Looks good to me, I have only a minor nitpick, shouldn't the ENOENT error in sysdb_delete_recursive_op_done() be fatal ? Given it should never happen, does it make sense to allow to continue ? Simo. ok, it is now fatal as all other errors bye, Sumit This new version adds a missing return after a tevent_req_done() call. bye, Sumit From 44a77225d38dd5998e6da56fa420cdb817bddf94 Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 29 Oct 2009 12:57:57 +0100 Subject: [PATCH] add sysdb_delete_recursive request to sysdb API --- server/db/sysdb.c | 12 server/db/sysdb.h | 10 +++ server/db/sysdb_ops.c | 153 server/tests/sysdb-tests.c | 111 ++- 4 files changed, 282 insertions(+), 4 deletions(-) diff --git a/server/db/sysdb.c b/server/db/sysdb.c index 5811ddc..a2ac3b2 100644 --- a/server/db/sysdb.c +++ b/server/db/sysdb.c @@ -1417,3 +1417,15 @@ int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list, /* definitely not found */ return ENOENT; } + + +int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(void **) discard_const(m1), + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(void **) discard_const(m2), + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} + diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 00a3378..72f56db 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -190,6 +190,8 @@ struct ldb_dn *sysdb_custom_dn(struct sysdb_ctx *ctx, void *memctx, struct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *ctx); struct ldb_context *sysdb_handle_get_ldb(struct sysdb_handle *handle); +int compare_ldb_dn_comp_num(const void *m1, const void *m2); + /* function to start and finish a
Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Mon, 2009-11-02 at 14:06 +0100, Sumit Bose wrote: Looks good to me, I have only a minor nitpick, shouldn't the ENOENT error in sysdb_delete_recursive_op_done() be fatal ? Given it should never happen, does it make sense to allow to continue ? Simo. ok, it is now fatal as all other errors bye, Sumit This new version adds a missing return after a tevent_req_done() call. ACK Simo. -- Simo Sorce * Red Hat, Inc * New York ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel
Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Fri, 2009-10-30 at 12:01 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 11:26:39PM +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 09:32:34PM +, Simo Sorce wrote: On Thu, 2009-10-29 at 19:40 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 01:39:21PM +0100, Sumit Bose wrote: Hi, this patch adds a recursive delete request to the sysdb API. It has the same interface as sysdb_delete_entry, but does not delete the entry, but its children. bye, Sumit This is a new version of the patch which tries to delete the entry AND all its children. It searches all objects with a subtree search, sorts the result so that the ones with the most components come first and finally loops over the results and deletes them. Comments inline. + +subreq = sysdb_search_entry_send(state, ev, handle, dn, LDB_SCOPE_SUBTREE, + distinguishedName=*, NULL); Please use (objectclass=*) as filter to catch all entries. I would prefer to stay with distinguishedName, because it is auto-generated and always present. Also please set attrs. Passing NULL, means you will retrieve all attributes wasting a lot of memory unnecessarily. You are interested only in the entries msg-dn, so you probably do not want any attribute returned at all. ah, I thought NULL means nothing, now I pass { NULL } [..] +static int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} Please move this function in sysdb.c, it's a generic function that can be used by multiple functions and here just interrupts reading the program flow. done +static void sysdb_delete_recursive_loop(struct tevent_req *subreq) [...] I think you should split the this function into a function that receives the results of sysdb_search_entry_recv() and then another one that sets the loop. If necessary use the trick I used in sdap_cli_connect to do continuation functions (see the sdap_cli_*_step functions). done The rest looks good to me. Thanks for reviewing. bye, Sumit sorry, this new patch fixes a compiler warning. Looks good to me, I have only a minor nitpick, shouldn't the ENOENT error in sysdb_delete_recursive_op_done() be fatal ? Given it should never happen, does it make sense to allow to continue ? Simo. -- Simo Sorce * Red Hat, Inc * New York ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel
Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Fri, Oct 30, 2009 at 05:42:10PM -0400, Simo Sorce wrote: On Fri, 2009-10-30 at 12:01 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 11:26:39PM +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 09:32:34PM +, Simo Sorce wrote: On Thu, 2009-10-29 at 19:40 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 01:39:21PM +0100, Sumit Bose wrote: Hi, this patch adds a recursive delete request to the sysdb API. It has the same interface as sysdb_delete_entry, but does not delete the entry, but its children. bye, Sumit This is a new version of the patch which tries to delete the entry AND all its children. It searches all objects with a subtree search, sorts the result so that the ones with the most components come first and finally loops over the results and deletes them. Comments inline. + +subreq = sysdb_search_entry_send(state, ev, handle, dn, LDB_SCOPE_SUBTREE, + distinguishedName=*, NULL); Please use (objectclass=*) as filter to catch all entries. I would prefer to stay with distinguishedName, because it is auto-generated and always present. Also please set attrs. Passing NULL, means you will retrieve all attributes wasting a lot of memory unnecessarily. You are interested only in the entries msg-dn, so you probably do not want any attribute returned at all. ah, I thought NULL means nothing, now I pass { NULL } [..] +static int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} Please move this function in sysdb.c, it's a generic function that can be used by multiple functions and here just interrupts reading the program flow. done +static void sysdb_delete_recursive_loop(struct tevent_req *subreq) [...] I think you should split the this function into a function that receives the results of sysdb_search_entry_recv() and then another one that sets the loop. If necessary use the trick I used in sdap_cli_connect to do continuation functions (see the sdap_cli_*_step functions). done The rest looks good to me. Thanks for reviewing. bye, Sumit sorry, this new patch fixes a compiler warning. Looks good to me, I have only a minor nitpick, shouldn't the ENOENT error in sysdb_delete_recursive_op_done() be fatal ? Given it should never happen, does it make sense to allow to continue ? Simo. ok, it is now fatal as all other errors bye, Sumit From de69fe0de87ede1acabc37a94070a2f932a3ea00 Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 29 Oct 2009 12:57:57 +0100 Subject: [PATCH] add sysdb_delete_recursive request to sysdb API --- server/db/sysdb.c | 12 server/db/sysdb.h | 10 +++ server/db/sysdb_ops.c | 152 server/tests/sysdb-tests.c | 111 +++- 4 files changed, 281 insertions(+), 4 deletions(-) diff --git a/server/db/sysdb.c b/server/db/sysdb.c index 5811ddc..a2ac3b2 100644 --- a/server/db/sysdb.c +++ b/server/db/sysdb.c @@ -1417,3 +1417,15 @@ int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list, /* definitely not found */ return ENOENT; } + + +int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(void **) discard_const(m1), + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(void **) discard_const(m2), + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} + diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 00a3378..72f56db 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -190,6 +190,8 @@ struct ldb_dn *sysdb_custom_dn(struct sysdb_ctx *ctx, void *memctx, struct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *ctx); struct ldb_context *sysdb_handle_get_ldb(struct sysdb_handle *handle); +int compare_ldb_dn_comp_num(const void *m1, const void *m2); + /* function to start and finish a transaction * sysdb_transaction_send() will queue a request for a transaction * when it is done it will call the tevent_req callback, which must @@ -311,6 +313,14 @@ struct tevent_req *sysdb_delete_entry_send(TALLOC_CTX *mem_ctx, bool
Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Thu, Oct 29, 2009 at 01:39:21PM +0100, Sumit Bose wrote: Hi, this patch adds a recursive delete request to the sysdb API. It has the same interface as sysdb_delete_entry, but does not delete the entry, but its children. bye, Sumit This is a new version of the patch which tries to delete the entry AND all its children. It searches all objects with a subtree search, sorts the result so that the ones with the most components come first and finally loops over the results and deletes them. bye, Sumit From 0f087f921f5f3e26557049a25822c6183efcad91 Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 29 Oct 2009 12:57:57 +0100 Subject: [PATCH] add sysdb_delete_recursive request to sysdb API --- server/db/sysdb.h |8 +++ server/db/sysdb_ops.c | 145 server/tests/sysdb-tests.c | 111 - 3 files changed, 260 insertions(+), 4 deletions(-) diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 00a3378..fcb8e5a 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -311,6 +311,14 @@ struct tevent_req *sysdb_delete_entry_send(TALLOC_CTX *mem_ctx, bool ignore_not_found); int sysdb_delete_entry_recv(struct tevent_req *req); + +struct tevent_req *sysdb_delete_recursive_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct sysdb_handle *handle, + struct ldb_dn *dn, + bool ignore_not_found); +int sysdb_delete_recursive_recv(struct tevent_req *req); + /* Search Entry */ struct tevent_req *sysdb_search_entry_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c index acff5e5..882ef45 100644 --- a/server/db/sysdb_ops.c +++ b/server/db/sysdb_ops.c @@ -300,6 +300,151 @@ int sysdb_delete_entry_recv(struct tevent_req *req) } +/* =Remove-Subentries-From-Sysdb=== */ + +struct sysdb_delete_recursive_state { +struct tevent_context *ev; +struct sysdb_handle *handle; + +bool ignore_not_found; + +struct ldb_reply *ldbreply; +size_t msgs_count; +struct ldb_message **msgs; +size_t current_item; +}; + +static void sysdb_delete_recursive_loop(struct tevent_req *subreq); + +struct tevent_req *sysdb_delete_recursive_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct sysdb_handle *handle, + struct ldb_dn *dn, + bool ignore_not_found) +{ +struct tevent_req *req, *subreq; +struct sysdb_delete_recursive_state *state; +int ret; + +req = tevent_req_create(mem_ctx, state, +struct sysdb_delete_recursive_state); +if (!req) return NULL; + +state-ev = ev; +state-handle = handle; +state-ignore_not_found = ignore_not_found; +state-ldbreply = NULL; +state-msgs_count = 0; +state-msgs = NULL; +state-current_item = 0; + +subreq = sysdb_search_entry_send(state, ev, handle, dn, LDB_SCOPE_SUBTREE, + distinguishedName=*, NULL); + +if (!subreq) { +ERROR_OUT(ret, ENOMEM, fail); +} +tevent_req_set_callback(subreq, sysdb_delete_recursive_loop, req); + +return req; + +fail: +DEBUG(6, (Error: %d (%s)\n, ret, strerror(ret))); +tevent_req_error(req, ret); +tevent_req_post(req, ev); +return req; +} + +static int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} + +static void sysdb_delete_recursive_loop(struct tevent_req *subreq) +{ +struct tevent_req *req = tevent_req_callback_data(subreq, + struct tevent_req); +struct sysdb_delete_recursive_state *state = tevent_req_data(req, + struct sysdb_delete_recursive_state); +int ret; +struct ldb_request *ldbreq; + +if (state-current_item == 0) { +ret = sysdb_search_entry_recv(subreq, state, state-msgs_count, + state-msgs); +talloc_zfree(subreq); +if (ret) { +if (state-ignore_not_found ret == ENOENT) { +tevent_req_done(req); +} +DEBUG(6, (Search error: %d
Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Thu, 2009-10-29 at 19:40 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 01:39:21PM +0100, Sumit Bose wrote: Hi, this patch adds a recursive delete request to the sysdb API. It has the same interface as sysdb_delete_entry, but does not delete the entry, but its children. bye, Sumit This is a new version of the patch which tries to delete the entry AND all its children. It searches all objects with a subtree search, sorts the result so that the ones with the most components come first and finally loops over the results and deletes them. Comments inline. From 0f087f921f5f3e26557049a25822c6183efcad91 Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 29 Oct 2009 12:57:57 +0100 Subject: [PATCH] add sysdb_delete_recursive request to sysdb API --- server/db/sysdb.h |8 +++ server/db/sysdb_ops.c | 145 server/tests/sysdb-tests.c | 111 - 3 files changed, 260 insertions(+), 4 deletions(-) diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 00a3378..fcb8e5a 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -311,6 +311,14 @@ struct tevent_req *sysdb_delete_entry_send(TALLOC_CTX *mem_ctx, bool ignore_not_found); int sysdb_delete_entry_recv(struct tevent_req *req); + +struct tevent_req *sysdb_delete_recursive_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct sysdb_handle *handle, + struct ldb_dn *dn, + bool ignore_not_found); +int sysdb_delete_recursive_recv(struct tevent_req *req); + /* Search Entry */ struct tevent_req *sysdb_search_entry_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c index acff5e5..882ef45 100644 --- a/server/db/sysdb_ops.c +++ b/server/db/sysdb_ops.c @@ -300,6 +300,151 @@ int sysdb_delete_entry_recv(struct tevent_req *req) } +/* =Remove-Subentries-From-Sysdb=== */ + +struct sysdb_delete_recursive_state { +struct tevent_context *ev; +struct sysdb_handle *handle; + +bool ignore_not_found; + +struct ldb_reply *ldbreply; +size_t msgs_count; +struct ldb_message **msgs; +size_t current_item; +}; + +static void sysdb_delete_recursive_loop(struct tevent_req *subreq); + +struct tevent_req *sysdb_delete_recursive_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct sysdb_handle *handle, + struct ldb_dn *dn, + bool ignore_not_found) +{ +struct tevent_req *req, *subreq; +struct sysdb_delete_recursive_state *state; +int ret; + +req = tevent_req_create(mem_ctx, state, +struct sysdb_delete_recursive_state); +if (!req) return NULL; + +state-ev = ev; +state-handle = handle; +state-ignore_not_found = ignore_not_found; +state-ldbreply = NULL; +state-msgs_count = 0; +state-msgs = NULL; +state-current_item = 0; + +subreq = sysdb_search_entry_send(state, ev, handle, dn, LDB_SCOPE_SUBTREE, + distinguishedName=*, NULL); Please use (objectclass=*) as filter to catch all entries. Also please set attrs. Passing NULL, means you will retrieve all attributes wasting a lot of memory unnecessarily. You are interested only in the entries msg-dn, so you probably do not want any attribute returned at all. [..] +static int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} Please move this function in sysdb.c, it's a generic function that can be used by multiple functions and here just interrupts reading the program flow. +static void sysdb_delete_recursive_loop(struct tevent_req *subreq) [...] I think you should split the this function into a function that receives the results of sysdb_search_entry_recv() and then another one that sets the loop. If necessary use the trick I used in sdap_cli_connect to do continuation functions (see the sdap_cli_*_step functions). The rest looks good to me. Simo. -- Simo Sorce * Red Hat, Inc * New York
Re: [SSSD] [PATCH] add sysdb_delete_recursive request to sysdb API
On Thu, Oct 29, 2009 at 09:32:34PM +, Simo Sorce wrote: On Thu, 2009-10-29 at 19:40 +0100, Sumit Bose wrote: On Thu, Oct 29, 2009 at 01:39:21PM +0100, Sumit Bose wrote: Hi, this patch adds a recursive delete request to the sysdb API. It has the same interface as sysdb_delete_entry, but does not delete the entry, but its children. bye, Sumit This is a new version of the patch which tries to delete the entry AND all its children. It searches all objects with a subtree search, sorts the result so that the ones with the most components come first and finally loops over the results and deletes them. Comments inline. + +subreq = sysdb_search_entry_send(state, ev, handle, dn, LDB_SCOPE_SUBTREE, + distinguishedName=*, NULL); Please use (objectclass=*) as filter to catch all entries. I would prefer to stay with distinguishedName, because it is auto-generated and always present. Also please set attrs. Passing NULL, means you will retrieve all attributes wasting a lot of memory unnecessarily. You are interested only in the entries msg-dn, so you probably do not want any attribute returned at all. ah, I thought NULL means nothing, now I pass { NULL } [..] +static int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} Please move this function in sysdb.c, it's a generic function that can be used by multiple functions and here just interrupts reading the program flow. done +static void sysdb_delete_recursive_loop(struct tevent_req *subreq) [...] I think you should split the this function into a function that receives the results of sysdb_search_entry_recv() and then another one that sets the loop. If necessary use the trick I used in sdap_cli_connect to do continuation functions (see the sdap_cli_*_step functions). done The rest looks good to me. Thanks for reviewing. bye, Sumit Simo. -- Simo Sorce * Red Hat, Inc * New York From 693c4cc20d13a53340c9ffccfb165ffa8e57af2c Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 29 Oct 2009 12:57:57 +0100 Subject: [PATCH] add sysdb_delete_recursive request to sysdb API --- server/db/sysdb.c | 12 +++ server/db/sysdb.h | 10 +++ server/db/sysdb_ops.c | 159 server/tests/sysdb-tests.c | 111 +- 4 files changed, 288 insertions(+), 4 deletions(-) diff --git a/server/db/sysdb.c b/server/db/sysdb.c index 5811ddc..1df3f77 100644 --- a/server/db/sysdb.c +++ b/server/db/sysdb.c @@ -1417,3 +1417,15 @@ int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list, /* definitely not found */ return ENOENT; } + + +int compare_ldb_dn_comp_num(const void *m1, const void *m2) +{ +struct ldb_message *msg1 = talloc_get_type(*(const void **) m1, + struct ldb_message); +struct ldb_message *msg2 = talloc_get_type(*(const void **) m2, + struct ldb_message); + +return ldb_dn_get_comp_num(msg2-dn) - ldb_dn_get_comp_num(msg1-dn); +} + diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 00a3378..72f56db 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -190,6 +190,8 @@ struct ldb_dn *sysdb_custom_dn(struct sysdb_ctx *ctx, void *memctx, struct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *ctx); struct ldb_context *sysdb_handle_get_ldb(struct sysdb_handle *handle); +int compare_ldb_dn_comp_num(const void *m1, const void *m2); + /* function to start and finish a transaction * sysdb_transaction_send() will queue a request for a transaction * when it is done it will call the tevent_req callback, which must @@ -311,6 +313,14 @@ struct tevent_req *sysdb_delete_entry_send(TALLOC_CTX *mem_ctx, bool ignore_not_found); int sysdb_delete_entry_recv(struct tevent_req *req); + +struct tevent_req *sysdb_delete_recursive_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct sysdb_handle *handle, + struct ldb_dn *dn, + bool ignore_not_found); +int sysdb_delete_recursive_recv(struct tevent_req *req); + /* Search Entry */ struct tevent_req *sysdb_search_entry_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/server/db/sysdb_ops.c