- go through mail-process.c. nfs test?
- support !include and !include_try
- add back all setting verification code from master
- - plugins:
- - backwards compatibility so userdb can continue returning quota_* etc?
- - acl: master_user, acl_groups are now plugin envs..
+ - master_user, acl_groups are now plugin envs.. is it correct?
- proxying: support fallbacking to local (or other?) server if the first
one is down
user_attrs {
-I$(top_srcdir)/src/lib-imap \
-I$(top_srcdir)/src/lib-index \
-I$(top_srcdir)/src/lib-storage \
+ -DPKG_RUNDIR=\""$(rundir)"\" \
-DMODULEDIR=\""$(moduledir)"\"
imap_LDFLAGS = -export-dynamic
{ SET_DEFLIST, name, offsetof(struct imap_settings, field), defines }
static struct setting_define imap_setting_defines[] = {
+ DEF(SET_STR, base_dir),
+ DEF(SET_STR, auth_socket_path),
+
DEF(SET_BOOL, mail_debug),
DEF(SET_BOOL, shutdown_clients),
DEF(SET_BOOL, verbose_proctitle),
};
static struct imap_settings imap_default_settings = {
+ MEMBER(base_dir) PKG_RUNDIR,
+ MEMBER(auth_socket_path) "auth-master",
+
MEMBER(mail_debug) FALSE,
MEMBER(shutdown_clients) FALSE,
MEMBER(verbose_proctitle) FALSE,
static pool_t settings_pool = NULL;
+static void fix_base_path(struct imap_settings *set, const char **str)
+{
+ if (*str != NULL && **str != '\0' && **str != '/') {
+ *str = p_strconcat(settings_pool,
+ set->base_dir, "/", *str, NULL);
+ }
+}
+
void imap_settings_read(const struct imap_settings **set_r,
const struct mail_user_settings **user_set_r)
{
&mail_user_setting_parser_info
};
struct setting_parser_context *parser;
- const char *const *expanded;
+ struct imap_settings *set;
+ const char *const *expanded, *value;
void **sets;
if (settings_pool == NULL)
expanded = t_strsplit(getenv("VARS_EXPANDED"), " ");
settings_parse_set_keys_expandeded(parser, settings_pool, expanded);
+ /* settings from userdb are in the VARS_EXPANDED list. for each
+ unknown setting in the list assume it's a plugin setting. */
+ for (; *expanded != NULL; expanded++) {
+ if (settings_parse_is_valid_key(parser, *expanded))
+ continue;
+
+ value = getenv(t_str_ucase(*expanded));
+ if (value == NULL)
+ continue;
+
+ settings_parse_line(parser, t_strconcat("plugin/", *expanded,
+ "=", value, NULL));
+ }
sets = settings_parser_get_list(parser);
- *set_r = sets[0];
+ set = sets[0];
+ fix_base_path(set, &set->auth_socket_path);
+
+ *set_r = set;
*user_set_r = sets[1];
settings_parser_deinit(&parser);
}
struct mail_user_settings;
struct imap_settings {
+ const char *base_dir;
+ const char *auth_socket_path;
+
bool mail_debug;
bool shutdown_clients;
bool verbose_proctitle;
}
dict_drivers_register_builtin();
- mail_users_init(getenv("AUTH_SOCKET_PATH"), getenv("DEBUG") != NULL);
+ mail_users_init(set->auth_socket_path, set->mail_debug);
clients_init();
commands_init();
}
}
+bool settings_parse_is_valid_key(struct setting_parser_context *ctx,
+ const char *key)
+{
+ const struct setting_define *def;
+ struct setting_link *link;
+
+ return settings_find_key(ctx, key, &def, &link);
+}
+
int settings_parse_line(struct setting_parser_context *ctx, const char *line)
{
const char *key, *value;
void settings_parse_save_input(struct setting_parser_context *ctx,
string_t *dest);
+/* Returns TRUE if the given key is a valid setting. */
+bool settings_parse_is_valid_key(struct setting_parser_context *ctx,
+ const char *key);
/* Parse a single line. Returns 1 if OK, 0 if key is unknown, -1 if error. */
int settings_parse_line(struct setting_parser_context *ctx, const char *line);
/* Parse data already read in input stream. */
pid_t *pid_r)
{
const struct var_expand_table *var_expand_table;
- const char *p, *addr, *mail, *chroot_dir, *home_dir, *full_home_dir;
+ const char *p, *addr, *chroot_dir, *home_dir, *full_home_dir;
const char *system_user, *master_user, *key;
struct mail_process_group *process_group;
char title[1024];
}
t_array_init(&extra_args, 16);
- mail = home_dir = chroot_dir = system_user = ""; master_user = NULL;
+ home_dir = chroot_dir = system_user = ""; master_user = NULL;
uid = (uid_t)-1; gid = (gid_t)-1; nice_value = 0;
home_given = FALSE;
for (; *args != NULL; args++) {
if (strncmp(*args, "home=", 5) == 0) {
home_dir = *args + 5;
home_given = TRUE;
- } else if (strncmp(*args, "mail=", 5) == 0)
- mail = *args + 5;
- else if (strncmp(*args, "chroot=", 7) == 0)
+ } else if (strncmp(*args, "mail=", 5) == 0) {
+ const char *arg;
+
+ arg = t_strconcat("mail_location=", *args + 5, NULL);
+ array_append(&extra_args, &arg, 1);
+ } else if (strncmp(*args, "chroot=", 7) == 0)
chroot_dir = *args + 7;
else if (strncmp(*args, "nice=", 5) == 0)
nice_value = atoi(*args + 5);
{ type, #name, offsetof(struct convert_settings, name), NULL }
static struct setting_define convert_setting_defines[] = {
+ DEF(SET_STR, base_dir),
DEF(SET_STR, auth_socket_path),
+
{ SET_STRLIST, "plugin", offsetof(struct convert_settings, plugin_envs), NULL },
SETTING_DEFINE_LIST_END
};
static struct convert_settings convert_default_settings = {
- MEMBER(auth_socket_path) PKG_RUNDIR"/auth-master"
+ MEMBER(base_dir) PKG_RUNDIR,
+ MEMBER(auth_socket_path) "auth-master"
};
struct setting_parser_info convert_setting_parser_info = {
static pool_t settings_pool = NULL;
+static void fix_base_path(struct convert_settings *set, const char **str)
+{
+ if (*str != NULL && **str != '\0' && **str != '/') {
+ *str = p_strconcat(settings_pool,
+ set->base_dir, "/", *str, NULL);
+ }
+}
+
void convert_settings_read(const struct convert_settings **set_r,
const struct mail_user_settings **user_set_r)
{
&mail_user_setting_parser_info
};
struct setting_parser_context *parser;
- const char *const *expanded;
+ struct convert_settings *set;
void **sets;
if (settings_pool == NULL)
settings_parser_get_error(parser));
}
- expanded = t_strsplit(getenv("VARS_EXPANDED"), " ");
- settings_parse_set_keys_expandeded(parser, settings_pool, expanded);
-
sets = settings_parser_get_list(parser);
- *set_r = sets[0];
+ set = sets[0];
+ fix_base_path(set, &set->auth_socket_path);
+
+ *set_r = set;
*user_set_r = sets[1];
settings_parser_deinit(&parser);
}
struct mail_user_settings;
struct convert_settings {
+ const char *base_dir;
const char *auth_socket_path;
ARRAY_DEFINE(plugin_envs, const char *);
#include "array.h"
#include "env-util.h"
#include "restrict-access.h"
+#include "str.h"
#include "auth-client.h"
#include "auth-master.h"
static void auth_set_env(const char *user, struct auth_user_reply *reply)
{
const char *const *fields, *key, *value;
+ string_t *expanded_vars;
unsigned int i, count;
if (reply->gid != (gid_t)-1 && getegid() != reply->gid) {
current_uid = reply->uid;
}
+ expanded_vars = t_str_new(128);
+ str_append(expanded_vars, "VARS_EXPANDED=");
fields = array_get(&reply->extra_fields, &count);
for (i = 0; i < count; i++) {
- key = t_str_ucase(t_strcut(fields[i], '='));
+ key = t_strcut(fields[i], '=');
value = strchr(fields[i], '=');
if (value != NULL)
value++;
else
value = "1";
- env_put(t_strconcat(key, "=", value, NULL));
+ env_put(t_strconcat(t_str_ucase(key), "=", value, NULL));
+
+ str_append(expanded_vars, key);
+ str_append_c(expanded_vars, ' ');
}
+ env_put(str_c(expanded_vars));
env_put(t_strconcat("HOME=", reply->home, NULL));
}
{ type, #name, offsetof(struct expire_settings, name), NULL }
static struct setting_define expire_setting_defines[] = {
+ DEF(SET_STR, base_dir),
DEF(SET_STR, auth_socket_path),
+
{ SET_STRLIST, "plugin", offsetof(struct expire_settings, plugin_envs), NULL },
SETTING_DEFINE_LIST_END
};
static struct expire_settings expire_default_settings = {
- MEMBER(auth_socket_path) PKG_RUNDIR"/auth-master"
+ MEMBER(base_dir) PKG_RUNDIR,
+ MEMBER(auth_socket_path) "auth-master"
};
struct setting_parser_info expire_setting_parser_info = {
static pool_t settings_pool = NULL;
+static void fix_base_path(struct expire_settings *set, const char **str)
+{
+ if (*str != NULL && **str != '\0' && **str != '/') {
+ *str = p_strconcat(settings_pool,
+ set->base_dir, "/", *str, NULL);
+ }
+}
+
void expire_settings_read(const struct expire_settings **set_r,
const struct mail_user_settings **user_set_r)
{
&mail_user_setting_parser_info
};
struct setting_parser_context *parser;
- const char *const *expanded;
+ struct expire_settings *set;
+ const char *const *expanded, *value;
void **sets;
if (settings_pool == NULL)
expanded = t_strsplit(getenv("VARS_EXPANDED"), " ");
settings_parse_set_keys_expandeded(parser, settings_pool, expanded);
+ /* settings from userdb are in the VARS_EXPANDED list. for each
+ unknown setting in the list assume it's a plugin setting. */
+ for (; *expanded != NULL; expanded++) {
+ if (settings_parse_is_valid_key(parser, *expanded))
+ continue;
+
+ value = getenv(t_str_ucase(*expanded));
+ if (value == NULL)
+ continue;
+
+ settings_parse_line(parser, t_strconcat("plugin/", *expanded,
+ "=", value, NULL));
+ }
sets = settings_parser_get_list(parser);
- *set_r = sets[0];
+ set = sets[0];
+ fix_base_path(set, &set->auth_socket_path);
+
+ *set_r = set;
*user_set_r = sets[1];
settings_parser_deinit(&parser);
}
struct mail_user_settings;
struct expire_settings {
+ const char *base_dir;
const char *auth_socket_path;
ARRAY_DEFINE(plugin_envs, const char *);
-I$(top_srcdir)/src/lib-dict \
-I$(top_srcdir)/src/lib-mail \
-I$(top_srcdir)/src/lib-storage \
+ -DPKG_RUNDIR=\""$(rundir)"\" \
-DMODULEDIR=\""$(moduledir)"\"
pop3_LDFLAGS = -export-dynamic
}
dict_drivers_register_builtin();
- mail_users_init(getenv("AUTH_SOCKET_PATH"), getenv("DEBUG") != NULL);
+ mail_users_init(set->auth_socket_path, set->mail_debug);
clients_init();
module_dir_init(modules);
{ SET_DEFLIST, name, offsetof(struct pop3_settings, field), defines }
static struct setting_define pop3_setting_defines[] = {
+ DEF(SET_STR, base_dir),
+ DEF(SET_STR, auth_socket_path),
+
DEF(SET_BOOL, mail_debug),
DEF(SET_BOOL, shutdown_clients),
DEF(SET_BOOL, verbose_proctitle),
};
static struct pop3_settings pop3_default_settings = {
+ MEMBER(base_dir) PKG_RUNDIR,
+ MEMBER(auth_socket_path) "auth-master",
+
MEMBER(mail_debug) FALSE,
MEMBER(shutdown_clients) FALSE,
MEMBER(verbose_proctitle) FALSE,
static pool_t settings_pool = NULL;
+static void fix_base_path(struct pop3_settings *set, const char **str)
+{
+ if (*str != NULL && **str != '\0' && **str != '/') {
+ *str = p_strconcat(settings_pool,
+ set->base_dir, "/", *str, NULL);
+ }
+}
+
void pop3_settings_read(const struct pop3_settings **set_r,
const struct mail_user_settings **user_set_r)
{
&mail_user_setting_parser_info
};
struct setting_parser_context *parser;
- const char *const *expanded;
+ struct pop3_settings *set;
+ const char *const *expanded, *value;
void **sets;
if (settings_pool == NULL)
expanded = t_strsplit(getenv("VARS_EXPANDED"), " ");
settings_parse_set_keys_expandeded(parser, settings_pool, expanded);
+ /* settings from userdb are in the VARS_EXPANDED list. for each
+ unknown setting in the list assume it's a plugin setting. */
+ for (; *expanded != NULL; expanded++) {
+ if (settings_parse_is_valid_key(parser, *expanded))
+ continue;
+
+ value = getenv(t_str_ucase(*expanded));
+ if (value == NULL)
+ continue;
+
+ settings_parse_line(parser, t_strconcat("plugin/", *expanded,
+ "=", value, NULL));
+ }
sets = settings_parser_get_list(parser);
- *set_r = sets[0];
+ set = sets[0];
+ fix_base_path(set, &set->auth_socket_path);
+
+ *set_r = set;
*user_set_r = sets[1];
settings_parser_deinit(&parser);
}
struct mail_user_settings;
struct pop3_settings {
+ const char *base_dir;
+ const char *auth_socket_path;
+
bool mail_debug;
bool shutdown_clients;
bool verbose_proctitle;