Impossible to use method search_s in BaseLdap if attribute 'page_size' is not 0.

Bug #1305056 reported by Sergey Nikitin
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Sergey Nikitin

Bug Description

/opt/stack/keystone/keystone/common/ldap/core.py #493-520

def search_s(self, base, scope,
                 filterstr='(objectClass=*)', attrlist=None, attrsonly=0):
        # NOTE(morganfainberg): Remove "None" singletons from this list, which
        # allows us to set mapped attributes to "None" as defaults in config.
        # Without this filtering, the ldap query would raise a TypeError since
        # attrlist is expected to be an iterable of strings.
        if attrlist is not None:
            attrlist = [attr for attr in attrlist if attr is not None]
        LOG.debug('LDAP search: base=%s scope=%s filterstr=%s '
                  'attrs=%s attrsonly=%s',
                  base, scope, filterstr, attrlist, attrsonly)
        if self.page_size:
            ldap_result = self._paged_search_s(base, scope,
                                               filterstr, attrlist)
        else:
            base_utf8 = utf8_encode(base)
            filterstr_utf8 = utf8_encode(filterstr)
            if attrlist is None:
                attrlist_utf8 = None
            else:
                attrlist_utf8 = map(utf8_encode, attrlist)
            ldap_result = self.conn.search_s(base_utf8, scope,
                                             filterstr_utf8,
                                             attrlist_utf8, attrsonly)

            py_result = convert_ldap_result(ldap_result)

        return py_result

Variable 'py_result' can be not initialized if self.page_size > 0 because it's initialized only in the 'else' block.

Changed in keystone:
assignee: nobody → Sergey Nikitin (snikitin)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/86325

Changed in keystone:
status: New → In Progress
Revision history for this message
Dolph Mathews (dolph) wrote :

This doesn't appear to be an issue in milestone-proposed (icehouse)

Changed in keystone:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/86325
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=a9d4e59e86d7d4502b714c407a37418799f85005
Submitter: Jenkins
Branch: master

commit a9d4e59e86d7d4502b714c407a37418799f85005
Author: Sergey Nikitin <email address hidden>
Date: Wed Apr 9 17:27:28 2014 +0400

    Fixed wrong behavior in method search_s in BaseLdap class.

    Variable 'py_result' can be not initialized if self.page_size > 0
    because it's initialized only in the 'else' block.

    Closes bug 1305056
    Change-Id: Ib9cfb2c03279d97ec0c1a4f8cb45fe5b568b9d7a

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
milestone: none → juno-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: juno-1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.