[ejabberd] extauth issue - script aborting due to exception vs. quitting because of shutdown of ejabberd

David Gregory david at envieinteractive.com
Mon Aug 9 22:54:46 MSD 2010


I'm having an issue where my .py authentication script is shutting down due
to an exception.  I'm using a close variation of this:



http://tkabber.jabber.ru/files/contributions/check_mysql_python.txt



The way this is written, it will abort on any exception.  Leaving ejabberd
with no external authentication.  This isn't very fault tolerant.



In my particular case, the exception is mysql related:

  File "/etc/ejabberd/JabberAuth.py", line 135, in ?

    op_result = auth(ejab_request[1], ejab_request[2], ejab_request[3])

  File "/etc/ejabberd/JabberAuth.py", line 98, in auth

    data=db_entry(in_user)

  File "/etc/ejabberd/JabberAuth.py", line 84, in db_entry

    dbcur.execute("SELECT %s,%s FROM %s WHERE %s
='%s'"%(db_username_field,db_password_field , db_table, db_username_field,
in_user))

  File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 163, in
execute

    self.errorhandler(self, exc, value)

  File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 35,
in defaulterrorhandler

    raise errorclass, errorvalue

_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')



This particular exception isn't anything to do with ejabberd, obviously.
It's my problem.



I could, on certain exceptions, keep looping and waiting for input, rather
than quitting the python script.



However----



If I do that, and I have to restart ejabberd for other reasons, I get
multiple JabberAuth.py instances running.  I don't want that.



Here's my question: How does ejabberd tell an extauth script to quit
gracefully?  It seems like, at the moment, it sends "bad input", which
causes an exception, which causes the script to quit - This is a guess,
however.  How can I have my script detect the difference between a
legitimate quit request and an exception?



The protocol listed here:

https://git.process-one.net/ejabberd/mainline/blobs/raw/2.1.x/doc/dev.html#htoc8



doesn't seem to provide any answers.  I'm hoping someone can help me.



Thanks!



-Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20100809/72741cdc/attachment.html>


More information about the ejabberd mailing list