[Freeipa-devel] [PATCH] 0139 trustdomain_find: make sure we skip short entries when --pkey-only is specified

Alexander Bokovoy abokovoy at redhat.com
Thu Feb 27 10:06:54 UTC 2014


On Thu, 27 Feb 2014, Martin Kosek wrote:
>On 02/26/2014 05:03 PM, Alexander Bokovoy wrote:
>> 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.
>>
>
>It still crashes:
>
>[Thu Feb 27 04:55:51.245147 2014] [:error] [pid 3479] Traceback (most recent
>call last):
>[Thu Feb 27 04:55:51.245149 2014] [:error] [pid 3479]   File
>"/usr/lib/python2.7/site-packages/         ipaserver/rpcserver.py", line 333,
>in wsgi_execute
>[Thu Feb 27 04:55:51.245152 2014] [:error] [pid 3479]     result =
>self.Command[name](*args, **options)
>[Thu Feb 27 04:55:51.245155 2014] [:error] [pid 3479]   File
>"/usr/lib/python2.7/site-packages/ipalib/  frontend.py", line 447, in __call__
>[Thu Feb 27 04:55:51.245157 2014] [:error] [pid 3479]     self.validate_output(ret)
>[Thu Feb 27 04:55:51.245159 2014] [:error] [pid 3479]   File
>"/usr/lib/python2.7/site-packages/ipalib/  frontend.py", line 947, in
>validate_output
>[Thu Feb 27 04:55:51.245162 2014] [:error] [pid 3479]     nice, o.name, o.type,
>type(value), value)
>[Thu Feb 27 04:55:51.245164 2014] [:error] [pid 3479] TypeError:
>trustdomain_find.validate_output():
>[Thu Feb 27 04:55:51.245167 2014] [:error] [pid 3479]   output['truncated']:
>need <type 'bool'>; got
>
>
>You need to "return truncated", not just "return". When this is changed, patch
>works as expected.
Yep, thanks!

New patch attached.

-- 
/ Alexander Bokovoy
-------------- next part --------------
>From 78f01ada3f1cce43df7bfcc3647747e600d39c2f 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..bd71253 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 truncated
         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