static int config_include(ConfigArgs *c);
#ifdef HAVE_TLS
static int config_tls_option(ConfigArgs *c);
-static int config_tls_verify(ConfigArgs *c);
+static int config_tls_config(ConfigArgs *c);
#endif
enum {
static ConfigTable SystemConfiguration[] = {
/* This attr is read-only */
- { "", "", 0, 0, 0, ARG_MAGIC|ARG_STRING,
+ { "", "", 0, 0, 0, ARG_MAGIC,
&config_fname, "( OLcfgAt:78 NAME 'olcConfigFile' "
"DESC 'File for slapd configuration directives' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL },
{ "TLSCRLCheck", NULL, 0, 0, 0,
#ifdef HAVE_TLS
- CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_option,
+ CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_config,
#else
ARG_IGNORED, NULL,
#endif
"SYNTAX OMsDirectoryString )", NULL, NULL },
{ "TLSVerifyClient", NULL, 0, 0, 0,
#ifdef HAVE_TLS
- CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_verify,
+ CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_config,
#else
ARG_IGNORED, NULL,
#endif
case ARG_INT: c->value_int = *(int *)cf->arg_item; break;
case ARG_LONG: c->value_long = *(long *)cf->arg_item; break;
case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)cf->arg_item; break;
- case ARG_STRING: c->value_string = *(char **)cf->arg_item; break;
+ case ARG_STRING:
+ if ( *(char **)cf->arg_item )
+ c->value_string = ch_strdup(*(char **)cf->arg_item);
+ break;
}
}
if ( cf->arg_type & ARGS_POINTER) {
if ( c->value_string && c->value_string[0]) {
ber_str2bv( c->value_string, 0, 0, &bv);
} else {
- rc = 1;
+ return 1;
}
break;
}
- ber_bvarray_add(&c->rvalue_vals, &bv);
+ if (( cf->arg_type & ARGS_POINTER ) == ARG_STRING )
+ ber_bvarray_add(&c->rvalue_vals, &bv);
+ else
+ value_add(&c->rvalue_vals, &bv);
}
return rc;
}
break;
case CFG_SALT:
if ( passwd_salt )
- c->value_string = passwd_salt;
+ c->value_string = ch_strdup( passwd_salt );
else
rc = 1;
break;
c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) != 0;
break;
case CFG_AZPOLICY:
- c->value_string = (char *)slap_sasl_getpolicy();
+ c->value_string = ch_strdup( slap_sasl_getpolicy());
break;
case CFG_AZREGEXP:
rc = 1;
break;
}
case CFG_REPLOG:
- c->value_string = c->be->be_replogfile;
+ if ( c->be->be_replogfile )
+ c->value_string = ch_strdup( c->be->be_replogfile );
break;
case CFG_ROOTDSE: {
ConfigFile *cf = (ConfigFile *)c->line;
if ( cf->c_dseFiles ) {
- c->rvalue_vals = cf->c_dseFiles;
+ value_add( &c->rvalue_vals, cf->c_dseFiles );
} else {
rc = 1;
}
break;
case CFG_LOGFILE:
if ( logfileName )
- c->value_string = logfileName;
+ c->value_string = ch_strdup( logfileName );
else
rc = 1;
break;
config_fname(ConfigArgs *c) {
if(c->emit && c->line) {
ConfigFile *cf = (ConfigFile *)c->line;
- c->value_string = cf->c_file.bv_val;
+ value_add_one( &c->rvalue_vals, &cf->c_file );
return 0;
}
return(1);
if(c->emit) {
int rc = 1;
if (!BER_BVISEMPTY(&default_search_base)) {
- ber_bvarray_add(&c->rvalue_vals, &default_search_base);
- ber_bvarray_add(&c->rvalue_nvals, &default_search_nbase);
+ value_add_one(&c->rvalue_vals, &default_search_base);
+ value_add_one(&c->rvalue_nvals, &default_search_nbase);
rc = 0;
}
return rc;
struct berval bv;
for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
- ber_bvarray_add(&c->rvalue_vals, &bv);
+ value_add_one(&c->rvalue_vals, &bv);
}
return i ? 0 : 1;
}
struct berval dn;
int rc;
if ( c->emit ) {
- ber_bvarray_add(&c->rvalue_vals, &c->be->be_schemadn);
- ber_bvarray_add(&c->rvalue_nvals, &c->be->be_schemandn);
+ value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
+ value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
return 0;
}
c->be->be_schemadn = c->value_dn;
struct berval pdn, ndn;
int rc;
if (c->emit) {
- int i;
- for (i=0; !BER_BVISNULL(&c->be->be_suffix[i]); i++) {
- ber_bvarray_add(&c->rvalue_vals, &c->be->be_suffix[i]);
- ber_bvarray_add(&c->rvalue_nvals, &c->be->be_nsuffix[i]);
+ if ( !BER_BVISNULL( &c->be->be_suffix[0] )) {
+ value_add( &c->rvalue_vals, c->be->be_suffix );
+ value_add( &c->rvalue_nvals, c->be->be_nsuffix );
+ return 0;
+ } else {
+ return 1;
}
- return i ? 0 : 1;
}
#ifdef SLAPD_MONITOR_DN
if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
static int
config_rootdn(ConfigArgs *c) {
if (c->emit) {
- ber_bvarray_add(&c->rvalue_vals, &c->be->be_rootdn);
- ber_bvarray_add(&c->rvalue_nvals, &c->be->be_rootndn);
- return 0;
+ if ( !BER_BVISNULL( &c->be->be_rootdn )) {
+ value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
+ value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
+ return 0;
+ } else {
+ return 1;
+ }
}
c->be->be_rootdn = c->value_dn;
c->be->be_rootndn = c->value_ndn;
Backend *tbe;
if (c->emit) {
if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
- c->value_string="*";
+ c->value_string=ch_strdup("*");
return 0;
}
return 1;
return(0);
}
+int
+mask_to_verbs(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t m) {
+ int i, j;
+ struct berval bv;
+
+ if (!m) return 1;
+ for (i=0; v[i].word; i++) {
+ if ( v[i].mask == -1 && m != v[i].mask ) continue;
+ if ( m & v[i].mask ) {
+ ber_str2bv( v[i].word, 0, 0, &bv );
+ value_add_one( &c->rvalue_vals, &bv );
+ }
+ }
+ return 0;
+}
+
static int
config_restrict(ConfigArgs *c) {
slap_mask_t restrictops = 0;
- int i, j;
- struct verb_mask_list restrictable_exops[] = {
- { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
- { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
- { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
- { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
- { NULL, 0 }
- };
+ int i;
struct verb_mask_list restrictable_ops[] = {
{ "bind", SLAP_RESTRICT_OP_BIND },
{ "add", SLAP_RESTRICT_OP_ADD },
{ "rename", SLAP_RESTRICT_OP_RENAME },
{ "delete", SLAP_RESTRICT_OP_DELETE },
{ "search", SLAP_RESTRICT_OP_SEARCH },
- { "compare", SLAP_RESTRICT_OP_COMPARE },
+ { "compare", SLAP_RESTRICT_OP_COMPARE },
{ "read", SLAP_RESTRICT_OP_READS },
{ "write", SLAP_RESTRICT_OP_WRITES },
+ { "extended", SLAP_RESTRICT_OP_EXTENDED },
+ { "extended=" LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
+ { "extended=" LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
+ { "extended=" LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
+ { "extended=" LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
{ NULL, 0 }
};
if (c->emit) {
- return 1;
+ return mask_to_verbs( c, restrictable_ops, c->be->be_restrictops );
}
- for(i = 1; i < c->argc; i++) {
- j = verb_to_mask(c, restrictable_ops, i);
- if(restrictable_ops[j].word) {
- restrictops |= restrictable_ops[j].mask;
- continue;
- } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
- char *e = c->argv[i] + STRLENOF("extended");
- if(e[0] == '=') {
- int k = verb_to_mask(c, restrictable_exops, e[1]);
- if(restrictable_exops[k].word) {
- restrictops |= restrictable_exops[k].mask;
- continue;
- } else break;
- } else if(!e[0]) {
- restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
- restrictops |= SLAP_RESTRICT_OP_EXTENDED;
- } else break;
- }
- }
- if(i < c->argc) {
- c->be->be_restrictops |= restrictops;
- return(0);
+ i = verbs_to_mask( c, restrictable_ops, &restrictops );
+ if ( i ) {
+ Debug(LDAP_DEBUG_ANY, "%s: "
+ "unknown operation %s in \"restrict <features>\" line\n",
+ c->log, c->argv[i], 0);
+ return(1);
}
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unknown operation %s in \"restrict <features>\" line\n",
- c->log, c->argv[i], 0);
- return(1);
+ if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
+ restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
+ c->be->be_restrictops |= restrictops;
+ return(0);
}
static int
{ NULL, 0 }
};
if (c->emit) {
- return 1;
+ return mask_to_verbs( c, allowable_ops, global_allows );
}
i = verbs_to_mask(c, allowable_ops, &allows);
if ( i ) {
{ NULL, 0 }
};
if (c->emit) {
- return 1;
+ return mask_to_verbs( c, disallowable_ops, global_disallows );
}
i = verbs_to_mask(c, disallowable_ops, &disallows);
if ( i ) {
{ NULL, 0 }
};
if (c->emit) {
- return 1;
+ return mask_to_verbs( c, requires_ops, c->be->be_requires );
}
i = verbs_to_mask(c, requires_ops, &requires);
if ( i ) {
{ "Any", -1 },
{ NULL, 0 }
};
- ldap_syslog = 0;
if (c->emit) {
- return 1;
+ return mask_to_verbs( c, loglevel_ops, ldap_syslog );
}
+ ldap_syslog = 0;
+
for( i=1; i < c->argc; i++ ) {
int level;
config_referral(ConfigArgs *c) {
struct berval vals[2];
if (c->emit) {
- return 1;
+ if ( default_referral ) {
+ value_add( &c->rvalue_vals, default_referral );
+ return 0;
+ } else {
+ return 1;
+ }
}
if(validate_global_referral(c->argv[1])) {
Debug(LDAP_DEBUG_ANY, "%s: "
return(1);
}
- ber_str2bv(c->argv[1], 0, 1, &vals[0]);
+ ber_str2bv(c->argv[1], 0, 0, &vals[0]);
vals[1].bv_val = NULL; vals[1].bv_len = 0;
if(value_add(&default_referral, vals)) return(LDAP_OTHER);
return(0);
int rc;
if (c->emit) {
if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
- ber_bvarray_add(&c->rvalue_vals, &c->be->be_update_ndn);
- ber_bvarray_add(&c->rvalue_nvals, &c->be->be_update_ndn);
+ value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
+ value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
return 0;
}
return 1;
config_updateref(ConfigArgs *c) {
struct berval vals[2];
if (c->emit) {
- return 1;
+ if ( c->be->be_update_refs ) {
+ value_add( &c->rvalue_vals, c->be->be_update_refs );
+ return 0;
+ } else {
+ return 1;
+ }
}
if(!SLAP_SHADOW(c->be)) {
Debug(LDAP_DEBUG_ANY, "%s: "
config_include(ConfigArgs *c) {
unsigned long savelineno = c->lineno;
int rc;
- ConfigFile *cf = ch_calloc( 1, sizeof(ConfigFile));
+ ConfigFile *cf;
ConfigFile *cfsave = cfn;
ConfigFile *cf2 = NULL;
if (c->emit) {
return 1;
}
+ cf = ch_calloc( 1, sizeof(ConfigFile));
if ( cfn->c_kids ) {
for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
cf2->c_sibs = cf;
static int
config_tls_option(ConfigArgs *c) {
int flag;
- if (c->emit) {
- return 1;
- }
switch(c->type) {
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_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
-#ifdef HAVE_OPENSSL_CRL
- case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
-#endif
default: Debug(LDAP_DEBUG_ANY, "%s: "
"unknown tls_option <%x>\n",
c->log, c->type, 0);
}
+ if (c->emit) {
+ return 1;
+ }
return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
}
static int
-config_tls_verify(ConfigArgs *c) {
- int i;
+config_tls_config(ConfigArgs *c) {
+ int i, flag;
if (c->emit) {
return 1;
}
+ switch(c->type) {
+#ifdef HAVE_OPENSSL_CRL
+ case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
+#endif
+ case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
+ }
if(isdigit((unsigned char)c->argv[1][0])) {
i = atoi(c->argv[1]);
- return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
+ return(ldap_pvt_tls_set_option(NULL, flag, &i));
} else {
- return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
+ return(ldap_int_tls_config(NULL, flag, c->argv[1]));
}
}
#endif
return(0);
}
-
-#if 0
-/* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
-static int
-load_ucdata( char *path )
-{
-#if 0
- static int loaded = 0;
- int err;
-
- if ( loaded ) {
- return( 0 );
- }
- err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
- if ( err ) {
- Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
- err, 0, 0 );
-
- return( -1 );
- }
- loaded = 1;
- return( 1 );
-#else
- /* ucdata is now hardcoded */
- return( 0 );
-#endif
-}
-#endif
-
void
config_destroy( )
{