/* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "path-util.h"
#include "module-dir.h"
#include "env-util.h"
#include "guid.h"
#include "hash.h"
#include "hostpid.h"
#include "ostream.h"
#include "str.h"
#include "strescape.h"
#include "settings-parser.h"
#include "master-interface.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 <ctype.h>
#include <unistd.h>
#include <sysexits.h>
struct prefix_stack {
unsigned int prefix_idx;
unsigned int str_pos;
};
struct config_dump_human_context {
};
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;
unsigned int count;
if (count == 1) {
} else {
}
return sc;
}
{
struct prefix_stack *s;
}
static struct config_dump_human_context *
bool check_settings, bool in_section)
{
if (check_settings)
if (in_section)
return ctx;
}
{
}
{
if (len == 0)
return FALSE;
return TRUE;
return TRUE;
return FALSE;
}
static int ATTR_NULL(4)
const char *setting_name_filter, bool hide_passwords)
{
bool unique_key;
int ret = 0;
return -1;
/* strings are sorted so that all lists come first */
if (p[1] == '\0') {
/* "strlist=" */
} else {
/* string is in format: "list=0 1 2" */
*args);
}
}
} T_END;
unique_key = FALSE;
p + 2, NULL);
unique_key = TRUE;
}
if (setting_name_filter_len > 0) {
/* see if this setting matches the name filter */
setting_name_filter_len) == 0 &&
goto end;
}
j = 0;
/* if there are open sections and this key isn't in it,
close the sections */
while (prefix_idx != UINT_MAX) {
indent--;
else {
}
} else {
/* keep the prefix */
j = prefix_idx + 1;
break;
}
}
/* see if this key is in some section */
for (; j < prefix_count; j++) {
prefix_idx = j;
if (p != NULL)
else
else
}
indent++;
if (unique_key)
goto end;
else
goto again;
}
}
if (unique_key) key++;
else {
}
end: ;
} T_END;
while (prefix_idx != UINT_MAX) {
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 *const *modules, bool hide_passwords)
{
unsigned int indent;
int ret = 0;
/* first filter should be the global one */
filters++;
ret = -1;
if (ctx->list_prefix_sent)
}
return ret;
}
static int ATTR_NULL(4)
bool hide_passwords)
{
int ret;
if (setting_name_filter == NULL)
return ret;
}
static int
bool hide_passwords)
{
const char *const *str;
return -1;
continue;
if (hide_key)
else {
}
break;
dump_section = TRUE;
}
}
if (dump_section)
return 0;
}
void *context)
{
unsigned int i;
if (setting_name_filters == NULL) {
return;
}
for (i = 0; setting_name_filters[i] != NULL; i++) {
}
}
void *context ATTR_UNUSED)
{
T_BEGIN {
} T_END;
}
{
struct config_module_parser *l;
const char *const *value;
const void *set;
continue;
return *value;
}
}
}
return "";
}
{
else {
value = "";
}
} else {
}
}
struct hostname_format {
unsigned int numcount;
bool zeropadding;
};
static void
unsigned int num)
{
str_truncate(str, 0);
if (!fmt->zeropadding)
else
}
{
const char *p;
unsigned int n, limit;
HASH_TABLE(void *, void *) hosts;
const char *host2;
/* host%d, host%2d, host%02d */
if (p == NULL)
i_fatal("Host parameter missing %%d");
if (*p == '0') {
p++;
}
if (!i_isdigit(*p))
else
if (*p++ != 'd')
i_fatal("Host parameter missing %%d");
} else {
/* detect host1[suffix] vs host01[suffix] */
len--;
len--;
}
i_fatal("Hostname '%s' has no digits, can't verify",
}
}
limit *= 10;
for (n = 0; n < limit; n++) {
i_error("Duplicate host hashes: %s and %s",
duplicates = TRUE;
} else {
}
}
if (duplicates)
else {
printf("No duplicate host hashes in %s .. %s\n",
exit(0);
}
}
{
return;
}
i_warning("Dovecot was last started using %s, "
}
}
{
/* don't use EX_CONFIG, because it often causes MTAs to bounce
the mails back. */
*status = EX_TEMPFAIL;
}
{
ARRAY(const char *) module_names;
unsigned int i;
/* we're coming from (e.g.) LDA */
}
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 'd':
break;
case 'f':
break;
case 'h':
break;
case 'H':
host_verify = TRUE;
break;
case 'm':
break;
case 'n':
break;
case 'N':
break;
case 'p':
break;
case 'P':
break;
case 'S':
break;
case 'x':
expand_vars = TRUE;
break;
default:
return FATAL_DEFAULT;
}
}
array_idx(&module_names, 0);
/* use strcmp() instead of !=, because dovecot -n always gives us
-c parameter */
if (host_verify)
if (c == 'e') {
i_fatal("Missing command for -e");
/* print only a single config setting */
} else if (!simple_output) {
/* print the config file path before parsing it, so in case
of errors it's still shown */
}
if (print_plugin_banner) {
struct module *m;
}
}
&error)) == 0 &&
error);
}
if (simple_output) {
} else if (setting_name_filters != NULL) {
ret2 = 0;
/* ignore settings-check failures in configuration. this allows
using doveconf to lookup settings for things like install or
uninstall scripts where the configuration might
(temporarily) not be fully usable */
ret = 0;
for (i = 0; setting_name_filters[i] != NULL; i++) {
setting_name_filters[i], hide_passwords) < 0)
ret2 = -1;
}
const char *info;
if (*info != '\0')
if (!config_path_specified)
if (scope == CONFIG_DUMP_SCOPE_ALL)
printf("# NOTE: Send doveconf -n output instead when asking for help.\n");
} else {
/* Standalone binary is getting its configuration via
doveconf. Clean the environment before calling it.
Do this only if the environment exists, because
lib-master doesn't set it if it doesn't want the
environment to be cleaned (e.g. -k parameter). */
const char *import_environment =
}
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;
}