mail-user.c (dovecot-2.3.16) | : | mail-user.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
#include "mkdir-parents.h" | #include "mkdir-parents.h" | |||
#include "safe-mkstemp.h" | #include "safe-mkstemp.h" | |||
#include "str.h" | #include "str.h" | |||
#include "strescape.h" | #include "strescape.h" | |||
#include "var-expand.h" | #include "var-expand.h" | |||
#include "settings-parser.h" | #include "settings-parser.h" | |||
#include "iostream-ssl.h" | #include "iostream-ssl.h" | |||
#include "fs-api.h" | #include "fs-api.h" | |||
#include "auth-master.h" | #include "auth-master.h" | |||
#include "master-service.h" | #include "master-service.h" | |||
#include "master-service-ssl-settings.h" | ||||
#include "dict.h" | #include "dict.h" | |||
#include "mail-storage-settings.h" | #include "mail-storage-settings.h" | |||
#include "mail-storage-private.h" | #include "mail-storage-private.h" | |||
#include "mail-storage-service.h" | #include "mail-storage-service.h" | |||
#include "mail-namespace.h" | #include "mail-namespace.h" | |||
#include "mail-storage.h" | #include "mail-storage.h" | |||
#include "mailbox-list-private.h" | #include "mailbox-list-private.h" | |||
#include "mail-autoexpunge.h" | #include "mail-autoexpunge.h" | |||
#include "mail-user.h" | #include "mail-user.h" | |||
skipping to change at line 219 | skipping to change at line 220 | |||
*_user = NULL; | *_user = NULL; | |||
if (user->refcount > 1) { | if (user->refcount > 1) { | |||
user->refcount--; | user->refcount--; | |||
return; | return; | |||
} | } | |||
user->deinitializing = TRUE; | user->deinitializing = TRUE; | |||
/* call deinit() and deinit_pre() with refcount=1, otherwise we may | /* call deinit() and deinit_pre() with refcount=1, otherwise we may | |||
assert-crash in mail_user_ref() that is called by some handlers. */ | assert-crash in mail_user_ref() that is called by some handlers. */ | |||
user->v.deinit_pre(user); | T_BEGIN { | |||
user->v.deinit(user); | user->v.deinit_pre(user); | |||
user->v.deinit(user); | ||||
} T_END; | ||||
event_unref(&user->event); | event_unref(&user->event); | |||
i_assert(user->refcount == 1); | i_assert(user->refcount == 1); | |||
pool_unref(&user->pool); | pool_unref(&user->pool); | |||
} | } | |||
void mail_user_deinit(struct mail_user **user) | void mail_user_deinit(struct mail_user **user) | |||
{ | { | |||
i_assert((*user)->refcount == 1); | i_assert((*user)->refcount == 1); | |||
mail_user_unref(user); | mail_user_unref(user); | |||
} | } | |||
skipping to change at line 566 | skipping to change at line 569 | |||
void mail_user_set_get_temp_prefix(string_t *dest, | void mail_user_set_get_temp_prefix(string_t *dest, | |||
const struct mail_user_settings *set) | const struct mail_user_settings *set) | |||
{ | { | |||
str_append(dest, set->mail_temp_dir); | str_append(dest, set->mail_temp_dir); | |||
str_append(dest, "/dovecot."); | str_append(dest, "/dovecot."); | |||
str_append(dest, master_service_get_name(master_service)); | str_append(dest, master_service_get_name(master_service)); | |||
str_append_c(dest, '.'); | str_append_c(dest, '.'); | |||
} | } | |||
const char *mail_user_get_volatile_dir(struct mail_user *user) | ||||
{ | ||||
struct mailbox_list *inbox_list = | ||||
mail_namespace_find_inbox(user->namespaces)->list; | ||||
return inbox_list->set.volatile_dir; | ||||
} | ||||
int mail_user_lock_file_create(struct mail_user *user, const char *lock_fname, | int mail_user_lock_file_create(struct mail_user *user, const char *lock_fname, | |||
unsigned int lock_secs, | unsigned int lock_secs, | |||
struct file_lock **lock_r, const char **error_r) | struct file_lock **lock_r, const char **error_r) | |||
{ | { | |||
const char *home, *path; | const char *home, *path; | |||
int ret; | int ret; | |||
if ((ret = mail_user_get_home(user, &home)) < 0) { | if ((ret = mail_user_get_home(user, &home)) < 0) { | |||
/* home lookup failed - shouldn't really happen */ | /* home lookup failed - shouldn't really happen */ | |||
*error_r = "Failed to lookup home directory"; | *error_r = "Failed to lookup home directory"; | |||
skipping to change at line 589 | skipping to change at line 600 | |||
if (ret == 0) { | if (ret == 0) { | |||
*error_r = "User has no home directory"; | *error_r = "User has no home directory"; | |||
errno = EINVAL; | errno = EINVAL; | |||
return -1; | return -1; | |||
} | } | |||
const struct mail_storage_settings *mail_set = | const struct mail_storage_settings *mail_set = | |||
mail_user_set_get_storage_set(user); | mail_user_set_get_storage_set(user); | |||
struct file_create_settings lock_set = { | struct file_create_settings lock_set = { | |||
.lock_timeout_secs = lock_secs, | .lock_timeout_secs = lock_secs, | |||
.lock_method = mail_set->parsed_lock_method, | .lock_settings = { | |||
.lock_method = mail_set->parsed_lock_method, | ||||
}, | ||||
}; | }; | |||
struct mailbox_list *inbox_list = | struct mailbox_list *inbox_list = | |||
mail_namespace_find_inbox(user->namespaces)->list; | mail_namespace_find_inbox(user->namespaces)->list; | |||
if (inbox_list->set.volatile_dir == NULL) | if (inbox_list->set.volatile_dir == NULL) | |||
path = t_strdup_printf("%s/%s", home, lock_fname); | path = t_strdup_printf("%s/%s", home, lock_fname); | |||
else { | else { | |||
path = t_strdup_printf("%s/%s", inbox_list->set.volatile_dir, | path = t_strdup_printf("%s/%s", inbox_list->set.volatile_dir, | |||
lock_fname); | lock_fname); | |||
lock_set.mkdir_mode = 0700; | lock_set.mkdir_mode = 0700; | |||
} | } | |||
skipping to change at line 692 | skipping to change at line 705 | |||
user2->auth_token = p_strdup(user2->pool, user->auth_token); | user2->auth_token = p_strdup(user2->pool, user->auth_token); | |||
user2->auth_user = p_strdup(user2->pool, user->auth_user); | user2->auth_user = p_strdup(user2->pool, user->auth_user); | |||
user2->session_id = p_strdup(user2->pool, user->session_id); | user2->session_id = p_strdup(user2->pool, user->session_id); | |||
user2->session_create_time = user->session_create_time; | user2->session_create_time = user->session_create_time; | |||
user2->userdb_fields = user->userdb_fields == NULL ? NULL : | user2->userdb_fields = user->userdb_fields == NULL ? NULL : | |||
p_strarray_dup(user2->pool, user->userdb_fields); | p_strarray_dup(user2->pool, user->userdb_fields); | |||
return user2; | return user2; | |||
} | } | |||
void mail_user_init_ssl_client_settings(struct mail_user *user, | void mail_user_init_ssl_client_settings(struct mail_user *user, | |||
struct ssl_iostream_settings *ssl_set) | struct ssl_iostream_settings *ssl_set_r) | |||
{ | { | |||
const struct mail_storage_settings *mail_set = | if (user->_service_user == NULL) { | |||
mail_user_set_get_storage_set(user); | /* Internal test user that should never actually need any | |||
SSL settings. */ | ||||
i_zero(ssl_set_r); | ||||
return; | ||||
} | ||||
const struct master_service_ssl_settings *ssl_set = | ||||
mail_storage_service_user_get_ssl_settings(user->_service_user); | ||||
mail_storage_settings_init_ssl_client_settings(mail_set, ssl_set); | master_service_ssl_client_settings_to_iostream_set(ssl_set, | |||
pool_datastack_create(), ssl_set_r); | ||||
} | } | |||
void mail_user_init_fs_settings(struct mail_user *user, | void mail_user_init_fs_settings(struct mail_user *user, | |||
struct fs_settings *fs_set, | struct fs_settings *fs_set, | |||
struct ssl_iostream_settings *ssl_set) | struct ssl_iostream_settings *ssl_set_r) | |||
{ | { | |||
fs_set->event_parent = user->event; | fs_set->event_parent = user->event; | |||
fs_set->username = user->username; | fs_set->username = user->username; | |||
fs_set->session_id = user->session_id; | fs_set->session_id = user->session_id; | |||
fs_set->base_dir = user->set->base_dir; | fs_set->base_dir = user->set->base_dir; | |||
fs_set->temp_dir = user->set->mail_temp_dir; | fs_set->temp_dir = user->set->mail_temp_dir; | |||
fs_set->debug = user->mail_debug; | fs_set->debug = user->mail_debug; | |||
fs_set->enable_timing = user->stats_enabled; | fs_set->enable_timing = user->stats_enabled; | |||
fs_set->ssl_client_set = ssl_set; | fs_set->ssl_client_set = ssl_set_r; | |||
mail_user_init_ssl_client_settings(user, ssl_set); | mail_user_init_ssl_client_settings(user, ssl_set_r); | |||
} | } | |||
void mail_user_stats_fill(struct mail_user *user, struct stats *stats) | void mail_user_stats_fill(struct mail_user *user, struct stats *stats) | |||
{ | { | |||
user->v.stats_fill(user, stats); | user->v.stats_fill(user, stats); | |||
} | } | |||
static int | static int | |||
mail_user_home_mkdir_try_ns(struct mail_namespace *ns, const char *home) | mail_user_home_mkdir_try_ns(struct mail_namespace *ns, const char *home) | |||
{ | { | |||
skipping to change at line 783 | skipping to change at line 804 | |||
return ret < 0 ? -1 : 0; | return ret < 0 ? -1 : 0; | |||
} | } | |||
/* fallback to a safe mkdir() with 0700 mode */ | /* fallback to a safe mkdir() with 0700 mode */ | |||
if (mkdir_parents(home, 0700) < 0 && errno != EEXIST) { | if (mkdir_parents(home, 0700) < 0 && errno != EEXIST) { | |||
e_error(user->event, "mkdir_parents(%s) failed: %m", home); | e_error(user->event, "mkdir_parents(%s) failed: %m", home); | |||
return -1; | return -1; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
const struct dict_op_settings * | ||||
mail_user_get_dict_op_settings(struct mail_user *user) | ||||
{ | ||||
if (user->dict_op_set == NULL) { | ||||
user->dict_op_set = p_new(user->pool, struct dict_op_settings, 1) | ||||
; | ||||
user->dict_op_set->username = p_strdup(user->pool, user->username | ||||
); | ||||
if (mail_user_get_home(user, &user->dict_op_set->home_dir) <= 0) | ||||
user->dict_op_set->home_dir = NULL; | ||||
} | ||||
return user->dict_op_set; | ||||
} | ||||
static const struct var_expand_func_table mail_user_var_expand_func_table_arr[] = { | static const struct var_expand_func_table mail_user_var_expand_func_table_arr[] = { | |||
{ "userdb", mail_user_var_expand_func_userdb }, | { "userdb", mail_user_var_expand_func_userdb }, | |||
{ NULL, NULL } | { NULL, NULL } | |||
}; | }; | |||
const struct var_expand_func_table *mail_user_var_expand_func_table = | const struct var_expand_func_table *mail_user_var_expand_func_table = | |||
mail_user_var_expand_func_table_arr; | mail_user_var_expand_func_table_arr; | |||
End of changes. 10 change blocks. | ||||
10 lines changed or deleted | 45 lines changed or added |