changeset 3897:9dc2f8f0eb59 HEAD

When starting with --exec-mail, keep USER and HOME environments and clear the rest.
author Timo Sirainen <tss@iki.fi>
date Sun, 15 Jan 2006 21:02:19 +0200
parents 7aea43511bac
children 3bbd7ba3315e
files src/master/main.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/main.c	Sun Jan 15 21:01:46 2006 +0200
+++ b/src/master/main.c	Sun Jan 15 21:02:19 2006 +0200
@@ -698,7 +698,7 @@
 int main(int argc, char *argv[])
 {
 	/* parse arguments */
-	const char *exec_protocol = NULL, *exec_section = NULL;
+	const char *exec_protocol = NULL, *exec_section = NULL, *user, *home;
 	bool foreground = FALSE, ask_key_pass = FALSE;
 	int i;
 
@@ -767,12 +767,11 @@
 		t_pop();
 	}
 
-	if (exec_protocol != NULL)
-		mail_process_exec(exec_protocol, exec_section);
-
 	/* save TZ environment. AIX depends on it to get the timezone
 	   correctly. */
 	env_tz = getenv("TZ");
+	user = getenv("USER");
+	home = getenv("HOME");
 
 	/* clean up the environment of everything */
 	env_clean();
@@ -781,6 +780,13 @@
 	if (env_tz != NULL)
 		env_put(t_strconcat("TZ=", env_tz, NULL));
 
+	if (exec_protocol != NULL) {
+		/* Put back user and home */
+		env_put(t_strconcat("USER=", user, NULL));
+		env_put(t_strconcat("HOME=", home, NULL));
+		mail_process_exec(exec_protocol, exec_section);
+	}
+
 	open_fds();
 
 	if (!foreground)