If an empty member list was passed in we would crap out because we were trying to iterate over None. Add a test for this.

ticket 486

rob
>From 877d45f579b865d3f4ea3d17036c3a9e73e9f624 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Fri, 19 Nov 2010 14:56:25 -0500
Subject: [PATCH] Gracefully handle an empty members list

This can occur if you do something like:

$ ipa hbac-add-host --hosts="" testrule

options will have an entry for 'host' but it will be None whcih is
not iterable.

ticket 486
---
 ipalib/plugins/baseldap.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index e1c0ca2..79475a8 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -868,7 +868,10 @@ class LDAPModMember(LDAPQuery):
             for ldap_obj_name in self.obj.attribute_members[attr]:
                 dns[attr][ldap_obj_name] = []
                 failed[attr][ldap_obj_name] = []
-                for name in options.get(to_cli(ldap_obj_name), []):
+                names = options.get(to_cli(ldap_obj_name), [])
+                if not names:
+                    continue
+                for name in names:
                     if not name:
                         continue
                     ldap_obj = self.api.Object[ldap_obj_name]
-- 
1.7.2.1

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

Reply via email to