Bug 57976 - Additional maildirs for aliases since upgrade to UCS 5.2
Summary: Additional maildirs for aliases since upgrade to UCS 5.2
Status: CLOSED FIXED
Alias: None
Product: UCS
Classification: Unclassified
Component: Mail - Dovecot
Version: UCS 5.2
Hardware: Other Linux
: P5 normal
Target Milestone: UCS 5.2-3-errata
Assignee: Julia Bremer
QA Contact: Iván.Delgado
URL: https://git.knut.univention.de/univen...
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-20 18:12 CET by Mathias Behrle
Modified: 2025-10-16 08:34 CEST (History)
13 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 7: Crash: Bug causes crash or data loss
Who will be affected by this bug?: 4: Will affect most installed domains
How will those affected feel about the bug?: 4: A User would return the product
User Pain: 0.640
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2025082721000073, 2025091121000163, 2025091521000156, 2025092321000061, 2025071621000096
Bug group (optional):
Customer ID: 01427
Max CVSS v3 score:


Attachments
Dovecot debug log (3.74 KB, application/octet-stream)
2025-03-07 12:05 CET, Mathias Behrle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Behrle 2025-02-20 18:12:42 CET
On the UCS there are defined 4 mail domains, all user accounts get primary mail addresses/mailboxes in those domains. Some users have defined aliases.

Since the upgrade to 5.2 additional maildirs for aliases are created in the top level directory, they are always empty. Deleting thos obviously useless maildirs will lead to re-creation.
Comment 1 Mathias Behrle 2025-03-07 12:05:54 CET
Created attachment 11297 [details]
Dovecot debug log
Comment 2 Mathias Behrle 2025-03-07 12:16:31 CET
Tracking down the issue:
- Only users with aliased mailboxes are affected
- The problem exists only with dovecot user lookup, not with lmtp

Have a look at the joined debug log:

Mär 06 16:05:20 ucs dovecot[449038]: imap(<user_name>)<454171><T7ah1a0vCsDAqGTL>: Debug: Namespace inbox: type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/var/spool/dovecot/private//<user_name>/Maildir
Mär 06 16:05:20 ucs dovecot[449038]: imap(<user_name>)<454171><T7ah1a0vCsDAqGTL>: Debug: maildir++: root=/var/spool/dovecot/private//<user_name>/Maildir, index=, indexpvt=, control=, inbox=/var/spool/dovecot/private//<user_name>/Maildir, alt=            

The LDAP lookup results in //<user_name> instead of /<mail_domain>/<local_part>
I couldn't track down so far the failing LDAP lookup.

The problem is a major annoyance, because mail clients are regularly reloading the complete mailbox after showing initially empty mailboxes after some operations such as sending a mail.
Comment 3 Markus Meissner 2025-06-23 10:23:58 CEST
We've got the same problem. Our temporary fix is to create symbolic links at the top level dir to the matching directory (user.name → domain/user.name). Please let me know if I can do anything to help with debugging.
Comment 7 Ole Schwiegert univentionstaff 2025-09-02 08:18:45 CEST
It seems that this is a known problem with the auth cache in dovecot (https://help.univention.com/t/dovecot-seltsame-userordern-im-hauptverzeichnis/9849).

On of my colleagues condensed the workaround in a help article: https://help.univention.com/t/problem-dovecot-userdb-cache-causing-incorrect-home-directory-on-cached-imap-logins/24477
Comment 8 Mathias Behrle 2025-09-02 10:52:06 CEST
If this issue should really be related to Dovecots userdb cache, I am still  wondering why it appeared on upgrade of an existent installation to 5.2 (according to the links it existed already in UCS 4.0/4.2).

Does there exist an issue on dovecots bugtracker?
Comment 9 Florian Best univentionstaff 2025-09-02 11:10:31 CEST
Sound implausible to me as well, that a bug in dovecot which once was fixed (in older Debian versions) just re-occurred.
And I don't see that we have patches for dovecot. So we also didn't forget to re-apply a patch from UCS 4 ind UCS 5.

It would help, if somebody could test the workaround and say if that works.
Comment 10 Finn David univentionstaff 2025-09-03 10:55:36 CEST
(In reply to Florian Best from comment #9)
> It would help, if somebody could test the workaround and say if that works.

We've got feedback from our customer in #2025082221000153, that the workaround (disabling the cache) worked and no problems occured since then (~6 days).
Comment 13 Mathias Behrle 2025-09-17 10:45:48 CEST
(In reply to Florian Best from comment #9)

> It would help, if somebody could test the workaround and say if that works.

I can confirm as well, that disabling dovecots auth cache seems to work and no additional maildirs are created.
Comment 16 Julia Bremer univentionstaff 2025-10-09 18:30:50 CEST
9dfd50f003 Bug #57976: Advisories
e2e00fe7e9 Bug #57976: Adjust test timeout
1adaaa2dcf Bug #57976: Change greylisting script to use mailPrimaryAddress as auth validation
a6e57e40a0 Bug #57976: Create test for login against dovecot
1cf862cb33 Bug #57976: Remove pam univentionmailcyrus
38c3d9823a Bug #57976: Fix authentication using mailaddress in postfix
facbcc3984 Bug #57976: Fix authentication using mailaddress in dovecot


Package: univention-mail-postfix
Version: 16.3.0
Release: 5.2-0
Scope: errata5.2-3

Package: univention-mail-dovecot
Version: 8.3.1
Release: 5.2-0
Scope: errata5.2-3

Package: univention-pam
Version: 15.3.1
Release: 5.2-0
Scope: errata5.2-3


The reason for the additional mail directories was some confusion between the dovecot cache and the information it gathered from the authentication modules.
Since forever, we have a PAM module used in dovecot and postfix that translates the mailPrimaryAddress when used during authentication to a username.

If this translation happens (and the dovecot auth cache is already filled, thus no additional LDAP lookup is done), then dovecot regards the user identity as "username" instead of "mailPrimaryAddress".
If the behaviour change is due to a difference in dovecot or in PAM is unclear.

But this confusion only happens because we harshly translate the address to a username every time.
Since using sssd this is not necessary anymore.
We now configure sssd so that it can authenticate the user also using the mailPrimaryAddress. Thus the translation is not needed anymore.
We were able to reduce the complexity of the pam configuration as well as remove obsolete code, while fixing the issue without having to disable the auth cache of dovecot. Disabling the auth cache of dovecot results in 2x slower authentication, so we highly recommend enabling the cache after the fixed packages are installed.
Comment 17 Iván.Delgado univentionstaff 2025-10-14 10:47:44 CEST
QA:
 Code changes: OK
 Advisories: OK
 Login after receive a mail, do not create a new mailDir: OK
 OX Functional account works: Fail but don't apply to this bug see #58699
  ~ After upgrade from 5.0 works 
  ~ New installation don't work
Comment 19 Mathias Behrle 2025-10-16 08:34:30 CEST
(In reply to Julia Bremer from comment #16)
> 9dfd50f003 Bug #57976: Advisories
> e2e00fe7e9 Bug #57976: Adjust test timeout
> 1adaaa2dcf Bug #57976: Change greylisting script to use mailPrimaryAddress
> as auth validation
> a6e57e40a0 Bug #57976: Create test for login against dovecot
> 1cf862cb33 Bug #57976: Remove pam univentionmailcyrus
> 38c3d9823a Bug #57976: Fix authentication using mailaddress in postfix
> facbcc3984 Bug #57976: Fix authentication using mailaddress in dovecot
> 
> 
> Package: univention-mail-postfix
> Version: 16.3.0
> Release: 5.2-0
> Scope: errata5.2-3
> 
> Package: univention-mail-dovecot
> Version: 8.3.1
> Release: 5.2-0
> Scope: errata5.2-3
> 
> Package: univention-pam
> Version: 15.3.1
> Release: 5.2-0
> Scope: errata5.2-3
> 
> 
> The reason for the additional mail directories was some confusion between
> the dovecot cache and the information it gathered from the authentication
> modules.
> Since forever, we have a PAM module used in dovecot and postfix that
> translates the mailPrimaryAddress when used during authentication to a
> username.
> 
> If this translation happens (and the dovecot auth cache is already filled,
> thus no additional LDAP lookup is done), then dovecot regards the user
> identity as "username" instead of "mailPrimaryAddress".
> If the behaviour change is due to a difference in dovecot or in PAM is
> unclear.
> 
> But this confusion only happens because we harshly translate the address to
> a username every time.
> Since using sssd this is not necessary anymore.
> We now configure sssd so that it can authenticate the user also using the
> mailPrimaryAddress. Thus the translation is not needed anymore.
> We were able to reduce the complexity of the pam configuration as well as
> remove obsolete code, while fixing the issue without having to disable the
> auth cache of dovecot. Disabling the auth cache of dovecot results in 2x
> slower authentication, so we highly recommend enabling the cache after the
> fixed packages are installed.

Confirmed: deployed 5.2-3 errata263, reactivated the auth cache, no more additional maildirs.

Thanks!