Commit a4e56278 authored by Vitaly Lipatov's avatar Vitaly Lipatov

parse_mail_log: add --list support, add email to access

parent de364f1a
......@@ -4,5 +4,7 @@ grep "Connection refused" /var/log/mail/all | grep "reject: RCPT" | grep "Sender
> $0.out
# sed "s!.*RCPT from \(.*\)\[.*from=<\(.*\)> to=<\(.*\)>.*!host=\1 from=\2 to=\3!g"
echo
echo "==============="
date
$(dirname $0)/parse_mail_log.py
......@@ -22,7 +22,7 @@ def check_http(url):
def append_ip(host, ip, email):
today = datetime.datetime.now()
f = open('/etc/postfix/access-our', 'a')
f.write("\n# "+str(today)+": "+host+"\n"+ip+" OK\n#"+email+" OK\n");
f.write("\n# "+str(today)+": "+host+"\n"+ip+" OK\n"+email+" OK\n");
f.close()
print ip
......@@ -64,7 +64,13 @@ if __name__== "__main__":
#r1 = parse_row (test_string)
#print r1
read_exists_ip()
list_only = 0
if len(sys.argv) > 1:
if sys.argv[1] == "--list":
list_only = 1
if not list_only:
read_exists_ip()
f = open('check_web_letters.sh.out', 'r')
result = []
......@@ -75,7 +81,11 @@ if __name__== "__main__":
continue
if line not in result:
result.append(line)
#print line
if list_only:
print line
continue
sp = string.split(line['from'],'@')
# если домен почты совпадает с хостом отправителя
if sp[1] == line['host']:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment