diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index 55f168e188..b0aafa6740 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -1836,6 +1836,9 @@ ldif_tool_entry_open( BackendDB *be, int mode ) { struct ldif_tool *tl = &((struct ldif_info *) be->be_private)->li_tool; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + tl->ecurrent = 0; return 0; } @@ -1847,6 +1850,9 @@ ldif_tool_entry_close( BackendDB *be ) Entry **entries = tl->entries; ID i; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + for ( i = tl->ecount; i--; ) if ( entries[i] ) entry_free( entries[i] ); @@ -1947,6 +1953,9 @@ ldif_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) char *parentdir; Operation op = {0}; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + op.o_bd = be; rc = ldif_prepare_create( &op, e, &path, &parentdir, &errmsg ); if ( rc == LDAP_SUCCESS ) { diff --git a/servers/slapd/back-mdb/tools.c b/servers/slapd/back-mdb/tools.c index 00de36e930..39767837f9 100644 --- a/servers/slapd/back-mdb/tools.c +++ b/servers/slapd/back-mdb/tools.c @@ -101,6 +101,9 @@ mdb_tool_entry_get_int( BackendDB *be, ID id, Entry **ep ); int mdb_tool_entry_open( BackendDB *be, int mode ) { + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + /* In Quick mode, commit once per 500 entries */ mdb_writes = 0; if ( slapMode & SLAP_TOOL_QUICK ) @@ -147,6 +150,9 @@ int mdb_tool_entry_open( int mdb_tool_entry_close( BackendDB *be ) { + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + #ifdef MDB_TOOL_IDL_CACHING if ( mdb_tool_info ) { int i; @@ -652,6 +658,9 @@ ID mdb_tool_entry_put( Operation op = {0}; Opheader ohdr = {0}; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); diff --git a/servers/slapd/back-ndb/tools.cpp b/servers/slapd/back-ndb/tools.cpp index 82187da658..251e21aea2 100644 --- a/servers/slapd/back-ndb/tools.cpp +++ b/servers/slapd/back-ndb/tools.cpp @@ -62,6 +62,9 @@ int ndb_tool_entry_open( { struct ndb_info *ni = (struct ndb_info *) be->be_private; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + myNdb = new Ndb( ni->ni_cluster[0], ni->ni_dbname ); return myNdb->init(1024); } @@ -70,6 +73,9 @@ extern "C" int ndb_tool_entry_close( BackendDB *be ) { + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + if ( myPutTxn ) { int rc = myPutTxn->execute(NdbTransaction::Commit); if( rc != 0 ) { @@ -408,6 +414,9 @@ ID ndb_tool_entry_put( assert( text->bv_val != NULL ); assert( text->bv_val[0] == '\0' ); /* overconservative? */ + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(ndb_tool_entry_put) "( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 ); diff --git a/servers/slapd/back-wt/tools.c b/servers/slapd/back-wt/tools.c index 63b63bef89..cb66db9a8d 100644 --- a/servers/slapd/back-wt/tools.c +++ b/servers/slapd/back-wt/tools.c @@ -49,6 +49,9 @@ wt_tool_entry_open( BackendDB *be, int mode ) struct wt_info *wi = (struct wt_info *) be->be_private; int rc; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + wc = wt_ctx_init(wi); if( !wc ){ Debug( LDAP_DEBUG_ANY, @@ -71,6 +74,9 @@ wt_tool_entry_open( BackendDB *be, int mode ) int wt_tool_entry_close( BackendDB *be ) { + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + if( reader ) { reader->close(reader); reader = NULL; @@ -300,6 +306,9 @@ wt_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) Operation op = {0}; Opheader ohdr = {0}; + if ( slapMode & SLAP_TOOL_DRYRUN ) + return 0; + assert( slapMode & SLAP_TOOL_MODE ); assert( text != NULL ); assert( text->bv_val != NULL ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 89d3aa4ae4..d3ad3dd666 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1607,6 +1607,7 @@ LDAP_SLAPD_V (int) slapMode; #define SLAP_TOOL_QUICK 0x0800 #define SLAP_TOOL_NO_SCHEMA_CHECK 0x1000 #define SLAP_TOOL_VALUE_CHECK 0x2000 +#define SLAP_TOOL_DRYRUN 0x4000 #define SLAP_SERVER_RUNNING 0x8000 diff --git a/servers/slapd/slapadd.c b/servers/slapd/slapadd.c index 7bc21b5505..8a52cdb937 100644 --- a/servers/slapd/slapadd.c +++ b/servers/slapd/slapadd.c @@ -400,7 +400,7 @@ slapadd( int argc, char **argv ) SLAP_DBFLAGS(be) &= ~(SLAP_DBFLAG_NO_SCHEMA_CHECK); } - if( !dryrun && be->be_entry_open( be, 1 ) != 0 ) { + if( be->be_entry_open && be->be_entry_open( be, 1 ) != 0 ) { fprintf( stderr, "%s: could not open database.\n", progname ); exit( EXIT_FAILURE ); @@ -442,7 +442,7 @@ slapadd( int argc, char **argv ) break; } - if ( !dryrun ) { + if ( be->be_entry_put ) { /* * Initialize text buffer */ @@ -504,7 +504,7 @@ slapadd( int argc, char **argv ) ch_free( buf ); - if ( !dryrun ) { + if ( be->be_entry_close ) { if ( enable_meter ) { fprintf( stderr, "Closing DB..." ); } diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index 09b2215466..73900a825c 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -554,6 +554,7 @@ slap_tool_init( case 'u': /* dry run */ dryrun++; + mode |= SLAP_TOOL_DRYRUN; break; case 'v': /* turn on verbose */