From a2405e0a7e31a128774b3e4077c1199d3a3cdf5e Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 6 Apr 2007 00:21:02 +0000 Subject: [PATCH] Axe slurpd / replog support --- servers/slapd/Makefile.in | 4 +- servers/slapd/add.c | 4 - servers/slapd/backend.c | 21 -- servers/slapd/bconfig.c | 373 +-------------------- servers/slapd/delete.c | 7 - servers/slapd/init.c | 3 - servers/slapd/modify.c | 8 - servers/slapd/modrdn.c | 8 - servers/slapd/overlays/dds.c | 11 +- servers/slapd/overlays/ppolicy.c | 2 +- servers/slapd/passwd.c | 7 +- servers/slapd/proto-slap.h | 14 - servers/slapd/repl.c | 555 ------------------------------- servers/slapd/result.c | 8 - servers/slapd/slap.h | 13 - 15 files changed, 26 insertions(+), 1012 deletions(-) delete mode 100644 servers/slapd/repl.c diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index e19e739a8f..fcc9a4ce83 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -29,7 +29,7 @@ SRCS = main.c globals.c bconfig.c config.c daemon.c \ dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \ value.c ava.c bind.c unbind.c abandon.c filterentry.c \ phonetic.c acl.c str2filter.c aclparse.c init.c user.c \ - repl.c lock.c controls.c extended.c passwd.c \ + lock.c controls.c extended.c passwd.c \ schema.c schema_check.c schema_init.c schema_prep.c \ schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \ oidm.c starttls.c index.c sets.c referral.c root_dse.c \ @@ -47,7 +47,7 @@ OBJS = main.o globals.o bconfig.o config.o daemon.o \ dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \ value.o ava.o bind.o unbind.o abandon.o filterentry.o \ phonetic.o acl.o str2filter.o aclparse.o init.o user.o \ - repl.o lock.o controls.o extended.o passwd.o \ + lock.o controls.o extended.o passwd.o \ schema.o schema_check.o schema_init.o schema_prep.o \ schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \ oidm.o starttls.o index.o sets.o referral.o root_dse.o \ diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 8d22d54afc..02b721f325 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -290,7 +290,6 @@ fe_op_add( Operation *op, SlapReply *rs ) int repl_user = be_isupdate( op ); if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn ); - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; op->o_bd = op_be; @@ -322,9 +321,6 @@ fe_op_add( Operation *op, SlapReply *rs ) send_ldap_result( op, rs ); goto done; } - - cb.sc_next = op->o_callback; - op->o_callback = &cb; } rc = op->o_bd->be_add( op, rs ); diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 35486ced58..b5d005b180 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -440,16 +440,6 @@ void backend_destroy_one( BackendDB *bd, int dynamic ) } acl_destroy( bd->be_acl, frontendDB->be_acl ); limits_destroy( bd->be_limits ); - if ( bd->be_replogfile ) { - ch_free( bd->be_replogfile ); - } - if ( bd->be_replica_argsfile ) { - ch_free( bd->be_replica_argsfile ); - } - if ( bd->be_replica_pidfile ) { - ch_free( bd->be_replica_pidfile ); - } - destroy_replica_info( bd ); if ( !BER_BVISNULL( &bd->be_update_ndn ) ) { ch_free( bd->be_update_ndn.bv_val ); } @@ -500,17 +490,6 @@ int backend_destroy(void) free( bd->be_rootpw.bv_val ); } acl_destroy( bd->be_acl, frontendDB->be_acl ); - - if ( bd->be_replogfile != NULL ) { - free( bd->be_replogfile ); - } - if ( bd->be_replica_argsfile ) { - ch_free( bd->be_replica_argsfile ); - } - if ( bd->be_replica_pidfile ) { - ch_free( bd->be_replica_pidfile ); - } - assert( bd->be_replica == NULL ); } return 0; diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 5dfc35e542..e62e27f478 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -125,10 +125,10 @@ static ConfigDriver config_requires; static ConfigDriver config_security; static ConfigDriver config_referral; static ConfigDriver config_loglevel; -static ConfigDriver config_replica; static ConfigDriver config_updatedn; static ConfigDriver config_updateref; static ConfigDriver config_include; +static ConfigDriver config_obsolete; #ifdef HAVE_TLS static ConfigDriver config_tls_option; static ConfigDriver config_tls_config; @@ -160,10 +160,6 @@ enum { CFG_DIT, CFG_ATTR, CFG_ATOPT, - CFG_REPLICA_ARGSFILE, - CFG_REPLICA_PIDFILE, - CFG_REPLICATIONINTERVAL, - CFG_REPLOG, CFG_ROOTDSE, CFG_LOGFILE, CFG_PLUGIN, @@ -455,20 +451,20 @@ static ConfigTable config_back_cf_table[] = { &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' " "SUP labeledURI SINGLE-VALUE )", NULL, NULL }, { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC, - &config_replica, "( OLcfgDbAt:0.7 NAME 'olcReplica' " + &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' " "EQUALITY caseIgnoreMatch " "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL }, - { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLICA_ARGSFILE, - &config_generic, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' " + { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC, + &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' " "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, - { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLICA_PIDFILE, - &config_generic, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' " + { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC, + &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' " "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, - { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|ARG_INT|CFG_REPLICATIONINTERVAL, - &config_generic, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' " + { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC, + &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, - { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG, - &config_generic, "( OLcfgGlAt:46 NAME 'olcReplogFile' " + { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC, + &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' " "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC, &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' " @@ -921,25 +917,6 @@ config_generic(ConfigArgs *c) { rc = (!i); break; } - case CFG_REPLICA_ARGSFILE: - if ( c->be->be_replica_argsfile ) - c->value_string = ch_strdup( c->be->be_replica_argsfile ); - break; - case CFG_REPLICA_PIDFILE: - if ( c->be->be_replica_pidfile ) - c->value_string = ch_strdup( c->be->be_replica_pidfile ); - break; - case CFG_REPLICATIONINTERVAL: - if ( c->be->be_replicationinterval > 0 ) { - c->value_int = c->be->be_replicationinterval; - } else { - rc = 1; - } - break; - case CFG_REPLOG: - if ( c->be->be_replogfile ) - c->value_string = ch_strdup( c->be->be_replogfile ); - break; case CFG_ROOTDSE: { ConfigFile *cf = c->private; if ( cf->c_dseFiles ) { @@ -1097,25 +1074,6 @@ config_generic(ConfigArgs *c) { passwd_salt = NULL; break; - case CFG_REPLICA_ARGSFILE: - ch_free( c->be->be_replica_argsfile ); - c->be->be_replica_argsfile = NULL; - break; - - case CFG_REPLICA_PIDFILE: - ch_free( c->be->be_replica_pidfile ); - c->be->be_replica_pidfile = NULL; - break; - - case CFG_REPLICATIONINTERVAL: - c->be->be_replicationinterval = 0; - break; - - case CFG_REPLOG: - ch_free( c->be->be_replogfile ); - c->be->be_replogfile = NULL; - break; - case CFG_LOGFILE: ch_free( logfileName ); logfileName = NULL; @@ -1473,85 +1431,6 @@ config_generic(ConfigArgs *c) { } break; - case CFG_REPLICA_ARGSFILE: - if(SLAP_MONITOR(c->be)) { - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replica-argsfile\" should not be used " - "inside monitor database\n", - c->log, 0, 0); - /* FIXME: should this be an error? */ - return(0); - } - - if ( c->be->be_replica_argsfile != NULL ) { - /* FIXME: error? */ - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replica-argsfile\" already provided; " - "replacing \"%s\" with \"%s\".\n", - c->log, c->be->be_replica_argsfile, c->value_string ); - ch_free( c->be->be_replica_argsfile ); - } - - c->be->be_replica_argsfile = c->value_string; - break; - - case CFG_REPLICA_PIDFILE: - if(SLAP_MONITOR(c->be)) { - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replica-pidfile\" should not be used " - "inside monitor database\n", - c->log, 0, 0); - /* FIXME: should this be an error? */ - return(0); - } - - if ( c->be->be_replica_pidfile != NULL ) { - /* FIXME: error? */ - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replica-pidfile\" already provided; " - "replacing \"%s\" with \"%s\".\n", - c->log, c->be->be_replica_pidfile, c->value_string ); - ch_free( c->be->be_replica_pidfile ); - } - - c->be->be_replica_pidfile = c->value_string; - break; - - case CFG_REPLICATIONINTERVAL: - if(SLAP_MONITOR(c->be)) { - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replicationinterval\" should not be used " - "inside monitor database\n", - c->log, 0, 0); - /* FIXME: should this be an error? */ - return(0); - } - - c->be->be_replicationinterval = c->value_int; - break; - - case CFG_REPLOG: - if(SLAP_MONITOR(c->be)) { - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replogfile\" should not be used " - "inside monitor database\n", - c->log, 0, 0); - /* FIXME: should this be an error? */ - return(0); - } - - if ( c->be->be_replogfile != NULL ) { - /* FIXME: error? */ - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replogfile\" already provided; " - "replacing \"%s\" with \"%s\".\n", - c->log, c->be->be_replogfile, c->value_string ); - ch_free( c->be->be_replogfile ); - } - - c->be->be_replogfile = c->value_string; - break; - case CFG_ROOTDSE: if(root_dse_read_file(c->argv[1])) { snprintf( c->msg, sizeof( c->msg ), "<%s> could not read file", c->argv[0] ); @@ -2850,230 +2729,6 @@ anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) { return ptr; } -static void -replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv ) -{ - int len; - char *ptr; - struct berval bc = BER_BVNULL; - char numbuf[32]; - - assert( !BER_BVISNULL( &ri->ri_bindconf.sb_uri ) ); - - BER_BVZERO( bv ); - - len = snprintf(numbuf, sizeof( numbuf ), SLAP_X_ORDERED_FMT, i ); - if ( len >= sizeof( numbuf ) ) { - /* FIXME: how can indicate error? */ - return; - } - - if ( ri->ri_nsuffix ) { - for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) { - len += ri->ri_nsuffix[i].bv_len + STRLENOF(" suffix=\"\""); - } - } - if ( ri->ri_attrs ) { - len += STRLENOF(" attrs"); - if ( ri->ri_exclude ) len++; - for (i=0; !BER_BVISNULL( &ri->ri_attrs[i].an_name ); i++) { - len += 1 + ri->ri_attrs[i].an_name.bv_len; - } - } - bindconf_unparse( &ri->ri_bindconf, &bc ); - len += bc.bv_len; - - bv->bv_val = ch_malloc(len + 1); - bv->bv_len = len; - - ptr = lutil_strcopy( bv->bv_val, numbuf ); - - /* start with URI from bindconf */ - assert( !BER_BVISNULL( &bc ) ); - if ( bc.bv_val ) { - strcpy( ptr, bc.bv_val ); - ch_free( bc.bv_val ); - } - - if ( ri->ri_nsuffix ) { - for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) { - ptr = lutil_strcopy( ptr, " suffix=\"" ); - ptr = lutil_strcopy( ptr, ri->ri_nsuffix[i].bv_val ); - *ptr++ = '"'; - } - } - if ( ri->ri_attrs ) { - ptr = lutil_strcopy( ptr, " attrs" ); - if ( ri->ri_exclude ) *ptr++ = '!'; - *ptr++ = '='; - ptr = anlist_unparse( ri->ri_attrs, ptr, 0 ); - } -} - -static int -config_replica(ConfigArgs *c) { - int i, nr = -1; - char *replicahost = NULL, *replicauri = NULL; - LDAPURLDesc *ludp; - - if (c->op == SLAP_CONFIG_EMIT) { - if (c->be->be_replica) { - struct berval bv; - for (i=0;c->be->be_replica[i]; i++) { - replica_unparse( c->be->be_replica[i], i, &bv ); - ber_bvarray_add( &c->rvalue_vals, &bv ); - } - return 0; - } - return 1; - } else if ( c->op == LDAP_MOD_DELETE ) { - /* FIXME: there is no replica_free function */ - if ( c->valx < 0 ) { - } else { - } - } - if(SLAP_MONITOR(c->be)) { - Debug(LDAP_DEBUG_ANY, "%s: " - "\"replica\" should not be used inside monitor database\n", - c->log, 0, 0); - return(0); /* FIXME: should this be an error? */ - } - - for(i = 1; i < c->argc; i++) { - if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) { - ber_len_t len; - - if ( replicauri ) { - snprintf( c->msg, sizeof( c->msg ), "<%s> replica host/URI already specified", c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n", c->log, c->msg, replicauri ); - return(1); - } - - replicahost = c->argv[i] + STRLENOF("host="); - len = strlen( replicahost ) + STRLENOF("ldap://"); - replicauri = ch_malloc( len + 1 ); - snprintf( replicauri, len + 1, "ldap://%s", replicahost ); - replicahost = replicauri + STRLENOF( "ldap://"); - nr = add_replica_info(c->be, replicauri, replicahost); - break; - } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) { - ber_len_t len; - - if ( replicauri ) { - snprintf( c->msg, sizeof( c->msg ), "<%s> replica host/URI already specified", c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n", c->log, c->msg, replicauri ); - return(1); - } - - if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) { - snprintf( c->msg, sizeof( c->msg ), "<%s> invalid uri", c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 ); - return(1); - } - if(!ludp->lud_host) { - ldap_free_urldesc(ludp); - snprintf( c->msg, sizeof( c->msg ), "<%s> invalid uri - missing hostname", - c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 ); - return(1); - } - - len = strlen(ludp->lud_scheme) + strlen(ludp->lud_host) + - STRLENOF("://") + 1; - if (ludp->lud_port != LDAP_PORT) { - if (ludp->lud_port < 1 || ludp->lud_port > 65535) { - ldap_free_urldesc(ludp); - snprintf( c->msg, sizeof( c->msg ), "<%s> invalid port", - c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 ); - return(1); - } - len += STRLENOF(":65535"); - } - replicauri = ch_malloc( len ); - replicahost = lutil_strcopy( replicauri, ludp->lud_scheme ); - replicahost = lutil_strcopy( replicahost, "://" ); - if (ludp->lud_port == LDAP_PORT) { - strcpy( replicahost, ludp->lud_host ); - } else { - sprintf( replicahost, "%s:%d",ludp->lud_host,ludp->lud_port ); - } - ldap_free_urldesc(ludp); - nr = add_replica_info(c->be, replicauri, replicahost); - break; - } - } - if(i == c->argc) { - snprintf( c->msg, sizeof( c->msg ), "<%s> missing host or uri", c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 ); - return(1); - } else if(nr == -1) { - snprintf( c->msg, sizeof( c->msg ), "<%s> unable to add replica", c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n", c->log, c->msg, - replicauri ? replicauri : "" ); - return(1); - } else { - for(i = 1; i < c->argc; i++) { - if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) { - /* dealt with separately; don't let it get to bindconf */ - ; - - } else if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) { - /* dealt with separately; don't let it get to bindconf */ - ; - - } else if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) { - switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) { - case 1: - Debug( LDAP_DEBUG_ANY, "%s: " - "suffix \"%s\" in \"replica\" line is not valid for backend.\n", - c->log, c->argv[i] + STRLENOF("suffix="), 0); - return 1; - break; - case 2: - Debug( LDAP_DEBUG_ANY, "%s: " - "unable to normalize suffix in \"replica\" line.\n", - c->log, 0, 0); - return 1; - break; - } - - } else if (!strncasecmp(c->argv[i], "attr", STRLENOF("attr")) - || !strncasecmp(c->argv[i], "attrs", STRLENOF("attrs"))) - { - int exclude = 0; - char *arg = c->argv[i] + STRLENOF("attr"); - if (arg[0] == 's') { - arg++; - } else { - Debug( LDAP_DEBUG_ANY, - "%s: \"attr\" " - "is deprecated (and undocumented); " - "use \"attrs\" instead.\n", - c->log, 0, 0 ); - } - if(arg[0] == '!') { - arg++; - exclude = 1; - } - if(arg[0] != '=') { - continue; - } - if(add_replica_attrs(c->be, nr, arg + 1, exclude)) { - snprintf( c->msg, sizeof( c->msg ), "<%s> unknown attribute", c->argv[0] ); - Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n", - c->log, c->msg, arg + 1); - return(1); - } - } else if ( bindconf_parse( c->argv[i], - &c->be->be_replica[nr]->ri_bindconf ) ) { - return(1); - } - } - } - return(0); -} - static int config_updatedn(ConfigArgs *c) { if (c->op == SLAP_CONFIG_EMIT) { @@ -3170,6 +2825,14 @@ config_updateref(ConfigArgs *c) { return(0); } +static int +config_obsolete(ConfigArgs *c) { + snprintf( c->msg, sizeof( c->msg ), "<%s> keyword is obsolete (ignored)", + c->argv[0] ); + Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0); + return(0); +} + static int config_include(ConfigArgs *c) { int savelineno = c->lineno; diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index e31c51bbdb..183066b7d6 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -168,15 +168,8 @@ fe_op_delete( Operation *op, SlapReply *rs ) struct berval org_dn = BER_BVNULL; struct berval org_ndn = BER_BVNULL; int org_managedsait; - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; op->o_bd = op_be; - - if ( !op->o_bd->be_update_ndn.bv_len || !repl_user ) { - cb.sc_next = op->o_callback; - op->o_callback = &cb; - } - op->o_bd->be_delete( op, rs ); org_req_dn = op->o_req_dn; diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 1e54b7193b..5666a49b99 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -69,8 +69,6 @@ ldap_pvt_thread_mutex_t gmtime_mutex; slap_counters_t slap_counters; -ldap_pvt_thread_mutex_t replog_mutex; - static const char* slap_name = NULL; int slapMode = SLAP_UNDEFINED_MODE; @@ -137,7 +135,6 @@ slap_init( int mode, const char *name ) ldap_pvt_thread_pool_init( &connection_pool, connection_pool_max, 0); - ldap_pvt_thread_mutex_init( &replog_mutex ); ldap_pvt_thread_mutex_init( &slap_counters.sc_sent_mutex ); ldap_pvt_thread_mutex_init( &slap_counters.sc_ops_mutex ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 292d0b29d8..b902e8d32f 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -287,7 +287,6 @@ fe_op_modify( Operation *op, SlapReply *rs ) */ if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn ); - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; op->o_bd = op_be; @@ -299,13 +298,6 @@ fe_op_modify( Operation *op, SlapReply *rs ) goto cleanup; } } - - if ( !repl_user ) { - /* but multimaster slapd logs only the ones - * not from a replicator user */ - cb.sc_next = op->o_callback; - op->o_callback = &cb; - } op->o_bd->be_modify( op, rs ); } else { /* send a referral */ diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 0e511a761e..221a20e8d9 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -306,15 +306,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) int repl_user = be_isupdate( op ); if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; - op->o_bd = op_be; - - if ( !op->o_bd->be_update_ndn.bv_len || !repl_user ) - { - cb.sc_next = op->o_callback; - op->o_callback = &cb; - } op->o_bd->be_modrdn( op, rs ); if ( op->o_bd->be_delete ) { diff --git a/servers/slapd/overlays/dds.c b/servers/slapd/overlays/dds.c index 80999f6381..b90fcd0e43 100644 --- a/servers/slapd/overlays/dds.c +++ b/servers/slapd/overlays/dds.c @@ -123,7 +123,7 @@ dds_expire( void *ctx, dds_info_t *di ) Connection conn = { 0 }; OperationBuffer opbuf; Operation *op; - slap_callback sc = { 0 }, sc2 = { 0 }; + slap_callback sc = { 0 }; dds_cb_t dc = { 0 }; dds_expire_t *de = NULL, **dep; SlapReply rs = { REP_RESULT }; @@ -193,10 +193,8 @@ done_search:; op->o_tag = LDAP_REQ_DELETE; op->o_callback = ≻ - sc.sc_response = slap_replog_cb; + sc.sc_response = slap_null_cb; sc.sc_private = NULL; - sc.sc_next = &sc2; - sc2.sc_response = slap_null_cb; for ( ntotdeletes = 0, ndeletes = 1; dc.dc_ndnlist != NULL && ndeletes > 0; ) { ndeletes = 0; @@ -989,7 +987,6 @@ dds_op_extended( Operation *op, SlapReply *rs ) SlapReply rs2 = { REP_RESULT }; Operation op2 = *op; slap_callback sc = { 0 }; - slap_callback sc2 = { 0 }; Modifications ttlmod = { { 0 } }; struct berval ttlvalues[ 2 ]; char ttlbuf[] = "31557600"; @@ -1082,9 +1079,7 @@ dds_op_extended( Operation *op, SlapReply *rs ) op2.o_bd = &db; db.bd_info = (BackendInfo *)on->on_info; op2.o_callback = ≻ - sc.sc_response = slap_replog_cb; - sc.sc_next = &sc2; - sc2.sc_response = slap_null_cb; + sc.sc_response = slap_null_cb; op2.o_relax = SLAP_CONTROL_CRITICAL; op2.orm_modlist = &ttlmod; diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index 48ecf68219..9a7abd0215 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -1512,7 +1512,7 @@ ppolicy_modify( Operation *op, SlapReply *rs ) slap_callback *sc; for ( sc = op->o_callback; sc; sc=sc->sc_next ) { - if ( sc->sc_response == slap_replog_cb && + if ( sc->sc_response == slap_null_cb && sc->sc_private ) { req_pwdexop_s *qpw = sc->sc_private; newpw = qpw->rs_new; diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index 327de020e0..2b87fac664 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -52,15 +52,12 @@ int passwd_extop( req_extended_s qext = op->oq_extended; Modifications *ml; slap_callback cb = { NULL, slap_null_cb, NULL, NULL }; - slap_callback cb2 = { NULL, slap_replog_cb, NULL, NULL }; int i, nhash; char **hashes; int rc; BackendDB *op_be; int freenewpw = 0; - cb2.sc_next = &cb; - assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) == 0 ); if( op->o_dn.bv_len == 0 ) { @@ -275,9 +272,9 @@ old_good: slap_callback *sc = op->o_callback; op->o_tag = LDAP_REQ_MODIFY; - op->o_callback = &cb2; + op->o_callback = &cb; op->orm_modlist = qpw->rs_mods; - cb2.sc_private = qpw; /* let Modify know this was pwdMod, + cb.sc_private = qpw; /* let Modify know this was pwdMod, * if it cares... */ rs->sr_err = op->o_bd->be_modify( op, rs ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index e811ed3220..c665adc3b1 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1412,18 +1412,6 @@ LDAP_SLAPD_F (int) get_alias_dn LDAP_P(( int *err, const char **text )); -/* - * repl.c - */ -LDAP_SLAPD_F (int) add_replica_info LDAP_P(( Backend *be, - const char *uri, const char *host )); -LDAP_SLAPD_F (int) destroy_replica_info LDAP_P (( Backend *be )); -LDAP_SLAPD_F (int) add_replica_suffix LDAP_P(( Backend *be, - int nr, const char *suffix )); -LDAP_SLAPD_F (int) add_replica_attrs LDAP_P(( Backend *be, - int nr, char *attrs, int exclude )); -LDAP_SLAPD_F (void) replog LDAP_P(( Operation *op )); - /* * result.c */ @@ -1437,7 +1425,6 @@ LDAP_SLAPD_F (int) slap_send_search_reference LDAP_P(( Operation *op, SlapReply LDAP_SLAPD_F (int) slap_send_search_entry LDAP_P(( Operation *op, SlapReply *rs )); LDAP_SLAPD_F (int) slap_null_cb LDAP_P(( Operation *op, SlapReply *rs )); LDAP_SLAPD_F (int) slap_freeself_cb LDAP_P(( Operation *op, SlapReply *rs )); -LDAP_SLAPD_F (int) slap_replog_cb LDAP_P(( Operation *op, SlapReply *rs )); LDAP_SLAPD_V( const struct berval ) slap_pre_read_bv; LDAP_SLAPD_V( const struct berval ) slap_post_read_bv; @@ -1856,7 +1843,6 @@ LDAP_SLAPD_V (int) connection_pool_max; LDAP_SLAPD_V (int) slap_tool_thread_max; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) entry2str_mutex; -LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) replog_mutex; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) gmtime_mutex; diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c deleted file mode 100644 index 280977294a..0000000000 --- a/servers/slapd/repl.c +++ /dev/null @@ -1,555 +0,0 @@ -/* repl.c - log modifications for replication purposes */ -/* $OpenLDAP$ */ -/* This work is part of OpenLDAP Software . - * - * Copyright 1998-2007 The OpenLDAP Foundation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the OpenLDAP - * Public License. - * - * A copy of this license is available in the file LICENSE in the - * top-level directory of the distribution or, alternatively, at - * . - */ -/* Portions Copyright (c) 1995 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - */ - -#include "portable.h" - -#include - -#include -#include -#include - -#ifdef HAVE_SYS_FILE_H -#include -#endif - -#include "slap.h" -#include "ldif.h" - -int -add_replica_info( - Backend *be, - const char *uri, - const char *host ) -{ - int i = 0; - - assert( be != NULL ); - assert( host != NULL ); - - if ( be->be_replica != NULL ) { - for ( ; be->be_replica[ i ] != NULL; i++ ); - } - - be->be_replica = ch_realloc( be->be_replica, - sizeof( struct slap_replica_info * )*( i + 2 ) ); - - be->be_replica[ i ] - = ch_calloc( sizeof( struct slap_replica_info ), 1 ); - ber_str2bv( uri, 0, 0, &be->be_replica[ i ]->ri_bindconf.sb_uri ); - be->be_replica[ i ]->ri_host = host; - be->be_replica[ i ]->ri_nsuffix = NULL; - be->be_replica[ i ]->ri_attrs = NULL; - be->be_replica[ i + 1 ] = NULL; - - return( i ); -} - -int -destroy_replica_info( - Backend *be ) -{ - int i = 0; - - assert( be != NULL ); - - if ( be->be_replica == NULL ) { - return 0; - } - - for ( ; be->be_replica[ i ] != NULL; i++ ) { - ber_bvarray_free( be->be_replica[ i ]->ri_nsuffix ); - - if ( be->be_replica[ i ]->ri_attrs ) { - AttributeName *an = be->be_replica[ i ]->ri_attrs; - int j; - - for ( j = 0; !BER_BVISNULL( &an[ j ].an_name ); j++ ) - { - ch_free( an[ j ].an_name.bv_val ); - } - ch_free( an ); - } - - bindconf_free( &be->be_replica[ i ]->ri_bindconf ); - - ch_free( be->be_replica[ i ] ); - } - - ch_free( be->be_replica ); - - return 0; -} - -int -add_replica_suffix( - Backend *be, - int nr, - const char *suffix -) -{ - struct berval dn, ndn; - int rc; - - dn.bv_val = (char *) suffix; - dn.bv_len = strlen( dn.bv_val ); - - rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL ); - if( rc != LDAP_SUCCESS ) { - return 2; - } - - if ( select_backend( &ndn, 0, 0 ) != be ) { - free( ndn.bv_val ); - return 1; - } - - ber_bvarray_add( &be->be_replica[nr]->ri_nsuffix, &ndn ); - return 0; -} - -int -add_replica_attrs( - Backend *be, - int nr, - char *attrs, - int exclude -) -{ - if ( be->be_replica[nr]->ri_attrs != NULL ) { - if ( be->be_replica[nr]->ri_exclude != exclude ) { - fprintf( stderr, "attr selective replication directive '%s' conflicts with previous one (discarded)\n", attrs ); - ch_free( be->be_replica[nr]->ri_attrs ); - be->be_replica[nr]->ri_attrs = NULL; - } - } - - be->be_replica[nr]->ri_exclude = exclude; - be->be_replica[nr]->ri_attrs = str2anlist( be->be_replica[nr]->ri_attrs, - attrs, "," ); - return ( be->be_replica[nr]->ri_attrs == NULL ); -} - -static void -print_vals( FILE *fp, struct berval *type, struct berval *bv ); -static void -replog1( struct slap_replica_info *ri, Operation *op, FILE *fp, long now); - -void -replog( Operation *op ) -{ - FILE *fp, *lfp; - int i; -/* undef NO_LOG_WHEN_NO_REPLICAS */ -#ifdef NO_LOG_WHEN_NO_REPLICAS - int count = 0; -#endif /* NO_LOG_WHEN_NO_REPLICAS */ - int subsets = 0; - long now = slap_get_time(); - char *replogfile; - - replogfile = op->o_bd->be_replogfile ? op->o_bd->be_replogfile : - frontendDB->be_replogfile; - if ( !replogfile ) { - return; - } - - ldap_pvt_thread_mutex_lock( &replog_mutex ); - if ( (fp = lock_fopen( replogfile, "a", &lfp )) == NULL ) { - ldap_pvt_thread_mutex_unlock( &replog_mutex ); - return; - } - - for ( i = 0; op->o_bd->be_replica != NULL && op->o_bd->be_replica[i] != NULL; i++ ) { - /* check if dn's suffix matches legal suffixes, if any */ - if ( op->o_bd->be_replica[i]->ri_nsuffix != NULL ) { - int j; - - for ( j = 0; op->o_bd->be_replica[i]->ri_nsuffix[j].bv_val; j++ ) { - if ( dnIsSuffix( &op->o_req_ndn, &op->o_bd->be_replica[i]->ri_nsuffix[j] ) ) { - break; - } - } - - if ( !op->o_bd->be_replica[i]->ri_nsuffix[j].bv_val ) { - /* do not add "replica:" line */ - continue; - } - } - /* See if we only want a subset of attributes */ - if ( op->o_bd->be_replica[i]->ri_attrs != NULL && - ( op->o_tag == LDAP_REQ_MODIFY || op->o_tag == LDAP_REQ_ADD || op->o_tag == LDAP_REQ_EXTENDED ) ) { - if ( !subsets ) { - subsets = i + 1; - } - /* Do attribute subsets by themselves in a second pass */ - continue; - } - - fprintf( fp, "replica: %s\n", op->o_bd->be_replica[i]->ri_host ); -#ifdef NO_LOG_WHEN_NO_REPLICAS - ++count; -#endif /* NO_LOG_WHEN_NO_REPLICAS */ - } - -#ifdef NO_LOG_WHEN_NO_REPLICAS - if ( count == 0 && subsets == 0 ) { - /* if no replicas matched, drop the log - * (should we log it anyway?) */ - lock_fclose( fp, lfp ); - ldap_pvt_thread_mutex_unlock( &replog_mutex ); - - return; - } -#endif /* NO_LOG_WHEN_NO_REPLICAS */ - - replog1( NULL, op, fp, now ); - - if ( subsets > 0 ) { - for ( i = subsets - 1; op->o_bd->be_replica[i] != NULL; i++ ) { - - /* If no attrs, we already did this above */ - if ( op->o_bd->be_replica[i]->ri_attrs == NULL ) { - continue; - } - - /* check if dn's suffix matches legal suffixes, if any */ - if ( op->o_bd->be_replica[i]->ri_nsuffix != NULL ) { - int j; - - for ( j = 0; op->o_bd->be_replica[i]->ri_nsuffix[j].bv_val; j++ ) { - if ( dnIsSuffix( &op->o_req_ndn, &op->o_bd->be_replica[i]->ri_nsuffix[j] ) ) { - break; - } - } - - if ( !op->o_bd->be_replica[i]->ri_nsuffix[j].bv_val ) { - /* no matching suffix found, skip it */ - continue; - } - } - switch( op->o_tag ) { - case LDAP_REQ_EXTENDED: - /* quick hack for extended operations */ - /* assume change parameter is a Modifications* */ - /* fall thru */ - case LDAP_REQ_MODIFY: - case LDAP_REQ_ADD: - break; - default: - /* Other operations were logged in the first pass */ - continue; - } - replog1( op->o_bd->be_replica[i], op, fp, now ); - } - } - - lock_fclose( fp, lfp ); - ldap_pvt_thread_mutex_unlock( &replog_mutex ); -} - -static void -rephdr( - struct slap_replica_info *ri, - Operation *op, - FILE *fp, - long now -) -{ - if ( ri ) { - fprintf( fp, "replica: %s\n", ri->ri_host ); - } - fprintf( fp, "time: %ld\n", now ); - fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val ); -} - -static void -replog1( - struct slap_replica_info *ri, - Operation *op, - FILE *fp, - long now -) -{ - Modifications *ml; - Attribute *a; - AttributeName *an; - int dohdr = 1, ocs = -1; - struct berval vals[2]; - - vals[1].bv_val = NULL; - vals[1].bv_len = 0; - - switch ( op->o_tag ) { - case LDAP_REQ_EXTENDED: - /* quick hack for extended operations */ - /* assume change parameter is a Modifications* */ - /* fall thru */ - - case LDAP_REQ_MODIFY: - for ( ml = op->orm_modlist; ml != NULL; ml = ml->sml_next ) { - char *did = NULL, *type = ml->sml_desc->ad_cname.bv_val; - switch ( ml->sml_op ) { - case LDAP_MOD_ADD: - did = "add"; break; - - case LDAP_MOD_DELETE: - did = "delete"; break; - - case LDAP_MOD_REPLACE: - did = "replace"; break; - - case LDAP_MOD_INCREMENT: - did = "increment"; break; - } - if ( ri && ri->ri_attrs ) { - int is_in = ad_inlist( ml->sml_desc, ri->ri_attrs ); - - /* skip if: - * 1) the attribute is not in the list, - * and it's not an exclusion list - * 2) the attribute is in the list - * and it's an exclusion list, - * and either the objectClass attribute - * has already been dealt with or - * this is not the objectClass attr - */ - if ( ( !is_in && !ri->ri_exclude ) - || ( ( is_in && ri->ri_exclude ) - && ( !ocs || ml->sml_desc != slap_schema.si_ad_objectClass ) ) ) - { - continue; - } - - /* If this is objectClass, see if the value is included - * in any subset, otherwise drop it. - */ - if ( ocs && ml->sml_desc == slap_schema.si_ad_objectClass - && ml->sml_values ) - { - int i, first = 1; - - if ( ocs == -1 ) ocs = 0; - - for ( i=0; ml->sml_values[i].bv_val; i++ ) { - int match = 0; - for ( an = ri->ri_attrs; an->an_name.bv_val; an++ ) { - if ( an->an_oc ) { - struct berval bv = an->an_name; - - ocs = 1; - match |= an->an_oc_exclude; - - switch ( bv.bv_val[ 0 ] ) { - case '@': - case '+': - case '!': - bv.bv_val++; - bv.bv_len--; - break; - } - - if ( ml->sml_values[i].bv_len == bv.bv_len - && !strcasecmp(ml->sml_values[i].bv_val, - bv.bv_val ) ) - { - match = !an->an_oc_exclude; - break; - } - } - } - /* Objectclasses need no special treatment, drop into - * regular processing - */ - if ( !ocs ) break; - - match ^= ri->ri_exclude; - /* Found a match, log it */ - if ( match ) { - if ( dohdr ) { - rephdr( ri, op, fp, now ); - fprintf( fp, "changetype: modify\n" ); - dohdr = 0; - } - if ( first ) { - fprintf( fp, "%s: %s\n", did, type ); - first = 0; - } - vals[0] = ml->sml_values[i]; - print_vals( fp, &ml->sml_desc->ad_cname, vals ); - ocs = 2; - } - - } - /* Explicit objectclasses have been handled already */ - if ( ocs ) { - if ( ocs == 2 ) { - fprintf( fp, "-\n" ); - } - continue; - } - } - } - if ( dohdr ) { - rephdr( ri, op, fp, now ); - fprintf( fp, "changetype: modify\n" ); - dohdr = 0; - } - fprintf( fp, "%s: %s\n", did, type ); - if ( ml->sml_values ) { - print_vals( fp, &ml->sml_desc->ad_cname, ml->sml_values ); - } - fprintf( fp, "-\n" ); - } - break; - - case LDAP_REQ_ADD: - for ( a = op->ora_e->e_attrs ; a != NULL; a=a->a_next ) { - if ( ri && ri->ri_attrs ) { - int is_in = ad_inlist( a->a_desc, ri->ri_attrs ); - - /* skip if: - * 1) the attribute is not in the list, - * and it's not an exclusion list - * 2) the attribute is in the list - * and it's an exclusion list, - * and either the objectClass attribute - * has already been dealt with or - * this is not the objectClass attr - */ - if ( ( !is_in && !ri->ri_exclude ) - || ( ( is_in && ri->ri_exclude ) - && ( !ocs || a->a_desc != slap_schema.si_ad_objectClass ) ) ) - { - continue; - } - - /* If the list includes objectClass names, - * only include those classes in the - * objectClass attribute - */ - if ( ocs && a->a_desc == slap_schema.si_ad_objectClass ) { - int i; - - if ( ocs == -1 ) ocs = 0; - - for ( i=0; a->a_vals[i].bv_val; i++ ) { - int match = 0; - for ( an = ri->ri_attrs; an->an_name.bv_val; an++ ) { - if ( an->an_oc ) { - struct berval bv = an->an_name; - - ocs = 1; - match |= an->an_oc_exclude; - - switch ( bv.bv_val[ 0 ] ) { - case '@': - case '+': - case '!': - bv.bv_val++; - bv.bv_len--; - break; - } - - if ( a->a_vals[i].bv_len == bv.bv_len - && !strcasecmp(a->a_vals[i].bv_val, - bv.bv_val ) ) - { - match = !an->an_oc_exclude; - break; - } - } - } - if ( !ocs ) break; - - match ^= ri->ri_exclude; - if ( match ) { - if ( dohdr ) { - rephdr( ri, op, fp, now ); - fprintf( fp, "changetype: add\n" ); - dohdr = 0; - } - vals[0] = a->a_nvals[i]; - print_vals( fp, &a->a_desc->ad_cname, vals ); - } - } - if ( ocs ) continue; - } - } - if ( dohdr ) { - rephdr( ri, op, fp, now ); - fprintf( fp, "changetype: add\n" ); - dohdr = 0; - } - print_vals( fp, &a->a_desc->ad_cname, a->a_vals ); - } - break; - - case LDAP_REQ_DELETE: - rephdr( ri, op, fp, now ); - fprintf( fp, "changetype: delete\n" ); - break; - - case LDAP_REQ_MODRDN: - rephdr( ri, op, fp, now ); - fprintf( fp, "changetype: modrdn\n" ); - fprintf( fp, "newrdn: %s\n", op->orr_newrdn.bv_val ); - fprintf( fp, "deleteoldrdn: %d\n", op->orr_deleteoldrdn ? 1 : 0 ); - if( op->orr_newSup != NULL ) { - fprintf( fp, "newsuperior: %s\n", op->orr_newSup->bv_val ); - } - } - fprintf( fp, "\n" ); -} - -static void -print_vals( - FILE *fp, - struct berval *type, - struct berval *bv ) -{ - ber_len_t i, len; - char *buf, *bufp; - - for ( i = 0, len = 0; bv && bv[i].bv_val; i++ ) { - if ( bv[i].bv_len > len ) - len = bv[i].bv_len; - } - - len = LDIF_SIZE_NEEDED( type->bv_len, len ) + 1; - buf = (char *) ch_malloc( len ); - - for ( ; bv && bv->bv_val; bv++ ) { - bufp = buf; - ldif_sput( &bufp, LDIF_PUT_VALUE, type->bv_val, - bv->bv_val, bv->bv_len ); - *bufp = '\0'; - - fputs( buf, fp ); - - } - free( buf ); -} diff --git a/servers/slapd/result.c b/servers/slapd/result.c index ae6a42dd0f..4debc048fa 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -54,14 +54,6 @@ int slap_freeself_cb( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; } -int slap_replog_cb( Operation *op, SlapReply *rs ) -{ - if ( rs->sr_err == LDAP_SUCCESS ) { - replog( op ); - } - return SLAP_CB_CONTINUE; -} - static char *v2ref( BerVarray ref, const char *text ) { size_t len = 0, i = 0; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 75d74994d2..cb0bbcbac5 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1569,14 +1569,6 @@ typedef struct slap_bindconf { #endif } slap_bindconf; -struct slap_replica_info { - const char *ri_host; /* points to host part of uri */ - BerVarray ri_nsuffix; /* array of suffixes this replica accepts */ - AttributeName *ri_attrs; /* attrs to replicate, NULL=all */ - int ri_exclude; /* 1 => exclude ri_attrs */ - slap_bindconf ri_bindconf; /* for back-config */ -}; - typedef struct slap_verbmasks { struct berval word; const slap_mask_t mask; @@ -1857,11 +1849,6 @@ struct BackendDB { slap_access_t be_dfltaccess; /* access given if no acl matches */ /* Replica Information */ - struct slap_replica_info **be_replica; /* replicas of this backend (in master) */ - char *be_replogfile; /* replication log file (in master) */ - char *be_replica_argsfile; /* per-replog replica args file */ - char *be_replica_pidfile; /* per-replog replica pid file */ - int be_replicationinterval; /* per-replog replicationinterval */ struct berval be_update_ndn; /* allowed to make changes (in replicas) */ BerVarray be_update_refs; /* where to refer modifying clients to */ struct be_pcl *be_pending_csn_list; -- 2.39.5