Fixes https://fedorahosted.org/sssd/ticket/1728

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York
>From 7988a75e552918e164d0693c6c4de2a5c4a30db6 Mon Sep 17 00:00:00 2001
From: Simo Sorce <[email protected]>
Date: Tue, 18 Dec 2012 20:52:02 -0500
Subject: [PATCH] memberof: Prevent unneded failure case

When deleting a user we would fail the operation completely if the member
attribute was not found on one of the groups it was allegedly member of.
Failing in this case is unnecessary, and can cause issues.
Found trying to upgrade db versione (and failing) on one of my RHEL machines.
Also removed a tray \ in the companion function that removes ghost members,
that function needs no changes as it was already ignoring this kind of
failure.
---
 src/ldb_modules/memberof.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c
index 0f947fb06694e80d1fccf6392fbe3c87821adbeb..f7eeb4070748d4a4f517c44520f9a501dd48a245 100644
--- a/src/ldb_modules/memberof.c
+++ b/src/ldb_modules/memberof.c
@@ -2617,7 +2617,12 @@ static int mbof_del_muop_callback(struct ldb_request *req,
         return ldb_module_done(ctx->req, NULL, NULL,
                                LDB_ERR_OPERATIONS_ERROR);
     }
-    if (ares->error != LDB_SUCCESS) {
+    /* if the attribute was not present it means the db is not
+     * perfectly consistent but failing here is not useful
+     * anyway and missing entries cause no harm if we are trying
+     * to remove them anyway */
+    if (ares->error != LDB_SUCCESS &&
+        ares->error != LDB_ERR_NO_SUCH_ATTRIBUTE) {
         return ldb_module_done(ctx->req,
                                ares->controls,
                                ares->response,
@@ -2733,7 +2738,7 @@ static int mbof_del_ghop_callback(struct ldb_request *req,
      * might have been directly nested in the parent as well and
      * updated with another replace operation.
      */
-    if (ares->error != LDB_SUCCESS &&  \
+    if (ares->error != LDB_SUCCESS &&
         ares->error != LDB_ERR_NO_SUCH_ATTRIBUTE) {
         return ldb_module_done(ctx->req,
                                ares->controls,
-- 
1.8.0.1

_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to