Skip to content
Snippets Groups Projects
Commit 2f3df0f3 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Handle case where mailname file does not exist.

parent 59a62ae4
No related branches found
No related tags found
No related merge requests found
......@@ -80,10 +80,14 @@ def check_relay(conf: dict) -> int:
u.warning("Cannot determine public IP address")
return 3
# check domain origin
with open("/etc/mailname", "r") as mailname:
data = mailname.read().strip()
if data not in ("ubicast.tv", "ubicast.eu"):
u.warning("/etc/mailname does not contain ubicast.eu or ubicast.tv")
if os.path.exists("/etc/mailname"):
with open("/etc/mailname", "r") as mailname:
myorigin = mailname.read().strip()
else:
out = subprocess.getoutput("grep myorigin /etc/postfix/main.cf")
myorigin = out.replace("myorigin", "").strip()
if myorigin not in ("ubicast.tv", "ubicast.eu"):
u.warning("The \"myorigin\" setting does not contain ubicast.eu or ubicast.tv")
return 3
# check spf
result, _ = spf.check2(i=ip_addr, s="support@ubicast.eu", h="")
......@@ -128,7 +132,7 @@ def check_send_test_email(conf: dict) -> int:
else:
u.info("Sender address is not set")
cmd = "echo 'test email' | mail -s 'Email used to test configuration.' {}{}".format(sender, email)
subprocess.getstatusoutput(cmd)
subprocess.getoutput(cmd)
# init vars
timeout = 120
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment