After a lot of banging my head against a wall I finally figured this
one
out.  If figured I'd post the solution in case someone else runs into
the same problem.

I found the solution when I googled this
http://www.mail-archive.com/php-b...@lists.php.net/msg02201.html

Someone in the php world had a similar problem.  It turns out that
openldap and oracle both have functions called ldap_modify_s.
Occasionally
my program would call the oracle version instead of the the openldap
version and promptly seg fault.

The solution was to put

LD_PRELOAD=/usr/lib/libldap.so
export LD_PRELOAD

into /usr/local/apache2/bin/envvars



On Feb 17, 3:42 pm, molhacker <wpwalt...@gmail.com> wrote:
> I've been running into a very frustrating situation with a seg fault
> in Apache when authenticating Django usingLDAP.  The problem is
> intermittent, probably one out of every 5 logins causes the seg fault.
>
> The code I'm using forLDAP(borrowed from the web, thanks Mick)
> authentication is shown below
>
> Here's what I'm running
>
> Django-1.0.2-final
> Python 2.5.2
> httpd-2.2.9
> openldap-2.4.14
> python-ldap-2.3.5
> CentOS release 4.6 (Final)
>
> I've tried both mod_python-3.3.1 and mod_wsgi-2.3 I get the crash in
> both cases.  I've read that there are conflicts with mod_php, but this
> is not the issue, PHP has never been installed on this server.
>
> The code below runs perfectly in a standalone program, it only
> segfaults in Apache.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Pat
>
> importldap
>
> from django.conf import settings
> from django.contrib.auth.models import User, check_password
>
> class LDAPBackend:
>     # fromhttp://blogs.translucentcode.org/mick/tags/django/
>     def authenticate(self, username=None, password=None):
>         username = "%...@example.com" % (username)
>         l =ldap.open('ldap.example.com')
>         try:
>             l.simple_bind_s(username, password)
>             valid = True
>         exceptldap.LDAPError, e:
>             valid = False
>         if valid:
>             try:
>                 user = User.objects.get(username=username)
>             except User.DoesNotExist:
>                 # Create a new user. Note that we can set password to
> anything
>                 # as it won't be checked, the password from
> settings.py will.
>                 user = User(username=username, password='obtained fromldap')
>                 user.is_staff = True
>                 user.is_superuser = True
>                 user.save()
>             return user
>         return None
>
>     def get_user(self, user_id):
>         try:
>             return User.objects.get(pk=user_id)
>         except User.DoesNotExist:
>             return None
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to