doveadm-auth-server.c revision 2ac5f36aa7c2e7a07ba8815d43a6d7483f62e74c
/* Copyright (c) 2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "var-expand.h"
#include "wildcard-match.h"
#include "settings-parser.h"
#include "master-service.h"
#include "master-service-settings.h"
#include "auth-client.h"
#include "auth-master.h"
#include "auth-server-connection.h"
#include "master-auth.h"
#include "master-login-auth.h"
#include "mail-storage-service.h"
#include "mail-user.h"
#include "ostream.h"
#include "json-parser.h"
#include "doveadm.h"
#include "doveadm-print.h"
#include <stdio.h>
#include <unistd.h>
struct authtest_input {
const char *username;
const char *master_user;
const char *password;
struct auth_user_info info;
bool success;
struct auth_client_request *request;
struct master_auth_request master_auth_req;
unsigned int auth_id;
unsigned int auth_pid;
const char *auth_cookie;
};
static struct auth_master_connection *
doveadm_get_auth_master_conn(const char *auth_socket_path)
{
enum auth_master_flags flags = 0;
if (doveadm_debug)
}
static int
const struct authtest_input *input,
const char *show_field, bool userdb)
{
int ret;
if (userdb) {
} else {
}
if (ret < 0) {
const char *msg;
} else {
fields[0]);
}
ret = -1;
} else if (ret == 0) {
t_strdup_printf("\"error\":\"%s: user doesn't exist\"",
lookup_name));
} else if (show_field != NULL) {
}
}
} else {
if (updated_username != NULL) {
str_truncate(jsonval, 0);
}
if (*field == '\0') continue;
str_truncate(jsonval, 0);
if (p != NULL) {
}
str_truncate(jsonval, 0);
if (p != NULL) {
str_truncate(jsonval, 0);
} else {
}
}
}
return ret;
}
{
i_fatal("lip: Invalid ip");
i_fatal("rip: Invalid ip");
i_fatal("lport: Invalid port number");
i_fatal("rport: Invalid port number");
} else {
}
}
static void
const struct authtest_input *input,
char *const *users)
{
struct auth_master_user_list_ctx *ctx;
unsigned int i;
break;
}
}
if (auth_master_user_list_deinit(&ctx) < 0)
i_fatal("user listing failed");
}
{
const char *master_socket_path = NULL;
struct auth_master_connection *conn;
unsigned int count;
int c;
switch (c) {
case 'a':
break;
default:
return;
}
}
if (master_socket_path == NULL) {
"/auth-master", NULL);
}
i_error("Cache flush failed");
} else {
doveadm_print_init("formatted");
doveadm_print_formatted_set_format("%{entries} cache entries flushed\n");
doveadm_print_header_simple("entries");
}
}
const char *show_field)
{
str_truncate(jvalue, 0);
}
static void
const char *const *userdb_fields,
const char *show_field)
{
const struct mail_storage_settings *mail_set;
unsigned int i;
}
if (userdb_fields != NULL) {
for (i = 0; userdb_fields[i] != NULL; i++) {
else {
key = userdb_fields[i];
value = "";
}
*key != '\0') {
}
}
}
}
static int
const struct authtest_input *input,
const char *show_field, const char *expand_field)
{
struct mail_storage_service_user *service_user;
const char *error, *const *userdb_fields;
int ret;
&service_user, &user,
&error)) <= 0) {
pool_unref(&pool);
if (ret < 0)
return -1;
);
return 0;
}
if (expand_field == NULL)
else {
&error) <= 0) {
} else {
str_truncate(value, 0);
}
}
pool_unref(&pool);
return 1;
}
{
const char * const *optval;
const char *auth_socket_path = NULL;
struct auth_master_connection *conn;
struct authtest_input input;
int ret;
i_error("No user(s) specified");
return;
}
i_error("-e can't be used with -u");
return;
}
i_error("-e can't be used with -f");
return;
}
break;
}
}
if (have_wildcards) {
return;
}
if (!userdb_only) {
}
str_truncate(json, 0);
if (first)
else
ret = !userdb_only ?
switch (ret) {
case -1:
break;
case 0:
break;
}
}
if (storage_service != NULL)
}
static
struct doveadm_cmd_ver2 doveadm_cmd_auth_server[] = {
{
.name = "auth cache flush",
.usage = "[-a <master socket path>] [<user> [...]]",
},
{
.name = "user",
.cmd = cmd_user_ver2,
.usage = "[-a <userdb socket path>] [-x <auth info>] [-f field] [-e <value>] [-u] <user mask> [...]",
}
};
void doveadm_register_auth_server_commands(void)
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(doveadm_cmd_auth_server); i++) {
}
}