def get_passwords(self): cursor = self.db_cursor(self.password_query, (self.username,)) data = cursor.fetchall() if not data: log.info("username '%s' not found in sqlauth database", self.username) return None return tuple(str(x[0]) for x in data)
def get_password(self): if not os.path.exists(self.filename): log.error("Error: sqlauth cannot find the database file '%s'", self.filename) return None log("sqlauth.get_password() found database file '%s'", self.filename) try: conn = sqlite3.connect(self.filename) cursor = conn.cursor() cursor.execute(self.password_query, [self.username]) data = cursor.fetchone() except sqlite3.DatabaseError as e: log("get_password()", exc_info=True) log.error("Error: sqlauth database access problem:") log.error(" %s", e) return None if not data: log.info("username '%s' not found in sqlauth database", self.username) return None return str(data[0])
def main(argv): from xpra.platform import program_context from xpra.log import enable_color with program_context("Auth-Test", "Auth-Test"): enable_color() for x in ("-v", "--verbose"): if x in tuple(argv): log.enable_debug() argv.remove(x) if len(argv) != 3: log.warn("invalid number of arguments") log.warn("usage: %s [--verbose] username password", argv[0]) return 1 username = argv[1] password = argv[2] a = Authenticator(username=username) if a.check(password): log.info("authentication succeeded") return 0 log.error("authentication failed") return 1