Does it happen for mod_wsgi daemon mode as well as embedded mode? If happens for daemon mode, create a single daemon process and then use method described in:
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Debugging_Crashes_With_GDB to try and capture a stack trace for where it crashes. This may be the only way to get a clue as to what is going on. Graham On Feb 18, 8:28 am, molhacker <wpwalt...@gmail.com> wrote: > Hi Bruno, > > Not sure what you mean by a "a log for this error" > > Here's what I see in the Apache error log > > Tue Feb 17 15:10:03 2009] [notice] child pid 16071 exit signal > Segmentation fault (11) > > I tried using ldap.initialize rather than ldap.open, but I'm getting > the same error. Any other > ideas on how to track down the source of the error would be greatly > appreciated. > > Pat > > On Feb 17, 4:08 pm, Bruno Tikami <brunotik...@gmail.com> wrote: > > > On Tue, Feb 17, 2009 at 5: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 using LDAP. The problem is > > > intermittent, probably one out of every 5 logins causes the seg fault. > > > > The code I'm using for LDAP (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 > > > > import ldap > > > > 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 > > > except ldap.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 from > > > ldap') > > > 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 > > > Hi Pat, > > > do you have any log for this error ? > > > I have a production code on which I do exactly the same you de (even > > creating new users). The only difference is that I don't user open/bind: > > > conn = ldap.initialize('ldap://host') > > dn = '' # dn stuff > > > try: > > lcon = conn.simple_bind_s(dn %username, password) > > print 'OK' > > return "200" > > except ldap.INVALID_CREDENTIALS, e: > > return "400" > > > Hope that helps. > > > Tkm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---