X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbconfig.c;h=bf13855d9dd72b280db5dd5bad2f2d6287f5b8b5;hb=f57a216f1cb425e208b5609e1b0451e988583ce1;hp=8d5ca2a6fbc37da31216db98ecd2e12ff694c63e;hpb=9d0c7b24c68ff241b9b6bdb793f6ea2deb8fbfc7;p=openldap diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 8d5ca2a6fb..bf13855d9d 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -190,6 +190,7 @@ enum { CFG_IX_INTLEN, CFG_SYNTAX, CFG_ACL_ADD, + CFG_SYNC_SUBENTRY, CFG_LAST }; @@ -604,6 +605,10 @@ static ConfigTable config_back_cf_table[] = { &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' " "EQUALITY distinguishedNameMatch " "SYNTAX OMsDN )", NULL, NULL }, + { "sync_use_subentry", NULL, 0, 0, 0, ARG_ON_OFF|ARG_DB|ARG_MAGIC|CFG_SYNC_SUBENTRY, + &config_generic, "( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' " + "DESC 'Store sync context in a subentry' " + "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC, &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' " "EQUALITY caseIgnoreMatch " @@ -815,7 +820,7 @@ static ConfigOCs cf_ocs[] = { "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ " "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ " "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ " - "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ " + "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ " "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ " "olcMonitoring ) )", Cft_Database, NULL, cfAddDatabase }, @@ -1085,6 +1090,9 @@ config_generic(ConfigArgs *c) { case CFG_LASTMOD: c->value_int = (SLAP_NOLASTMOD(c->be) == 0); break; + case CFG_SYNC_SUBENTRY: + c->value_int = (SLAP_SYNC_SUBENTRY(c->be) != 0); + break; case CFG_MIRRORMODE: if ( SLAP_SHADOW(c->be)) c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0); @@ -1197,6 +1205,7 @@ config_generic(ConfigArgs *c) { case CFG_SSTR_IF_MAX: case CFG_SSTR_IF_MIN: case CFG_ACL_ADD: + case CFG_SYNC_SUBENTRY: break; /* no-ops, requires slapd restart */ @@ -1901,6 +1910,13 @@ sortval_reject: SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN; break; + case CFG_SYNC_SUBENTRY: + if (c->value_int) + SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SYNC_SUBENTRY; + else + SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SYNC_SUBENTRY; + break; + case CFG_SSTR_IF_MAX: if (c->value_uint < index_substr_if_minlen) { snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] ); @@ -1994,29 +2010,40 @@ sortval_reject: case CFG_REWRITE: { struct berval bv; char *line; - + int rc = 0; + + if ( c->op == LDAP_MOD_ADD ) { + c->argv++; + c->argc--; + } if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv)) - return(1); + rc = 1; + if ( rc == 0 ) { - if ( c->argc > 1 ) { - char *s; + if ( c->argc > 1 ) { + char *s; - /* quote all args but the first */ - line = ldap_charray2str( c->argv, "\" \"" ); - ber_str2bv( line, 0, 0, &bv ); - s = ber_bvchr( &bv, '"' ); - assert( s != NULL ); - /* move the trailing quote of argv[0] to the end */ - AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) ); - bv.bv_val[ bv.bv_len - 1 ] = '"'; + /* quote all args but the first */ + line = ldap_charray2str( c->argv, "\" \"" ); + ber_str2bv( line, 0, 0, &bv ); + s = ber_bvchr( &bv, '"' ); + assert( s != NULL ); + /* move the trailing quote of argv[0] to the end */ + AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) ); + bv.bv_val[ bv.bv_len - 1 ] = '"'; - } else { - ber_str2bv( c->argv[ 0 ], 0, 1, &bv ); + } else { + ber_str2bv( c->argv[ 0 ], 0, 1, &bv ); + } + + ber_bvarray_add( &authz_rewrites, &bv ); } - - ber_bvarray_add( &authz_rewrites, &bv ); + if ( c->op == LDAP_MOD_ADD ) { + c->argv--; + c->argc++; + } + return rc; } - break; #endif @@ -2181,14 +2208,23 @@ config_sizelimit(ConfigArgs *c) { rc = 1; return rc; } else if ( c->op == LDAP_MOD_DELETE ) { - /* Reset to defaults */ - lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT; - lim->lms_s_hard = 0; - lim->lms_s_unchecked = -1; - lim->lms_s_pr = 0; - lim->lms_s_pr_hide = 0; - lim->lms_s_pr_total = 0; - return 0; + /* Reset to defaults or values from frontend */ + if ( c->be == frontendDB ) { + lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT; + lim->lms_s_hard = 0; + lim->lms_s_unchecked = -1; + lim->lms_s_pr = 0; + lim->lms_s_pr_hide = 0; + lim->lms_s_pr_total = 0; + } else { + lim->lms_s_soft = frontendDB->be_def_limit.lms_s_soft; + lim->lms_s_hard = frontendDB->be_def_limit.lms_s_hard; + lim->lms_s_unchecked = frontendDB->be_def_limit.lms_s_unchecked; + lim->lms_s_pr = frontendDB->be_def_limit.lms_s_pr; + lim->lms_s_pr_hide = frontendDB->be_def_limit.lms_s_pr_hide; + lim->lms_s_pr_total = frontendDB->be_def_limit.lms_s_pr_total; + } + goto ok; } for(i = 1; i < c->argc; i++) { if(!strncasecmp(c->argv[i], "size", 4)) { @@ -2213,6 +2249,35 @@ config_sizelimit(ConfigArgs *c) { lim->lms_s_hard = 0; } } + +ok: + if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) { + /* This is a modification to the global limits apply it to + * the other databases as needed */ + AttributeDescription *ad=NULL; + const char *text = NULL; + CfEntryInfo *ce = c->ca_entry->e_private; + + slap_str2ad(c->argv[0], &ad, &text); + /* if we got here... */ + assert( ad != NULL ); + + if ( ce->ce_type == Cft_Global ){ + ce = ce->ce_kids; + } + for (; ce; ce=ce->ce_sibs) { + Entry *dbe = ce->ce_entry; + if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB) + && (!attr_find(dbe->e_attrs, ad)) ) { + ce->ce_be->be_def_limit.lms_s_soft = lim->lms_s_soft; + ce->ce_be->be_def_limit.lms_s_hard = lim->lms_s_hard; + ce->ce_be->be_def_limit.lms_s_unchecked =lim->lms_s_unchecked; + ce->ce_be->be_def_limit.lms_s_pr =lim->lms_s_pr; + ce->ce_be->be_def_limit.lms_s_pr_hide =lim->lms_s_pr_hide; + ce->ce_be->be_def_limit.lms_s_pr_total =lim->lms_s_pr_total; + } + } + } return(0); } @@ -2232,10 +2297,15 @@ config_timelimit(ConfigArgs *c) { rc = 1; return rc; } else if ( c->op == LDAP_MOD_DELETE ) { - /* Reset to defaults */ - lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT; - lim->lms_t_hard = 0; - return 0; + /* Reset to defaults or values from frontend */ + if ( c->be == frontendDB ) { + lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT; + lim->lms_t_hard = 0; + } else { + lim->lms_t_soft = frontendDB->be_def_limit.lms_t_soft; + lim->lms_t_hard = frontendDB->be_def_limit.lms_t_hard; + } + goto ok; } for(i = 1; i < c->argc; i++) { if(!strncasecmp(c->argv[i], "time", 4)) { @@ -2260,6 +2330,31 @@ config_timelimit(ConfigArgs *c) { lim->lms_t_hard = 0; } } + +ok: + if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) { + /* This is a modification to the global limits apply it to + * the other databases as needed */ + AttributeDescription *ad=NULL; + const char *text = NULL; + CfEntryInfo *ce = c->ca_entry->e_private; + + slap_str2ad(c->argv[0], &ad, &text); + /* if we got here... */ + assert( ad != NULL ); + + if ( ce->ce_type == Cft_Global ){ + ce = ce->ce_kids; + } + for (; ce; ce=ce->ce_sibs) { + Entry *dbe = ce->ce_entry; + if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB) + && (!attr_find(dbe->e_attrs, ad)) ) { + ce->ce_be->be_def_limit.lms_t_soft = lim->lms_t_soft; + ce->ce_be->be_def_limit.lms_t_hard = lim->lms_t_hard; + } + } + } return(0); } @@ -4584,7 +4679,6 @@ schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs, ad = NULL; slap_bv2ad( &bv, &ad, &text ); ct = config_find_table( colst, nocs, ad, ca ); - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); } if ( cfn->c_oc_head ) { @@ -4592,7 +4686,6 @@ schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs, ad = NULL; slap_bv2ad( &bv, &ad, &text ); ct = config_find_table( colst, nocs, ad, ca ); - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); } if ( cfn->c_at_head ) { @@ -4600,7 +4693,6 @@ schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs, ad = NULL; slap_bv2ad( &bv, &ad, &text ); ct = config_find_table( colst, nocs, ad, ca ); - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); } if ( cfn->c_syn_head ) { @@ -4608,7 +4700,6 @@ schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs, ad = NULL; slap_bv2ad( &bv, &ad, &text ); ct = config_find_table( colst, nocs, ad, ca ); - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); } if ( cfn->c_om_head ) { @@ -4616,7 +4707,6 @@ schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs, ad = NULL; slap_bv2ad( &bv, &ad, &text ); ct = config_find_table( colst, nocs, ad, ca ); - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); } cfo = p->ce_private; @@ -4683,6 +4773,9 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: " "DN=\"%s\" already exists\n", log_prefix, e->e_name.bv_val, 0 ); + /* global schema ignores all writes */ + if ( ce->ce_type == Cft_Schema && ce->ce_parent->ce_type == Cft_Global ) + return LDAP_COMPARE_TRUE; return LDAP_ALREADY_EXISTS; } } @@ -4907,10 +5000,10 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, ok: /* Newly added databases and overlays need to be started up */ if ( CONFIG_ONLINE_ADD( ca )) { - if ( colst[0]->co_type == Cft_Database ) { + if ( coptr->co_type == Cft_Database ) { rc = backend_startup_one( ca->be, &ca->reply ); - } else if ( colst[0]->co_type == Cft_Overlay ) { + } else if ( coptr->co_type == Cft_Overlay ) { if ( ca->bi->bi_db_open ) { BackendInfo *bi_orig = ca->be->bd_info; ca->be->bd_info = ca->bi; @@ -4936,7 +5029,7 @@ ok: ce->ce_parent = last; ce->ce_entry = entry_dup( e ); ce->ce_entry->e_private = ce; - ce->ce_type = colst[0]->co_type; + ce->ce_type = coptr->co_type; ce->ce_be = ca->be; ce->ce_bi = ca->bi; ce->ce_private = ca->ca_private; @@ -4981,12 +5074,12 @@ ok: done: if ( rc ) { - if ( (colst[0]->co_type == Cft_Database) && ca->be ) { + if ( (coptr->co_type == Cft_Database) && ca->be ) { if ( ca->be != frontendDB ) backend_destroy_one( ca->be, 1 ); - } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) { + } else if ( (coptr->co_type == Cft_Overlay) && ca->bi ) { overlay_destroy_one( ca->be, (slap_overinst *)ca->bi ); - } else if ( colst[0]->co_type == Cft_Schema ) { + } else if ( coptr->co_type == Cft_Schema ) { schema_destroy_one( ca, colst, nocs, last ); } } @@ -5168,7 +5261,14 @@ out2:; ldap_pvt_thread_pool_resume( &connection_pool ); out:; - send_ldap_result( op, rs ); + { int repl = op->o_dont_replicate; + if ( rs->sr_err == LDAP_COMPARE_TRUE ) { + rs->sr_err = LDAP_SUCCESS; + op->o_dont_replicate = 1; + } + send_ldap_result( op, rs ); + op->o_dont_replicate = repl; + } slap_graduate_commit_csn( op ); return rs->sr_err; } @@ -5412,7 +5512,6 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs, ca->valx = -1; ca->line = NULL; ca->argc = 1; - ca->argv[0] = ct->ad->ad_cname.bv_val; rc = config_del_vals( ct, ca ); if ( rc ) rc = LDAP_OTHER; if ( s ) @@ -5460,7 +5559,6 @@ out: ca->valx = -1; ca->line = NULL; ca->argc = 1; - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); } for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) { @@ -5476,7 +5574,6 @@ out: ca->valx = -1; ca->line = NULL; ca->argc = 1; - ca->argv[0] = ct->ad->ad_cname.bv_val; config_del_vals( ct, ca ); s = attr_find( save_attrs, a->a_desc ); if ( s ) { @@ -6706,10 +6803,30 @@ config_tool_entry_first( BackendDB *be ) CfBackInfo *cfb = be->be_private; BackendInfo *bi = cfb->cb_db.bd_info; - if ( bi && bi->bi_tool_entry_first ) + if ( bi && bi->bi_tool_entry_first ) { return bi->bi_tool_entry_first( &cfb->cb_db ); - else - return NOID; + } + if ( bi && bi->bi_tool_entry_first_x ) { + return bi->bi_tool_entry_first_x( &cfb->cb_db, + NULL, LDAP_SCOPE_DEFAULT, NULL ); + } + return NOID; +} + +static ID +config_tool_entry_first_x( + BackendDB *be, + struct berval *base, + int scope, + Filter *f ) +{ + CfBackInfo *cfb = be->be_private; + BackendInfo *bi = cfb->cb_db.bd_info; + + if ( bi && bi->bi_tool_entry_first_x ) { + return bi->bi_tool_entry_first_x( &cfb->cb_db, base, scope, f ); + } + return NOID; } static ID @@ -6956,6 +7073,7 @@ config_back_initialize( BackendInfo *bi ) bi->bi_tool_entry_open = config_tool_entry_open; bi->bi_tool_entry_close = config_tool_entry_close; bi->bi_tool_entry_first = config_tool_entry_first; + bi->bi_tool_entry_first_x = config_tool_entry_first_x; bi->bi_tool_entry_next = config_tool_entry_next; bi->bi_tool_entry_get = config_tool_entry_get; bi->bi_tool_entry_put = config_tool_entry_put;