Compare commits
5 commits
a88f298e98
...
2a7e4fcd6e
Author | SHA1 | Date | |
---|---|---|---|
|
2a7e4fcd6e | ||
|
1ad357ba4a | ||
|
6a4de62467 | ||
|
7118641d78 | ||
|
4bed400c7d |
1 changed files with 6 additions and 7 deletions
|
@ -61,7 +61,7 @@ try:
|
||||||
)
|
)
|
||||||
database.set_session(readonly=True, autocommit=True)
|
database.set_session(readonly=True, autocommit=True)
|
||||||
logging.debug(database.get_dsn_parameters())
|
logging.debug(database.get_dsn_parameters())
|
||||||
except:
|
except Exception:
|
||||||
logging.error("Unable to initialize database, check settings!")
|
logging.error("Unable to initialize database, check settings!")
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -69,7 +69,6 @@ except:
|
||||||
|
|
||||||
@atexit.register
|
@atexit.register
|
||||||
def close_db():
|
def close_db():
|
||||||
cursor.close()
|
|
||||||
database.close()
|
database.close()
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +93,7 @@ def ejabberd_in():
|
||||||
|
|
||||||
input_length = sys.stdin.buffer.read(2)
|
input_length = sys.stdin.buffer.read(2)
|
||||||
|
|
||||||
if len(input_length) is not 2:
|
if len(input_length) != 2:
|
||||||
logging.debug("ejabberd sent us wrong things!")
|
logging.debug("ejabberd sent us wrong things!")
|
||||||
raise EjabberdInputError('Wrong input from ejabberd!')
|
raise EjabberdInputError('Wrong input from ejabberd!')
|
||||||
|
|
||||||
|
@ -138,16 +137,16 @@ def get_password(user, host):
|
||||||
cursor.execute(db_query_getpass, {"user": user.lower(), "host": host})
|
cursor.execute(db_query_getpass, {"user": user.lower(), "host": host})
|
||||||
data = cursor.fetchone()
|
data = cursor.fetchone()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
return data[0] if data != None else None
|
return data[0] if data is not None else None
|
||||||
|
|
||||||
|
|
||||||
def isuser(user, host):
|
def isuser(user, host):
|
||||||
return get_password(user, host) != None
|
return get_password(user, host) is not None
|
||||||
|
|
||||||
|
|
||||||
def auth(user, host, password):
|
def auth(user, host, password):
|
||||||
db_password = get_password(user, host)
|
db_password = get_password(user, host)
|
||||||
if db_password == None:
|
if db_password is None:
|
||||||
logging.debug("Wrong username: %s@%s" % (user, host))
|
logging.debug("Wrong username: %s@%s" % (user, host))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -172,7 +171,7 @@ while True:
|
||||||
ejab_request = ejabberd_in().split(':', 3)
|
ejab_request = ejabberd_in().split(':', 3)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.exception("Exception occured while reading stdin")
|
logging.exception("Exception occured while reading stdin")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue