Mercurial > dovecot > original-hg > dovecot-1.2
changeset 779:f126b666859e HEAD
New setting: default_mail_env which can be used to specify where to find
users mailbox. Default is still to use autodetection. Authentication process
can override this if needed, it's possible with passwd-file authentication.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 12 Dec 2002 08:04:29 +0200 |
parents | 9c9d89e56514 |
children | 1cc947617c8b |
files | dovecot-example.conf src/master/imap-process.c src/master/settings.c src/master/settings.h |
diffstat | 4 files changed, 66 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dovecot-example.conf Thu Dec 12 07:33:50 2002 +0200 +++ b/dovecot-example.conf Thu Dec 12 08:04:29 2002 +0200 @@ -134,6 +134,12 @@ # allow shell access for users. #valid_chroot_dirs = +# Default MAIL environment to use when it's not set. By leaving this empty +# dovecot tries to do some automatic detection as described in +# doc/mail-storages.txt. $U will be replaced with username. Some examples: +# "maildir:/var/mail/$U/Maildir", "mbox:~/mail/" +#default_mail_env = + # Space-separated list of fields to cache for all mails. Currently these # fields are allowed followed by a list of commands they speed up: #
--- a/src/master/imap-process.c Thu Dec 12 07:33:50 2002 +0200 +++ b/src/master/imap-process.c Thu Dec 12 08:04:29 2002 +0200 @@ -2,6 +2,7 @@ #include "common.h" #include "env-util.h" +#include "temp-string.h" #include "restrict-access.h" #include "restrict-process-size.h" @@ -62,6 +63,44 @@ return FALSE; } +static const char *expand_mail_env(const char *env, const char *user, + const char *home) +{ + TempString *str; + const char *p; + + str = t_string_new(256); + + /* it's either type:data or just data */ + p = strchr(env, ':'); + if (p != NULL) { + while (env != p) { + t_string_append_c(str, *env); + env++; + } + + t_string_append_c(str, *env++); + } + + if (env[0] == '~' && env[1] == '/') { + /* expand home */ + t_string_append(str, home); + env++; + } + + /* expand $U if found */ + for (; *env != '\0'; env++) { + if (*env == '$' && env[1] == 'U') { + t_string_append(str, user); + env++; + } else { + t_string_append_c(str, *env); + } + } + + return str->str; +} + MasterReplyResult create_imap_process(int socket, IPADDR *ip, const char *user, uid_t uid, gid_t gid, const char *home, int chroot, const char *env[]) @@ -69,7 +108,7 @@ static char *argv[] = { NULL, "-s", NULL, NULL }; char host[MAX_IP_LEN], title[1024]; pid_t pid; - int i, j, err; + int i, j, err, found_mail; if (imap_process_count == set_max_imap_processes) { i_error("Maximum number of imap processes exceeded"); @@ -111,9 +150,23 @@ (void)close(socket); /* setup environment */ - while (env[0] != NULL && env[1] != NULL) { + found_mail = FALSE; + for (; env[0] != NULL && env[1] != NULL; env += 2) { + if (strcmp(env[0], "MAIL") == 0) { + if (env[1] == NULL || *env[1] == '\0') + continue; + + found_mail = TRUE; + } + env_put(t_strconcat(env[0], "=", env[1], NULL)); - env += 2; + } + + if (!found_mail) { + const char *mail; + + mail = expand_mail_env(set_default_mail_env, user, home); + env_put(t_strconcat("MAIL=", mail, NULL)); } env_put(t_strconcat("HOME=", home, NULL));
--- a/src/master/settings.c Thu Dec 12 07:33:50 2002 +0200 +++ b/src/master/settings.c Thu Dec 12 08:04:29 2002 +0200 @@ -59,6 +59,7 @@ { "last_valid_uid", SET_INT, &set_last_valid_uid }, { "first_valid_gid", SET_INT, &set_first_valid_gid }, { "last_valid_gid", SET_INT, &set_last_valid_gid }, + { "default_mail_env", SET_STR, &set_default_mail_env }, { "mail_cache_fields", SET_STR, &set_mail_cache_fields }, { "mail_never_cache_fields", SET_STR, &set_mail_never_cache_fields }, @@ -124,6 +125,7 @@ unsigned int set_first_valid_uid = 500, set_last_valid_uid = 0; unsigned int set_first_valid_gid = 1, set_last_valid_gid = 0; +char *set_default_mail_env = NULL; char *set_mail_cache_fields = "MessagePart"; char *set_mail_never_cache_fields = NULL; unsigned int set_mailbox_check_interval = 30;
--- a/src/master/settings.h Thu Dec 12 07:33:50 2002 +0200 +++ b/src/master/settings.h Thu Dec 12 08:04:29 2002 +0200 @@ -42,11 +42,13 @@ extern unsigned int set_first_valid_uid, set_last_valid_uid; extern unsigned int set_first_valid_gid, set_last_valid_gid; +extern char *set_default_mail_env; extern char *set_mail_cache_fields; extern char *set_mail_never_cache_fields; extern unsigned int set_mailbox_check_interval; extern int set_mail_save_crlf; extern int set_mail_read_mmaped; +extern int set_mail_read_mmaped; extern int set_maildir_copy_with_hardlinks; extern int set_maildir_check_content_changes; extern char *set_mbox_locks;