mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
Compare commits
1 Commits
socks-setu
...
mailname
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6a94944e0 |
@@ -59,7 +59,7 @@ def lookup_passdb(db, user, password):
|
|||||||
return userdata
|
return userdata
|
||||||
|
|
||||||
|
|
||||||
def handle_dovecot_request(msg, db):
|
def handle_dovecot_request(msg, db, mail_domain):
|
||||||
print(f"received msg: {msg!r}", file=sys.stderr)
|
print(f"received msg: {msg!r}", file=sys.stderr)
|
||||||
short_command = msg[0]
|
short_command = msg[0]
|
||||||
if short_command == "L": # LOOKUP
|
if short_command == "L": # LOOKUP
|
||||||
@@ -70,13 +70,15 @@ def handle_dovecot_request(msg, db):
|
|||||||
res = ""
|
res = ""
|
||||||
if namespace == "shared":
|
if namespace == "shared":
|
||||||
if type == "userdb":
|
if type == "userdb":
|
||||||
res = lookup_userdb(db, user)
|
if user.endswith(f"@{mail_domain}"):
|
||||||
|
res = lookup_userdb(db, user)
|
||||||
if res:
|
if res:
|
||||||
reply_command = "O"
|
reply_command = "O"
|
||||||
else:
|
else:
|
||||||
reply_command = "N"
|
reply_command = "N"
|
||||||
elif type == "passdb":
|
elif type == "passdb":
|
||||||
res = lookup_passdb(db, user, password=args[0])
|
if user.endswith(f"@{mail_domain}"):
|
||||||
|
res = lookup_passdb(db, user, password=args[0])
|
||||||
if res:
|
if res:
|
||||||
reply_command = "O"
|
reply_command = "O"
|
||||||
else:
|
else:
|
||||||
@@ -95,6 +97,8 @@ def main():
|
|||||||
socket = sys.argv[1]
|
socket = sys.argv[1]
|
||||||
passwd_entry = pwd.getpwnam(sys.argv[2])
|
passwd_entry = pwd.getpwnam(sys.argv[2])
|
||||||
db = Database(sys.argv[3])
|
db = Database(sys.argv[3])
|
||||||
|
with open("/etc/mailname", "r") as fp:
|
||||||
|
mail_domain = fp.read().strip()
|
||||||
|
|
||||||
class Handler(StreamRequestHandler):
|
class Handler(StreamRequestHandler):
|
||||||
def handle(self):
|
def handle(self):
|
||||||
@@ -102,7 +106,7 @@ def main():
|
|||||||
msg = self.rfile.readline().strip().decode()
|
msg = self.rfile.readline().strip().decode()
|
||||||
if not msg:
|
if not msg:
|
||||||
break
|
break
|
||||||
res = handle_dovecot_request(msg, db)
|
res = handle_dovecot_request(msg, db, mail_domain)
|
||||||
if res:
|
if res:
|
||||||
print(f"sending result: {res!r}", file=sys.stderr)
|
print(f"sending result: {res!r}", file=sys.stderr)
|
||||||
self.wfile.write(res.encode("ascii"))
|
self.wfile.write(res.encode("ascii"))
|
||||||
|
|||||||
@@ -244,6 +244,13 @@ def deploy_chatmail(mail_domain: str, mail_server: str, dkim_selector: str) -> N
|
|||||||
restarted=dovecot_need_restart,
|
restarted=dovecot_need_restart,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# This file is used by auth proxy.
|
||||||
|
# https://wiki.debian.org/EtcMailName
|
||||||
|
server.shell(
|
||||||
|
name="Setup /etc/mailname",
|
||||||
|
commands=[f"echo {mail_domain} >/etc/mailname; chmod 644 /etc/mailname"],
|
||||||
|
)
|
||||||
|
|
||||||
def callback():
|
def callback():
|
||||||
result = server.shell(
|
result = server.shell(
|
||||||
commands=[
|
commands=[
|
||||||
|
|||||||
Reference in New Issue
Block a user