Thanks Jan.

Find the new patch attached.

Cheers,
Thorsten


On [Tue, 26.08.2014 18:19], Jan Cholasta wrote:
Hi,

Dne 26.8.2014 v 17:53 Thorsten Scherf napsal(a):
pwpolicy-add: Added better error handling
   Make error message more meaningful when a password policy is added
for a non
   existing group.
   https://fedorahosted.org/freeipa/ticket/4334

thanks for the patch.

Instead of raising NotFound manually, please use:

   self.api.Object.group.handle_not_found(keys[-1])

It raises NotFound as well, but automatically creates the error message.

Honza

--
Jan Cholasta
>From 57840cb4195f4f23134f5b7c899a4790d814d659 Mon Sep 17 00:00:00 2001
From: Thorsten Scherf <tsch...@redhat.com>
Date: Tue, 26 Aug 2014 19:21:29 +0200
Subject: [PATCH] pwpolicy-add: Added better error handling

    Make error message more meaningful when a password policy is added for a non
    existing group.

    https://fedorahosted.org/freeipa/ticket/4334
---
 ipalib/plugins/pwpolicy.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py
index 
1976675c56000cff14b211e115fda28105107c15..165d54889b016e95b3a4e805f79fc49a8b135228
 100644
--- a/ipalib/plugins/pwpolicy.py
+++ b/ipalib/plugins/pwpolicy.py
@@ -159,9 +159,14 @@ class cosentry_add(LDAPCreate):
 
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, 
**options):
         assert isinstance(dn, DN)
+        
         # check for existence of the group
         group_dn = self.api.Object.group.get_dn(keys[-1])
-        result = ldap.get_entry(group_dn, ['objectclass'])
+        try:
+            result = ldap.get_entry(group_dn, ['objectclass'])
+        except errors.NotFound:
+            self.api.Object.group.handle_not_found(keys[-1]) 
+
         oc = map(lambda x:x.lower(),result['objectclass'])
         if 'mepmanagedentry' in oc:
             raise errors.ManagedPolicyError()
-- 
1.9.3

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

Reply via email to