David Lee
2006-Sep-05 08:54 UTC
[Dovecot] rc7 bug? [Was: deliver LDA and INBOX location] (fwd)
Anyone had any thoughts on the item below? If the problem is with my config, I'd like to be guided towards how I might resolve it. If it is a bug in rc7, it would be good to fix it, and I'd be happy to beta-test. -- : David Lee I.T. Service : : Senior Systems Programmer Computer Centre : : Durham University : : http://www.dur.ac.uk/t.d.lee/ South Road : : Durham DH1 3LE : : Phone: +44 191 334 2752 U.K. : ---------- Forwarded message ---------- Date: Fri, 1 Sep 2006 10:22:20 +0100 (BST) From: David Lee <t.d.lee at durham.ac.uk> To: dovecot at dovecot.org Subject: Re: [Dovecot] rc7 bug? [Was: deliver LDA and INBOX location] On Thu, 31 Aug 2006, David Lee wrote:> [...] > We have a well-established different convention which subdivides this, > based on the last two digits of the uid: "/var/spool/mail/12/fred" (for > fred's uid as something ending "[...]12"). This is working nicely with > dovecot, using the new rc7 functionality: > default_mail_env = mbox:%h:INBOX=/var/spool/mail/%-2.02i/%u:[...] > > I am now trying to get sendmail to use dovecot's "deliver" as the LDA, > [...] The main problem is that, according to the log file, the delivery > attempt is being made to an INBOX "/var/spool/mail//fred". That is, it > seems to be ignoring the "default_mail_env" setting. > > Have I missed something in the wiki, or is this a bug of some sort?I have looked deeper at my problem (abov). It seems to be a bug in rc7, and probably an "always been there" bug. I sprinked a few "i_info(...)" diagnostics into "deliver.c" where it does 'getenv("MAIL")' and 'getenv("DEFAULT_MAIL_ENV")'. It shows that these are being successfully read from the 'dovecot.conf' file (good). But, crucially, it seems that the "%" variable substitution is incomplete: line 483: MAIL [null] line 486: MAIL mbox:%h:INBOX=/var/spool/mail/%-2.02i/%u:INDEX=/var/spool/mail/indexes/%d/%n line 492: MAIL mbox:/home/fred:INBOX=/var/spool/mail//fred:INDEX=/var/spool/mail/indexes//fred (Aside: The act of inserting the 'i_info' will have knocked the line numbers adrift by a couple. But it shows what is (not) happening.) Note in the "INBOX=..." clause that while "%u" and "%h" have been successfully expanded (good), the "%i" variant (UNIX uid) has failed to get expanded (bad). I'm new to dovecot, so am on a steep learning curve and am unfamiliar with the source code and dovecot's principles. So it would probably take me ages to work out a suitable patch, and even then it might be inappropriate. But hopefully the above information is sufficient and suitable for someone (Timo?) to investigate more expertly and fully. If someone can produce a patch (or hints of what to patch and where) I would certainly intend to test it and work on it for you. Hope that helps. Many thanks in advance. -- : David Lee I.T. Service : : Senior Systems Programmer Computer Centre : : Durham University : : http://www.dur.ac.uk/t.d.lee/ South Road : : Durham DH1 3LE : : Phone: +44 191 334 2752 U.K. :
Tapio Sokura
2006-Sep-05 14:49 UTC
[Dovecot] rc7 bug? [Was: deliver LDA and INBOX location] (fwd)
Quoting David Lee <t.d.lee at durham.ac.uk>:> Anyone had any thoughts on the item below?I see you have stumbled upon the same problem that prompted me to subscribe to this list. I'm running rc7 as well and the deliver LDA is ignoring default_mail_env. As a workaround I have now explicitly specified each user's home directory in userdb, but it would be cleaner if the default could be used. I didn't look far into the dovecot code, but from what I peeked it looks like deliver/auth-client.c bails out at function auth_parse_input, if it doesn't receive a home directory from the userdb. No provisions there for checking default_mail_env. Or maybe I'm looking at the wrong place.. Tapio
David Lee
2006-Sep-05 15:40 UTC
[Dovecot] RC7: BUG! and patch [Was: Re: rc7 bug? [Was: deliver LDA and INBOX location] (fwd)]
On Tue, 5 Sep 2006, David Lee wrote:> Anyone had any thoughts on the item below? [see earlier in thread] > > If the problem is with my config, I'd like to be guided towards how I > might resolve it. > > If it is a bug in rc7, it would be good to fix it, and I'd be happy to > beta-test.BUG in rc7 (and probably from much earlier). The LDA 'deliver' fails to honour any uid (%i) setting in dovecot.conf. So delivery and reading happen in different places if 'default_mail_env' uses a '%i' variant. Clearly incorrect behaviour. Attached is a draft of a patch which fixes the problem. Please could the patch be reviewed and, in some form, applied? Thanks. -- : David Lee I.T. Service : : Senior Systems Programmer Computer Centre : : Durham University : : http://www.dur.ac.uk/t.d.lee/ South Road : : Durham DH1 3LE : : Phone: +44 191 334 2752 U.K. : -------------- next part -------------- --- src/deliver/deliver.c.orig 2006-08-10 22:47:56.000000000 +0100 +++ src/deliver/deliver.c 2006-09-05 16:29:32.850394000 +0100 @@ -231,7 +231,7 @@ } static const struct var_expand_table * -get_var_expand_table(const char *user, const char *home) +get_var_expand_table(const char *user, const char *home, uid_t uid) { static struct var_expand_table static_tab[] = { { 'u', NULL }, @@ -242,6 +242,7 @@ { 'l', NULL }, { 'r', NULL }, { 'p', NULL }, + { 'i', NULL }, { '\0', NULL } }; struct var_expand_table *tab; @@ -258,6 +259,7 @@ tab[5].value = NULL; tab[6].value = NULL; tab[7].value = my_pid; + tab[8].value = dec2str(uid); return tab; } @@ -356,7 +358,8 @@ struct istream *input; struct mailbox_transaction_context *t; struct mail *mail; - uid_t process_euid; + struct passwd *upw; + uid_t process_euid, uid; int i, ret; lib_init(); @@ -432,6 +435,13 @@ "destination user parameter (-d user) not given"); } + /* get user's details (in particular, the real uid) */ + upw = getpwnam(user); + if (upw == NULL) { + i_fatal("Couldn't lookup user's details (user=%s)", user); + } + uid = upw->pw_uid; + config_file_init(config_path); open_logfile(user); @@ -483,7 +493,7 @@ if (mail_env == NULL) mail_env = getenv("DEFAULT_MAIL_ENV"); if (mail_env != NULL) { - table = get_var_expand_table(destination, getenv("HOME")); + table = get_var_expand_table(destination, getenv("HOME"), uid); mail_env = expand_mail_env(mail_env, table); }