Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lmtp returning mailbox unknown rather than over quota in 3.0.4 (from email) #2191

Closed
brong opened this issue Nov 3, 2017 · 3 comments
Closed
Assignees
Labels
3.0 affects 3.0 bug

Comments

@brong
Copy link
Member

brong commented Nov 3, 2017

Hi,

that's surprising and the same here.

I think there is a bug in imap/lmtpengine.c, function process_recipient:

verify_user returns the correct error code as we can see with LOG_DEBUG
"on":

Nov 2 14:10:50 popc lmtp[2092]: verify_user(test@sendmaid.org) failed:
Over quota

but this return code is not used in process_recipient

There we have:

[...]
     if (sl) {
         char *rcpt = xstrndup(addr, sl);
         mbname = mbname_from_recipient(rcpt, msg->ns);
         free(rcpt);

         int forcedowncase = config_getswitch(IMAPOPT_LMTP_DOWNCASE_RCPT);
         if (forcedowncase) mbname_downcaseuser(mbname);

         /* strip username if postuser */
         if (!strcmpsafe(mbname_localpart(mbname), 
config_getstring(IMAPOPT_POSTUSER))) {
             mbname_set_localpart(mbname, NULL);
             if (!config_virtdomains || 
!strcmpsafe(mbname_domain(mbname), config_defdomain))
                 mbname_set_domain(mbname, NULL);
         }

         if (verify_user(mbname,
                         (quota_t) (ignorequota ? -1 : msg->size),
                         ignorequota ? -1 : 1, msg->authstate)) {
             mbname_free(&mbname);
         }
     }

     if (!mbname) {
         const char *catchall = 
config_getstring(IMAPOPT_LMTP_CATCHALL_MAILBOX);
         if (catchall) {
             mbname = mbname_from_userid(catchall);
             if (verify_user(mbname,
                             ignorequota ? -1 : msg->size,
                             ignorequota ? -1 : 1, msg->authstate)) {
                 mbname_free(&mbname);
             }
         }
     }

     if (!mbname) {
         /* we lost */
         return IMAP_MAILBOX_NONEXISTENT;
     }
[...]

means as far as I understand: if verify_user returns its error (for
example IMAP_QUOTA_EXCEEDED), mbname is freed and process_recipient
always returns IMAP_MAILBOX_NONEXISTENT.

Below is a patch that works for me. But I don't know if this is a good
way to fix it.
Hopefully one of the developers helps :)

Regards, Edda

diff -Naur cyrus-imapd-3.0.4.orig/imap/lmtpengine.c 
cyrus-imapd-3.0.4/imap/lmtpengine.c
--- cyrus-imapd-3.0.4.orig/imap/lmtpengine.c    2017-09-04 
02:09:46.000000000 +0200
+++ cyrus-imapd-3.0.4/imap/lmtpengine.c    2017-11-02 13:59:56.764175245 
+0100
@@ -830,6 +830,7 @@
      }

      mbname_t *mbname = NULL;
+    int r = 0;

      size_t sl = strlen(addr);
      if (addr[sl-1] == '>') sl--;
@@ -849,7 +850,7 @@
                  mbname_set_domain(mbname, NULL);
          }

-        if (verify_user(mbname,
+        if (r = verify_user(mbname,
                          (quota_t) (ignorequota ? -1 : msg->size),
                          ignorequota ? -1 : 1, msg->authstate)) {
              mbname_free(&mbname);
@@ -860,7 +861,7 @@
          const char *catchall = 
config_getstring(IMAPOPT_LMTP_CATCHALL_MAILBOX);
          if (catchall) {
              mbname = mbname_from_userid(catchall);
-            if (verify_user(mbname,
+            if (r = verify_user(mbname,
                              ignorequota ? -1 : msg->size,
                              ignorequota ? -1 : 1, msg->authstate)) {
                  mbname_free(&mbname);
@@ -870,6 +871,9 @@

      if (!mbname) {
          /* we lost */
+    if (r) {
+        return r;
+        }
          return IMAP_MAILBOX_NONEXISTENT;
      }

Am 02.11.17 um 09:27 schrieb Maros Vegh:

Hello,

i'm using compiled cyrus version 3.0.4 on Debian 9.2.

When the Postfix server is trying to deliver a message via lmtp to 
cyrus mailbox which is over quota, it receives the 550-Mailbox unknown 
return code and not the 452 or 552 Over quota.

In the previous version 2.5.10 it worked fine with default values in 
imapd.conf

Is it a bug or my fault?

Thanks

Maros Vegh
@postilion
Copy link
Contributor

@elliefm @brong Any chance of a new point release with this in it, before year end? We have a few Cyrus 2.5.X to 3.0.X upgrades planned for the holidays, but proper over-quota response is critical to these clients. A new 3.0.5 release would be greatly appreciated.

@elliefm
Copy link
Contributor

elliefm commented Nov 30, 2017

Good thinking, I'm gonna put this on my list for next week :)

@MarkMartinec
Copy link

Btw, this is now in the 3.0.5 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 affects 3.0 bug
Projects
None yet
Development

No branches or pull requests

4 participants