switch(c->type) {
case CFG_BACKEND:
if(!(c->bi = backend_info(c->argv[1]))) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "backend %s failed init!\n", c->log, c->argv[1], 0);
+ sprintf( c->msg, "<%s> failed init", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
+ c->log, c->msg, c->argv[1] );
return(1);
}
break;
} else if ( !strcasecmp( c->argv[1], "frontend" )) {
c->be = frontendDB;
} else if(!(c->be = backend_db_init(c->argv[1]))) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "database %s failed init!\n", c->log, c->argv[1], 0);
+ sprintf( c->msg, "<%s> failed init", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
+ c->log, c->msg, c->argv[1] );
return(1);
}
break;
case CFG_AZPOLICY:
ch_free(c->value_string);
if (slap_sasl_setpolicy( c->argv[1] )) {
- Debug(LDAP_DEBUG_ANY, "%s: unable to parse value \"%s\" in"
- " \"authz-policy <policy>\"\n",
- c->log, c->argv[1], 0 );
+ sprintf( c->msg, "<%s> unable to parse value", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[1] );
return(1);
}
break;
{
char *txt = slap_sasl_secprops( c->argv[1] );
if ( txt ) {
- Debug(LDAP_DEBUG_ANY, "%s: sasl-secprops: %s\n",
- c->log, txt, 0 );
+ snprintf( c->msg, sizeof(c->msg), "<%s> %s",
+ c->argv[0], txt );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
return(1);
}
break;
case CFG_ROOTDSE:
if(read_root_dse_file(c->argv[1])) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "could not read \"rootDSE <filename>\" line\n",
- c->log, 0, 0);
+ sprintf( c->msg, "<%s> could not read file", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+ c->log, c->msg, c->argv[1] );
return(1);
}
{
case CFG_LASTMOD:
if(SLAP_NOLASTMODCMD(c->be)) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "lastmod not available for %s databases\n",
- c->log, c->be->bd_info->bi_type, 0);
+ sprintf( c->msg, "<%s> not available for %s database",
+ c->argv[0], c->be->bd_info->bi_type );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+ c->log, c->msg, 0 );
return(1);
}
if(c->value_int)
case CFG_SSTR_IF_MAX:
if (c->value_int < index_substr_if_minlen) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "invalid max value (%d)\n",
- c->log, c->value_int, 0 );
+ sprintf( c->msg, "<%s> invalid value", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
+ c->log, c->msg, c->value_int );
return(1);
}
index_substr_if_maxlen = c->value_int;
case CFG_SSTR_IF_MIN:
if (c->value_int > index_substr_if_maxlen) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "invalid min value (%d)\n",
- c->log, c->value_int, 0 );
+ sprintf( c->msg, "<%s> invalid value", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
+ c->log, c->msg, c->value_int );
return(1);
}
index_substr_if_minlen = c->value_int;
static int
config_cfdir(ConfigArgs *c) {
if(c->op == SLAP_CONFIG_EMIT) {
- value_add_one( &c->rvalue_vals, &cfdir );
- return 0;
+ if ( !BER_BVISEMPTY( &cfdir )) {
+ value_add_one( &c->rvalue_vals, &cfdir );
+ return 0;
+ }
+ return 1;
}
return(0);
}
}
if(default_search_nbase.bv_len) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "default search base \"%s\" already defined "
- "(discarding old)\n",
- c->log, default_search_base.bv_val, 0);
free(default_search_base.bv_val);
free(default_search_nbase.bv_val);
}
}
for(i = 1; i < c->argc; i++) {
if(!lutil_passwd_scheme(c->argv[i])) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "password scheme \"%s\" not available\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> schema not available", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
+ c->log, c->msg, c->argv[i]);
} else {
ldap_charray_add(&default_passwd_hash, c->argv[i]);
}
if(!default_passwd_hash) {
- Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
- c->log, 0, 0 );
+ sprintf( c->msg, "<%s> no valid hashes found", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+ c->log, c->msg, 0 );
return(1);
}
}
if(!strncasecmp(c->argv[i], "size", 4)) {
rc = limits_parse_one(c->argv[i], lim);
if ( rc ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unable to parse value", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
} else {
} else {
lim->lms_s_soft = strtol(c->argv[i], &next, 0);
if(next == c->argv[i]) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unable to parse limit", c->argv[0]);
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return(1);
} else if(next[0] != '\0') {
Debug(LDAP_DEBUG_ANY, "%s: "
if(!strncasecmp(c->argv[i], "time", 4)) {
rc = limits_parse_one(c->argv[i], lim);
if ( rc ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unable to parse value", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
} else {
} else {
lim->lms_t_soft = strtol(c->argv[i], &next, 0);
if(next == c->argv[i]) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unable to parse limit", c->argv[0]);
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return(1);
} else if(next[0] != '\0') {
Debug(LDAP_DEBUG_ANY, "%s: "
}
#ifdef SLAPD_MONITOR_DN
if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "\"%s\" is reserved for monitoring slapd\n",
- c->log, SLAPD_MONITOR_DN, 0);
+ sprintf( c->msg, "<%s> DN is reserved for monitoring slapd",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
+ c->log, c->msg, SLAPD_MONITOR_DN);
return(1);
}
#endif
free(pdn.bv_val);
free(ndn.bv_val);
} else if(tbe) {
- Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
- c->log, tbe->be_suffix[0].bv_val, 0);
+ sprintf( c->msg, "<%s> suffix already served by a preceding backend",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, tbe->be_suffix[0].bv_val);
free(pdn.bv_val);
free(ndn.bv_val);
return(1);
tbe = select_backend(&c->be->be_rootndn, 0, 0);
if(tbe != c->be) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "rootpw can only be set when rootdn is under suffix\n",
- c->log, 0, 0);
+ sprintf( c->msg, "<%s> can only be set when rootdn is under suffix",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+ c->log, c->msg, 0);
return(1);
}
if ( !BER_BVISNULL( &c->be->be_rootpw ))
}
i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
if ( i ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unknown operation %s in \"restrict <features>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unknown operation", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
}
i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
if ( i ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unknown feature %s in \"allow <features>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unknown feature", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
global_allows |= allows;
}
i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
if ( i ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unknown feature %s in \"disallow <features>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unknown feature", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
global_disallows |= disallows;
}
i = verbs_to_mask(c->argc, c->argv, requires_ops, &requires);
if ( i ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unknown feature %s in \"require <features>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unknown feature", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
c->be->be_requires = requires;
if ( isdigit( c->argv[i][0] ) ) {
level = strtol( c->argv[i], &next, 10 );
if ( next == NULL || next[0] != '\0' ) {
- Debug( LDAP_DEBUG_ANY,
- "%s: unable to parse level \"%s\" "
- "in \"loglevel <level> [...]\" line.\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unable to parse level", c->argv[0] );
+ Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return( 1 );
}
} else {
int j = verb_to_mask(c->argv[i], loglevel_ops);
if(BER_BVISNULL(&loglevel_ops[j].word)) {
- Debug( LDAP_DEBUG_ANY,
- "%s: unknown level \"%s\" "
- "in \"loglevel <level> [...]\" line.\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unknown level", c->argv[0] );
+ Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return( 1 );
}
level = loglevel_ops[j].mask;
return 0;
}
if(validate_global_referral(c->argv[1])) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "invalid URL (%s) in \"referral\" line.\n",
- c->log, c->argv[1], 0);
+ sprintf( c->msg, "<%s> invalid URL", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
+ c->log, c->msg, c->argv[1]);
return(1);
}
}
}
if ( !tgt ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unknown factor %s in \"security <factors>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unknown factor", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
*tgt = strtol(src, &next, 10);
if(next == NULL || next[0] != '\0' ) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unable to parse factor \"%s\" in \"security <factors>\" line\n",
- c->log, c->argv[i], 0);
+ sprintf( c->msg, "<%s> unable to parse factor", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, c->argv[i]);
return(1);
}
}
break;
} else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "replica line contains invalid "
- "uri definition.\n", c->log, 0, 0);
+ sprintf( c->msg, "<%s> invalid uri", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
return(1);
}
if(!ludp->lud_host) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "replica line contains invalid "
- "uri definition - missing hostname.\n",
- c->log, 0, 0);
+ sprintf( c->msg, "<%s> invalid uri - missing hostname",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
return(1);
}
ldap_free_urldesc(ludp);
}
}
if(i == c->argc) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "missing host or uri in \"replica\" line\n",
- c->log, 0, 0);
+ sprintf( c->msg, "<%s> missing host or uri", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
return(1);
} else if(nr == -1) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "unable to add replica \"%s\"\n",
- c->log, replicauri, 0);
+ sprintf( c->msg, "<%s> unable to add replica", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n", c->log, c->msg, replicauri );
return(1);
} else {
for(i = 1; i < c->argc; i++) {
continue;
}
if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "attribute \"%s\" in \"replica\" line is unknown\n",
- c->log, arg + 1, 0);
+ sprintf( c->msg, "<%s> unknown attribute", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
+ c->log, c->msg, arg + 1);
return(1);
}
} else if ( bindconf_parse( c->argv[i],
return 0;
}
if(SLAP_SHADOW(c->be)) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "updatedn: database already shadowed.\n",
- c->log, 0, 0);
+ sprintf( c->msg, "<%s> database already shadowed", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+ c->log, c->msg, 0);
return(1);
}
rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
if(rc != LDAP_SUCCESS) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "updatedn DN is invalid: %d (%s)\n",
- c->log, rc, ldap_err2string( rc ));
+ sprintf( c->msg, "<%s> invalid DN %d (%s)", c->argv[0],
+ rc, ldap_err2string(rc));
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+ c->log, c->msg, 0 );
return(1);
}
return 0;
}
if(!SLAP_SHADOW(c->be)) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "updateref line must come after syncrepl or updatedn.\n",
- c->log, 0, 0);
+ sprintf( c->msg, "<%s> must appear after syncrepl or updatedn",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+ c->log, c->msg, 0);
return(1);
}
if(validate_global_referral(c->argv[1])) {
- Debug(LDAP_DEBUG_ANY, "%s: "
- "invalid URL (%s) in \"updateref\" line.\n",
- c->log, c->argv[1], 0);
+ sprintf( c->msg, "<%s> invalid URL", c->argv[0] );
+ Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
+ c->log, c->msg, c->argv[1]);
return(1);
}
ber_str2bv(c->argv[1], 0, 0, &val);
else cfn->c_kids = NULL;
ch_free( cf->c_file.bv_val );
ch_free( cf );
+ } else {
+ c->private = cf;
}
return(rc);
}
if (last->ce_type == Cft_Global )
goto ok;
/* FALLTHRU */
+ ca.private = ch_calloc( 1, sizeof(ConfigFile) );
+ cfn = ca.private;
case Cft_Global:
ca.be = LDAP_STAILQ_FIRST(&backendDB);
break;
nocs = 0; /* ignored */
break;
}
+ if ( last->ce_type == Cft_Global )
+ cfn = &cf_prv;
+ else
+ cfn = last->ce_private;
type_ad = cfAd_include;
break;
#ifdef SLAPD_MODULES
case Cft_Module: {
+#if 0
ModPaths *mp;
char *ptr;
ptr = strchr( e->e_name.bv_val, '{' );
}
module_path( mp->mp_path.bv_val );
ca.private = mp;
+#endif
}
break;
#endif
ce->ce_type = colst[0]->co_type;
ce->ce_be = ca.be;
ce->ce_bi = ca.bi;
+ ce->ce_private = ca.private;
if ( !last ) {
cfb->cb_root = ce;
} else if ( last->ce_kids ) {
static int
config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
- char *textbuf, int textsize )
+ ConfigArgs *ca )
{
CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
int rc = LDAP_UNWILLING_TO_PERFORM;
Modifications *ml;
Entry *e = ce->ce_entry;
Attribute *save_attrs = e->e_attrs, *oc_at;
- ConfigArgs ca = {0};
ConfigTable *ct;
CfOcInfo **colst;
int i, nocs;
e->e_attrs = attrs_dup( e->e_attrs );
- init_config_argv( &ca );
- ca.be = ce->ce_be;
- ca.bi = ce->ce_bi;
- ca.private = ce->ce_private;
+ init_config_argv( ca );
+ ca->be = ce->ce_be;
+ ca->bi = ce->ce_bi;
+ ca->private = ce->ce_private;
+ strcpy( ca->log, "back-config" );
for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
ct = config_find_table( colst, nocs, ml->sml_desc );
BerVarray vals = NULL, nvals;
int *idx = NULL;
if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
- rc = LDAP_UNWILLING_TO_PERFORM;
- snprintf(textbuf, textsize, "cannot delete %s",
- ml->sml_desc );
- rs->sr_text = textbuf;
+ rc = LDAP_OTHER;
+ snprintf( ca->msg, sizeof(ca->msg),
+ "<%s> cannot be deleted" );
+ snprintf(ca->msg, sizeof(ca->msg), "cannot delete %s",
+ ml->sml_desc->ad_cname.bv_val );
goto out;
}
if ( ml->sml_op == LDAP_MOD_REPLACE ) {
}
rc = modify_delete_vindex(e, &ml->sml_mod,
get_permissiveModify(op),
- &rs->sr_text, textbuf, textsize, idx );
+ &rs->sr_text, ca->msg, sizeof(ca->msg), idx );
if ( ml->sml_op == LDAP_MOD_REPLACE ) {
ml->sml_values = vals;
ml->sml_nvalues = nvals;
navals >= 0 ) {
int j = strtol( ml->sml_values[i].bv_val+1, NULL, 0 );
if ( j < navals ) {
- rc = LDAP_UNWILLING_TO_PERFORM;
- snprintf(textbuf, textsize, "cannot insert %s",
- ml->sml_desc );
- rs->sr_text = textbuf;
+ rc = LDAP_OTHER;
+ snprintf(ca->msg, sizeof(ca->msg), "cannot insert %s",
+ ml->sml_desc->ad_cname.bv_val );
goto out;
}
}
- rc = check_vals( ct, &ca, ml, 0 );
+ rc = check_vals( ct, ca, ml, 0 );
if ( rc ) goto out;
}
}
rc = modify_add_values(e, &ml->sml_mod,
get_permissiveModify(op),
- &rs->sr_text, textbuf, textsize );
+ &rs->sr_text, ca->msg, sizeof(ca->msg) );
/* If value already exists, show success here
* and ignore this operation down below.
if(rc == LDAP_SUCCESS) {
/* check that the entry still obeys the schema */
rc = entry_schema_check(op->o_bd, e, NULL,
- &rs->sr_text, textbuf, textsize );
+ &rs->sr_text, ca->msg, sizeof(ca->msg) );
}
if ( rc == LDAP_SUCCESS ) {
/* Basic syntax checks are OK. Do the actual settings. */
bv.bv_len -= ptr - bv.bv_val;
bv.bv_val = ptr;
}
- ca.line = bv.bv_val;
- ca.valx = d->idx[i];
- rc = config_del_vals( ct, &ca );
+ ca->line = bv.bv_val;
+ ca->valx = d->idx[i];
+ rc = config_del_vals( ct, ca );
if ( rc != LDAP_SUCCESS ) break;
for (j=i+1; j < d->nidx; j++)
if ( d->idx[j] >d->idx[i] )
d->idx[j]--;
}
} else {
- ca.valx = -1;
- ca.line = NULL;
- rc = config_del_vals( ct, &ca );
+ ca->valx = -1;
+ ca->line = NULL;
+ rc = config_del_vals( ct, ca );
}
if ( ml->sml_values ) {
ch_free( dels );
case LDAP_MOD_ADD:
for (i=0; ml->sml_values[i].bv_val; i++) {
- ca.line = ml->sml_values[i].bv_val;
- ca.valx = -1;
+ ca->line = ml->sml_values[i].bv_val;
+ ca->valx = -1;
if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
- ca.line[0] == '{' ) {
- ptr = strchr( ca.line, '}' );
+ ca->line[0] == '{' ) {
+ ptr = strchr( ca->line, '}' );
if ( ptr ) {
- ca.valx = strtol( ca.line+1, NULL, 0 );
- ca.line = ptr+1;
+ ca->valx = strtol( ca->line+1, NULL, 0 );
+ ca->line = ptr+1;
}
}
- rc = config_parse_add( ct, &ca );
+ rc = config_parse_add( ct, ca );
if ( rc ) {
rc = LDAP_OTHER;
goto out;
}
out:
- if ( ca.cleanup )
- ca.cleanup( &ca );
+ if ( ca->cleanup )
+ ca->cleanup( ca );
if ( rc == LDAP_SUCCESS ) {
attrs_free( save_attrs );
} else {
attrs_free( e->e_attrs );
e->e_attrs = save_attrs;
}
- ch_free( ca.argv );
+ ch_free( ca->argv );
if ( colst ) ch_free( colst );
return rc;
CfBackInfo *cfb;
CfEntryInfo *ce, *last;
Modifications *ml;
- char textbuf[SLAP_TEXT_BUFLEN];
+ ConfigArgs ca = {0};
struct berval rdn;
char *ptr;
AttributeDescription *rad = NULL;
* 3) perform the individual config operations.
* 4) store Modified entry in underlying LDIF backend.
*/
- rs->sr_err = config_modify_internal( ce, op, rs, textbuf, sizeof(textbuf) );
- if ( rs->sr_err == LDAP_SUCCESS && cfb->cb_use_ldif ) {
+ rs->sr_err = config_modify_internal( ce, op, rs, &ca );
+ if ( rs->sr_err ) {
+ rs->sr_text = ca.msg;
+ } else if ( cfb->cb_use_ldif ) {
BackendDB *be = op->o_bd;
slap_callback sc = { NULL, slap_null_cb, NULL, NULL };
op->o_bd = &cfb->cb_db;
int rc, i;
char *ptr;
const char *text;
- char textbuf[SLAP_TEXT_BUFLEN];
- size_t textlen = sizeof(textbuf);
AttributeType **at;
Attribute *oc_at;
}
}
oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
- rc = structural_class(oc_at->a_vals, &val, NULL, &text, textbuf, textlen);
+ rc = structural_class(oc_at->a_vals, &val, NULL, &text, c->msg,
+ sizeof(c->msg));
attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &val, NULL );
return 0;
c.bi = be->bd_info;
c.private = cfb->cb_config;
ct = c.bi->bi_cf_table;
- ce->ce_private = cfb;
+ ce->ce_private = c.private;
config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
if ( op ) {
op->ora_e = e;
c->argv[1] = "";
}
if(Conf->min_args && (c->argc < Conf->min_args)) {
- Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> missing <%s> argument\n",
- c->log, Conf->name, Conf->what);
+ sprintf( c->msg, "<%s> missing <%s> argument",
+ c->argv[0], Conf->what );
+ Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n", c->log, c->msg, 0 );
return(ARG_BAD_CONF);
}
if(Conf->max_args && (c->argc > Conf->max_args)) {
- Debug(LDAP_DEBUG_CONFIG, "%s: extra cruft after <%s> in <%s> line (ignored)\n",
- c->log, Conf->what, Conf->name);
+ sprintf( c->msg, "<%s> extra cruft after <%s> ignored",
+ c->argv[0], Conf->what );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );
}
if((arg_type & ARG_DB) && !c->be) {
- Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> allowed only within database declaration\n",
- c->log, Conf->name, 0);
+ sprintf( c->msg, "<%s> only allowed within database declaration",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
+ c->log, c->msg, 0);
return(ARG_BAD_CONF);
}
if((arg_type & ARG_PRE_BI) && c->bi) {
- Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any backend %sdeclaration\n",
- c->log, Conf->name, ((arg_type & ARG_PRE_DB)
- ? "or database " : "") );
+ sprintf( c->msg, "<%s> must occur before any backend %sdeclaration",
+ c->argv[0], (arg_type & ARG_PRE_DB) ? "or database " : "" );
+ Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
+ c->log, c->msg, 0 );
return(ARG_BAD_CONF);
}
if((arg_type & ARG_PRE_DB) && c->be && c->be != frontendDB) {
- Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any database declaration\n",
- c->log, Conf->name, 0);
+ sprintf( c->msg, "<%s> must occur before any database declaration",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
+ c->log, c->msg, 0);
return(ARG_BAD_CONF);
}
if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
- Debug(LDAP_DEBUG_CONFIG, "%s: old <%s> format not supported\n",
- c->log, Conf->name, 0);
+ sprintf( c->msg, "<%s> old format not supported", c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
+ c->log, c->msg, 0);
return(ARG_BAD_CONF);
}
if((arg_type & ARGS_POINTER) && !Conf->arg_item && !(arg_type & ARG_OFFSET)) {
- Debug(LDAP_DEBUG_CONFIG, "%s: null arg_item for <%s>\n",
- c->log, Conf->name, 0);
+ sprintf( c->msg, "<%s> invalid config_table, arg_item is NULL",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
+ c->log, c->msg, 0);
return(ARG_BAD_CONF);
}
c->type = arg_user = (arg_type & ARGS_USERLAND);
!strcasecmp(c->argv[1], "false")) {
iarg = 0;
} else {
- Debug(LDAP_DEBUG_CONFIG, "%s: ignoring ", c->log, 0, 0);
- Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
- Conf->what, c->argv[1], Conf->name);
+ sprintf( c->msg, "<%s> invalid value, ignored",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
+ c->log, c->msg, 0 );
return(0);
}
break;
j = (arg_type & ARG_NONZERO) ? 1 : 0;
if(iarg < j && larg < j && barg < j ) {
larg = larg ? larg : (barg ? barg : iarg);
- Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
- Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf->what, larg, Conf->name);
+ sprintf( c->msg, "<%s> invalid value, ignored",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
+ c->log, c->msg, 0 );
return(ARG_BAD_CONF);
}
switch(arg_type & ARGS_NUMERIC) {
ber_str2bv( c->argv[1], 0, 0, &bv );
rc = dnPrettyNormal( NULL, &bv, &c->value_dn, &c->value_ndn, NULL );
if ( rc != LDAP_SUCCESS ) {
- Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
- Debug(LDAP_DEBUG_CONFIG, "%s DN is invalid %d (%s)\n",
- Conf->name, rc, ldap_err2string( rc ));
+ sprintf( c->msg, "<%s> invalid DN %d (%s)",
+ c->argv[0], rc, ldap_err2string( rc ));
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s\n" , c->log, c->msg, 0);
return(ARG_BAD_CONF);
}
if ( check_only ) {
arg_type = Conf->arg_type;
if(arg_type & ARG_MAGIC) {
if(!c->be) c->be = frontendDB;
+ c->msg[0] = '\0';
rc = (*((ConfigDriver*)Conf->arg_item))(c);
#if 0
if(c->be == frontendDB) c->be = NULL;
#endif
if(rc) {
- Debug(LDAP_DEBUG_CONFIG, "%s: handler for <%s> exited with %d!\n",
- c->log, Conf->name, rc);
+ if ( !c->msg[0] ) {
+ sprintf( c->msg, "<%s> handler exited with %d",
+ c->argv[0], rc );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
+ c->log, c->msg, 0 );
+ }
return(ARG_BAD_CONF);
}
return(0);
else if (c->bi)
ptr = c->bi->bi_private;
else {
- Debug(LDAP_DEBUG_CONFIG, "%s: offset for <%s> missing base pointer!\n",
- c->log, Conf->name, 0);
+ sprintf( c->msg, "<%s> offset is missing base pointer",
+ c->argv[0] );
+ Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
+ c->log, c->msg, 0);
return(ARG_BAD_CONF);
}
ptr = (void *)((char *)ptr + (int)Conf->arg_item);
case ARG_STRING: {
char *cc = *(char**)ptr;
if(cc) {
- if (arg_type & ARG_UNIQUE) {
+ if ((arg_type & ARG_UNIQUE) && c->op == SLAP_CONFIG_ADD ) {
Debug(LDAP_DEBUG_CONFIG, "%s: already set %s!\n",
c->log, Conf->name, 0 );
return(ARG_BAD_CONF);