[Dovecot] rc7 bug? [Was: deliver LDA and INBOX location] (fwd)

David Lee t.d.lee at durham.ac.uk
Tue Sep 5 18:46:55 EEST 2006


On Tue, 5 Sep 2006, Tapio Sokura wrote:

> 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..

Ah!  Our emails cross...

I have just drafted a patch to address the issue of "%i" being ignored.
The patch is re-attached here.

You mention home directories; my issue was uid (%i).  You also mention
default_mail_env being ignored; for me it seemed to be "mostly, but not
entirely, OK".

So our issues may be somewhat different.  Nevertheless the patch might
give an idea of the sort of thing that might be relevant.

DISCLAIMER:  I'm a newcomer to dovecot.  This patch is completely
unverified (at present) by anyone else, and it might diverge from
established dovecot 'best practice' principles.  Own risk, etc.

-- 

:  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);
 	}
 


More information about the dovecot mailing list