Webmin "Read User Email" destroying symlinks in /var/mail

I have a Webmin 1.510+virtualmin 3.78.gpl installation up and running. I am using usernames in the format user@domain.tld

Since I am also using postfix, every user gets created as a pair user-domain, user@domain and each mailbox file is created as user-domain.tld with a symlink in the format user@domain.tld pointing at it:

-rw-r--r-- 1 ciccio@gigatest .it gigatest.it 7097 Jul 11 17:59 ciccio-gigatest.it
lrwxrwxrwx 1 root               root          28 Jul 11 18:07 ciccio@gigatest .it -> /var/mail/ciccio-gigatest.it

This is perfectly normal and expected.

However, every time I delete a message using Webmin's "Read User Email" module, the symlink gets destroyed and replaced with a regular file:

-rw-r--r-- 1 ciccio@gigatest .it gigatest.it 7097 Jul 11 17:59 ciccio-gigatest.it
-rw-r--r-- 1 ciccio@gigatest .it gigatest.it 6308 Jul 11 18:20 ciccio@gigatest. it

This leads to problems since new mails are delivered from postfix directly into the user-domain file, while the user would always access the now stale user@domain file.

Is it a bug? Is there some setting I need to look at?

Thanks.

Note: I had to add a space space between '.' and 'it' otherwise the user@domain would get interpreted as mailto:

Status: 
Closed (fixed)

Comments

Joe's picture
Submitted by Joe on Sun, 07/11/2010 - 14:47 Pro Licensee

While this does sound like a bug that needs fixing, and I'm assigning it to Jamie, I will mention that Maildir is a much better option than mbox mail in /var/mail for most folks. In particular, there are a lot of tricky bits that need to be setup just right for user@domain.tld usernames to work (like the symlinks) that are just automatic in a Maildir deployment (Maildir goes into the users home directory, so there is no way to get the wrong mailbox file and no symlinks are needed).

It's also generally faster for large mailboxes, particularly for IMAP users (because there is no big lock on the whole spool, multiple operations on different messages can happen out of sequence).

That does look like a bug..

When you read and delete mail, are you doing it for the ciccio-gigatest.it user, or the variant with the @ in the username?

Ok, I see the cause of this .. it's a Webmin bug. I will fix it in Webmin 1.520.

@ Joe
While Maildir is interesting, I am tied to a bunch of reporting tools/scripts that relay on /var/mail/ for the inboxes. Also I am afraid that the use of current/read email in the Maildir could impact on a system with strict quota since emails needs to be duplicated at a certain point while changing state.

@Jamie
To accommodate the use of user@domain with postfix, Virtualmin creates two entries in /etc/passwd, one being "user@domain", the other being "user-domain":

ciccio@gigatest .it:x:558:520:ciccio:/home/gigatest.it/homes/ciccio:/dev/null
ciccio-gigatest.it:x:558:520:ciccio:/home/gigatest.it/homes/ciccio:/dev/null

When the "Read User Email" module needs to decide what file to open in /var/mail it looks at /etc/passwd and gets the first entry related to the user.

So when the module access the emails, it opens /var/mail/ciccio@gigatest .it that - because we are using postfix - is a symlink to ciccio-gigatest.it.

Unfortunately when you delete emails, the remaining messages gets dumped in ciccio@gigatest .it that at this point becomes a regular file.

As a quick workaround, in order to suit the needs of my dumb users and my needs about usernames uniqueness, I have:

1) reverted to the username-domain style
2) Removed user@domain entries from /etc/passwd
3) Configured Dovecot to rewrite "@" as "-"

It will be interesting when it will come to perform SASL authentication and I will need to find a way to perform the same rewrite from postfix.

I was thinking about canonical names but I am not sure at what stage the map is read (that is before or after SASL invocation).

Cheers.

P.S. Sorry for the many, many edits. :)

Yes, there is a code bug in Webmin that causes it to not handle deletion properly in a symlinked mailbox file. It will only be fixed in Webmin 1.520..

Automatically closed -- issue fixed for 2 weeks with no activity.