Skip to content
Snippets Groups Projects
Commit bcde36df authored by Florent Thiery's avatar Florent Thiery
Browse files

fix postfix test, fixes #20388

parent 23eff59b
No related branches found
No related tags found
No related merge requests found
...@@ -4,34 +4,17 @@ ...@@ -4,34 +4,17 @@
Check that emails can be sent. Check that emails can be sent.
''' '''
import os import os
import re
import subprocess import subprocess
import sys import sys
if not os.path.exists('/etc/postfix'): if not os.path.exists('/etc/postfix'):
print('Postfix dir does not exists, test skipped.') print('Postfix dir does not exists, test skipped.')
sys.exit(1)
else: else:
# check that postfix listens the port 25 correctly # check that postfix listens the port 25 correctly
out = subprocess.check_output('netstat -pant | grep \':25\'', shell=True) status, out = subprocess.getstatusoutput('netstat -pant | grep master | grep 127.0.0.1:25', shell=True)
out = out.decode('utf-8') if out else '' if status != 0:
# netstat -pant output columns are:
# Proto | Recv-Q | Send-Q | Local address | Foreign address | State | PID/Program name
expected = r'tcp +\d +\d +127\.0\.0\.1:25 +0\.0\.0\.0:\* +LISTEN +[\d]+/master'
found = False
if out:
for line in out.split('\n'):
line = re.sub(r' +', ' ', line)
if line:
if not re.match(expected, line):
print('Unexpected result for postfix listening ports:\n%s' % line)
sys.exit(1)
else:
found = True
if not found:
print('The port 25 is not listened by any process.') print('The port 25 is not listened by any process.')
sys.exit(1) sys.exit(1)
print('Postfix listening port: OK.') print('Postfix listening port: OK.')
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