SpamExperts/pyzor

Centos 7 stop client.py:72:send:gaierror: emails when no internet connection

Closed this issue · 17 comments

Hello,

Centos 7 uses pyzor-0.5.0-10.el7 from epel. On startup if there is no internet it keeps sending loads of emails with the content below.

[abrt] pyzor: client.py:72:send:gaierror: [Errno -2] Name or service not known

Is there any way of reducing/disabling this? ie just send one email. Think it does one a minute??

Cheers Greg

Steps to replicate

  1. Start system with no internet connection

Subject: [abrt] pyzor: client.py:72:send:gaierror: [Errno -2] Name or service not known
Date: 2018-09-17 16:58
From: user@localhost.co.uk
To: root@localhost.co.uk

reason: client.py:72:send:gaierror: [Errno -2] Name or service not known
cmdline: /usr/bin/python -Wignore::DeprecationWarning /bin/pyzor check
executable: /bin/pyzor
package: pyzor-0.5.0-10.el7
component: pyzor
pid: 4056
hostname: myhost.co.uk
count: 16
abrt_version: 2.1.11
analyzer: Python
architecture: x86_64
duphash: ffd78c98559986c3774da9db9f54477d36b283b8
event_log:
kernel: 3.10.0-862.11.6.el7.x86_64
last_occurrence: 1537199905
os_release: CentOS Linux release 7.5.1804 (Core)
pkg_arch: noarch
pkg_epoch: 0
pkg_fingerprint: 6A2F AEA2 352C 64E5
pkg_name: pyzor
pkg_release: 10.el7
pkg_vendor: Fedora Project
pkg_version: 0.5.0
runlevel: unknown
time: Fri 14 Sep 2018 16:46:47 BST
type: Python
uid: 89
username: postfix
uuid: ffd78c98559986c3774da9db9f54477d36b283b8

backtrace:
:client.py:72:send:gaierror: [Errno -2] Name or service not known
:
:Traceback (most recent call last):
: File "/bin/pyzor", line 8, in
: pyzor.client.run()
: File "/usr/lib/python2.7/site-packages/pyzor/client.py", line 1022,
in run
: ExecCall().run()
: File "/usr/lib/python2.7/site-packages/pyzor/client.py", line 205, in
run
: if not apply(dispatch, (self, args)):
: File "/usr/lib/python2.7/site-packages/pyzor/client.py", line 285, in
check
: runner.run(server, (digest, server))
: File "/usr/lib/python2.7/site-packages/pyzor/client.py", line 813, in
run
: response = apply(self.routine, varargs, kwargs)
: File "/usr/lib/python2.7/site-packages/pyzor/client.py", line 58, in
check
: self.send(msg, address)
: File "/usr/lib/python2.7/site-packages/pyzor/client.py", line 72, in
send
: self.socket.sendto(mac_msg_str, 0, address)
:gaierror: [Errno -2] Name or service not known
:
:Local variables in innermost frame:
:mac_msg_str: 'User: anonymous\nTime: 1536940006\nSig:
e98f90c634b43541da0a0a4083f014531210cabc\n\nOp: check\nOp-Digest:
d4799b6635caaa20305ac45f068d8763c9c86cae\nThread: 48262\nPV: 2.0\n\n'
:msg: <pyzor.CheckRequest object at 0x7ff9d532b090>
:account: ('anonymous', (None, 0L))
:self: <pyzor.client.Client object at 0x7ff9d531eef0>
:address: ('public.pyzor.org', 24441)
environ:
:run_mailscanner=1
:ms_cron_ps=1
:ms_cron_check=1
:TMPDIR=/var/spool/MailScanner/incoming/SpamAssassin-Temp
:ramdisk_sync=0
:PATH=/sbin:/bin:/usr/sbin:/usr/bin
:ramdisk_store=/var/spool/MailScanner/ramdisk_store
:ms_cron_av=0
:LANG=en_GB.UTF-8
:ms_core=/usr/share/MailScanner
:SHLVL=1
:ms_etc=/etc/MailScanner
:ms_lib=/usr/lib/MailScanner
:ms_cron_ps_restart=0
:stopped_lockfile=/var/lock/subsys/MailScanner.off
:q_days=30
:HOME=/var/spool/postfix
:ms_cron_sa=1
:ms_cron_sn=0
:ms_vs_conf=/etc/MailScanner/virus.scanners.conf
:ms_cron_msg_alert=0
:_=/usr/sbin/MailScanner
:HOSTNAME=myhost.co.uk
:PWD=/
:ms_conf=/etc/MailScanner/MailScanner.conf
machineid:
:systemd=32ee67d79a074dc58e9c5382a3ff69eb
:sosreport_uploader-dmidecode=a4a2273316b6a695a1726d32a1bf3f9b9f9186906d24f5ec06cf2d09c9c16c3b
os_info:
:NAME="CentOS Linux"
:VERSION="7 (Core)"
:ID="centos"
:ID_LIKE="rhel fedora"
:VERSION_ID="7"
:PRETTY_NAME="CentOS Linux 7 (Core)"
:ANSI_COLOR="0;31"
:CPE_NAME="cpe:/o:centos:centos:7"
:HOME_URL="https://www.centos.org/"
:BUG_REPORT_URL="https://bugs.centos.org/"
:
:CENTOS_MANTISBT_PROJECT="CentOS-7"
:CENTOS_MANTISBT_PROJECT_VERSION="7"
:REDHAT_SUPPORT_PRODUCT="centos"
:REDHAT_SUPPORT_PRODUCT_VERSION="7"

Pyzor 0.5 is many years out of date. Does this happen with 1.0?

Not sure, as its the default package used. Maybe I can comment out the line #72 in client.py ?

self.socket.sendto(mac_msg_str, 0, address)

Does it need recompiling?

Installed Packages
Name : pyzor
Arch : noarch
Version : 0.5.0
Release : 10.el7
Size : 253 k
Repo : installed
From repo : epel
Summary : Pyzor collaborative spam filtering system
URL : http://pyzor.sourceforge.net/
Licence : GPLv2+
Description : Pyzor is a collaborative, networked system to detect
: and block spam using identifying digests of messages.
: Pyzor is similar to Vipul's Razor except implemented
: in python, and using fully open source servers.
:
: Pyzor can be used either standalone, or to augment the
: spam filtering ability of spamassassin. spamassassin
: is highly recommended.

Cheers Greg

It uses a url that no longer exists? Maybe it does not do anything other than using alot of resources sending emails?

class ServerList(list):
inform_url = 'http://pyzor.sourceforge.net/cgi-bin/inform-servers-0-3-x'

def read(self, serverfile):
    for line in serverfile:
        orig_line = line
        line = line.strip()
        if line and not line.startswith('#') and \
            re.match('[a-zA-Z0-9.-]+:[0-9]+', line):
            self.append(pyzor.Address.from_str(line))

SourceForge seems to be having issues at the moment. Recent Pyzor (again for many years) doesn't use that URL; I'm not sure if it actually still works or not.

The socket.sendto line is actually sending the request, so commenting that out will not be good. If the issue is that it can't get the list of servers, then there is likely a way to just hardcode public.pyzor.org instead.

I don't know Centos really, sorry. Is there some maintainer of the package that could be contacted to get it updated? I'd be happy to help do that if there's anything that can be done on this side. Or if they want to stick to the really old 0.5 for some reason, then we can probably make a patch if it is just the server list request that's failing.

Centos uses redhat, I can try and log it with centos, but it really is rh who do the package updates. In the past (for me) nothing gets done.

It handles the bad URL OK, it's when there is no internet it goes wrong. I don't really do python. I looked at the latest version but could not find the code that tests for an actual internet connection. I don't mind doing a local fix, where in the latest code does it do the check? Maybe I can copy it over? I need to run the system off line (on a laptop) but it slows down alot scanning all the emails.

Cheers Greg

There isn't really a check. It's a fairly unusual situation for a mail server to be processing mail without an Internet connection.

What you'd likely want to do is catch the issue, e.g.:

        try:
            self.socket.sendto(mac_msg_str, 0 , address)
        except socket.error:
            return

However, while this should stop it crashing, I suspect it will then just timeout waiting for a response that will never come, so it's not ideal.

Pyzor's obviously not going to work if there's no connection. Is there a way to instead just skip the Pyzor check completely (ie. higher up) in this case?

From the back trace, could add the catch to the existing? Thought CommError would cater for a socket.error?

line #813 response = apply(self.routine, varargs, kwargs), add the socket.error ?

def run(self, server, varargs, kwargs=None):
if kwargs is None:
kwargs = {}
message = "%s\t" % str(server)
response = None
try:
response = apply(self.routine, varargs, kwargs)
self.handle_response(response, message)
except (CommError, KeyError, ValueError), e:
sys.stderr.write(message + ("%s: %s\n"
% (e.class.name, e)))
self.all_ok = False

....the latest version should cater for this, I work on the laptop alot, so should crash gracefully.

Cheers Greg

Modifying the catch worked

except (CommError, socket.error, KeyError, ValueError)

empty mailwatch que :-)

Cheers Greg

Sorry, had to go to a couple of meetings. Great that you've solved it.

FYI in case you're interested, CommError is an exception specific to Pyzor, but socket.error is from the standard library, so lower level, which is why catching CommError isn't going to catch socket.error.

Still, without this mod the latest version will generate lost of rubbish emails and system abrt error logs on the crash when not connected, can this be fixed? This is a bug, the system thinks it is.

Cheers Greg

It doesn't really seem like a bug in Pyzor to me - it seems like crashing when trying to do something that relies on an Internet connection without an Internet connection is reasonable. The system using Pyzor (I'm guessing from the paths that's SA in this case) is what should be automatically switching off tests that require a resource that isn't available.

Having Pyzor indicate that there's no match if there's no Internet connection isn't correct behaviour. Having it silently output nothing isn't correct behaviour. If it output a different error, e.g. the error is caught and a less verbose one it output, that doesn't really fix the resulting issue.

I could conceivably get pyzor updated in EPEL7, though I only really care about the Fedora version. I didn't even realize it was in EPEL.

Edit: If someone wants that, it would be best to file a ticket at bugzilla.redhat.com. And if I do update it, it will be a minimal port from the current Fedora version, which means it will need the python36 stack. That may be too much of a change for EPEL; I'm not really sure.

What version is in latest Fedora? Thought packages from Fedora releases make it into epel eventually.

Sorry should have looked,

Rawhide 1.0.0-16.20180724git2b8d76d.fc29 None
Fedora 29 1.0.0-16.20180724git2b8d76d.fc29 None
Fedora 28 1.0.0-16.20180724git2b8d76d.fc28 (update) None
Fedora 27 1.0.0-16.20180724git2b8d76d.fc27 (update) None
Fedora EPEL 7 0.5.0-10.el7 None
Fedora EPEL 6 0.5.0-3.el6 None

They only make it into EPEL if someone does the work to get them there. In this case since nobody is actually maintaining the EPEL branches, I can either retire them (so the ancient packages disappear from the repositories) or update them. I might consider doing EPEL7 if it's easy (and someone files a bug asking for it) but there's no way I'm touching EPEL6.

Does the current version do anything? Url's seems out of date? To keep it alive it might be worth the work.

Also catching the exception I no longer have a strange boot problem. eg if I boot without wifi, then next day boot with wifi my laptop would hang and a ctrl-alt-del restart is needed, then it would boot ok (with the wifi). Vice versa also. Maybe the abrt stuff was doing something / got confused?

Cheers Greg

...Not really sure how the pyzor works, but it seems to be in a loop with no wifi/network? Initially tries to load, crashes then abrt sends an email of the crash, then pyzor tries what it does on the new email, and then crashes and abrt sends another email and so on.