[dovecot-cvs] dovecot/src/deliver deliver.c, 1.52, 1.53 deliver.h, 1.2, 1.3 smtp-client.c, 1.3, 1.4

tss at dovecot.org tss at dovecot.org
Tue Mar 6 18:57:38 EET 2007


Update of /var/lib/cvs/dovecot/src/deliver
In directory talvi:/tmp/cvs-serv11473

Modified Files:
	deliver.c deliver.h smtp-client.c 
Log Message:
Keep only TZ and HOME environments when calling sendmail.



Index: deliver.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/deliver/deliver.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- deliver.c	6 Mar 2007 13:14:09 -0000	1.52
+++ deliver.c	6 Mar 2007 16:57:35 -0000	1.53
@@ -453,12 +453,32 @@
 "               [-f <envelope sender>]\n");
 }
 
+void deliver_env_clean(void)
+{
+	const char *tz, *home;
+
+	tz = getenv("TZ");
+	if (tz != NULL)
+		tz = t_strconcat("TZ=", tz, NULL);
+	home = getenv("HOME");
+	if (home != NULL)
+		home = t_strconcat("HOME=", home, NULL);
+
+	/* Note that if the original environment was set with env_put(), the
+	   environment strings will be invalid after env_clean(). That's why
+	   we t_strconcat() them above. */
+	env_clean();
+
+	if (tz != NULL) env_put(tz);
+	if (home != NULL) env_put(home);
+}
+
 int main(int argc, char *argv[])
 {
 	const char *config_path = DEFAULT_CONFIG_FILE;
 	const char *envelope_sender = DEFAULT_ENVELOPE_SENDER;
 	const char *mailbox = "INBOX";
-	const char *auth_socket, *env_tz;
+	const char *auth_socket;
 	const char *home, *destination, *user, *mail_env, *value;
         const struct var_expand_table *table;
         enum mail_storage_flags flags;
@@ -483,14 +503,7 @@
         lib_signals_ignore(SIGXFSZ, TRUE);
 #endif
 
-	/* Clean up environment. */
-	env_tz = getenv("TZ");
-	home = getenv("HOME");
-	env_clean();
-	if (env_tz != NULL)
-		env_put(t_strconcat("TZ=", env_tz, NULL));
-	if (home != NULL)
-		env_put(t_strconcat("HOME=", home, NULL));
+	deliver_env_clean();
 
 	destination = NULL;
 	for (i = 1; i < argc; i++) {

Index: deliver.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/deliver/deliver.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- deliver.h	16 Jun 2006 09:30:07 -0000	1.2
+++ deliver.h	6 Mar 2007 16:57:35 -0000	1.3
@@ -19,6 +19,8 @@
 
 extern deliver_mail_func_t *deliver_mail;
 
+void deliver_env_clean(void);
+
 /* Save a mail into given mailbox with given flags and keywords. */
 int deliver_save(struct mail_storage *storage, const char *mailbox,
 		 struct mail *mail, enum mail_flags flags,

Index: smtp-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/deliver/smtp-client.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smtp-client.c	18 Nov 2006 14:06:34 -0000	1.3
+++ smtp-client.c	6 Mar 2007 16:57:35 -0000	1.4
@@ -42,6 +42,8 @@
 	if (dup2(fd, STDIN_FILENO) < 0)
 		i_fatal("dup2() failed: %m");
 
+	deliver_env_clean();
+
 	(void)execv(deliver_set->sendmail_path, (char **)argv);
 	i_fatal("execv(%s) failed: %m", deliver_set->sendmail_path);
 }



More information about the dovecot-cvs mailing list