From 0138e59355fb28d63fb1dcb6d31e0f5bfe8f4ecb Mon Sep 17 00:00:00 2001 From: missytake Date: Tue, 17 Oct 2023 19:12:55 +0200 Subject: [PATCH] doveauth: removed doveauth.py from the project --- chatmaild/pyproject.toml | 1 - chatmaild/src/chatmaild/doveauth.py | 65 ----------------------------- 2 files changed, 66 deletions(-) delete mode 100644 chatmaild/src/chatmaild/doveauth.py diff --git a/chatmaild/pyproject.toml b/chatmaild/pyproject.toml index 56060f0..adce021 100644 --- a/chatmaild/pyproject.toml +++ b/chatmaild/pyproject.toml @@ -10,7 +10,6 @@ dependencies = [ ] [project.scripts] -doveauth = "chatmaild.doveauth:main" doveauth-dictproxy = "chatmaild.dictproxy:main" filtermail = "chatmaild.filtermail:main" diff --git a/chatmaild/src/chatmaild/doveauth.py b/chatmaild/src/chatmaild/doveauth.py deleted file mode 100644 index de50d95..0000000 --- a/chatmaild/src/chatmaild/doveauth.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 -import base64 -import sys - -from .database import Database - - -def get_user_data(db, user): - with db.read_connection() as conn: - result = conn.get_user(user) - if result: - result["uid"] = "vmail" - result["gid"] = "vmail" - return result - - -def create_user(db, user, password): - with db.write_transaction() as conn: - conn.create_user(user, password) - return dict(home=f"/home/vmail/{user}", uid="vmail", gid="vmail", password=password) - - -def verify_user(db, user, password): - userdata = get_user_data(db, user) - if userdata: - if userdata.get("password") == password: - userdata["status"] = "ok" - else: - userdata["status"] = "fail" - else: - userdata = create_user(db, user, password) - userdata["status"] = "ok" - - return userdata - - -def lookup_user(db, user): - userdata = get_user_data(db, user) - if userdata: - userdata["status"] = "ok" - else: - userdata["status"] = "fail" - return userdata - - -def dump_result(res): - for key, value in res.items(): - print(f"{key}={value}") - - -def main(): - db = Database("/home/vmail/passdb.sqlite") - if sys.argv[1] == "hexauth": - login = base64.b16decode(sys.argv[2]).decode() - password = base64.b16decode(sys.argv[3]).decode() - res = verify_user(db, login, password) - dump_result(res) - elif sys.argv[1] == "hexlookup": - login = base64.b16decode(sys.argv[2]).decode() - res = lookup_user(db, login) - dump_result(res) - - -if __name__ == "__main__": - main()