From: Timo Sirainen Date: Wed, 16 Apr 2003 16:05:45 +0000 (+0300) Subject: chdir() to base_dir at startup. chdir() mail processes to home dir if it's X-Git-Tag: 1.1.alpha1~4739 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef519597878f7b21f16ac4b458104664ab9b140d;p=thirdparty%2Fdovecot%2Fcore.git chdir() to base_dir at startup. chdir() mail processes to home dir if it's known. --HG-- branch : HEAD --- diff --git a/src/master/mail-process.c b/src/master/mail-process.c index 9a02288701..3aca9a62c8 100644 --- a/src/master/mail-process.c +++ b/src/master/mail-process.c @@ -105,7 +105,7 @@ int create_mail_process(int socket, struct ip_addr *ip, const char *data) { static const char *argv[] = { NULL, NULL, NULL }; - const char *host, *mail; + const char *host, *mail, *home_dir; char title[1024]; pid_t pid; int i, err; @@ -154,8 +154,14 @@ int create_mail_process(int socket, struct ip_addr *ip, restrict_process_size(process_size, (unsigned int)-1); + home_dir = data + reply->home_idx; + if (*home_dir != '\0') { + if (chdir(home_dir) < 0) + i_fatal("chdir(%s) failed: %m", home_dir); + } + env_put("LOGGED_IN=1"); - env_put(t_strconcat("HOME=", data + reply->home_idx, NULL)); + env_put(t_strconcat("HOME=", home_dir, NULL)); env_put(t_strconcat("MAIL_CACHE_FIELDS=", set->mail_cache_fields, NULL)); env_put(t_strconcat("MAIL_NEVER_CACHE_FIELDS=", diff --git a/src/master/main.c b/src/master/main.c index 7bdc0903b5..4a05f85e80 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -396,6 +396,9 @@ static void daemonize(void) if (setsid() < 0) i_fatal("setsid() failed: %m"); + + if (chdir(set->base_dir) < 0) + i_fatal("chdir(%s) failed: %m", set->base_dir); } static void print_help(void)