Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve tuples for ldap modification operations #48258

Merged
merged 1 commit into from
Jun 22, 2018

Conversation

nullify005
Copy link
Contributor

@nullify005 nullify005 commented Jun 22, 2018

What does this PR do?

Preserves the tuples which are passed into the decoding method for ldap modify operations

What issues does this PR fix or reference?

Fixes #46887 (comment)

Specifically:

          ID: slapd suffix
    Function: ldap.managed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1905, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1830, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/ldap.py", line 334, in managed
                  __salt__['ldap3.add'](l, dn, n)
                File "/usr/lib/python2.7/dist-packages/salt/modules/ldap3.py", line 417, in add
                  l.c.add_s(dn, modlist)
                File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 209, in add_s
                  msgid = self.add(dn,modlist)
                File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 206, in add
                  return self.add_ext(dn,modlist,None,None)
                File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 191, in add_ext
                  return self._ldap_call(self._l.add_ext,dn,modlist,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
                File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 106, in _ldap_call
                  result = func(*args,**kwargs)
              TypeError: ('expected a tuple', ['objectClass', ['top', 'dcObject', 'organization']])
     Started: 03:49:06.574923
    Duration: 7.598 ms
     Changes: 

Which I traced to this in modules/ldap3.py before & after the utils.data.decode:

[DEBUG   ] ====> modlist before: [(0, u'olcRootPW', [u'{SSHA}whatever'])]
[DEBUG   ] ====> modlist after: [[0, 'olcRootPW', ['{SSHA}whatever']]]

Notice that the inner tuple gets converted to a list which the underlying ldap library isn't fond of

Turning on preserve_tuples fixes the issue

Previous Behavior

ldap modify operations fail

New Behavior

ldap modify operations succeed

Tests written?

No

Commits signed with GPG?

No

@nullify005
Copy link
Contributor Author

Can we also get this backported to 2018.3 pretty please?

@ghost
Copy link

ghost commented Jun 22, 2018

FYI: Tested & approved, it fixes ldap entries creations & modifications.

@rallytime rallytime added the bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch label Jun 22, 2018
Copy link
Contributor

@terminalmage terminalmage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rallytime this needs a backport to 2018.3

EDIT: nvm I see you're already on top of it 😄

@rallytime
Copy link
Contributor

@nullify005 I am happy to backport this, but in the future, feel free to submit bug fixes to their appropriate branches. We will then merge them forward. You can learn more here if you're interested on how we manage this. :)

@rallytime rallytime merged commit 254f8fc into saltstack:develop Jun 22, 2018
@rallytime rallytime added ZZZ[Done]-back-ported-bf RETIRED The pull request has been back-ported to an older branch. and removed bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch labels Jun 25, 2018
rallytime pushed a commit that referenced this pull request Jun 25, 2018
xenophonf added a commit to irtnog/salt-states that referenced this pull request Oct 17, 2018
…18.3.3

The following PR fixes the `expected a tuple` error when modifying
LDAP objects:

saltstack/salt#48258

See also this issue:

saltstack/salt#46887
@importepeu importepeu mentioned this pull request Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ZZZ[Done]-back-ported-bf RETIRED The pull request has been back-ported to an older branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ldap.managed broken with 2018.3.0
3 participants