/usr/share/pyshared/MailPing/incoming.py is in mailping 0.0.4ubuntu5+really0.0.4-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import os, shutil
from MailPing import mail, maildir, fileutil
def process(statedir):
def _processEmail(subdir, filename):
ident = mail.getID(os.path.join(subdir, filename))
if ident is None:
maildir.create(os.path.normpath(os.path.join(subdir, '..', '..', 'junk')))
shutil.move(os.path.join(subdir, filename),
os.path.normpath(os.path.join(subdir, '..', '..', 'junk', 'new', filename)))
else:
pending = os.path.normpath(os.path.join(subdir,
'..', '..',
'pending', ident))
timestamp = fileutil.getTime(pending)
if timestamp < 0:
maildir.create(os.path.normpath(os.path.join(subdir, '..', '..', 'broken')))
shutil.move(os.path.join(subdir, filename),
os.path.normpath(os.path.join(subdir, '..', '..', 'broken', 'new', filename)))
else:
lastSuccess = fileutil.getTime(os.path.normpath(os.path.join(subdir,
'..', '..',
'success')))
if timestamp > lastSuccess:
shutil.move(os.path.join(subdir, filename),
os.path.normpath(os.path.join(subdir, '..', '..', 'success.msg')))
shutil.move(pending,
os.path.normpath(os.path.join(subdir, '..', '..', 'success')))
deliveryTime = maildir.getTimeFromFilename(filename)
if isinstance(deliveryTime, int):
# If delivery time has only 1 second precision,
# truncate current time to same accuracy, to avoid
# deliveries seeming to happen before creation
# of the pending file.
#
# The race could trigger if mailping-cron is
# run in a tight loop, or if it is later changed
# to do probe sending before incoming processing.
timestamp = int(timestamp)
if deliveryTime is not None and deliveryTime >= timestamp:
fileutil.writeFile(os.path.normpath(os.path.join(subdir, '..', '..', 'latency')),
'%f\n' % (deliveryTime - timestamp))
else:
os.unlink(os.path.join(subdir, filename))
os.unlink(pending)
maildir.process(os.path.join(statedir, 'incoming'),
_processEmail)
|