Bug 256478 - mail/cyrus-imap34 NOTIFY(EVENT): datagram too large
Summary: mail/cyrus-imap34 NOTIFY(EVENT): datagram too large
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Hajimu UMEMOTO
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-08 10:22 UTC by Jesper Schmitz Mouridsen
Modified: 2021-08-22 12:18 UTC (History)
0 users

See Also:


Attachments
proposed patch to fix notify issue (2.86 KB, patch)
2021-06-14 10:14 UTC, Hajimu UMEMOTO
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesper Schmitz Mouridsen freebsd_committer 2021-06-08 10:22:08 UTC
Hi
Using notifyd you get NOTIFY(EVENT): datagram too large 
when using notifyd 

It is bececase net.local.dgram.maxdgram is smaller than on linux default is 2048 so you get a bufsiz of 204-32=172 most events are bigger. so add_arg fails here:

if (*buflen + len > max_size) return -1;


(max_size is bufsiz)


a Workaround is to set sysctl net.local.dgram.maxdgram higher e.g to 655552

But perhaps a patch that does not divide with 10
work-basic/cyrus-imapd-3.4.1/imap/notify.c:223:    bufsiz = MIN(bufsiz / 10 - 32, NOTIFY_MAXSIZE);

work-basic/cyrus-imapd-3.4.1/notifyd/notifyd.c:123:    bufsiz = MIN(bufsiz / 10 - 32, NOTIFY_MAXSIZE); 

Is better?
Comment 1 Hajimu UMEMOTO freebsd_committer 2021-06-14 10:14:58 UTC
Created attachment 225796 [details]
proposed patch to fix notify issue
Comment 2 Hajimu UMEMOTO freebsd_committer 2021-06-14 10:16:12 UTC
Thank you for the report.
I think it is better to increase the size of socket buffer.
Is the attached patch work for you?
Comment 3 Jesper Schmitz Mouridsen freebsd_committer 2021-06-14 14:08:18 UTC
(In reply to Hajimu UMEMOTO from comment #2)

Thanks.

Yes the patch works for me, I do not know how large the events can become though.
Perhaps this should be discussed with upstream?

The settings triggering this bug (without the patch) btw is

event_notifier: external
notify_external: /usr/local/bin/dump.pl

cat /usr/local/bin/dump.pl 
#!/usr/local/bin/perl 
use strict;
use warnings;
open FH,">/tmp/t";

while (<STDIN>) {
print FH $_
} 

It might be a problem on older cyrus-imapd versions as well.
Comment 4 Hajimu UMEMOTO freebsd_committer 2021-06-19 05:55:39 UTC
(In reply to Jesper Schmitz Mouridsen from comment #3)

> Yes the patch works for me, I do not know how large the events can become though.
> Perhaps this should be discussed with upstream?

Thank you for testing.
I'm not sure how large the buffer is, too.
In any way, it doesn't work on other than Linux at least FreeBSD.
So, it should be reported to upstream.

> The settings triggering this bug (without the patch) btw is
>
> event_notifier: external
> notify_external: /usr/local/bin/dump.pl

Btw, you can put the notification to syslog by the following setting:

  event_notifier: log

> It might be a problem on older cyrus-imapd versions as well.

Yes, the change was committed on 18 Jul 2017 by following issue:

  https://github.com/cyrusimap/cyrus-imapd/issues/1674
Comment 5 commit-hook freebsd_committer 2021-06-19 08:48:35 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2d1887b68b126bf7cec16962f807ac266dc4c4df

commit 2d1887b68b126bf7cec16962f807ac266dc4c4df
Author:     Hajimu UMEMOTO <ume@FreeBSD.org>
AuthorDate: 2021-06-19 08:39:13 +0000
Commit:     Hajimu UMEMOTO <ume@FreeBSD.org>
CommitDate: 2021-06-19 08:48:06 +0000

    mail/cyrus-imapd3[24]: NOTIFY(EVENT): datagram too large when using notifyd.

    PR:             256478
    Reported by:    jsm

 mail/cyrus-imapd32/Makefile                        |  2 +-
 .../cyrus-imapd32/files/patch-imap__notify.c (new) | 45 ++++++++++++++++++++
 .../files/patch-notifyd__notifyd.c (new)           | 44 ++++++++++++++++++++
 mail/cyrus-imapd34/Makefile                        |  2 +-
 .../cyrus-imapd34/files/patch-imap__notify.c (new) | 48 ++++++++++++++++++++++
 .../files/patch-notifyd__notifyd.c (new)           | 44 ++++++++++++++++++++
 6 files changed, 183 insertions(+), 2 deletions(-)
Comment 6 Hajimu UMEMOTO freebsd_committer 2021-06-20 04:35:03 UTC
I've raised the issue:

  https://github.com/cyrusimap/cyrus-imapd/issues/3531