doveadm-auth.c revision 4a0d2f71a13f1f7be1a861a410d6961bc798579e
/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "askpass.h"
#include "base64.h"
#include "str.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 "mail-storage-service.h"
#include "mail-user.h"
#include "doveadm.h"
#include "doveadm-print.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct authtest_input {
const char *username;
const char *password;
struct auth_user_info info;
bool success;
};
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) {
else {
}
} else if (ret == 0) {
"%s: user %s doesn't exist\n", lookup_name,
} else if (show_field != NULL) {
}
} else {
if (p == NULL)
else {
printf(" %-10s: %s\n",
}
}
}
return ret;
}
static void
enum auth_request_status status,
const char *data_base64 ATTR_UNUSED,
{
if (!io_loop_is_running(current_ioloop))
return;
if (status == 0)
i_fatal("passdb expects SASL continuation");
if (status < 0)
else {
}
printf("extra fields:\n");
}
}
{
struct auth_request_info info;
if (!connected)
i_fatal("Couldn't connect to auth socket");
}
static void
{
struct auth_client *client;
if (auth_socket_path == NULL) {
"/auth-client", NULL);
}
}
{
i_fatal("lip: Invalid ip");
i_fatal("rip: Invalid ip");
} 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:
}
}
if (master_socket_path == NULL) {
"auth-master", NULL);
}
i_error("Cache flush failed");
} else {
}
}
{
const char *auth_socket_path = NULL;
struct authtest_input input;
int c;
switch (c) {
case 'a':
break;
case 'x':
break;
default:
}
}
t_askpass("Password: ");
}
{
struct auth_master_connection *conn;
struct authtest_input input;
const char *show_field = NULL;
int c, ret;
switch (c) {
case 'a':
break;
case 'f':
show_field = optarg;
break;
case 'x':
break;
default:
}
}
if (first)
else
putchar('\n');
switch (ret) {
case -1:
break;
case 0:
break;
}
}
}
const char *show_field)
{
if (show_field == NULL) {
}
}
const struct authtest_input *input,
const char *show_field)
{
struct mail_storage_service_user *service_user;
const struct mail_storage_settings *mail_set;
unsigned int i;
int ret;
&service_user, &user,
&error)) <= 0) {
pool_unref(&pool);
if (ret < 0)
return -1;
"userdb lookup: user %s doesn't exist\n",
return 0;
}
if (show_field == NULL) {
doveadm_print_header_simple("field");
doveadm_print_header_simple("value");
}
if (userdb_fields != NULL) {
for (i = 0; userdb_fields[i] != NULL; i++) {
else {
key = userdb_fields[i];
value = "";
}
}
}
pool_unref(&pool);
return 1;
}
{
struct auth_master_connection *conn;
struct authtest_input input;
const char *show_field = NULL;
unsigned int i;
int c, ret;
switch (c) {
case 'a':
break;
case 'f':
show_field = optarg;
break;
case 'u':
userdb_only = TRUE;
break;
case 'x':
break;
default:
}
}
break;
}
}
if (have_wildcards) {
return;
}
if (!userdb_only) {
}
if (first)
else
putchar('\n');
ret = !userdb_only ?
switch (ret) {
case -1:
break;
case 0:
break;
}
}
if (storage_service != NULL)
}
struct doveadm_cmd doveadm_cmd_auth[] = {
{ cmd_auth_test, "auth test",
"[-a <auth socket path>] [-x <auth info>] <user> [<password>]" },
{ cmd_auth_lookup, "auth lookup",
"[-a <userdb socket path>] [-x <auth info>] [-f field] <user> [...]" },
{ cmd_auth_cache_flush, "auth cache flush",
"[-a <master socket path>] [<user> [...]]" },
{ cmd_user, "user",
"[-a <userdb socket path>] [-x <auth info>] [-f field] [-u] <user mask> [...]" }
};
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(doveadm_cmd_auth); i++) {
help(&doveadm_cmd_auth[i]);
}
i_unreached();
}
void doveadm_register_auth_commands(void)
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(doveadm_cmd_auth); i++)
}