doveconf.c revision 41942258112e4131de96b6a4399c1a8ac83a23cb
/* Copyright (c) 2005-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "abspath.h"
#include "module-dir.h"
#include "env-util.h"
#include "ostream.h"
#include "str.h"
#include "settings-parser.h"
#include "master-service.h"
#include "all-settings.h"
#include "sysinfo-get.h"
#include "config-connection.h"
#include "config-parser.h"
#include "config-request.h"
#include "dovecot-version.h"
#include <stdio.h>
#include <unistd.h>
struct prefix_stack {
unsigned int prefix_idx;
unsigned int str_pos;
};
struct config_dump_human_context {
struct config_export_context *export_ctx;
unsigned int list_prefix_sent:1;
};
#define LIST_KEY_PREFIX "\001"
#define UNIQUE_KEY_SUFFIX "\xff"
static const char *indent_str = " !!!!";
static void
{
const char *p;
switch (type) {
case CONFIG_KEY_NORMAL:
break;
case CONFIG_KEY_LIST:
break;
case CONFIG_KEY_UNIQUE_KEY:
break;
case CONFIG_KEY_ERROR:
return;
}
}
{
unsigned int i = 0;
return 0;
i++;
}
if (s1[i] == '=')
return -1;
if (s2[i] == '=')
return 1;
}
{
const struct prefix_stack *s;
struct prefix_stack sc;
unsigned int count;
if (count == 1) {
} else {
}
return sc;
}
{
struct prefix_stack *s;
s->str_pos = -1U;
}
static struct config_dump_human_context *
bool check_settings)
{
struct config_dump_human_context *ctx;
enum config_dump_flags flags;
if (check_settings)
return ctx;
}
{
}
static int
{
struct prefix_stack prefix;
unsigned int prefix_idx = -1U;
bool unique_key;
int ret = 0;
return -1;
*args);
}
} T_END;
unique_key = FALSE;
p + 2, NULL);
unique_key = TRUE;
}
j = 0;
while (prefix_idx != -1U) {
indent--;
else {
}
} else {
/* keep the prefix */
j = prefix_idx + 1;
break;
}
}
for (; j < prefix_count; j++) {
prefix_idx = j;
if (p != NULL)
else
indent++;
if (unique_key)
goto end;
else
goto again;
}
}
if (unique_key) key++;
end: ;
} T_END;
while (prefix_idx != -1U) {
break;
indent--;
}
/* flush output before writing errors */
ret = -1;
}
return ret;
}
static unsigned int
const struct config_filter *filter)
{
unsigned int indent = 0;
if (filter->local_bits > 0) {
} else {
}
indent++;
}
indent++;
}
if (filter->remote_bits > 0) {
} else {
}
indent++;
}
indent++;
}
return indent;
}
static void
{
while (indent > 0) {
indent--;
}
}
static int
const struct config_filter *filter,
const char *module)
{
struct config_filter_parser *const *filters;
static struct config_dump_human_context *ctx;
unsigned int indent;
int ret = 0;
/* first filter should be the global one */
filters++;
FALSE);
ret = -1;
if (ctx->list_prefix_sent)
}
return ret;
}
static int
{
static struct config_dump_human_context *ctx;
int ret;
return ret;
}
static int
{
static struct config_dump_human_context *ctx;
const char *const *str;
unsigned int len;
return -1;
if (hide_key)
else {
}
break;
}
}
return 0;
}
void *context ATTR_UNUSED)
{
T_BEGIN {
} T_END;
}
static const char *get_mail_location(void)
{
struct config_module_parser *l;
const struct setting_define *def;
const char *const *value;
const void *set;
continue;
return *value;
}
}
}
return "";
}
{
&filter->local_bits) < 0)
i_fatal("lip: Invalid network mask");
&filter->remote_bits) < 0)
i_fatal("rip: Invalid network mask");
} else {
}
}
static void check_wrong_config(const char *config_path)
{
const char *prev_path;
return;
i_warning("Dovecot was last started using %s, "
}
}
{
struct config_filter filter;
i_set_failure_prefix("doveconf: ");
while ((c = master_getopt(master_service)) > 0) {
if (c == 'e') {
expand_vars = TRUE;
break;
}
switch (c) {
case 'a':
break;
case 'f':
break;
case 'h':
break;
case 'm':
break;
case 'n':
break;
case 'N':
break;
case 'x':
expand_vars = TRUE;
break;
default:
return FATAL_DEFAULT;
}
}
/* use strcmp() instead of !=, because dovecot -n always gives us
-c parameter */
if (c == 'e') {
i_fatal("Missing command for -e");
/* print only a single config setting */
} else {
/* print the config file path before parsing it, so in case
of errors it's still shown */
}
error);
}
if (setting_name_filter != NULL) {
const char *info;
if (*info != '\0')
if (!config_path_specified)
} else {
struct config_export_context *ctx;
env_put("DOVECONF_ENV=1");
if (config_export_finish(&ctx) < 0)
i_fatal("Invalid configuration");
}
if (ret < 0) {
/* delayed error */
}
if (ret2 < 0)
i_fatal("Errors in configuration");
return 0;
}