Entry *e = str2entry( buf );
if( e == NULL ) {
- fprintf( stderr, "%s: could not parse entry at line %d\n",
+ fprintf( stderr, "%s: could not parse entry (line=%d)\n",
progname, lineno );
rc = EXIT_FAILURE;
- continue;
+ if( continuemode ) continue;
+ break;
+ }
+
+ if( !noschemacheck ) {
+ /* make sure the DN is valid */
+ if( dn_normalize_case( e->e_ndn ) == NULL ) {
+ fprintf( stderr, "%s: bad dn=\"%s\" (line=%d)\n",
+ progname, e->e_dn, lineno );
+ rc = EXIT_FAILURE;
+ entry_free( e );
+ if( continuemode ) continue;
+ break;
+ }
+
+ /* check schema */
+ if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
+ fprintf( stderr, "%s: entry dn=\"%s\" violates schema violation (line=%d)\n",
+ progname, e->e_dn, lineno );
+ rc = EXIT_FAILURE;
+ entry_free( e );
+ if( continuemode ) continue;
+ break;
+ }
+
+ /* check backend */
+ if( select_backend( e->e_ndn ) != be ) {
+ fprintf( stderr, "%s: database not configured to hold dn=\"%s\" (line=%d)\n",
+ progname, e->e_dn, lineno );
+ rc = EXIT_FAILURE;
+ entry_free( e );
+ if( continuemode ) continue;
+ break;
+ }
}
id = be->be_entry_put( be, e );
if( id == NOID ) {
- fprintf( stderr, "%s: could not add entry (%s) at line %d\n",
+ fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d)\n",
progname, e->e_dn, lineno );
rc = EXIT_FAILURE;
+ entry_free( e );
+ if( continuemode ) continue;
+ break;
} else if ( verbose ) {
fprintf( stderr, "added: \"%s\" (%08ld)\n",
if ( e == NULL ) {
printf("# no data for entry id=%08lx\n\n", (long) id );
rc = EXIT_FAILURE;
- continue;
+ if( continuemode ) continue;
+ break;
}
data = entry2str( e, &len );
+ entry_free( e );
+
+ if ( data == NULL ) {
+ printf("# bad data for entry id=%08lx\n\n", (long) id );
+ rc = EXIT_FAILURE;
+ if( continuemode ) continue;
+ break;
+ }
fputs( data, ldiffp );
fputs( "\n", ldiffp );
char *conffile = SLAPD_DEFAULT_CONFIGFILE;
int truncatemode = 0;
int verbose = 0;
+int noschemacheck = 0;
+int continuemode = 0;
char *ldiffile = NULL;
FILE *ldiffp = NULL;
{
char *options = NULL;
fprintf( stderr,
- "usage: %s [-v] [-d debuglevel] [-f configfile]\n"
+ "usage: %s [-v] [-c] [-d debuglevel] [-f configfile]\n"
"\t[-n databasenumber | -b suffix]", progname );
switch( tool ) {
case SLAPADD:
- options = "\t[-l ldiffile]\n";
+ options = "\t[-s] [-l ldiffile]\n";
break;
case SLAPCAT:
switch( tool ) {
case SLAPADD:
- options = "b:d:f:l:n:tv";
+ options = "b:cd:f:l:n:stv";
break;
case SLAPINDEX:
- options = "b:d:f:n:v";
+ options = "b:cd:f:n:v";
break;
case SLAPCAT:
- options = "b:d:f:l:n:v";
+ options = "b:cd:f:l:n:v";
break;
default:
case 'b':
base = strdup( optarg );
+ case 'c': /* enable continue mode */
+ continuemode++;
+ break;
+
case 'd': /* turn on debugging */
ldap_debug += atoi( optarg );
break;
dbnum = atoi( optarg ) - 1;
break;
+ case 's': /* disable schema checking */
+ noschemacheck++;
+ break;
+
case 't': /* turn on truncate */
truncatemode++;
mode |= SLAP_TRUNCATE_MODE;
fprintf( stderr,
"entry id=%08lx: no data\n", (long) id );
rc = EXIT_FAILURE;
- continue;
+ if( continuemode ) continue;
+ break;
}
if( verbose ) {
if( strcasecmp( type, "dn" ) == 0 ) {
attr = attr_find( e->e_attrs, type );
- if( attr == NULL ) continue;
+ if( attr == NULL ) {
+ entry_free( e );
+ continue;
+ }
values = attr->a_vals;
type, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
{
rc = EXIT_FAILURE;
+
+ if( !continuemode ) {
+ entry_free( e );
+ break;
+ }
}
entry_free( e );