Compare commits

..

No commits in common. "2a7e4fcd6e2b3d739047bb46987cb3930e5b14f5" and "a88f298e98af40260cfdc0e10566e744b1087f71" have entirely different histories.

View file

@ -61,7 +61,7 @@ try:
)
database.set_session(readonly=True, autocommit=True)
logging.debug(database.get_dsn_parameters())
except Exception:
except:
logging.error("Unable to initialize database, check settings!")
time.sleep(10)
sys.exit(1)
@ -69,6 +69,7 @@ except Exception:
@atexit.register
def close_db():
cursor.close()
database.close()
@ -93,7 +94,7 @@ def ejabberd_in():
input_length = sys.stdin.buffer.read(2)
if len(input_length) != 2:
if len(input_length) is not 2:
logging.debug("ejabberd sent us wrong things!")
raise EjabberdInputError('Wrong input from ejabberd!')
@ -137,16 +138,16 @@ def get_password(user, host):
cursor.execute(db_query_getpass, {"user": user.lower(), "host": host})
data = cursor.fetchone()
cursor.close()
return data[0] if data is not None else None
return data[0] if data != None else None
def isuser(user, host):
return get_password(user, host) is not None
return get_password(user, host) != None
def auth(user, host, password):
db_password = get_password(user, host)
if db_password is None:
if db_password == None:
logging.debug("Wrong username: %s@%s" % (user, host))
return False
else:
@ -171,7 +172,7 @@ while True:
ejab_request = ejabberd_in().split(':', 3)
except EOFError:
break
except Exception:
except Exception as e:
logging.exception("Exception occured while reading stdin")
raise