]> git.sur5r.net Git - openldap/commitdiff
Rework slapadd schemacheck code to avoid unnecessary -s option
authorKurt Zeilenga <kurt@openldap.org>
Mon, 18 Sep 2000 18:10:22 +0000 (18:10 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 18 Sep 2000 18:10:22 +0000 (18:10 +0000)
build/version [deleted file]
doc/man/man8/slapadd.8
servers/slapd/entry.c
servers/slapd/tools/slapadd.c
servers/slapd/tools/slapcommon.c
servers/slapd/tools/slapcommon.h

diff --git a/build/version b/build/version
deleted file mode 100644 (file)
index b06c8ab..0000000
+++ /dev/null
@@ -1 +0,0 @@
-2.0.X-Engineering
index 47c237878419d97e21738f3d727e2fe9d4725335..f27be9935d2035edfe6e10f6f30664abe5eb84ff 100644 (file)
@@ -8,7 +8,6 @@ slapadd \- Add entries to a SLAPD database
 .B SBINDIR/slapadd
 .B [\-v]
 .B [\-c]
-.B [\-s]
 .B [\-d level]
 .B [\-b suffix]
 .B [\-n dbnum]
@@ -38,9 +37,6 @@ enable verbose mode.
 .B \-c
 enable continue (ignore errors) mode.
 .TP
-.B \-s
-disable schema and other checks.
-.TP
 .BI \-d " level"
 enable debugging messages as defined by the specified
 .IR level .
index c8817c87ef343c4145c814e59b28a4ea260e2693..9ce6f74d98e63b4b844119c537ff99289d4e7491 100644 (file)
@@ -117,6 +117,13 @@ str2entry( char *s )
                        Debug( LDAP_DEBUG_TRACE,
                                "<= str2entry: str2ad(%s): %s\n", type, text, 0 );
 
+                       if( slapMode & SLAP_TOOL_MODE ) {
+                               entry_free( e );
+                               free( value.bv_val );
+                               free( type );
+                               return NULL;
+                       }
+
                        rc = slap_str2undef_ad( type, &ad, &text );
 
                        if( rc != LDAP_SUCCESS ) {
@@ -126,7 +133,37 @@ str2entry( char *s )
                                entry_free( e );
                                free( value.bv_val );
                                free( type );
-                               return( NULL );
+                               return NULL;
+                       }
+               }
+
+               if( slapMode & SLAP_TOOL_MODE ) {
+                       slap_syntax_validate_func *validate =
+                               ad->ad_type->sat_syntax->ssyn_validate;
+
+                       if( !validate ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "str2entry: no validator for syntax %s\n",
+                                       ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
+                               entry_free( e );
+                               free( value.bv_val );
+                               free( type );
+                               return NULL;
+                       }
+
+                       /*
+                        * validate value per syntax
+                        */
+                       rc = validate( ad->ad_type->sat_syntax, &value );
+
+                       if( rc != 0 ) {
+                               Debug( LDAP_DEBUG_TRACE,
+                                       "str2entry: invalid value for syntax %s\n",
+                                       ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
+                               entry_free( e );
+                               free( value.bv_val );
+                               free( type );
+                               return NULL;
                        }
                }
 
index 4cf22f2457dd5a647923943868ab4812a12361fe..57623649042ae41dc9dac117d7d3c780af13b678 100644 (file)
@@ -59,7 +59,7 @@ main( int argc, char **argv )
 
                /* make sure the DN is valid */
                if( dn_normalize( e->e_ndn ) == NULL ) {
-                       fprintf( stderr, "%s: bad dn=\"%s\" (line=%d)\n",
+                       fprintf( stderr, "%s: invalid dn=\"%s\" (line=%d)\n",
                                progname, e->e_dn, lineno );
                        rc = EXIT_FAILURE;
                        entry_free( e );
@@ -67,7 +67,7 @@ main( int argc, char **argv )
                        break;
                }
 
-               /* make sure the DN is valid */
+               /* make sure the DN is not empty */
                if( e->e_ndn == '\0' ) {
                        fprintf( stderr, "%s: empty dn=\"%s\" (line=%d)\n",
                                progname, e->e_dn, lineno );
@@ -77,7 +77,18 @@ main( int argc, char **argv )
                        break;
                }
 
-               if( !noschemacheck ) {
+               /* 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;
+               }
+
+               if( global_schemacheck ) {
                        /* check schema */
                        const char *text;
                        if ( entry_schema_check( e, NULL, &text ) != LDAP_SUCCESS ) {
@@ -88,20 +99,9 @@ main( int argc, char **argv )
                                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 dn=\"%s\" (line=%d)\n",
                                progname, e->e_dn, lineno );
@@ -110,7 +110,9 @@ main( int argc, char **argv )
                        if( continuemode ) continue;
                        break;
 
-               } else if ( verbose ) {
+               }
+               
+               if ( verbose ) {
                        fprintf( stderr, "added: \"%s\" (%08lx)\n",
                                e->e_dn, (long) id );
                }
index 954635a801d62f93b522fae194cd46f82dbe0686..67793bb3685fe41d0b7ff829ae41f8548d80ac59 100644 (file)
@@ -23,7 +23,6 @@ char  *progname       = NULL;
 char   *conffile       = SLAPD_DEFAULT_CONFIGFILE;
 int            truncatemode = 0;
 int            verbose         = 0;
-int            noschemacheck = 0;
 int            continuemode = 0;
 
 char   *ldiffile       = NULL;
@@ -42,11 +41,11 @@ usage( int tool )
        char *options = NULL;
        fprintf( stderr,
                "usage: %s [-v] [-c] [-d debuglevel] [-f configfile]\n"
-                        "\t[-n databasenumber | -b suffix]", progname );
+                       "\t[-n databasenumber | -b suffix]", progname );
 
        switch( tool ) {
        case SLAPADD:
-               options = "\t[-s] [-l ldiffile]\n";
+               options = "\t[-l ldiffile]\n";
                break;
 
        case SLAPCAT:
@@ -97,7 +96,7 @@ slap_tool_init(
 
        switch( tool ) {
        case SLAPADD:
-               options = "b:cd:f:l:n:stv";
+               options = "b:cd:f:l:n:tv";
                break;
 
        case SLAPINDEX:
@@ -142,10 +141,6 @@ slap_tool_init(
                        dbnum = atoi( optarg ) - 1;
                        break;
 
-               case 's':       /* disable schema checking */
-                       noschemacheck++;
-                       break;
-
                case 't':       /* turn on truncate */
                        truncatemode++;
                        mode |= SLAP_TRUNCATE_MODE;
index dd0f1b1f55ab90eb8dd4b04f238a5d021bf8bfab..ca8dcf52077c95564a9dec29de4b2f65ab4cfd16 100644 (file)
@@ -24,7 +24,6 @@ extern        char    *conffile;
 extern Backend *be;
 extern int             appendmode;
 extern int             verbose;
-extern int             noschemacheck;
 extern int             continuemode;
 
 extern char    *ldiffile;