mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
ITS#4742 cleanup config error reporting
This commit is contained in:
parent
7a92d4af1f
commit
48fce3d119
@ -107,6 +107,7 @@ static ConfigTable log_cfats[] = {
|
||||
{ "logoldattr", "attrs", 2, 0, 0, ARG_MAGIC|LOG_OLDATTR,
|
||||
log_cf_gen, "( OLcfgOvAt:4.6 NAME 'olcAccessLogOldAttr' "
|
||||
"DESC 'Log old values of these attributes even if unmodified' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
@ -807,7 +808,10 @@ log_cf_gen(ConfigArgs *c)
|
||||
la->next = li->li_oldattrs;
|
||||
li->li_oldattrs = la;
|
||||
} 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;
|
||||
break;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ static ConfigTable constraintcfg[] = {
|
||||
4, 4, 0, ARG_MAGIC | CONSTRAINT_ATTRIBUTE, constraint_cf_gen,
|
||||
"( OLcfgOvAt:13.1 NAME 'olcConstraintAttribute' "
|
||||
"DESC 'regular expression constraint for attribute' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ NULL, NULL, 0, 0, 0, ARG_IGNORED }
|
||||
};
|
||||
@ -168,9 +169,10 @@ constraint_cf_gen( ConfigArgs *c )
|
||||
switch (c->type) {
|
||||
case CONSTRAINT_ATTRIBUTE:
|
||||
if ( slap_str2ad( c->argv[1], &ap.ap, &text ) ) {
|
||||
Debug( LDAP_DEBUG_CONFIG,
|
||||
"constraint_add: <%s>: attribute description unknown %s.\n",
|
||||
c->argv[1], text, 0 );
|
||||
snprintf( c->msg, sizeof( c->msg ),
|
||||
"%s <%s>: %s\n", c->argv[0], c->argv[1], text );
|
||||
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
|
||||
"%s: %s\n", c->log, c->msg, 0 );
|
||||
return( ARG_BAD_CONF );
|
||||
}
|
||||
|
||||
@ -184,17 +186,21 @@ constraint_cf_gen( ConfigArgs *c )
|
||||
|
||||
regerror( err, ap.re, errmsg, sizeof(errmsg) );
|
||||
ch_free(ap.re);
|
||||
Debug( LDAP_DEBUG_CONFIG,
|
||||
"%s: Illegal regular expression \"%s\": Error %s\n",
|
||||
c->argv[1], c->argv[3], errmsg);
|
||||
snprintf( c->msg, sizeof( c->msg ),
|
||||
"%s %s: Illegal regular expression \"%s\": Error %s",
|
||||
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;
|
||||
return( ARG_BAD_CONF );
|
||||
}
|
||||
ap.re_str = ch_strdup( c->argv[3] );
|
||||
} else {
|
||||
Debug( LDAP_DEBUG_CONFIG,
|
||||
"%s: Unknown constraint type: %s\n",
|
||||
c->argv[1], c->argv[2], 0 );
|
||||
snprintf( c->msg, sizeof( c->msg ),
|
||||
"%s %s: Unknown constraint type: %s",
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,7 @@ static ConfigTable refintcfg[] = {
|
||||
ARG_MAGIC|REFINT_ATTRS, refint_cf_gen,
|
||||
"( OLcfgOvAt:11.1 NAME 'olcRefintAttribute' "
|
||||
"DESC 'Attributes for referential integrity' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ "refint_nothing", "string", 2, 2, 0,
|
||||
ARG_DN|ARG_MAGIC|REFINT_NOTHING, refint_cf_gen,
|
||||
@ -208,13 +209,10 @@ refint_cf_gen(ConfigArgs *c)
|
||||
ip->next = dd->attrs;
|
||||
dd->attrs = ip;
|
||||
} else {
|
||||
Debug ( LDAP_DEBUG_CONFIG,
|
||||
"refint add: <%s>: %s\n",
|
||||
c->argv[i], text, NULL );
|
||||
strncpy ( c->msg,
|
||||
text,
|
||||
SLAP_TEXT_BUFLEN-1 );
|
||||
c->msg[SLAP_TEXT_BUFLEN-1] = '\0';
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -2281,27 +2281,31 @@ sp_cf_gen(ConfigArgs *c)
|
||||
switch ( c->type ) {
|
||||
case SP_CHKPT:
|
||||
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] );
|
||||
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;
|
||||
}
|
||||
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 );
|
||||
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;
|
||||
}
|
||||
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] );
|
||||
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;
|
||||
}
|
||||
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 );
|
||||
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;
|
||||
}
|
||||
si->si_chktime *= 60;
|
||||
@ -2311,9 +2315,10 @@ sp_cf_gen(ConfigArgs *c)
|
||||
int size = c->value_int;
|
||||
|
||||
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 );
|
||||
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;
|
||||
}
|
||||
sl = si->si_logs;
|
||||
|
@ -68,10 +68,12 @@ static ConfigTable uniquecfg[] = {
|
||||
{ "unique_ignore", "attribute...", 2, 0, 0, ARG_MAGIC|UNIQUE_IGNORE,
|
||||
unique_cf_gen, "( OLcfgOvAt:10.2 NAME 'olcUniqueIgnore' "
|
||||
"DESC 'Attributes for which uniqueness shall not be enforced' "
|
||||
"EQUALITY caseIgnoreMatch " /* Should use OID syntax */
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ "unique_attributes", "attribute...", 2, 0, 0, ARG_MAGIC|UNIQUE_ATTR,
|
||||
unique_cf_gen, "( OLcfgOvAt:10.3 NAME 'olcUniqueAttribute' "
|
||||
"DESC 'Attributes for which uniqueness shall be enforced' "
|
||||
"EQUALITY caseIgnoreMatch "
|
||||
"SYNTAX OMsDirectoryString )", NULL, NULL },
|
||||
{ "unique_strict", "on|off", 1, 2, 0,
|
||||
ARG_ON_OFF|ARG_OFFSET|UNIQUE_STRICT,
|
||||
@ -187,9 +189,10 @@ unique_cf_gen( ConfigArgs *c )
|
||||
case UNIQUE_BASE:
|
||||
if ( !dnIsSuffix ( &c->value_ndn,
|
||||
&be->be_nsuffix[0] ) ) {
|
||||
sprintf ( c->msg, "dn is not a suffix of backend base" );
|
||||
Debug ( LDAP_DEBUG_CONFIG, "unique add: %s\n",
|
||||
c->msg, NULL, NULL );
|
||||
sprintf ( c->msg, "%s dn is not a suffix of backend base",
|
||||
c->argv[0] );
|
||||
Debug ( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
|
||||
"%s: %s\n", c->log, c->msg, 0 );
|
||||
rc = ARG_BAD_CONF;
|
||||
}
|
||||
if ( ud->dn.bv_val ) ber_memfree ( ud->dn.bv_val );
|
||||
@ -216,13 +219,10 @@ unique_cf_gen( ConfigArgs *c )
|
||||
ud->attrs = up;
|
||||
}
|
||||
} else {
|
||||
Debug ( LDAP_DEBUG_CONFIG,
|
||||
"unique add: <%s>: %s\n",
|
||||
c->argv[i], text, NULL );
|
||||
strncpy ( c->msg,
|
||||
text,
|
||||
SLAP_TEXT_BUFLEN-1 );
|
||||
c->msg[SLAP_TEXT_BUFLEN-1] = '\0';
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user