char **default_passwd_hash = NULL;
struct berval default_search_base = BER_BVNULL;
struct berval default_search_nbase = BER_BVNULL;
-unsigned num_subordinates = 0;
ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
static int load_ucdata(char *path);
#endif
+int read_config_file(const char *fname, int depth, ConfigArgs *cf);
+
static int add_syncrepl LDAP_P(( Backend *, char **, int ));
static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
CFG_SALT,
CFG_LIMITS,
CFG_RO,
- CFG_SUB,
CFG_SASLOPT,
CFG_REWRITE,
CFG_DEPTH,
#ifdef SLAP_AUTH_REWRITE
{ "auth-rewrite", 2, 2, 14, NULL, ARG_MAGIC|CFG_REWRITE, &config_generic, NULL, NULL, NULL },
#endif
- { "sasl", 2, 2, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL }, /* XXX */
+ { "sasl", 2, 0, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL }, /* XXX */
{ "auth", 2, 2, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL },
{ "schemadn", 2, 2, 0, "dn", ARG_MAGIC, &config_schema_dn, NULL, NULL, NULL },
{ "ucdata-path", 2, 2, 0, "path", ARG_IGNORED, NULL, NULL, NULL, NULL },
{ "sizelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_SIZE, &config_sizelimit, NULL, NULL, NULL },
{ "timelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_TIME, &config_timelimit, NULL, NULL, NULL },
{ "limits", 2, 2, 0, "limits", ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic, NULL, NULL, NULL },
- { "subordinate", 2, 2, 0, "sub", ARG_DB|ARG_MAGIC|CFG_SUB, &config_generic, NULL, NULL, NULL },
{ "overlay", 2, 2, 0, "overlay", ARG_DB|ARG_MAGIC, &config_overlay, NULL, NULL, NULL },
{ "suffix", 2, 2, 0, "suffix", ARG_DB|ARG_MAGIC, &config_suffix, NULL, NULL, NULL },
{ "maxDerefDepth", 2, 2, 0, "depth", ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic, NULL, NULL, NULL },
ConfigArgs *
-new_config_args(BackendDB *be, const char *fname, int lineno, int argc, char **argv) {
+new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
+{
ConfigArgs *c;
- if(!(c = ch_calloc(1, sizeof(ConfigArgs)))) return(NULL);
+ c = ch_calloc( 1, sizeof( ConfigArgs ) );
+ if ( c == NULL ) return(NULL);
c->be = be;
c->fname = fname;
c->argc = argc;
c->value_int = c->value_long = c->value_ber_t = 0;
c->value_string = NULL;
if(arg_type & ARGS_NUMERIC) {
+ int j;
iarg = 0; larg = 0; barg = 0;
switch(arg_type & ARGS_NUMERIC) {
case ARG_INT: iarg = atoi(c->argv[1]); break;
}
break;
}
- i = (arg_type & ARG_NONZERO) ? 1 : 0;
+ j = (arg_type & ARG_NONZERO) ? 1 : 0;
rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
- if(iarg < i || larg < i || barg < i || rc) {
+ if(iarg < j || larg < j || barg < j || rc) {
larg = larg ? larg : (barg ? barg : iarg);
Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: " , c->fname, c->lineno, 0);
Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
case ARG_STRING: {
char *cc = *((char**)Conf[i].arg_item);
if(cc) ch_free(cc); /* potential memory leak */
- cc = c->value_string;
- /* memcpy(Conf[i].arg_item, &c->value_string, sizeof(void *)); */
+ *(char **)Conf[i].arg_item = c->value_string;
break;
}
}
int
read_config(const char *fname, int depth) {
- return(read_config_file(fname, depth, NULL));
+ return read_config_file(fname, depth, NULL);
}
int
-read_config_file(char *fname, int depth, ConfigArgs *cf)
+read_config_file(const char *fname, int depth, ConfigArgs *cf)
{
FILE *fp;
- char *line, *savefname;
ConfigArgs *c;
- int rc, i;
+ int rc;
- c = ch_calloc(1, sizeof(ConfigArgs));
+ c = ch_calloc( 1, sizeof( ConfigArgs ) );
+ if ( c == NULL ) {
+ return 1;
+ }
- if(depth) {
- memcpy(c, cf, sizeof(ConfigArgs));
+ if ( depth ) {
+ memcpy( c, cf, sizeof( ConfigArgs ) );
} else {
c->depth = depth; /* XXX */
c->bi = NULL;
}
c->fname = fname;
- c->argv = ch_calloc(ARGS_STEP + 1, sizeof(*c->argv));
+ c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
c->argv_size = ARGS_STEP + 1;
- if((fp = fopen(fname, "r")) == NULL) {
+ fp = fopen( fname, "r" );
+ if ( fp == NULL ) {
ldap_syslog = 1;
Debug(LDAP_DEBUG_ANY,
"could not open config file \"%s\": %s (%d)\n",
fp_getline_init(c);
- while(fp_getline(fp, c)) {
+ while ( fp_getline( fp, c ) ) {
/* skip comments and blank lines */
- if(c->line[0] == '#' || c->line[0] == '\0') continue;
- if(fp_parse_line(c)) goto badline;
+ if ( c->line[0] == '#' || c->line[0] == '\0' ) {
+ continue;
+ }
+ if ( fp_parse_line( c ) ) {
+ goto badline;
+ }
- if(c->argc < 1) {
+ if ( c->argc < 1 ) {
Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: bad config line (ignored)\n", fname, c->lineno, 0);
continue;
}
- rc = parse_config_table(SystemConfiguration, c);
- if(!rc) continue;
- if(rc & ARGS_USERLAND) switch(rc) { /* XXX a usertype would be opaque here */
- default: Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: unknown user type <%d>\n",
- c->fname, c->lineno, *c->argv);
- goto badline;
- } else if(rc == ARG_BAD_CONF || rc != ARG_UNKNOWN) {
+ rc = parse_config_table( SystemConfiguration, c );
+ if ( !rc ) {
+ continue;
+ }
+ if ( rc & ARGS_USERLAND ) {
+ switch(rc) { /* XXX a usertype would be opaque here */
+ default:
+ Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: unknown user type <%d>\n",
+ c->fname, c->lineno, *c->argv);
+ goto badline;
+ }
+
+ } else if ( rc == ARG_BAD_CONF || rc != ARG_UNKNOWN ) {
goto badline;
- } else if(c->bi && c->bi->bi_config) { /* XXX to check: could both be/bi_config? oops */
- if(rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv)) switch(rc) {
+
+ } else if ( c->bi && c->bi->bi_config ) { /* XXX to check: could both be/bi_config? oops */
+ rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv);
+ if ( rc ) {
+ switch(rc) {
case SLAP_CONF_UNKNOWN:
Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
"unknown directive <%s> inside backend info definition (ignored)\n",
continue;
default:
goto badline;
+ }
}
- } else if(c->be && c->be->be_config) {
- if(rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv)) switch(rc) {
+
+ } else if ( c->be && c->be->be_config ) {
+ rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv);
+ if ( rc ) {
+ switch(rc) {
case SLAP_CONF_UNKNOWN:
Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
"unknown directive <%s> inside backend database definition (ignored)\n",
continue;
default:
goto badline;
+ }
}
- } else if(frontendDB->be_config) {
- if(rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv)) switch(rc) {
+
+ } else if ( frontendDB->be_config ) {
+ rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
+ if ( rc ) {
+ switch(rc) {
case SLAP_CONF_UNKNOWN:
Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
"%s: line %lu: unknown directive <%s> inside global database definition (ignored)\n",
continue;
default:
goto badline;
+ }
}
+
} else {
Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
"unknown directive <%s> outside backend info and database definitions (ignored)\n",
fclose(fp);
if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
- ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
+ ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
&frontendDB->be_schemadn );
dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
}
c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
break;
- case CFG_SUB:
- SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
- num_subordinates++;
- break;
-
case CFG_SASLOPT:
/* XXX slap_sasl_config doesn't actually use the line argument */
if(slap_sasl_config(c->argc, c->argv, c->line, c->fname, c->lineno))
config_search_base(ConfigArgs *c) {
struct berval dn;
int rc;
- if(c->bi || c->be) {
+ if(c->bi || c->be != frontendDB) {
Debug(LDAP_DEBUG_ANY, "%s: line %lu: defaultSearchBase line must appear "
"prior to any backend or database definition\n",
c->fname, c->lineno, 0);
struct slap_limits_set *lim = &c->be->be_def_limit;
for(i = 1; i < c->argc; i++) {
if(!strncasecmp(c->argv[i], "size", 4)) {
- if(rc = limits_parse_one(c->argv[i], lim)) {
+ rc = limits_parse_one(c->argv[i], lim);
+ if ( rc ) {
Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
"unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
c->fname, c->lineno, c->argv[i]);
struct slap_limits_set *lim = &c->be->be_def_limit;
for(i = 1; i < c->argc; i++) {
if(!strncasecmp(c->argv[i], "time", 4)) {
- if(rc = limits_parse_one(c->argv[i], lim)) {
+ rc = limits_parse_one(c->argv[i], lim);
+ if ( rc ) {
Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
"unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
c->fname, c->lineno, c->argv[i]);
{ "update_anon", SLAP_ALLOW_UPDATE_ANON },
{ NULL, 0 }
};
- if(i = verbs_to_mask(c, allowable_ops, &allows)) {
+ i = verbs_to_mask(c, allowable_ops, &allows);
+ if ( i ) {
Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
"unknown feature %s in \"allow <features>\" line\n",
c->fname, c->lineno, c->argv[i]);
slap_mask_t disallows = 0;
int i;
struct verb_mask_list disallowable_ops[] = {
- { "bind_v2", SLAP_DISALLOW_BIND_ANON },
+ { "bind_anon", SLAP_DISALLOW_BIND_ANON },
{ "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
{ "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
{ "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
{ "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
{ NULL, 0 }
};
- if(i = verbs_to_mask(c, disallowable_ops, &disallows)) {
+ i = verbs_to_mask(c, disallowable_ops, &disallows);
+ if ( i ) {
Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
"unknown feature %s in \"disallow <features>\" line\n",
c->fname, c->lineno, c->argv[i]);
{ "strong", SLAP_REQUIRE_STRONG },
{ NULL, 0 }
};
- if(i = verbs_to_mask(c, requires_ops, &requires)) {
+ i = verbs_to_mask(c, requires_ops, &requires);
+ if ( i ) {
Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
"unknown feature %s in \"require <features>\" line\n",
c->fname, c->lineno, c->argv[i]);
config_tls_option(ConfigArgs *c) {
int flag;
switch(c->type) {
- CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
- CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
- CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
- CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
- CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
- CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
+ case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
+ case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
+ case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
+ case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
+ case CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
+ case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
#ifdef HAVE_OPENSSL_CRL
- CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
+ case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
#endif
default: Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
"unknown tls_option <%x>\n",
}
static int
-fp_getline(FILE *fp, ConfigArgs *c)
+fp_getline( FILE *fp, ConfigArgs *c )
{
char *p;
c->lineno++;
/* avoid stack of bufs */
- if(strncasecmp(line, "include", 7) == 0) {
+ if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
buf[0] = '\0';
c->line = line;
return(1);
}
- while(fgets(buf, sizeof(buf), fp)) {
- if(p = strchr(buf, '\n')) {
- if(p > buf && p[-1] == '\r') --p;
+ while ( fgets( buf, sizeof( buf ), fp ) ) {
+ p = strchr( buf, '\n' );
+ if ( p ) {
+ if ( p > buf && p[-1] == '\r' ) {
+ --p;
+ }
*p = '\0';
}
/* XXX ugly */
c->line = line;
- if(line[0] && (p = line + strlen(line) - 1)[0] == '\\' && p[-1] != '\\' ) {
+ if ( line[0]
+ && ( p = line + strlen( line ) - 1 )[0] == '\\'
+ && p[-1] != '\\' )
+ {
p[0] = '\0';
lcur--;
+
} else {
- if(!isspace((unsigned char)buf[0])) return(1);
+ if ( !isspace( (unsigned char)buf[0] ) ) {
+ return(1);
+ }
buf[0] = ' ';
}
CATLINE(buf);
{
char *token;
char *tline = ch_strdup(c->line);
- char logbuf[STRLENOF("pseudorootpw ***")]; /* longest secret */
char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
int i;
si->si_manageDSAit = 0;
si->si_tlimit = 0;
si->si_slimit = 0;
- si->si_syncUUID_ndn.bv_val = NULL;
- si->si_syncUUID_ndn.bv_len = 0;
si->si_presentlist = NULL;
LDAP_LIST_INIT( &si->si_nonpresentlist );
)
{
int gots = 0;
- int i, j;
- char *hp, *val;
- int nr_attr = 0;
+ int i;
+ char *val;
for ( i = 1; i < cargc; i++ ) {
if ( !strncasecmp( cargv[ i ], IDSTR "=",
}
ch_free( attr_fname );
} else {
- int j;
si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
if ( si->si_exanlist == NULL ) {
return -1;
} else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
STRLENOF( RETRYSTR "=" ) ) )
{
- char *str;
char **retry_list;
int j, k, n;
char *s;
char *lasts;
int i, j;
- const char *text;
char **new;
/* find last element in list */