bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
76537b1991e7815c7a867a997f7fa2b3c17412d4Aki Tuomiextern struct doveadm_cmd_ver2 doveadm_cmd_proxy[];
02aedbc20af0160091670233383d228f10b168afTimo Sirainenstatic void proxy_cmd_help(doveadm_command_t *cmd) ATTR_NORETURN;
02aedbc20af0160091670233383d228f10b168afTimo Sirainencmd_proxy_init(int argc, char *argv[], const char *getopt_args,
02aedbc20af0160091670233383d228f10b168afTimo Sirainen socket_path = t_strconcat(doveadm_settings->base_dir, "/ipc", NULL);
02aedbc20af0160091670233383d228f10b168afTimo Sirainen while ((c = getopt(argc, argv, getopt_args)) > 0) {
adad68df4602d80639d7f28e4c7550fbafbd8d60Timo Sirainenstatic void cmd_proxy_list_header(const char *const *args)
adad68df4602d80639d7f28e4c7550fbafbd8d60Timo Sirainen for (unsigned int i = 0; args[i] != NULL; i++) {
adad68df4602d80639d7f28e4c7550fbafbd8d60Timo Sirainen for (unsigned int j = 0; j < N_ELEMENTS(header_map); j++) {
02aedbc20af0160091670233383d228f10b168afTimo Sirainenstatic void cmd_proxy_list_callback(enum ipc_client_cmd_state state,
7a60e1dc9e93ef3f7c7fe1af6385a0bfa1e31bc3Timo Sirainen const char *const *args = t_strsplit_tabescaped(data);
02aedbc20af0160091670233383d228f10b168afTimo Sirainenstatic void cmd_proxy_list(int argc, char *argv[])
02aedbc20af0160091670233383d228f10b168afTimo Sirainen ctx = cmd_proxy_init(argc, argv, "a:", cmd_proxy_list);
adad68df4602d80639d7f28e4c7550fbafbd8d60Timo Sirainen ipc_client_cmd(ctx->ipc, "proxy\t*\tLIST-FULL",
ac1118842c3d80285e32d2cd53bda3e95e5be217Timo Sirainenstatic void cmd_proxy_kick_callback(enum ipc_client_cmd_state state,
ac1118842c3d80285e32d2cd53bda3e95e5be217Timo Sirainenstatic void cmd_proxy_kick(int argc, char *argv[])
75af6e5ca2c4685e2316d27364ac7b00def7fed7Timo Sirainen ctx = cmd_proxy_init(argc, argv, "a:f:", cmd_proxy_kick);
1f58bee818868d7261224766b66182c8eaf31ba8Aki Tuomi doveadm_print_formatted_set_format("%{count} connections kicked\n");
75af6e5ca2c4685e2316d27364ac7b00def7fed7Timo Sirainen str_append_tabescaped(cmd, ctx->username_field);
75af6e5ca2c4685e2316d27364ac7b00def7fed7Timo Sirainen ipc_client_cmd(ctx->ipc, str_c(cmd), cmd_proxy_kick_callback, NULL);
76537b1991e7815c7a867a997f7fa2b3c17412d4Aki TuomiDOVEADM_CMD_PARAM('a', "socket-path", CMD_PARAM_STR, 0)
9fc9965693110c250c6d6aa36ab60a77c934cc49Timo Sirainen .usage = "[-a <ipc socket path>] [-f <passdb field>] <user> [...]",
76537b1991e7815c7a867a997f7fa2b3c17412d4Aki TuomiDOVEADM_CMD_PARAM('a', "socket-path", CMD_PARAM_STR, 0)
75af6e5ca2c4685e2316d27364ac7b00def7fed7Timo SirainenDOVEADM_CMD_PARAM('f', "passdb-field", CMD_PARAM_STR, 0)
9fc9965693110c250c6d6aa36ab60a77c934cc49Timo SirainenDOVEADM_CMD_PARAM('\0', "user", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
02aedbc20af0160091670233383d228f10b168afTimo Sirainenstatic void proxy_cmd_help(doveadm_command_t *cmd)
02aedbc20af0160091670233383d228f10b168afTimo Sirainen unsigned int i;
02aedbc20af0160091670233383d228f10b168afTimo Sirainen for (i = 0; i < N_ELEMENTS(doveadm_cmd_proxy); i++) {
02aedbc20af0160091670233383d228f10b168afTimo Sirainen unsigned int i;
02aedbc20af0160091670233383d228f10b168afTimo Sirainen for (i = 0; i < N_ELEMENTS(doveadm_cmd_proxy); i++)