/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#if defined(BUILTIN_LDAP) || defined(PLUGIN_BUILD)
#include "array.h"
#include "str.h"
#include "settings.h"
#include "dict-ldap-settings.h"
#include <ctype.h>
enum section_type {
SECTION_ROOT = 0,
};
struct dict_ldap_map_attribute {
const char *name;
const char *variable;
};
struct setting_parser_ctx {
};
{ 0, NULL, 0 }
};
{
if (*p == '{') {
/* ${name} */
name = ++p;
p = strchr(p, '}');
if (p == NULL) {
/* error, but allow anyway */
return "";
}
*pattern = p + 1;
} else {
/* $name - ends at the first non-alnum_ character */
name = p;
for (; *p != '\0'; p++) {
if (!i_isalnum(*p) && *p != '_')
break;
}
*pattern = p;
}
return name;
}
{
const char *p, *name;
unsigned int i, count;
/* go through the variables in the pattern, replace them with plain
'$' character and add its ldap attribute */
if (*p != '$') {
str_append_c(pattern, *p);
p++;
continue;
}
p++;
name = pattern_read_name(&p);
for (i = 0; i < count; i++) {
break;
}
if (i == count) {
return t_strconcat("Missing LDAP attribute for variable: ",
}
/* mark this attribute as used */
}
/* make sure there aren't any unused attributes */
for (i = 0; i < count; i++) {
return t_strconcat("Unused variable: ",
}
}
return NULL;
}
{
return "Missing setting: pattern";
if (*ptr != '(')
return "Filter must start with (";
ptr--;
if (*ptr != ')')
return "Filter must end with )";
}
return "Missing setting: value_attribute";
/* default to commonName */
}
} else {
else return "Scope must be one, base or subtree";
}
/* no attributes besides value. allocate the array anyway. */
return "Missing attributes for pattern variables";
}
return NULL;
}
static const char *
struct setting_parser_ctx *ctx)
{
case SECTION_ROOT:
return NULL;
}
return NULL;
}
return NULL;
}
return "Invalid timeout value";
}
return NULL;
}
return "Invalid max_idle_time value";
}
return NULL;
}
return "invalid debug value";
}
return NULL;
}
} else {
return "tls must be yes, try or no";
}
return NULL;
}
break;
case SECTION_MAP:
case SECTION_FIELDS:
if (*value != '$') {
return t_strconcat("Value is missing '$' for attribute: ",
}
return NULL;
}
}
static bool
{
case SECTION_ROOT:
return FALSE;
return TRUE;
}
break;
case SECTION_MAP:
return FALSE;
}
return TRUE;
}
break;
case SECTION_FIELDS:
return FALSE;
}
break;
}
return FALSE;
}
struct dict_ldap_settings *
{
return NULL;
"Missing ldap uri", path);
return NULL;
}
}
#endif