Odd error with sasl_interactive_bind_s
David Hawes
dhawes at vt.edu
Wed Mar 2 21:28:31 CET 2005
Deepak,
Thank you for the patch and the explanation--I was working my way towards
that, but it would have taken a bit longer to poinpoint it... ;)
The patch works perfectly and my SASL EXTERNAL bind works as expected.
Thanks again for the help.
dave
On Wednesday 02 March 2005 15:11, Deepak Giridharagopal wrote:
> Hi, Dave!
>
> I've reproduced your bug, and I've attached a patch that fixes the
> problem. It might interest you to know that this bug doesn't affect more
> recent versions of Python, for what that's worth. :)
>
> The long answer:
>
> On Wed, 2005-03-02 at 12:30 -0500, David Hawes wrote:
> > Traceback (most recent call last):
> > File "sasl_bind.py", line 69, in ?
> > l.sasl_interactive_bind_s("", sasl_auth)
> > File "/usr/lib/python2.1/site-packages/ldap/ldapobject.py", line 196,
> > in sasl_interactive_bind_s return
> > self._ldap_call(self._l.sasl_interactive_bind_s,who,auth,serverctrls,clie
> >ntctrls ,sasl_flags)
> > File "/usr/lib/python2.1/site-packages/ldap/ldapobject.py", line
> > 94, in _ldap_call
> > result = func(*args,**kwargs)
> > TypeError: argument 5 must be impossible<bad format char>, not int
>
> Eek! This looks like a bug in the C code. The function that throws this
> error is PyArg_ParseTuple, a C function bundled with Python that takes
> Python objects and converts them to vanilla C-types.
>
> The offending bit looks to be lines 648-649 in LDAPObject.c:
>
> if (!PyArg_ParseTuple(args, "sOOOI", &who, &SASLObject, &serverctrls,
> &clientctrls, &sasl_flags ))
> return NULL;
>
> The 'sasl_flags' variable is declared as an unsigned int, but it looks
> like we're trying to convert it using the "I" flag, which is meant to
> convert longs. Replacing that "I" with "i" tells Python to convert that
> argument to an int (rather than a long), and it seems to do the trick.
>
> More info on these arcane conversion flags (for the curious):
> http://docs.python.org/api/arg-parsing.html
>
> Don't you just love C programming? :)
>
> The fix makes Python 2.1.3 work again, and the fix doesn't appear to
> break anything for more recent versions of Python (which, as I said,
> don't seem to suffer from the problem).
>
> Can you try the patch and let me know if it fixes things for you?
> Thanks, Dave!
>
> Cheers!
> deepak
>
> --
> Deepak Giridharagopal
> Applied Research Laboratories
> University of Texas at Austin
More information about the python-ldap
mailing list