Re: [Freeipa-devel] [PATCH] Notify user when deleting nonexistent user or group

2009-07-31 Thread Stephen Gallagher
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 07/31/2009 11:55 AM, Stephen Gallagher wrote:
 On 07/31/2009 06:02 AM, Jakub Hrozek wrote:
 On 07/30/2009 08:45 PM, Stephen Gallagher wrote:
 I'm going to nack the user notification patch. I think we need to think
 some more about this. The sysdb has an interface in place for returning
 ENOENT when trying to delete, we're just setting it
 state-ignore_not_found = true; in sysdb_delete_entry_send().
 I think the correct thing to do would be to modify that function so that
 it accepted a boolean value for whether or not to ignore it if it's not
 found.
 This way, we aren't doing an extra search.
 I agree, I didn't realize there was this option. Thanks for the review.
 
 Attached are three patches:
 * [PATCH 1/3] Add ignore_not_found parameter to sysdb delete functions
 changes the sysdb API, its invocations in the code and adds a test for
 the change
 * [PATCH 2/3] Use correct return codes
 The already-acked patch, included for clarity
 * [PATCH 3/3] Notify user when deleting nonexistent user or group
 Changes tools code to react with appropriate error message to ENOENT
 
  Jakub
 
 Ack to all three.
 
 
 ___
 Freeipa-devel mailing list
 Freeipa-devel@redhat.com
 https://www.redhat.com/mailman/listinfo/freeipa-devel
 
 

Pushed to master.
___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


- -- 
Stephen Gallagher
RHCE 804006346421761

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkpzF1sACgkQeiVVYja6o6OXNgCeJOL/NqEGHo2CGH52w6JtvDqF
Cb4AniNz+VPRX+wpAqFzfSLZN7lSzaBX
=Md5I
-END PGP SIGNATURE-

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] Notify user when deleting nonexistent user or group

2009-07-30 Thread Jakub Hrozek
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 07/30/2009 06:50 PM, Jakub Hrozek wrote:
 Before a deletion, search the sysdb for the entity and error
 out if it cannot be found.
 
 Fixes: RHBZ #513247, RHBZ #513250
 
   Jakub

This patch did conflict with the return codes patch. Attached are
rebased versions that can be applied on top of one another.

Jakub
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkpx2gwACgkQHsardTLnvCXRRACgvl0bHJxnwE4ppviWFVpanbHK
z/QAmwSILZVA0Gd+w9sAyLGY8h4XmROb
=BaJy
-END PGP SIGNATURE-
From 6a6313dba7c0d0dc2f6d53f0f46e2ed5058d839f Mon Sep 17 00:00:00 2001
From: Jakub Hrozek jhro...@redhat.com
Date: Thu, 30 Jul 2009 18:03:47 +0200
Subject: [PATCH 1/2] Use correct return codes

Some code paths that should exit with an error used potentionally
incorrect return code.
---
 server/tools/sss_groupdel.c |2 +-
 server/tools/sss_groupmod.c |2 +-
 server/tools/sss_userdel.c  |2 +-
 server/tools/sss_usermod.c  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/server/tools/sss_groupdel.c b/server/tools/sss_groupdel.c
index 98d73c3..2977826 100644
--- a/server/tools/sss_groupdel.c
+++ b/server/tools/sss_groupdel.c
@@ -99,7 +99,7 @@ static void group_del(struct tevent_req *req)
 
 subreq = sysdb_delete_entry_send(data, data-ev, data-handle, group_dn);
 if (!subreq)
-return groupdel_done(data, ret, NULL);
+return groupdel_done(data, ENOMEM, NULL);
 
 tevent_req_set_callback(subreq, group_del_done, data);
 }
diff --git a/server/tools/sss_groupmod.c b/server/tools/sss_groupmod.c
index 2fc6f9d..a7fec43 100644
--- a/server/tools/sss_groupmod.c
+++ b/server/tools/sss_groupmod.c
@@ -114,7 +114,7 @@ static void mod_group(struct tevent_req *req)
data-domain, data-name,
attrs, SYSDB_MOD_REP);
 if (!subreq) {
-return mod_group_done(data, ret);
+return mod_group_done(data, ENOMEM);
 }
 tevent_req_set_callback(subreq, mod_group_attr_done, data);
 return;
diff --git a/server/tools/sss_userdel.c b/server/tools/sss_userdel.c
index f70482c..c4d9abd 100644
--- a/server/tools/sss_userdel.c
+++ b/server/tools/sss_userdel.c
@@ -100,7 +100,7 @@ static void user_del(struct tevent_req *req)
 
 subreq = sysdb_delete_entry_send(data, data-ev, data-handle, user_dn);
 if (!subreq)
-return userdel_done(data, ret, NULL);
+return userdel_done(data, ENOMEM, NULL);
 
 tevent_req_set_callback(subreq, user_del_done, data);
 }
diff --git a/server/tools/sss_usermod.c b/server/tools/sss_usermod.c
index 6ef873b..7237f0b 100644
--- a/server/tools/sss_usermod.c
+++ b/server/tools/sss_usermod.c
@@ -140,7 +140,7 @@ static void mod_user(struct tevent_req *req)
   data-domain, data-name,
   data-attrs, SYSDB_MOD_REP);
 if (!subreq) {
-return mod_user_done(data, ret);
+return mod_user_done(data, ENOMEM);
 }
 tevent_req_set_callback(subreq, mod_user_attr_done, data);
 return;
-- 
1.6.2.5

From 25aebdd052af4269afa511719d86009ff0455162 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek jhro...@redhat.com
Date: Thu, 30 Jul 2009 11:40:08 +0200
Subject: [PATCH 2/2] Notify user when deleting nonexistent user or group

Before a deletion, search the sysdb for the entity and error
out if it cannot be found.

Fixes: RHBZ #513247, RHBZ #513250
---
 server/tools/sss_groupdel.c |   42 ++-
 server/tools/sss_userdel.c  |   45 +++---
 server/tools/tools_util.h   |1 +
 3 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/server/tools/sss_groupdel.c b/server/tools/sss_groupdel.c
index 2977826..be35053 100644
--- a/server/tools/sss_groupdel.c
+++ b/server/tools/sss_groupdel.c
@@ -77,12 +77,12 @@ fail:
 }
 
 static void group_del_done(struct tevent_req *subreq);
+static void group_search_done(struct tevent_req *subreq);
 
 static void group_del(struct tevent_req *req)
 {
 struct ops_ctx *data = tevent_req_callback_data(req, struct ops_ctx);
 struct tevent_req *subreq;
-struct ldb_dn *group_dn;
 int ret;
 
 ret = sysdb_transaction_recv(req, data, data-handle);
@@ -90,18 +90,40 @@ static void group_del(struct tevent_req *req)
 return groupdel_done(data, ret, NULL);
 }
 
-group_dn = sysdb_group_dn(data-ctx-sysdb, data,
+data-dn = sysdb_group_dn(data-ctx-sysdb, data,
   data-domain-name, data-name);
-if (group_dn == NULL) {
+if (data-dn == NULL) {
 DEBUG(1, (Could not construct a group DN\n));
 return groupdel_done(data, ENOMEM, NULL);
 }
 
-subreq = sysdb_delete_entry_send(data, data-ev, data-handle,