doveadm-kick.c revision 6fc40674e5a33787ae7fcd47a77a77ea20977994
/* Copyright (c) 2010-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "net.h"
#include "hash.h"
#include "doveadm.h"
#include "doveadm-who.h"
#include "doveadm-print.h"
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
struct kick_user {
const char *username;
ignored when the -f switch is given. */
};
struct kick_pid {
bool kick;
};
struct kick_context {
struct who_context who;
enum doveadm_client_type conn_type;
bool force_kick;
ARRAY(const char *) kicked_users;
};
static void
{
}
if (user_match)
return;
}
}
}
static bool
bool *show_warning)
{
unsigned int kick_count = 0;
return FALSE;
} else {
kick_count++;
}
if (kick_count == 0)
return FALSE;
!ctx->force_kick) {
}
}
*show_warning = TRUE;
return FALSE;
}
}
return TRUE;
}
static void
{
unsigned int i, count;
const char *const *users;
if (cli)
printf("no users kicked\n");
return;
}
if (cli) {
if (show_warning) {
printf("warning: other connections would also be "
"kicked from following users:\n");
} else {
printf("kicked connections from the following users:\n");
}
}
doveadm_print(users[0]);
for (i = 1; i < count; i++) {
doveadm_print(users[i]);
}
if (cli)
printf("\n");
if (show_warning)
printf("Use the '-f' option to enforce the disconnect.\n");
}
{
bool show_enforce_warning = FALSE;
struct hash_iterate_context *iter;
void *key;
}
if (show_enforce_warning) {
return;
}
continue;
} else {
}
}
}
}
{
const char *const *masks;
struct kick_context ctx;
return;
}
/* force-kick is a pretty ugly option. its output can't be
nicely translated to an API reply. it also wouldn't be very
useful in scripts, only for preventing a new admin from
accidentally kicking too many users. it's also useful only
in a non-recommended setup where processes are handling
multiple connections. so for now we'll preserve the option
for CLI, but always do a force-kick with non-CLI. */
}
return;
}
doveadm_print_formatted_set_format("%{result} ");
doveadm_print_header_simple("result");
kick_users(&ctx);
}
struct doveadm_cmd_ver2 doveadm_cmd_kick_ver2 = {
.name = "kick",
};