struct dsync_brain *brain2;
struct mail_user *user2;
struct setting_parser_context *set_parser;
- const char *set_line, *location;
+ const char *set_line, *location, *error;
bool brain1_running, brain2_running, changed1, changed2;
int ret;
if (settings_parse_line(set_parser, set_line) < 0)
i_unreached();
ret = mail_storage_service_next(ctx->ctx.storage_service,
- ctx->ctx.cur_service_user, &user2);
+ ctx->ctx.cur_service_user,
+ &user2, &error);
if (ret < 0) {
+ i_error("Failed to initialize user: %s", error);
ctx->ctx.exit_code = ret == -1 ? EX_TEMPFAIL : EX_CONFIG;
return -1;
}
static int
mail_storage_service_next_real(struct mail_storage_service_ctx *ctx,
struct mail_storage_service_user *user,
- struct mail_user **mail_user_r)
+ struct mail_user **mail_user_r,
+ const char **error_r)
{
struct mail_storage_service_privileges priv;
const char *error;
(user->flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0;
bool use_chroot;
- if (service_parse_privileges(ctx, user, &priv, &error) < 0) {
- i_error("%s", error);
+ if (service_parse_privileges(ctx, user, &priv, error_r) < 0)
return -2;
- }
if (*priv.home != '/' && *priv.home != '\0') {
- i_error("Relative home directory paths not supported: %s",
+ *error_r = t_strdup_printf(
+ "Relative home directory paths not supported: %s",
priv.home);
return -2;
}
if (service_drop_privileges(user, &priv,
disallow_root, temp_priv_drop,
FALSE, &error) < 0) {
- i_error("Couldn't drop privileges: %s", error);
+ *error_r = t_strdup_printf(
+ "Couldn't drop privileges: %s", error);
return -1;
}
if (!temp_priv_drop ||
module_dir_init(mail_storage_service_modules);
if (mail_storage_service_init_post(ctx, user, &priv,
- mail_user_r, &error) < 0) {
- i_error("User initialization failed: %s", error);
+ mail_user_r, error_r) < 0)
return -2;
- }
return 0;
}
int mail_storage_service_next(struct mail_storage_service_ctx *ctx,
struct mail_storage_service_user *user,
- struct mail_user **mail_user_r)
+ struct mail_user **mail_user_r,
+ const char **error_r)
{
char *old_log_prefix = i_strdup(i_get_failure_prefix());
int ret;
mail_storage_service_set_log_prefix(ctx, user->user_set, user,
&user->input, NULL);
i_set_failure_prefix("%s", old_log_prefix);
- ret = mail_storage_service_next_real(ctx, user, mail_user_r);
+ ret = mail_storage_service_next_real(ctx, user, mail_user_r, error_r);
if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT) != 0)
i_set_failure_prefix("%s", old_log_prefix);
i_free(old_log_prefix);
if (ret <= 0)
return ret;
- ret = mail_storage_service_next(ctx, user, mail_user_r);
+ ret = mail_storage_service_next(ctx, user, mail_user_r, error_r);
if (ret < 0) {
mail_storage_service_user_free(&user);
*error_r = ret == -2 ? ERRSTR_INVALID_USER_SETTINGS :
/* Returns 0 if ok, -1 if fatal error, -2 if error is user-specific. */
int mail_storage_service_next(struct mail_storage_service_ctx *ctx,
struct mail_storage_service_user *user,
- struct mail_user **mail_user_r);
+ struct mail_user **mail_user_r,
+ const char **error_r);
void mail_storage_service_restrict_setenv(struct mail_storage_service_ctx *ctx,
struct mail_storage_service_user *user);
/* Combine lookup() and next() into one call. */
return 0;
ret = mail_storage_service_next(storage_service,
- rcpt->service_user, &user);
- if (ret < 0)
+ rcpt->service_user, &user, &errstr);
+ if (ret < 0) {
+ i_error("Failed to initialize user %s: %s", rcpt->address, errstr);
return -1;
+ }
ns = mail_namespace_find_inbox(user->namespaces);
box = mailbox_alloc(ns->list, "INBOX", 0);
client_state_set(client, "DATA", username);
i_set_failure_prefix("lmtp(%s, %s): ", my_pid, username);
if (mail_storage_service_next(storage_service, rcpt->service_user,
- &client->state.dest_user) < 0) {
+ &client->state.dest_user, &error) < 0) {
+ i_error("Failed to initialize user: %s", error);
client_send_line(client, ERRSTR_TEMP_MAILBOX_FAIL,
rcpt->address);
return -1;