changeset 6358:6bd13d514294 HEAD

Fixed home directory handling which got broken by previous changes.
author Timo Sirainen <tss@iki.fi>
date Sun, 09 Sep 2007 03:58:57 +0300
parents a445f128744e
children c54c07f30a97
files src/deliver/auth-client.c src/deliver/deliver.c
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver/auth-client.c	Sat Sep 08 03:50:25 2007 +0300
+++ b/src/deliver/auth-client.c	Sun Sep 09 03:58:57 2007 +0300
@@ -90,6 +90,10 @@
 			chroot = *tmp + 7;
 		} else {
 			char *field = i_strdup(*tmp);
+
+			if (strncmp(field, "home=", 5) == 0)
+				env_put(t_strconcat("HOME=", field + 5, NULL));
+
 			array_append(conn->extra_fields, &field, 1);
 		}
 	}
--- a/src/deliver/deliver.c	Sat Sep 08 03:50:25 2007 +0300
+++ b/src/deliver/deliver.c	Sun Sep 09 03:58:57 2007 +0300
@@ -516,12 +516,14 @@
 static void expand_envs(const char *destination)
 {
         const struct var_expand_table *table;
-	const char *mail_env, *const *envs;
+	const char *mail_env, *const *envs, *home;
 	unsigned int i, count;
 	string_t *str;
 
+	home = getenv("HOME");
+
 	str = t_str_new(256);
-	table = get_var_expand_table(destination, getenv("HOME"));
+	table = get_var_expand_table(destination, home);
 	envs = array_get(&plugin_envs, &count);
 	for (i = 0; i < count; i++) {
 		str_truncate(str, 0);
@@ -533,7 +535,9 @@
 	if (mail_env != NULL) {
 		/* get the table again in case plugin envs provided the home
 		   directory (yea, kludgy) */
-		table = get_var_expand_table(destination, getenv("HOME"));
+		if (home == NULL)
+			home = getenv("HOME");
+		table = get_var_expand_table(destination, home);
 		mail_env = expand_mail_env(mail_env, table);
 	}
 	env_put(t_strconcat("MAIL=", mail_env, NULL));