[Freeipa-devel] [PATCH] 0139 trustdomain_find: make sure we skip short entries when --pkey-only is specified
Alexander Bokovoy
abokovoy at redhat.com
Wed Feb 26 16:03:36 UTC 2014
On Wed, 26 Feb 2014, Martin Kosek wrote:
>On 02/25/2014 06:56 PM, Alexander Bokovoy wrote:
>> Hi,
>>
>> Simple patch to fix KeyError as --pkey-only causes no attributes to be
>> returned and trustdomain_find.post_callback checked them
>> unconditionally.
>>
>>
>> https://fedorahosted.org/freeipa/ticket/4196
>
>Can we simply skip the whole loop when options.get('pkey_only', False)? I.e.:
>
> def post_callback(self, ldap, entries, truncated, *args, **options):
> if not options.get('pkey_only', False):
> trust_dn = self.obj.get_dn(args[0], trust_type=u'ad')
> trust_entry = ldap.get_entry(trust_dn)
> ...
>
>It seems to me that your way we still do one unnecessary LDAP search which is
>never used. With pkey_only we should not be filling anything in post_callback
>at all if it is not affecting the pkey.
Right, new patch attached.
--
/ Alexander Bokovoy
-------------- next part --------------
>From d6cc7f93bffcd6fd2be9f34c0aad0bb06b88c8d7 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <abokovoy at redhat.com>
Date: Wed, 26 Feb 2014 17:59:05 +0200
Subject: [PATCH 7/7] trustdomain_find: make sure we skip short entries when
--pkey-only is specified
With --pkey-only only primary key is returned. It makes no sense to check and
replace boolean values then.
https://fedorahosted.org/freeipa/ticket/4196
---
ipalib/plugins/trust.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py
index 0b6db27..353c6c7 100644
--- a/ipalib/plugins/trust.py
+++ b/ipalib/plugins/trust.py
@@ -1191,6 +1191,8 @@ class trustdomain_find(LDAPSearch):
return (filters, base_dn, ldap.SCOPE_SUBTREE)
def post_callback(self, ldap, entries, truncated, *args, **options):
+ if options.get('pkey_only', False):
+ return
trust_dn = self.obj.get_dn(args[0], trust_type=u'ad')
trust_entry = ldap.get_entry(trust_dn)
for entry in entries:
--
1.8.3.1
More information about the Freeipa-devel
mailing list