ITS#4742 cleanup config error reporting

This commit is contained in:
Howard Chu 2006-11-12 02:15:49 +00:00
parent 7a92d4af1f
commit 48fce3d119
5 changed files with 50 additions and 37 deletions

View File

@ -107,6 +107,7 @@ static ConfigTable log_cfats[] = {
{ "logoldattr", "attrs", 2, 0, 0, ARG_MAGIC|LOG_OLDATTR, { "logoldattr", "attrs", 2, 0, 0, ARG_MAGIC|LOG_OLDATTR,
log_cf_gen, "( OLcfgOvAt:4.6 NAME 'olcAccessLogOldAttr' " log_cf_gen, "( OLcfgOvAt:4.6 NAME 'olcAccessLogOldAttr' "
"DESC 'Log old values of these attributes even if unmodified' " "DESC 'Log old values of these attributes even if unmodified' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL }, "SYNTAX OMsDirectoryString )", NULL, NULL },
{ NULL } { NULL }
}; };
@ -807,7 +808,10 @@ log_cf_gen(ConfigArgs *c)
la->next = li->li_oldattrs; la->next = li->li_oldattrs;
li->li_oldattrs = la; li->li_oldattrs = la;
} else { } else {
sprintf( c->msg, "%s: %s", c->argv[i], text ); snprintf( c->msg, sizeof( c->msg ), "%s <%s>: %s",
c->argv[0], c->argv[i], text );
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
rc = ARG_BAD_CONF; rc = ARG_BAD_CONF;
break; break;
} }

View File

@ -64,6 +64,7 @@ static ConfigTable constraintcfg[] = {
4, 4, 0, ARG_MAGIC | CONSTRAINT_ATTRIBUTE, constraint_cf_gen, 4, 4, 0, ARG_MAGIC | CONSTRAINT_ATTRIBUTE, constraint_cf_gen,
"( OLcfgOvAt:13.1 NAME 'olcConstraintAttribute' " "( OLcfgOvAt:13.1 NAME 'olcConstraintAttribute' "
"DESC 'regular expression constraint for attribute' " "DESC 'regular expression constraint for attribute' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL }, "SYNTAX OMsDirectoryString )", NULL, NULL },
{ NULL, NULL, 0, 0, 0, ARG_IGNORED } { NULL, NULL, 0, 0, 0, ARG_IGNORED }
}; };
@ -168,9 +169,10 @@ constraint_cf_gen( ConfigArgs *c )
switch (c->type) { switch (c->type) {
case CONSTRAINT_ATTRIBUTE: case CONSTRAINT_ATTRIBUTE:
if ( slap_str2ad( c->argv[1], &ap.ap, &text ) ) { if ( slap_str2ad( c->argv[1], &ap.ap, &text ) ) {
Debug( LDAP_DEBUG_CONFIG, snprintf( c->msg, sizeof( c->msg ),
"constraint_add: <%s>: attribute description unknown %s.\n", "%s <%s>: %s\n", c->argv[0], c->argv[1], text );
c->argv[1], text, 0 ); Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return( ARG_BAD_CONF ); return( ARG_BAD_CONF );
} }
@ -184,17 +186,21 @@ constraint_cf_gen( ConfigArgs *c )
regerror( err, ap.re, errmsg, sizeof(errmsg) ); regerror( err, ap.re, errmsg, sizeof(errmsg) );
ch_free(ap.re); ch_free(ap.re);
Debug( LDAP_DEBUG_CONFIG, snprintf( c->msg, sizeof( c->msg ),
"%s: Illegal regular expression \"%s\": Error %s\n", "%s %s: Illegal regular expression \"%s\": Error %s",
c->argv[1], c->argv[3], errmsg); c->argv[0], c->argv[1], c->argv[3], errmsg);
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
ap.re = NULL; ap.re = NULL;
return( ARG_BAD_CONF ); return( ARG_BAD_CONF );
} }
ap.re_str = ch_strdup( c->argv[3] ); ap.re_str = ch_strdup( c->argv[3] );
} else { } else {
Debug( LDAP_DEBUG_CONFIG, snprintf( c->msg, sizeof( c->msg ),
"%s: Unknown constraint type: %s\n", "%s %s: Unknown constraint type: %s",
c->argv[1], c->argv[2], 0 ); c->argv[0], c->argv[1], c->argv[2] );
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return ( ARG_BAD_CONF ); return ( ARG_BAD_CONF );
} }

View File

@ -96,6 +96,7 @@ static ConfigTable refintcfg[] = {
ARG_MAGIC|REFINT_ATTRS, refint_cf_gen, ARG_MAGIC|REFINT_ATTRS, refint_cf_gen,
"( OLcfgOvAt:11.1 NAME 'olcRefintAttribute' " "( OLcfgOvAt:11.1 NAME 'olcRefintAttribute' "
"DESC 'Attributes for referential integrity' " "DESC 'Attributes for referential integrity' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL }, "SYNTAX OMsDirectoryString )", NULL, NULL },
{ "refint_nothing", "string", 2, 2, 0, { "refint_nothing", "string", 2, 2, 0,
ARG_DN|ARG_MAGIC|REFINT_NOTHING, refint_cf_gen, ARG_DN|ARG_MAGIC|REFINT_NOTHING, refint_cf_gen,
@ -208,13 +209,10 @@ refint_cf_gen(ConfigArgs *c)
ip->next = dd->attrs; ip->next = dd->attrs;
dd->attrs = ip; dd->attrs = ip;
} else { } else {
Debug ( LDAP_DEBUG_CONFIG, snprintf( c->msg, sizeof( c->msg ),
"refint add: <%s>: %s\n", "%s <%s>: %s", c->argv[0], c->argv[i], text );
c->argv[i], text, NULL ); Debug ( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
strncpy ( c->msg, "%s: %s\n", c->log, c->msg, 0 );
text,
SLAP_TEXT_BUFLEN-1 );
c->msg[SLAP_TEXT_BUFLEN-1] = '\0';
rc = ARG_BAD_CONF; rc = ARG_BAD_CONF;
} }
} }

View File

@ -2281,27 +2281,31 @@ sp_cf_gen(ConfigArgs *c)
switch ( c->type ) { switch ( c->type ) {
case SP_CHKPT: case SP_CHKPT:
if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) { if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) {
sprintf( c->msg, "%s unable to parse checkpoint ops # \"%s\"", snprintf( c->msg, sizeof( c->msg ), "%s unable to parse checkpoint ops # \"%s\"",
c->argv[0], c->argv[1] ); c->argv[0], c->argv[1] );
Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return ARG_BAD_CONF; return ARG_BAD_CONF;
} }
if ( si->si_chkops <= 0 ) { if ( si->si_chkops <= 0 ) {
sprintf( c->msg, "%s invalid checkpoint ops # \"%d\"", snprintf( c->msg, sizeof( c->msg ), "%s invalid checkpoint ops # \"%d\"",
c->argv[0], si->si_chkops ); c->argv[0], si->si_chkops );
Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return ARG_BAD_CONF; return ARG_BAD_CONF;
} }
if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) { if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) {
sprintf( c->msg, "%s unable to parse checkpoint time \"%s\"", snprintf( c->msg, sizeof( c->msg ), "%s unable to parse checkpoint time \"%s\"",
c->argv[0], c->argv[1] ); c->argv[0], c->argv[1] );
Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return ARG_BAD_CONF; return ARG_BAD_CONF;
} }
if ( si->si_chktime <= 0 ) { if ( si->si_chktime <= 0 ) {
sprintf( c->msg, "%s invalid checkpoint time \"%d\"", snprintf( c->msg, sizeof( c->msg ), "%s invalid checkpoint time \"%d\"",
c->argv[0], si->si_chkops ); c->argv[0], si->si_chkops );
Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return ARG_BAD_CONF; return ARG_BAD_CONF;
} }
si->si_chktime *= 60; si->si_chktime *= 60;
@ -2311,9 +2315,10 @@ sp_cf_gen(ConfigArgs *c)
int size = c->value_int; int size = c->value_int;
if ( size < 0 ) { if ( size < 0 ) {
sprintf( c->msg, "%s size %d is negative", snprintf( c->msg, sizeof( c->msg ), "%s size %d is negative",
c->argv[0], size ); c->argv[0], size );
Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
return ARG_BAD_CONF; return ARG_BAD_CONF;
} }
sl = si->si_logs; sl = si->si_logs;

View File

@ -68,10 +68,12 @@ static ConfigTable uniquecfg[] = {
{ "unique_ignore", "attribute...", 2, 0, 0, ARG_MAGIC|UNIQUE_IGNORE, { "unique_ignore", "attribute...", 2, 0, 0, ARG_MAGIC|UNIQUE_IGNORE,
unique_cf_gen, "( OLcfgOvAt:10.2 NAME 'olcUniqueIgnore' " unique_cf_gen, "( OLcfgOvAt:10.2 NAME 'olcUniqueIgnore' "
"DESC 'Attributes for which uniqueness shall not be enforced' " "DESC 'Attributes for which uniqueness shall not be enforced' "
"EQUALITY caseIgnoreMatch " /* Should use OID syntax */
"SYNTAX OMsDirectoryString )", NULL, NULL }, "SYNTAX OMsDirectoryString )", NULL, NULL },
{ "unique_attributes", "attribute...", 2, 0, 0, ARG_MAGIC|UNIQUE_ATTR, { "unique_attributes", "attribute...", 2, 0, 0, ARG_MAGIC|UNIQUE_ATTR,
unique_cf_gen, "( OLcfgOvAt:10.3 NAME 'olcUniqueAttribute' " unique_cf_gen, "( OLcfgOvAt:10.3 NAME 'olcUniqueAttribute' "
"DESC 'Attributes for which uniqueness shall be enforced' " "DESC 'Attributes for which uniqueness shall be enforced' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL }, "SYNTAX OMsDirectoryString )", NULL, NULL },
{ "unique_strict", "on|off", 1, 2, 0, { "unique_strict", "on|off", 1, 2, 0,
ARG_ON_OFF|ARG_OFFSET|UNIQUE_STRICT, ARG_ON_OFF|ARG_OFFSET|UNIQUE_STRICT,
@ -187,9 +189,10 @@ unique_cf_gen( ConfigArgs *c )
case UNIQUE_BASE: case UNIQUE_BASE:
if ( !dnIsSuffix ( &c->value_ndn, if ( !dnIsSuffix ( &c->value_ndn,
&be->be_nsuffix[0] ) ) { &be->be_nsuffix[0] ) ) {
sprintf ( c->msg, "dn is not a suffix of backend base" ); sprintf ( c->msg, "%s dn is not a suffix of backend base",
Debug ( LDAP_DEBUG_CONFIG, "unique add: %s\n", c->argv[0] );
c->msg, NULL, NULL ); Debug ( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
"%s: %s\n", c->log, c->msg, 0 );
rc = ARG_BAD_CONF; rc = ARG_BAD_CONF;
} }
if ( ud->dn.bv_val ) ber_memfree ( ud->dn.bv_val ); if ( ud->dn.bv_val ) ber_memfree ( ud->dn.bv_val );
@ -216,13 +219,10 @@ unique_cf_gen( ConfigArgs *c )
ud->attrs = up; ud->attrs = up;
} }
} else { } else {
Debug ( LDAP_DEBUG_CONFIG, snprintf( c->msg, sizeof( c->msg ),
"unique add: <%s>: %s\n", "%s <%s>: %s", c->argv[0], c->argv[i], text );
c->argv[i], text, NULL ); Debug ( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
strncpy ( c->msg, "%s: %s\n", c->log, c->msg, 0 );
text,
SLAP_TEXT_BUFLEN-1 );
c->msg[SLAP_TEXT_BUFLEN-1] = '\0';
rc = ARG_BAD_CONF; rc = ARG_BAD_CONF;
} }
} }