Bug 1689211 - Exim's greylist-tidy.sh daily cron reports an error when greylist.db is empty
Summary: Exim's greylist-tidy.sh daily cron reports an error when greylist.db is empty
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: exim
Version: 28
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
Assignee: Jaroslav Škarvada
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-15 12:39 UTC by Dennis Flaherty
Modified: 2019-03-29 19:18 UTC (History)
4 users (show)

Fixed In Version: exim-4.92-5.fc28 exim-4.92-5.fc29 exim-4.92-6.fc30
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-03-29 02:03:59 UTC


Attachments (Terms of Use)

Description Dennis Flaherty 2019-03-15 12:39:22 UTC
Description of problem:
Exim's greylist-tidy.sh daily cron reports an error when greylist.db is empty

Version-Release number of selected component (if applicable):
Exim 4.92

How reproducible:
Whenever the greylist.db is an empty file.

Steps to Reproduce:
1. Empty the /var/spool/exim/db/greylist.db file
2. Run /etc/cron.daily/greylist-tidy.sh
3. 

Actual results:
Error: near line 2: no such table: greylist

Expected results:
Nothing.

Additional info:
Fix is easy:

@@ -1,6 +1,6 @@
 #!/bin/bash
 
+if [ -s /var/spool/exim/db/greylist.db ]; then
-if [ -r /var/spool/exim/db/greylist.db ]; then
     sqlite3 /var/spool/exim/db/greylist.db <<EOF
 .timeout 5000
 DELETE FROM greylist WHERE expire < $((`date +%s` - 604800));

Comment 1 Dennis Flaherty 2019-03-15 12:44:54 UTC
I had made the above fix locally but each new version of Exim clobbers my local fix.

Comment 2 Jaroslav Škarvada 2019-03-19 10:50:37 UTC
Thanks, it makes sense.

Comment 3 Fedora Update System 2019-03-19 12:25:24 UTC
exim-4.92-5.fc30 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-05194f6b09

Comment 4 Fedora Update System 2019-03-19 12:25:36 UTC
exim-4.92-5.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-b46c6fd50c

Comment 5 Fedora Update System 2019-03-19 12:25:44 UTC
exim-4.92-5.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-037c4fac81

Comment 6 Dennis Flaherty 2019-03-19 12:41:28 UTC
Thank you Jaroslav.

Comment 7 David Woodhouse 2019-03-19 23:18:58 UTC
Why would the file be empty? The RPM's %post script creates it with the appropriate contents. You'd have to deliberately go and corrupt it, surely?

We don't normally make packages cope with someone who deliberately goes and corrupts their files.

Not that I have any particular objection to the change, but I'm confused by it.

Comment 8 Dennis Flaherty 2019-03-20 03:17:47 UTC
My greylist.db was indeed empty.  If a post script was supposed to create it with appropriate contents, I didn't see it.

I don't normally corrupt my files and post to bugzilla.

Comment 9 Jaroslav Škarvada 2019-03-20 12:27:27 UTC
(In reply to Dennis Flaherty from comment #8)
> My greylist.db was indeed empty.  If a post script was supposed to create it
> with appropriate contents, I didn't see it.
> 
> I don't normally corrupt my files and post to bugzilla.

The following is in the SPEC:
%post greylist
if [ ! -r %{_var}/spool/exim/db/greylist.db ]; then
   sqlite3 %{_var}/spool/exim/db/greylist.db < %{_sysconfdir}/exim/mk-greylist-db.sql
   chown exim.exim %{_var}/spool/exim/db/greylist.db
   chmod 0660 %{_var}/spool/exim/db/greylist.db
fi

so it should be initialized and your installation is very probably somehow corrupted.

The question is do we want the cron script to:
a) silently tolerate the corrupt file and not work or 
b) report error

After re-thinking about it, I think the b) is better way how to deal with it, so I am OK to revert the change.

Comment 10 Jaroslav Škarvada 2019-03-20 12:38:55 UTC
I tried to install exim-greylist on my test system and it was correctly initialized as expected:

sqlite3 /var/spool/exim/db/greylist.db .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE resenders (
	host		TEXT,
	helo		TEXT,
	time		INTEGER,
    PRIMARY KEY (host, helo)
);
CREATE TABLE greylist (
	id		TEXT PRIMARY KEY,
	expire		INTEGER,
	host		TEXT,
	helo		TEXT
);
COMMIT;

Comment 11 Dennis Flaherty 2019-03-20 12:50:38 UTC
I've removed exim-greylist on my system, then reinstalled it.  I now see a non-zero greylist.db.

Comment 12 David Woodhouse 2019-03-20 18:09:35 UTC
Note that the Exim snippets won't work when the DB is empty either. Making the cron job resilient to an empty file is all very well (and I don't really object to it), but anyone who is *using* this package won't cope with an empty file. And it doesn't provide any benefit at all to anyone who isn't using it.

Comment 13 Jaroslav Škarvada 2019-03-20 18:12:38 UTC
(In reply to David Woodhouse from comment #12)
> Note that the Exim snippets won't work when the DB is empty either. Making
> the cron job resilient to an empty file is all very well (and I don't really
> object to it), but anyone who is *using* this package won't cope with an
> empty file. And it doesn't provide any benefit at all to anyone who isn't
> using it.

OK, thanks for info, let's keep the change.

Comment 14 Fedora Update System 2019-03-20 22:02:02 UTC
exim-4.92-5.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-b46c6fd50c

Comment 15 Fedora Update System 2019-03-20 22:17:55 UTC
exim-4.92-5.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-037c4fac81

Comment 16 Fedora Update System 2019-03-21 00:13:29 UTC
exim-4.92-6.fc30 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-7b741dcaa4

Comment 17 Fedora Update System 2019-03-21 19:12:27 UTC
exim-4.92-6.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-7b741dcaa4

Comment 18 Fedora Update System 2019-03-29 02:03:59 UTC
exim-4.92-5.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 19 Fedora Update System 2019-03-29 02:58:49 UTC
exim-4.92-5.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.

Comment 20 Fedora Update System 2019-03-29 19:18:50 UTC
exim-4.92-6.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.