Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5220:7fbdcce95982 HEAD
Keep only TZ and HOME environments when calling sendmail.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 06 Mar 2007 18:57:35 +0200 |
parents | 0d2d526dcf8f |
children | c8a82d0fb443 |
files | src/deliver/deliver.c src/deliver/deliver.h src/deliver/smtp-client.c |
diffstat | 3 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/deliver/deliver.c Tue Mar 06 18:35:46 2007 +0200 +++ b/src/deliver/deliver.c Tue Mar 06 18:57:35 2007 +0200 @@ -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++) {
--- a/src/deliver/deliver.h Tue Mar 06 18:35:46 2007 +0200 +++ b/src/deliver/deliver.h Tue Mar 06 18:57:35 2007 +0200 @@ -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,
--- a/src/deliver/smtp-client.c Tue Mar 06 18:35:46 2007 +0200 +++ b/src/deliver/smtp-client.c Tue Mar 06 18:57:35 2007 +0200 @@ -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); }