Skip to content

Commit

Permalink
Don't hammer db when the connection fails
Browse files Browse the repository at this point in the history
This should avoid accidental DoSing of the MySQL database server.
  • Loading branch information
Andrew Engelbrecht committed Dec 19, 2016
1 parent e3afa2f commit 3bf855f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion auth_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#Setup
########################################################################

import sys, logging, struct, hashlib, MySQLdb, crypt, random, atexit
import sys, logging, struct, hashlib, MySQLdb, crypt, random, atexit, time

sys.stderr = open('/var/log/ejabberd/extauth_err.log', 'a')
logging.basicConfig(level=logging.INFO,
Expand All @@ -54,6 +54,7 @@
database=MySQLdb.connect(db_host, db_user, db_pass, db_name)
except:
logging.debug("Unable to initialize database, check settings!")
time.sleep(10)
sys.exit(1)

@atexit.register
Expand Down

0 comments on commit 3bf855f

Please sign in to comment.