mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
remove all occurences of hardcoded /home/vmail for database and mailbox dirs
This commit is contained in:
@@ -24,6 +24,7 @@ class Config:
|
||||
self.passthrough_senders = params["passthrough_senders"].split()
|
||||
self.passthrough_recipients = params["passthrough_recipients"].split()
|
||||
self.mailboxes_dir = params["mailboxes_dir"].strip().rstrip("/")
|
||||
self.passdb_path = params["passdb_path"].strip().rstrip("/")
|
||||
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
||||
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
||||
self.iroh_relay = params.get("iroh_relay")
|
||||
|
||||
@@ -27,6 +27,7 @@ def delete_inactive_users(db, config, CHUNK=100):
|
||||
|
||||
|
||||
def main():
|
||||
db = Database(sys.argv[1])
|
||||
config = read_config(sys.argv[2])
|
||||
(cfgpath,) = sys.argv[1:]
|
||||
config = read_config(cfgpath)
|
||||
db = Database(config.passdb_path)
|
||||
delete_inactive_users(db, config)
|
||||
|
||||
@@ -245,9 +245,9 @@ class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
|
||||
|
||||
|
||||
def main():
|
||||
socket = sys.argv[1]
|
||||
db = Database(sys.argv[2])
|
||||
config = read_config(sys.argv[3])
|
||||
socket, cfgpath = sys.argv[1:]
|
||||
config = read_config(cfgpath)
|
||||
db = Database(config.passdb_path)
|
||||
|
||||
class Handler(StreamRequestHandler):
|
||||
def handle(self):
|
||||
|
||||
@@ -45,6 +45,9 @@ passthrough_recipients = xstore@testrun.org groupsbot@hispanilandia.net
|
||||
# Directory where user mailboxes are stored
|
||||
mailboxes_dir = /home/vmail/mail/{mail_domain}
|
||||
|
||||
# user address sqlite database path
|
||||
passdb_path = /home/vmail/passdb.sqlite
|
||||
|
||||
# where the filtermail SMTP service listens
|
||||
filtermail_smtp_port = 10080
|
||||
|
||||
|
||||
@@ -128,12 +128,12 @@ class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
|
||||
|
||||
|
||||
def main():
|
||||
socket, vmail_dir, config_path = sys.argv[1:]
|
||||
socket, config_path = sys.argv[1:]
|
||||
|
||||
config = read_config(config_path)
|
||||
iroh_relay = config.iroh_relay
|
||||
|
||||
vmail_dir = Path(vmail_dir)
|
||||
vmail_dir = Path(config.mailboxes_dir)
|
||||
if not vmail_dir.exists():
|
||||
logging.error("vmail dir does not exist: %r", vmail_dir)
|
||||
return 1
|
||||
|
||||
@@ -18,7 +18,8 @@ def make_config(tmp_path):
|
||||
def make_conf(mail_domain):
|
||||
basedir = tmp_path.joinpath(f"vmail/{mail_domain}")
|
||||
basedir.mkdir(parents=True, exist_ok=True)
|
||||
overrides = dict(mailboxes_dir=str(basedir))
|
||||
passdb = tmp_path.joinpath("vmail/passdb.sqlite")
|
||||
overrides = dict(mailboxes_dir=str(basedir), passdb_path=str(passdb))
|
||||
write_initial_config(inipath, mail_domain=mail_domain, **overrides)
|
||||
return read_config(inipath)
|
||||
|
||||
|
||||
@@ -35,10 +35,13 @@ def test_read_config_testrun(make_config):
|
||||
assert config.passthrough_senders == []
|
||||
|
||||
|
||||
def test_get_user_maildir(make_config):
|
||||
def test_config_userstate_paths(make_config, tmp_path):
|
||||
config = make_config("something.testrun.org")
|
||||
mailboxes_dir = Path(config.mailboxes_dir)
|
||||
passdb_path = Path(config.passdb_path)
|
||||
assert mailboxes_dir.name == "something.testrun.org"
|
||||
assert passdb_path.name == "passdb.sqlite"
|
||||
assert passdb_path.is_relative_to(tmp_path)
|
||||
assert config.mail_domain == "something.testrun.org"
|
||||
path = Path(config.get_user_maildir("user1@something.testrun.org"))
|
||||
assert not path.exists()
|
||||
|
||||
Reference in New Issue
Block a user