[packages/python-ldaptor] - added fixes and updates from various github forks
baggins
baggins at pld-linux.org
Tue Jan 7 21:34:12 CET 2014
commit 06f90a4b1226e1bd31208b9958932cf8da25299c
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Tue Jan 7 21:33:35 2014 +0100
- added fixes and updates from various github forks
abandon.patch | 133 ++++++++++++++++++++++++++++++++++++
deprecated-exception.patch | 36 ++++++++++
module-typo.patch | 25 +++++++
python-ldaptor.spec | 12 ++++
sasl.patch | 166 +++++++++++++++++++++++++++++++++++++++++++++
starttls-fix.patch | 34 ++++++++++
unicode.patch | 84 +++++++++++++++++++++++
7 files changed, 490 insertions(+)
---
diff --git a/python-ldaptor.spec b/python-ldaptor.spec
index 7f6a6dd..544b164 100644
--- a/python-ldaptor.spec
+++ b/python-ldaptor.spec
@@ -14,6 +14,12 @@ Source0: https://codeload.github.com/antong/ldaptor/tar.gz/%{githash}?/python-ld
Source1: global.cfg
Patch0: %{name}-remove-webui.patch
Patch1: %{name}-doc-paths.patch
+Patch2: deprecated-exception.patch
+Patch3: module-typo.patch
+Patch4: sasl.patch
+Patch5: starttls-fix.patch
+Patch6: unicode.patch
+Patch7: abandon.patch
URL: https://github.com/antong/ldaptor
BuildRequires: python-distribute
BuildRequires: rpm-pythonprov
@@ -70,6 +76,12 @@ rm -rf ldaptor/test/web/
rm -f ldaptor/test/test_webui.*
%patch0 -p1
%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
%build
%{__python} setup.py build
diff --git a/abandon.patch b/abandon.patch
new file mode 100644
index 0000000..d3c540d
--- /dev/null
+++ b/abandon.patch
@@ -0,0 +1,133 @@
+From 549f3b2e81735b11aa8c8ce80736772ed9ee36a2 Mon Sep 17 00:00:00 2001
+From: Stefan Andersson <norox81 at gmail.com>
+Date: Fri, 3 Feb 2012 11:41:26 +0100
+Subject: [PATCH] Add LDAPAbandonRequest Cherry picked
+ 893b8f9a1dbdb7229849a9bc506bb0fa46491a00 from norox.
+
+---
+ ldaptor/protocols/pureldap.py | 32 ++++++++++++++++++++++++++++++--
+ ldaptor/test/test_pureldap.py | 19 +++++++++++++++++++
+ 2 files changed, 49 insertions(+), 2 deletions(-)
+
+diff --git a/ldaptor/protocols/pureldap.py b/ldaptor/protocols/pureldap.py
+index 974293d..a332de1 100644
+--- a/ldaptor/protocols/pureldap.py
++++ b/ldaptor/protocols/pureldap.py
+@@ -41,6 +41,9 @@ def escape(s):
+ s = s.replace('\0', r'\00')
+ return s
+
++class LDAPInteger(BERInteger):
++ pass
++
+ class LDAPString(BEROctetString):
+ pass
+
+@@ -1121,9 +1124,33 @@ class LDAPModifyDNResponse(LDAPResult):
+
+ #class LDAPCompareResponse(LDAPProtocolResponse):
+ #class LDAPCompareRequest(LDAPProtocolRequest):
+-#class LDAPAbandonRequest(LDAPProtocolRequest):
+-# needs_answer=0
+
++class LDAPAbandonRequest(LDAPProtocolRequest, LDAPInteger):
++ tag = CLASS_APPLICATION|0x10
++ needs_answer=0
++
++ def __init__(self, value=None, id=None, tag=None):
++ """
++ Initialize the object
++
++ l=LDAPAbandonRequest(id=1)
++ """
++ if id is None and value is not None:
++ id = value
++ LDAPProtocolRequest.__init__(self)
++ LDAPInteger.__init__(self, value=id, tag=tag)
++
++ def __str__(self):
++ return LDAPInteger.__str__(self)
++
++ def __repr__(self):
++ if self.tag==self.__class__.tag:
++ return self.__class__.__name__+"(id=%s)" \
++ %repr(self.value)
++ else:
++ return self.__class__.__name__ \
++ +"(id=%s, tag=%d)" \
++ %(repr(self.value), self.tag)
+
+ class LDAPOID(BEROctetString):
+ pass
+@@ -1330,4 +1357,5 @@ class LDAPBERDecoderContext(BERDecoderContext):
+ LDAPExtendedResponse.tag: LDAPExtendedResponse,
+ LDAPModifyDNRequest.tag: LDAPModifyDNRequest,
+ LDAPModifyDNResponse.tag: LDAPModifyDNResponse,
++ LDAPAbandonRequest.tag: LDAPAbandonRequest,
+ }
+diff --git a/ldaptor/test/test_pureldap.py b/ldaptor/test/test_pureldap.py
+index 16a6843..869485c 100644
+--- a/ldaptor/test/test_pureldap.py
++++ b/ldaptor/test/test_pureldap.py
+@@ -546,6 +546,25 @@ class KnownValues(unittest.TestCase):
+ + l('foo'))
+ ),
+
++ (pureldap.LDAPExtendedRequest,
++ [],
++ {'requestName': '42.42.42',
++ 'requestValue': None,
++ },
++ None,
++ [0x40|0x20|23, 1+1+8]
++ + ([0x80|0]
++ + [len('42.42.42')]
++ + l('42.42.42'))
++ ),
++
++ (pureldap.LDAPAbandonRequest,
++ [],
++ {'id': 3},
++ None,
++ [0x40|0x10, 0x01, 3]
++ ),
++
+ (pureldap.LDAPBindRequest,
+ [],
+ {'auth': ('PLAIN', 'test'),
+--
+1.8.5.1
+
+From 4d5656fc1fd2a7456357eb1e504e08f55c361aba Mon Sep 17 00:00:00 2001
+From: Stefan Andersson <norox81 at gmail.com>
+Date: Mon, 30 Jan 2012 13:48:41 +0100
+Subject: [PATCH] requestValue is optional according to RFC 2251, make it so.
+ added unittest and changed assert
+
+Conflicts:
+
+ ldaptor/protocols/pureldap.py
+ ldaptor/test/test_pureldap.py
+---
+ ldaptor/protocols/pureldap.py | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/ldaptor/protocols/pureldap.py b/ldaptor/protocols/pureldap.py
+index a332de1..aa16138 100644
+--- a/ldaptor/protocols/pureldap.py
++++ b/ldaptor/protocols/pureldap.py
+@@ -1125,6 +1125,11 @@ class LDAPModifyDNResponse(LDAPResult):
+ #class LDAPCompareResponse(LDAPProtocolResponse):
+ #class LDAPCompareRequest(LDAPProtocolRequest):
+
++class LDAPBERDecoderContext_LDAPAbandonRequest(BERDecoderContext):
++ Identities = {
++ CLASS_CONTEXT|0x50: BEROctetString,
++ }
++
+ class LDAPAbandonRequest(LDAPProtocolRequest, LDAPInteger):
+ tag = CLASS_APPLICATION|0x10
+ needs_answer=0
+--
+1.8.5.1
+
diff --git a/deprecated-exception.patch b/deprecated-exception.patch
new file mode 100644
index 0000000..e829649
--- /dev/null
+++ b/deprecated-exception.patch
@@ -0,0 +1,36 @@
+From 9ae91b2ba8d7d215e43b98ab37006b2271d20d7c Mon Sep 17 00:00:00 2001
+From: davide colombo <dcolombo at davec.(none)>
+Date: Fri, 18 Feb 2011 12:16:51 +0100
+Subject: [PATCH] Fix deprecated exception error
+
+---
+ ldaptor/protocols/ldap/ldaperrors.py | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/ldaptor/protocols/ldap/ldaperrors.py b/ldaptor/protocols/ldap/ldaperrors.py
+index ef609a3..b56d688 100644
+--- a/ldaptor/protocols/ldap/ldaperrors.py
++++ b/ldaptor/protocols/ldap/ldaperrors.py
+@@ -39,6 +39,11 @@ def __init__(self, msg):
+ pass
+
+ class LDAPException(Exception, LDAPResult):
++
++ def _get_message(self): return self.__message
++ def _set_message(self, value): self.__message = value
++ message = property(_get_message, _set_message)
++
+ def __init__(self, message=None):
+ Exception.__init__(self)
+ self.message=message
+@@ -52,7 +57,6 @@ def __str__(self):
+ else:
+ return 'Unknown LDAP error %r' % self
+
+-
+ class LDAPUnknownError(LDAPException):
+ resultCode=None
+
+--
+1.8.5.1
+
diff --git a/module-typo.patch b/module-typo.patch
new file mode 100644
index 0000000..450501c
--- /dev/null
+++ b/module-typo.patch
@@ -0,0 +1,25 @@
+From 43af9e185728ae3a006cbdea33d41f099f80c45f Mon Sep 17 00:00:00 2001
+From: Edmund Jorgensen <tomheon at gmail.com>
+Date: Tue, 22 May 2012 17:17:08 -0400
+Subject: [PATCH] Fix typo in module name: pureldap -> pureber.
+
+---
+ ldaptor/protocols/ldap/ldapserver.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ldaptor/protocols/ldap/ldapserver.py b/ldaptor/protocols/ldap/ldapserver.py
+index 38ae55c..1512827 100644
+--- a/ldaptor/protocols/ldap/ldapserver.py
++++ b/ldaptor/protocols/ldap/ldapserver.py
+@@ -43,7 +43,7 @@ def dataReceived(self, recd):
+ while 1:
+ try:
+ o, bytes=pureber.berDecodeObject(self.berdecoder, self.buffer)
+- except pureldap.BERExceptionInsufficientData: #TODO
++ except pureber.BERExceptionInsufficientData: #TODO
+ o, bytes=None, 0
+ self.buffer = self.buffer[bytes:]
+ if o is None:
+--
+1.8.5.1
+
diff --git a/sasl.patch b/sasl.patch
new file mode 100644
index 0000000..aa78bbb
--- /dev/null
+++ b/sasl.patch
@@ -0,0 +1,166 @@
+From f7440e50350710c0355f33d766f2ac10df8f5fd6 Mon Sep 17 00:00:00 2001
+From: Adam Goodman <akgood at garglezomper7.local>
+Date: Tue, 21 Jun 2011 16:04:22 -0400
+Subject: [PATCH] added very basic, low-level support for SASL credentials in
+ the pureldap module
+
+When constructing an LDAPBindRequest, now you can pass 'sasl=True' to
+indicate you're providing SASL, rather than plain, credentials. Then,
+provide the 'auth' parameter as a tuple of (mechanism,
+credentials). For example, if constructing a bind request for an
+Active Directory server, you might do something like:
+
+LDAPBindRequest(dn=..., auth=('GSS-SPNEGO', 'NTLMSSP...'), sasl=True)
+
+(note that 'NTLMSSP' begins an NTLM Negotiate Message)
+
+Also, when parsing server responses (e.g. LDAPBindResponse), the
+serverSaslCreds field will be populated if appropriate.
+
+None of this is exposed in the higher-level interfaces
+(e.g. LDAPClient) yet.
+---
+ ldaptor/protocols/pureldap.py | 47 +++++++++++++++++++++++++++++--------------
+ ldaptor/test/test_pureldap.py | 9 +++++++++
+ 2 files changed, 41 insertions(+), 15 deletions(-)
+
+diff --git a/ldaptor/protocols/pureldap.py b/ldaptor/protocols/pureldap.py
+index 3db3b4c..985fe7f 100644
+--- a/ldaptor/protocols/pureldap.py
++++ b/ldaptor/protocols/pureldap.py
+@@ -115,6 +115,7 @@ class LDAPProtocolResponse(LDAPProtocolOp):
+ class LDAPBERDecoderContext_LDAPBindRequest(BERDecoderContext):
+ Identities = {
+ CLASS_CONTEXT|0x00: BEROctetString,
++ CLASS_CONTEXT|0x03: BERSequence,
+ }
+
+ class LDAPBindRequest(LDAPProtocolRequest, BERSequence):
+@@ -125,14 +126,28 @@ def fromBER(klass, tag, content, berdecoder=None):
+ LDAPBERDecoderContext_LDAPBindRequest(
+ fallback=berdecoder))
+
++ sasl = False
++ auth = None
++ if isinstance(l[2], BEROctetString):
++ auth = l[2].value
++ elif isinstance(l[2], BERSequence):
++ auth = (l[2][0].value, l[2][1].value)
++ sasl = True
++
+ r = klass(version=l[0].value,
+ dn=l[1].value,
+- auth=l[2].value,
+- tag=tag)
++ auth=auth,
++ tag=tag,
++ sasl=sasl)
+ return r
+ fromBER = classmethod(fromBER)
+
+- def __init__(self, version=None, dn=None, auth=None, tag=None):
++ def __init__(self, version=None, dn=None, auth=None, tag=None, sasl=False):
++ """Constructor for LDAP Bind Request
++
++ For sasl=False, pass a string password for 'auth'
++ For sasl=True, pass a tuple of (mechanism, credentials) for 'auth'"""
++
+ LDAPProtocolRequest.__init__(self)
+ BERSequence.__init__(self, [], tag=tag)
+ self.version=version
+@@ -144,12 +159,18 @@ def __init__(self, version=None, dn=None, auth=None, tag=None):
+ self.auth=auth
+ if self.auth is None:
+ self.auth=''
++ assert(not sasl)
++ self.sasl=sasl
+
+ def __str__(self):
++ if not self.sasl:
++ auth_ber = BEROctetString(self.auth, tag=CLASS_CONTEXT|0)
++ else:
++ auth_ber = BERSequence([BEROctetString(self.auth[0]), BEROctetString(self.auth[1])], tag=CLASS_CONTEXT|3)
+ return str(BERSequence([
+ BERInteger(self.version),
+ BEROctetString(self.dn),
+- BEROctetString(self.auth, tag=CLASS_CONTEXT|0),
++ auth_ber,
+ ], tag=self.tag))
+
+ def __repr__(self):
+@@ -159,10 +180,9 @@ def __repr__(self):
+ l.append('auth=%s' % repr(self.auth))
+ if self.tag!=self.__class__.tag:
+ l.append('tag=%d' % self.tag)
++ l.append('sasl=%s' % repr(self.sasl))
+ return self.__class__.__name__+'('+', '.join(l)+')'
+
+-
+-
+ class LDAPReferral(BERSequence):
+ tag = CLASS_CONTEXT | 0x03
+
+@@ -242,8 +262,8 @@ def __repr__(self):
+ l.append('tag=%d' % self.tag)
+ return self.__class__.__name__+'('+', '.join(l)+')'
+
+-class LDAPBindResponse_serverSaslCreds(BERSequence):
+- tag = CLASS_CONTEXT|0x03
++class LDAPBindResponse_serverSaslCreds(BEROctetString):
++ tag = CLASS_CONTEXT|0x07
+
+ pass
+
+@@ -268,9 +288,8 @@ def fromBER(klass, tag, content, berdecoder=None):
+ assert 3<=len(l)<=4
+
+ try:
+- if isinstance(l[0], LDAPBindResponse_serverSaslCreds):
+- serverSaslCreds=l[0]
+- del l[0]
++ if isinstance(l[3], LDAPBindResponse_serverSaslCreds):
++ serverSaslCreds=l[3]
+ else:
+ serverSaslCreds=None
+ except IndexError:
+@@ -291,15 +310,13 @@ def fromBER(klass, tag, content, berdecoder=None):
+ fromBER = classmethod(fromBER)
+
+ def __init__(self, resultCode=None, matchedDN=None, errorMessage=None, referral=None, serverSaslCreds=None, tag=None):
+- LDAPResult.__init__(self, resultCode=resultCode, matchedDN=matchedDN, errorMessage=errorMessage, referral=referral, tag=None)
+- assert self.serverSaslCreds is None #TODO
++ LDAPResult.__init__(self, resultCode=resultCode, matchedDN=matchedDN, errorMessage=errorMessage,
++ referral=referral, serverSaslCreds=serverSaslCreds, tag=None)
+
+ def __str__(self):
+- assert self.serverSaslCreds is None #TODO
+ return LDAPResult.__str__(self)
+
+ def __repr__(self):
+- assert self.serverSaslCreds is None #TODO
+ return LDAPResult.__repr__(self)
+
+ class LDAPUnbindRequest(LDAPProtocolRequest, BERNull):
+diff --git a/ldaptor/test/test_pureldap.py b/ldaptor/test/test_pureldap.py
+index 16a6843..2065ba1 100644
+--- a/ldaptor/test/test_pureldap.py
++++ b/ldaptor/test/test_pureldap.py
+@@ -546,6 +546,15 @@ class KnownValues(unittest.TestCase):
+ + l('foo'))
+ ),
+
++ (pureldap.LDAPBindRequest,
++ [],
++ {'auth': ('PLAIN', 'test'),
++ 'sasl': True},
++ pureldap.LDAPBERDecoderContext(
++ fallback=pureldap.LDAPBERDecoderContext(fallback=pureber.BERDecoderContext()),
++ inherit=pureldap.LDAPBERDecoderContext(fallback=pureber.BERDecoderContext())),
++ [ord(x) for x in str(pureldap.LDAPBindRequest(auth=('PLAIN', 'test'), sasl=True))]
++ )
+ )
+
+ def testToLDAP(self):
+--
+1.8.5.1
+
diff --git a/starttls-fix.patch b/starttls-fix.patch
new file mode 100644
index 0000000..9cfa04c
--- /dev/null
+++ b/starttls-fix.patch
@@ -0,0 +1,34 @@
+From 9c6facce573820987f1ce591f5530e37422fff81 Mon Sep 17 00:00:00 2001
+From: Adam Goodman <akgood at garglezomper7.local>
+Date: Tue, 21 Jun 2011 16:09:40 -0400
+Subject: [PATCH] fix starttls support
+
+a small bug in the LDAPExtendedRequest constructor was making the
+LDAPStartTLSRequest constructor fail
+---
+ ldaptor/protocols/pureldap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/ldaptor/protocols/pureldap.py b/ldaptor/protocols/pureldap.py
+index 985fe7f..ee54829 100644
+--- a/ldaptor/protocols/pureldap.py
++++ b/ldaptor/protocols/pureldap.py
+@@ -1180,13 +1180,14 @@ def fromBER(klass, tag, content, berdecoder=None):
+ return r
+ fromBER = classmethod(fromBER)
+
+- def __init__(self, requestName, requestValue=None,
++ def __init__(self, requestName=None, requestValue=None,
+ tag=None):
+ LDAPProtocolRequest.__init__(self)
+ BERSequence.__init__(self, [], tag=tag)
+ assert requestName is not None
+ assert isinstance(requestName, basestring)
++ assert requestValue is None or isinstance(requestValue, basestring)
+ self.requestName=requestName
+ self.requestValue=requestValue
+
+ def __str__(self):
+--
+1.8.5.1
+
diff --git a/unicode.patch b/unicode.patch
new file mode 100644
index 0000000..fefc7d1
--- /dev/null
+++ b/unicode.patch
@@ -0,0 +1,84 @@
+From f693f61d6b6a6a53044ad3e5f7a7967bfb95d118 Mon Sep 17 00:00:00 2001
+From: davide colombo <dcolombo at davec.(none)>
+Date: Fri, 18 Feb 2011 12:10:41 +0100
+Subject: [PATCH] fix unicode problem with add contact
+
+---
+ ldaptor/protocols/ldap/ldapsyntax.py | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/ldaptor/protocols/ldap/ldapsyntax.py b/ldaptor/protocols/ldap/ldapsyntax.py
+index 471ffa6..9204d13 100644
+--- a/ldaptor/protocols/ldap/ldapsyntax.py
++++ b/ldaptor/protocols/ldap/ldapsyntax.py
+@@ -7,7 +7,7 @@
+ from ldaptor.protocols import pureldap, pureber
+ from ldaptor.samba import smbpassword
+ from ldaptor import ldapfilter, interfaces, delta, attributeset, entry
+-
++import codecs
+ class PasswordSetAggregateError(Exception):
+ """Some of the password plugins failed"""
+ def __init__(self, errors):
+@@ -393,9 +393,10 @@ def addChild(self, rdn, attributes):
+ ldapAttrType = pureldap.LDAPAttributeDescription(attrType)
+ l = []
+ for value in values:
++ if (isinstance(value, unicode)):
++ value = value.encode('utf-8')
+ l.append(pureldap.LDAPAttributeValue(value))
+ ldapValues = pureber.BERSet(l)
+-
+ ldapAttrs.append((ldapAttrType, ldapValues))
+ op=pureldap.LDAPAddRequest(entry=str(dn),
+ attributes=ldapAttrs)
+--
+1.8.5.1
+
+From 23518aba9f5b3a9cb994511906ba450b3d3f5618 Mon Sep 17 00:00:00 2001
+From: davide colombo <dcolombo at davec.(none)>
+Date: Fri, 18 Feb 2011 12:11:03 +0100
+Subject: [PATCH] fix unicode problem with modify contact
+
+---
+ ldaptor/delta.py | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/ldaptor/delta.py b/ldaptor/delta.py
+index 025fec6..68e165d 100644
+--- a/ldaptor/delta.py
++++ b/ldaptor/delta.py
+@@ -8,7 +8,7 @@
+ from ldaptor import attributeset
+ from ldaptor.protocols import pureldap, pureber
+ from ldaptor.protocols.ldap import ldif, distinguishedname
+-
++import codecs
+ class Modification(attributeset.LDAPAttributeSet):
+ def patch(self, entry):
+ raise NotImplementedError
+@@ -19,10 +19,20 @@ def asLDAP(self):
+ if self._LDAP_OP is None:
+ raise NotImplementedError("%s.asLDAP not implemented"
+ % self.__class__.__name__)
++ tmplist = list(self)
++ newlist = []
++ for x in range(len(tmplist)):
++ if (isinstance(tmplist[x], unicode)):
++ value = tmplist[x].encode('utf-8')
++ newlist.append(value)
++ else:
++ value = tmplist[x]
++ newlist.append(value)
++
+ return str(pureber.BERSequence([
+ pureber.BEREnumerated(self._LDAP_OP),
+ pureber.BERSequence([ pureldap.LDAPAttributeDescription(self.key),
+- pureber.BERSet(map(pureldap.LDAPString, list(self))),
++ pureber.BERSet(map(pureldap.LDAPString, newlist)),
+ ]),
+ ]))
+
+--
+1.8.5.1
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python-ldaptor.git/commitdiff/06f90a4b1226e1bd31208b9958932cf8da25299c
More information about the pld-cvs-commit
mailing list