mctx->cctx = cctx;
mctx->full_args = argv+1;
mctx->proxying = TRUE;
- mctx->cur_username = cctx->username;
mctx->service_flags |=
MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT |
MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
}
mctx->args = argv+optind;
- if (mctx->cur_username != NULL) {
- if (strchr(mctx->cur_username, '*') != NULL ||
- strchr(mctx->cur_username, '?') != NULL) {
+ if (cctx->username != NULL) {
+ if (strchr(cctx->username, '*') != NULL ||
+ strchr(cctx->username, '?') != NULL) {
add_username_header = TRUE;
}
}
static void
run_cmd(struct dsync_cmd_context *ctx, const char *const *args)
{
+ struct doveadm_cmd_context *cctx = ctx->ctx.cctx;
int fd_in[2], fd_out[2], fd_err[2];
ctx->remote_cmd_args = p_strarray_dup(ctx->ctx.pool, args);
if (ctx->remote_user_prefix) {
const char *prefix =
- t_strdup_printf("%s\n", ctx->ctx.cur_username);
+ t_strdup_printf("%s\n", cctx->username);
if (write_full(ctx->fd_out, prefix, strlen(prefix)) < 0)
i_fatal("write(remote out) failed: %m");
}
const struct mail_storage_settings *mail_set,
const char *target, bool ssl, const char **error_r)
{
+ struct doveadm_cmd_context *cctx = ctx->ctx.cctx;
struct doveadm_server *server;
struct server_connection *conn;
struct ioloop *ioloop;
if (doveadm_debug)
str_append_c(cmd, 'D');
str_append_c(cmd, '\t');
- str_append_tabescaped(cmd, ctx->ctx.cur_username);
+ str_append_tabescaped(cmd, cctx->username);
str_append(cmd, "\tdsync-server\t-u");
- str_append_tabescaped(cmd, ctx->ctx.cur_username);
+ str_append_tabescaped(cmd, cctx->username);
if (ctx->replicator_notify)
str_append(cmd, "\t-U");
str_append_c(cmd, '\n');
const char *location,
const char *const **remote_cmd_args_r, const char **error_r)
{
+ struct doveadm_cmd_context *cctx = ctx->ctx.cctx;
+
if (strncmp(location, "tcp:", 4) == 0) {
/* TCP connection to remote dsync */
ctx->remote_name = location+4;
return 0;
}
*remote_cmd_args_r =
- parse_ssh_location(ctx->remote_name, ctx->ctx.cur_username);
+ parse_ssh_location(ctx->remote_name, cctx->username);
return 0;
}
const char **error_r)
{
struct dsync_cmd_context *ctx = (struct dsync_cmd_context *)_ctx;
+ struct doveadm_cmd_context *cctx = _ctx->cctx;
const char *const *remote_cmd_args = NULL;
const struct mail_user_settings *user_set;
const struct mail_storage_settings *mail_set;
/* if we're executing remotely, give -u parameter if we also
did a userdb lookup. */
if ((_ctx->service_flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0)
- username = _ctx->cur_username;
+ username = cctx->username;
if (!mirror_get_remote_cmd(ctx, username, &remote_cmd_args)) {
/* it's a mail_location */
i_assert(cctx->username != NULL);
doveadm_cctx_to_storage_service_input(cctx, &ctx->storage_service_input);
- ctx->cur_username = cctx->username;
ctx->storage_service = mail_storage_service_init(master_service, NULL,
ctx->service_flags);
ctx->v.init(ctx, ctx->args);
continue;
}
cctx->username = user;
- ctx->cur_username = user;
doveadm_print_sticky("username", user);
T_BEGIN {
ret = doveadm_mail_next_user(ctx, &error);
}
if (ctx->iterate_single_user) {
- if (ctx->cur_username == NULL)
+ if (cctx->username == NULL)
i_fatal_status(EX_USAGE, "USER environment is missing and -u option not used");
if (!cli) {
/* we may access multiple users */
i_zero(&cctx);
cctx.conn_type = CLIENT_CONNECTION_TYPE_CLI;
+ cctx.username = getenv("USER");
ctx = doveadm_mail_cmdline_init(cmd);
ctx->cctx = &cctx;
ctx->full_args = (const void *)(argv + 1);
- ctx->cur_username = getenv("USER");
getopt_args = "AF:S:u:";
/* keep context's getopt_args first in case it contains '+' */
case 'u':
ctx->service_flags |=
MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
- ctx->cur_username = optarg;
- if (strchr(ctx->cur_username, '*') != NULL ||
- strchr(ctx->cur_username, '?') != NULL) {
- wildcard_user = ctx->cur_username;
- ctx->cur_username = NULL;
+ cctx.username = optarg;
+ if (strchr(cctx.username, '*') != NULL ||
+ strchr(cctx.username, '?') != NULL) {
+ wildcard_user = cctx.username;
+ cctx.username = NULL;
}
break;
case 'F':
cmd->name, argv[0]);
}
ctx->args = (const void *)argv;
- cctx.username = ctx->cur_username;
doveadm_mail_cmd_exec(ctx, wildcard_user);
doveadm_mail_cmd_free(ctx);
}
mctx = doveadm_mail_cmdline_init(&mail_cmd);
}
mctx->cctx = cctx;
- mctx->cur_username = cctx->username;
mctx->iterate_all_users = FALSE;
wildcard_user = NULL;
p_array_init(&full_args, mctx->pool, 8);
} else if (strcmp(arg->name, "user") == 0) {
mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
if (!tcp_server)
- mctx->cur_username = arg->value.v_string;
+ cctx->username = arg->value.v_string;
fieldstr = "-u";
array_append(&full_args, &fieldstr, 1);
mctx->add_username_header = TRUE;
else {
wildcard_user = arg->value.v_string;
- mctx->cur_username = NULL;
+ cctx->username = NULL;
}
- } else if (!tcp_server) {
- cctx->username = mctx->cur_username;
}
} else if (strcmp(arg->name, "user-file") == 0) {
mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
struct mail_search_args *search_args;
struct istream *users_list_input;
- const char *cur_username;
struct mail_storage_service_user *cur_service_user;
struct mail_user *cur_mail_user;
struct doveadm_mail_cmd_vfuncs v;