mail-storage-service.c (dovecot-2.3.16) | : | mail-storage-service.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
#include "ipwd.h" | #include "ipwd.h" | |||
#include "str.h" | #include "str.h" | |||
#include "time-util.h" | #include "time-util.h" | |||
#include "sleep.h" | #include "sleep.h" | |||
#include "var-expand.h" | #include "var-expand.h" | |||
#include "dict.h" | #include "dict.h" | |||
#include "settings-parser.h" | #include "settings-parser.h" | |||
#include "auth-master.h" | #include "auth-master.h" | |||
#include "master-service-private.h" | #include "master-service-private.h" | |||
#include "master-service-settings.h" | #include "master-service-settings.h" | |||
#include "master-service-ssl-settings.h" | ||||
#include "master-service-settings-cache.h" | #include "master-service-settings-cache.h" | |||
#include "mail-user.h" | #include "mail-user.h" | |||
#include "mail-namespace.h" | #include "mail-namespace.h" | |||
#include "mail-storage.h" | #include "mail-storage.h" | |||
#include "mail-storage-service.h" | #include "mail-storage-service.h" | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <time.h> | #include <time.h> | |||
#ifdef HAVE_SYS_TIME_H | #ifdef HAVE_SYS_TIME_H | |||
skipping to change at line 90 | skipping to change at line 91 | |||
enum mail_storage_service_flags flags; | enum mail_storage_service_flags flags; | |||
struct event *event; | struct event *event; | |||
ARRAY(struct event *) event_stack; | ARRAY(struct event *) event_stack; | |||
struct ioloop_context *ioloop_ctx; | struct ioloop_context *ioloop_ctx; | |||
const char *log_prefix, *auth_mech, *auth_token, *auth_user; | const char *log_prefix, *auth_mech, *auth_token, *auth_user; | |||
const char *system_groups_user, *uid_source, *gid_source; | const char *system_groups_user, *uid_source, *gid_source; | |||
const char *chdir_path; | const char *chdir_path; | |||
const struct mail_user_settings *user_set; | const struct mail_user_settings *user_set; | |||
const struct master_service_ssl_settings *ssl_set; | ||||
const struct setting_parser_info *user_info; | const struct setting_parser_info *user_info; | |||
struct setting_parser_context *set_parser; | struct setting_parser_context *set_parser; | |||
unsigned int session_id_counter; | unsigned int session_id_counter; | |||
bool anonymous:1; | bool anonymous:1; | |||
bool admin:1; | bool admin:1; | |||
}; | }; | |||
struct module *mail_storage_service_modules = NULL; | struct module *mail_storage_service_modules = NULL; | |||
skipping to change at line 672 | skipping to change at line 674 | |||
mail_storage_service_init_post(struct mail_storage_service_ctx *ctx, | mail_storage_service_init_post(struct mail_storage_service_ctx *ctx, | |||
struct mail_storage_service_user *user, | struct mail_storage_service_user *user, | |||
struct mail_storage_service_privileges *priv, | struct mail_storage_service_privileges *priv, | |||
const char *session_id_suffix, | const char *session_id_suffix, | |||
struct mail_user **mail_user_r, | struct mail_user **mail_user_r, | |||
const char **error_r) | const char **error_r) | |||
{ | { | |||
const char *home = priv->home; | const char *home = priv->home; | |||
struct mail_user_connection_data conn_data; | struct mail_user_connection_data conn_data; | |||
struct mail_user *mail_user; | struct mail_user *mail_user; | |||
int ret; | ||||
i_zero(&conn_data); | i_zero(&conn_data); | |||
conn_data.local_ip = &user->input.local_ip; | conn_data.local_ip = &user->input.local_ip; | |||
conn_data.remote_ip = &user->input.remote_ip; | conn_data.remote_ip = &user->input.remote_ip; | |||
conn_data.local_port = user->input.local_port; | conn_data.local_port = user->input.local_port; | |||
conn_data.remote_port = user->input.remote_port; | conn_data.remote_port = user->input.remote_port; | |||
conn_data.secured = user->input.conn_secured; | conn_data.secured = user->input.conn_secured; | |||
conn_data.ssl_secured = user->input.conn_ssl_secured; | conn_data.ssl_secured = user->input.conn_ssl_secured; | |||
/* NOTE: if more user initialization is added, add it also to | /* NOTE: if more user initialization is added, add it also to | |||
skipping to change at line 765 | skipping to change at line 768 | |||
e_error(user->event, "chdir(%s) failed: %m", | e_error(user->event, "chdir(%s) failed: %m", | |||
chdir_path); | chdir_path); | |||
else | else | |||
e_debug(mail_user->event, "Home dir not found: %s ", chdir_path); | e_debug(mail_user->event, "Home dir not found: %s ", chdir_path); | |||
if (chdir("/") < 0) | if (chdir("/") < 0) | |||
e_error(user->event, "chdir(/) failed: %m"); | e_error(user->event, "chdir(/) failed: %m"); | |||
} | } | |||
} | } | |||
if (mail_user_init(mail_user, error_r) < 0) { | T_BEGIN { | |||
ret = mail_user_init(mail_user, error_r); | ||||
} T_END_PASS_STR_IF(ret < 0, error_r); | ||||
if (ret < 0) { | ||||
mail_user_unref(&mail_user); | mail_user_unref(&mail_user); | |||
return -1; | return -1; | |||
} | } | |||
if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES) == 0) { | if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES) == 0) { | |||
if (mail_namespaces_init(mail_user, error_r) < 0) { | if (mail_namespaces_init(mail_user, error_r) < 0) { | |||
mail_user_deinit(&mail_user); | mail_user_deinit(&mail_user); | |||
return -1; | return -1; | |||
} | } | |||
} | } | |||
skipping to change at line 1074 | skipping to change at line 1080 | |||
i_zero(&set_input); | i_zero(&set_input); | |||
set_input.roots = ctx->set_roots; | set_input.roots = ctx->set_roots; | |||
set_input.preserve_user = TRUE; | set_input.preserve_user = TRUE; | |||
/* settings reader may exec doveconf, which is going to clear | /* settings reader may exec doveconf, which is going to clear | |||
environment, and if we're not doing a userdb lookup we want to | environment, and if we're not doing a userdb lookup we want to | |||
use $HOME */ | use $HOME */ | |||
set_input.preserve_home = | set_input.preserve_home = | |||
(flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) == 0; | (flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) == 0; | |||
set_input.use_sysexits = | set_input.use_sysexits = | |||
(flags & MAIL_STORAGE_SERVICE_FLAG_USE_SYSEXITS) != 0; | (flags & MAIL_STORAGE_SERVICE_FLAG_USE_SYSEXITS) != 0; | |||
set_input.no_ssl_ca = | ||||
(flags & MAIL_STORAGE_SERVICE_FLAG_NO_SSL_CA) != 0; | ||||
if (input != NULL) { | if (input != NULL) { | |||
set_input.module = input->module; | set_input.module = input->module; | |||
set_input.service = input->service; | set_input.service = input->service; | |||
set_input.username = input->username; | set_input.username = input->username; | |||
set_input.local_ip = input->local_ip; | set_input.local_ip = input->local_ip; | |||
set_input.remote_ip = input->remote_ip; | set_input.remote_ip = input->remote_ip; | |||
} | } | |||
if (input == NULL) { | if (input == NULL) { | |||
/* global settings read - don't create a cache for thi */ | /* global settings read - don't create a cache for thi */ | |||
skipping to change at line 1345 | skipping to change at line 1353 | |||
} | } | |||
user->input.session_create_time = input->session_create_time; | user->input.session_create_time = input->session_create_time; | |||
user->user_info = user_info; | user->user_info = user_info; | |||
user->flags = flags; | user->flags = flags; | |||
user->set_parser = settings_parser_dup(set_parser, user_pool); | user->set_parser = settings_parser_dup(set_parser, user_pool); | |||
sets = master_service_settings_parser_get_others(master_service, | sets = master_service_settings_parser_get_others(master_service, | |||
user->set_parser); | user->set_parser); | |||
user->user_set = sets[0]; | user->user_set = sets[0]; | |||
user->ssl_set = master_service_ssl_settings_get_from_parser(user->set_par ser); | ||||
user->gid_source = "mail_gid setting"; | user->gid_source = "mail_gid setting"; | |||
user->uid_source = "mail_uid setting"; | user->uid_source = "mail_uid setting"; | |||
/* Create an event that will be used as the default event for logging. | /* Create an event that will be used as the default event for logging. | |||
This event won't be a parent to any other events - mail_user.event | This event won't be a parent to any other events - mail_user.event | |||
will be used for that. */ | will be used for that. */ | |||
user->event = event_create(input->event_parent); | user->event = event_create(input->event_parent); | |||
event_set_forced_debug(user->event, | event_set_forced_debug(user->event, | |||
user->service_ctx->debug || (flags & MAIL_STORAGE_ SERVICE_FLAG_DEBUG) != 0); | user->service_ctx->debug || (flags & MAIL_STORAGE_ SERVICE_FLAG_DEBUG) != 0); | |||
event_add_fields(user->event, (const struct event_add_field []){ | event_add_fields(user->event, (const struct event_add_field []){ | |||
{ .key = "user", .value = user->input.username }, | { .key = "user", .value = user->input.username }, | |||
skipping to change at line 1406 | skipping to change at line 1415 | |||
possible that the plugins are already loaded, because the | possible that the plugins are already loaded, because the | |||
plugin loading is a global state. This is especially true | plugin loading is a global state. This is especially true | |||
with doveadm, which loads the mail_plugins immediately at | with doveadm, which loads the mail_plugins immediately at | |||
startup so it can find commands registered by plugins. It's | startup so it can find commands registered by plugins. It's | |||
fine that extra plugins are loaded - we'll just need to | fine that extra plugins are loaded - we'll just need to | |||
prevent any of their hooks from being called. One easy way | prevent any of their hooks from being called. One easy way | |||
to do this is just to clear out the mail_plugins setting: */ | to do this is just to clear out the mail_plugins setting: */ | |||
(void)settings_parse_line(user->set_parser, "mail_plugins="); | (void)settings_parse_line(user->set_parser, "mail_plugins="); | |||
} | } | |||
if (ret < 0) | ||||
mail_storage_service_user_unref(&user); | ||||
*user_r = user; | *user_r = user; | |||
return ret; | return ret; | |||
} | } | |||
int mail_storage_service_lookup(struct mail_storage_service_ctx *ctx, | int mail_storage_service_lookup(struct mail_storage_service_ctx *ctx, | |||
const struct mail_storage_service_input *input, | const struct mail_storage_service_input *input, | |||
struct mail_storage_service_user **user_r, | struct mail_storage_service_user **user_r, | |||
const char **error_r) | const char **error_r) | |||
{ | { | |||
char *old_log_prefix = i_strdup(i_get_failure_prefix()); | char *old_log_prefix = i_strdup(i_get_failure_prefix()); | |||
skipping to change at line 1442 | skipping to change at line 1453 | |||
update_log_prefix = TRUE; | update_log_prefix = TRUE; | |||
} else { | } else { | |||
/* we might be here because we're doing a user lookup for a | /* we might be here because we're doing a user lookup for a | |||
shared user. the log prefix is likely already usable, so | shared user. the log prefix is likely already usable, so | |||
just append our own without replacing the whole thing. */ | just append our own without replacing the whole thing. */ | |||
i_set_failure_prefix("%suser-lookup(%s): ", | i_set_failure_prefix("%suser-lookup(%s): ", | |||
old_log_prefix, input->username); | old_log_prefix, input->username); | |||
update_log_prefix = FALSE; | update_log_prefix = FALSE; | |||
} | } | |||
ret = mail_storage_service_lookup_real(ctx, input, update_log_prefix, | T_BEGIN { | |||
user_r, error_r); | ret = mail_storage_service_lookup_real(ctx, input, | |||
update_log_prefix, user_r, error_r); | ||||
} T_END_PASS_STR_IF(ret < 0, error_r); | ||||
i_set_failure_prefix("%s", old_log_prefix); | i_set_failure_prefix("%s", old_log_prefix); | |||
i_free(old_log_prefix); | i_free(old_log_prefix); | |||
return ret; | return ret; | |||
} | } | |||
void mail_storage_service_save_userdb_fields(struct mail_storage_service_ctx *ct x, | void mail_storage_service_save_userdb_fields(struct mail_storage_service_ctx *ct x, | |||
pool_t pool, const char *const **use rdb_fields_r) | pool_t pool, const char *const **use rdb_fields_r) | |||
{ | { | |||
i_assert(pool != NULL); | i_assert(pool != NULL); | |||
i_assert(userdb_fields_r != NULL); | i_assert(userdb_fields_r != NULL); | |||
skipping to change at line 1579 | skipping to change at line 1592 | |||
const char *session_id_suffix, | const char *session_id_suffix, | |||
struct mail_user **mail_user_r, | struct mail_user **mail_user_r, | |||
const char **error_r) | const char **error_r) | |||
{ | { | |||
char *old_log_prefix = i_strdup(i_get_failure_prefix()); | char *old_log_prefix = i_strdup(i_get_failure_prefix()); | |||
int ret; | int ret; | |||
mail_storage_service_set_log_prefix(ctx, user->user_set, user, | mail_storage_service_set_log_prefix(ctx, user->user_set, user, | |||
&user->input, NULL); | &user->input, NULL); | |||
i_set_failure_prefix("%s", old_log_prefix); | i_set_failure_prefix("%s", old_log_prefix); | |||
ret = mail_storage_service_next_real(ctx, user, | T_BEGIN { | |||
session_id_suffix, | ret = mail_storage_service_next_real(ctx, user, | |||
mail_user_r, error_r); | session_id_suffix, | |||
mail_user_r, error_r); | ||||
} T_END_PASS_STR_IF(ret < 0, error_r); | ||||
if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT) != 0) | if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT) != 0) | |||
i_set_failure_prefix("%s", old_log_prefix); | i_set_failure_prefix("%s", old_log_prefix); | |||
i_free(old_log_prefix); | i_free(old_log_prefix); | |||
return ret; | return ret; | |||
} | } | |||
void mail_storage_service_restrict_setenv(struct mail_storage_service_ctx *ctx, | void mail_storage_service_restrict_setenv(struct mail_storage_service_ctx *ctx, | |||
struct mail_storage_service_user *user) | struct mail_storage_service_user *user) | |||
{ | { | |||
struct mail_storage_service_privileges priv; | struct mail_storage_service_privileges priv; | |||
skipping to change at line 1779 | skipping to change at line 1794 | |||
{ | { | |||
return &user->input; | return &user->input; | |||
} | } | |||
struct setting_parser_context * | struct setting_parser_context * | |||
mail_storage_service_user_get_settings_parser(struct mail_storage_service_user * user) | mail_storage_service_user_get_settings_parser(struct mail_storage_service_user * user) | |||
{ | { | |||
return user->set_parser; | return user->set_parser; | |||
} | } | |||
const struct master_service_ssl_settings * | ||||
mail_storage_service_user_get_ssl_settings(struct mail_storage_service_user *use | ||||
r) | ||||
{ | ||||
return user->ssl_set; | ||||
} | ||||
struct mail_storage_service_ctx * | struct mail_storage_service_ctx * | |||
mail_storage_service_user_get_service_ctx(struct mail_storage_service_user *user ) | mail_storage_service_user_get_service_ctx(struct mail_storage_service_user *user ) | |||
{ | { | |||
return user->service_ctx; | return user->service_ctx; | |||
} | } | |||
pool_t mail_storage_service_user_get_pool(struct mail_storage_service_user *user ) | pool_t mail_storage_service_user_get_pool(struct mail_storage_service_user *user ) | |||
{ | { | |||
return user->pool; | return user->pool; | |||
} | } | |||
End of changes. 10 change blocks. | ||||
6 lines changed or deleted | 28 lines changed or added |