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

Projects
None yet
4 participants
@nullify005
Contributor

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

This comment has been minimized.

Contributor

nullify005 commented Jun 22, 2018

Can we also get this backported to 2018.3 pretty please?

@julientravelaer

This comment has been minimized.

julientravelaer commented Jun 22, 2018

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

@terminalmage

terminalmage approved these changes Jun 22, 2018 edited

@rallytime this needs a backport to 2018.3

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

@rallytime

This comment has been minimized.

Contributor

rallytime commented Jun 22, 2018

@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

6 of 10 checks passed

jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #10917 — ABORTED
Details
default Build finished.
Details
jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #5947 — FAILURE
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #20000 — FAILURE
Details
WIP ready for review
Details
codeclimate All good!
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #26151 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #18201 — SUCCESS
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #23875 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #22836 — SUCCESS
Details

rallytime added 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

fix(salt.modules.ldap3): backport ldap3 execution modules fixes in 20…
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment