mirror of
https://github.com/chatmail/relay.git
synced 2026-05-18 20:08:21 +00:00
Revert "cmdeploy: suppress shell output for local DNS queries"
This reverts commit c18ef083bfbd6a5e38a7bdaaa3c8ef8cca61cf74.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import importlib
|
import importlib
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
|
||||||
@@ -9,9 +8,9 @@ from . import remote
|
|||||||
|
|
||||||
def get_initial_remote_data(sshexec, mail_domain):
|
def get_initial_remote_data(sshexec, mail_domain):
|
||||||
if sshexec == "docker":
|
if sshexec == "docker":
|
||||||
return remote.rdns.perform_initial_checks(mail_domain, pre_command="docker exec chatmail ", shell=subprocess.check_output)
|
return remote.rdns.perform_initial_checks(mail_domain, pre_command="docker exec chatmail ")
|
||||||
elif sshexec == "localhost":
|
elif sshexec == "localhost":
|
||||||
return remote.rdns.perform_initial_checks(mail_domain, pre_command="", shell=subprocess.check_output)
|
return remote.rdns.perform_initial_checks(mail_domain, pre_command="")
|
||||||
return sshexec.logged(
|
return sshexec.logged(
|
||||||
call=remote.rdns.perform_initial_checks, kwargs=dict(mail_domain=mail_domain)
|
call=remote.rdns.perform_initial_checks, kwargs=dict(mail_domain=mail_domain)
|
||||||
)
|
)
|
||||||
@@ -50,7 +49,7 @@ def check_full_zone(sshexec, remote_data, out, zonefile) -> int:
|
|||||||
and return (exitcode, remote_data) tuple."""
|
and return (exitcode, remote_data) tuple."""
|
||||||
|
|
||||||
if sshexec in ["docker", "localhost"]:
|
if sshexec in ["docker", "localhost"]:
|
||||||
required_diff, recommended_diff = remote.rdns.check_zonefile(zonefile, remote_data["mail_domain"], shell=subprocess.check_output)
|
required_diff, recommended_diff = remote.rdns.check_zonefile(zonefile, remote_data["mail_domain"])
|
||||||
else:
|
else:
|
||||||
required_diff, recommended_diff = sshexec.logged(
|
required_diff, recommended_diff = sshexec.logged(
|
||||||
remote.rdns.check_zonefile,
|
remote.rdns.check_zonefile,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import re
|
|||||||
from .rshell import CalledProcessError, shell
|
from .rshell import CalledProcessError, shell
|
||||||
|
|
||||||
|
|
||||||
def perform_initial_checks(mail_domain, pre_command="", shell=shell):
|
def perform_initial_checks(mail_domain, pre_command=""):
|
||||||
"""Collecting initial DNS settings."""
|
"""Collecting initial DNS settings."""
|
||||||
assert mail_domain
|
assert mail_domain
|
||||||
if not shell("dig", fail_ok=True):
|
if not shell("dig", fail_ok=True):
|
||||||
@@ -28,7 +28,7 @@ def perform_initial_checks(mail_domain, pre_command="", shell=shell):
|
|||||||
res = dict(mail_domain=mail_domain, A=A, AAAA=AAAA, MTA_STS=MTA_STS, WWW=WWW)
|
res = dict(mail_domain=mail_domain, A=A, AAAA=AAAA, MTA_STS=MTA_STS, WWW=WWW)
|
||||||
res["acme_account_url"] = shell(pre_command + "acmetool account-url", fail_ok=True)
|
res["acme_account_url"] = shell(pre_command + "acmetool account-url", fail_ok=True)
|
||||||
res["dkim_entry"], res["web_dkim_entry"] = get_dkim_entry(
|
res["dkim_entry"], res["web_dkim_entry"] = get_dkim_entry(
|
||||||
mail_domain, pre_command, shell, dkim_selector="opendkim"
|
mail_domain, pre_command, dkim_selector="opendkim"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not MTA_STS or not WWW or (not A and not AAAA):
|
if not MTA_STS or not WWW or (not A and not AAAA):
|
||||||
@@ -40,7 +40,7 @@ def perform_initial_checks(mail_domain, pre_command="", shell=shell):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def get_dkim_entry(mail_domain, pre_command, shell, dkim_selector):
|
def get_dkim_entry(mail_domain, pre_command, dkim_selector):
|
||||||
try:
|
try:
|
||||||
dkim_pubkey = shell(
|
dkim_pubkey = shell(
|
||||||
f"{pre_command} openssl rsa -in /etc/dkimkeys/{dkim_selector}.private "
|
f"{pre_command} openssl rsa -in /etc/dkimkeys/{dkim_selector}.private "
|
||||||
@@ -57,7 +57,7 @@ def get_dkim_entry(mail_domain, pre_command, shell, dkim_selector):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def query_dns(typ, domain, shell):
|
def query_dns(typ, domain):
|
||||||
# Get autoritative nameserver from the SOA record.
|
# Get autoritative nameserver from the SOA record.
|
||||||
soa_answers = [
|
soa_answers = [
|
||||||
x.split()
|
x.split()
|
||||||
@@ -77,7 +77,7 @@ def query_dns(typ, domain, shell):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def check_zonefile(zonefile, mail_domain, shell=shell):
|
def check_zonefile(zonefile, mail_domain):
|
||||||
"""Check expected zone file entries."""
|
"""Check expected zone file entries."""
|
||||||
required = True
|
required = True
|
||||||
required_diff = []
|
required_diff = []
|
||||||
@@ -93,7 +93,7 @@ def check_zonefile(zonefile, mail_domain, shell=shell):
|
|||||||
zf_domain, zf_typ, zf_value = zf_line.split(maxsplit=2)
|
zf_domain, zf_typ, zf_value = zf_line.split(maxsplit=2)
|
||||||
zf_domain = zf_domain.rstrip(".")
|
zf_domain = zf_domain.rstrip(".")
|
||||||
zf_value = zf_value.strip()
|
zf_value = zf_value.strip()
|
||||||
query_value = query_dns(zf_typ, zf_domain, shell)
|
query_value = query_dns(zf_typ, zf_domain)
|
||||||
if zf_value != query_value:
|
if zf_value != query_value:
|
||||||
assert zf_typ in ("A", "AAAA", "CNAME", "CAA", "SRV", "MX", "TXT"), zf_line
|
assert zf_typ in ("A", "AAAA", "CNAME", "CAA", "SRV", "MX", "TXT"), zf_line
|
||||||
if required:
|
if required:
|
||||||
|
|||||||
Reference in New Issue
Block a user