404
404
cb_config_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode,
405
405
char *returntext, void *arg)
410
cb_backend *cb = (cb_backend *) arg;
410
cb_backend *cb = (cb_backend *) arg;
412
412
CB_ASSERT (cb!=NULL);
414
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
414
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
416
for (i = 0; mods[i] ; i++) {
416
for (i = 0; mods && mods[i] ; i++) {
417
417
attr_name = mods[i]->mod_type;
419
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
419
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
420
420
char * config_attr_value;
422
for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
423
config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
422
for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
423
config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
424
424
if (!cb_is_control_forwardable(cb,config_attr_value)) {
425
425
slapi_log_error(SLAPI_LOG_PLUGIN,CB_PLUGIN_SUBSYSTEM,
426
426
"control %s can't be forwarded.\n",config_attr_value);
428
428
return SLAPI_DSE_CALLBACK_ERROR;
431
if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
431
if(SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
433
433
cb_unregister_all_supported_control(cb);
436
436
cb_register_supported_control(cb,config_attr_value,0);
438
438
if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
439
cb_register_supported_control(cb,config_attr_value,0);
441
if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
442
cb_unregister_supported_control(cb,config_attr_value,0);
439
cb_register_supported_control(cb,config_attr_value,0);
441
if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
442
cb_unregister_supported_control(cb,config_attr_value,0);
445
if (NULL == mods[i]->mod_bvalues)
447
if (NULL == mods[i]->mod_bvalues){
446
448
cb_unregister_all_supported_control(cb);
448
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_DEBUG )) {
449
/* assume single-valued */
450
if (mods[i]->mod_op & LDAP_MOD_DELETE)
452
else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op))
455
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINING_COMPONENTS )) {
456
char * config_attr_value;
459
slapi_rwlock_wrlock(cb->config.rwl_config_lock);
461
for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
462
config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
463
if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
465
charray_free(cb->config.chaining_components);
466
cb->config.chaining_components=NULL;
469
/* XXXSD assume dn. Normalize it */
470
charray_add(&cb->config.chaining_components,
471
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
473
if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
474
charray_add(&cb->config.chaining_components,
475
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
477
if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
478
charray_remove(cb->config.chaining_components,
479
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)),
483
if (NULL == mods[i]->mod_bvalues) {
484
charray_free(cb->config.chaining_components);
485
cb->config.chaining_components=NULL;
488
slapi_rwlock_unlock(cb->config.rwl_config_lock);
490
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINABLE_COMPONENTS )) {
491
char * config_attr_value;
494
slapi_rwlock_wrlock(cb->config.rwl_config_lock);
496
for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
497
config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
498
if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
500
charray_free(cb->config.chainable_components);
501
cb->config.chainable_components=NULL;
504
charray_add(&cb->config.chainable_components,
505
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)
508
if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
509
charray_add(&cb->config.chainable_components,
510
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)
513
if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
514
charray_remove(cb->config.chainable_components,
515
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)
520
if (NULL == mods[i]->mod_bvalues) {
521
charray_free(cb->config.chainable_components);
522
cb->config.chainable_components=NULL;
525
slapi_rwlock_unlock(cb->config.rwl_config_lock);
451
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_DEBUG )) {
452
/* assume single-valued */
453
if (mods[i]->mod_op & LDAP_MOD_DELETE){
455
} else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
459
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINING_COMPONENTS )) {
460
char * config_attr_value;
463
slapi_rwlock_wrlock(cb->config.rwl_config_lock);
465
for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
466
config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
467
if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
469
charray_free(cb->config.chaining_components);
470
cb->config.chaining_components=NULL;
473
/* XXXSD assume dn. Normalize it */
474
charray_add(&cb->config.chaining_components,
475
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
477
if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
478
charray_add(&cb->config.chaining_components,
479
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
481
if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
482
char *remove_val = slapi_ch_strdup(config_attr_value);
483
charray_remove(cb->config.chaining_components,
484
slapi_dn_normalize(remove_val), 0 /* freeit */);
485
slapi_ch_free_string(&remove_val);
490
if (NULL == mods[i]->mod_bvalues) {
491
charray_free(cb->config.chaining_components);
492
cb->config.chaining_components=NULL;
495
slapi_rwlock_unlock(cb->config.rwl_config_lock);
497
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINABLE_COMPONENTS )) {
498
char *config_attr_value;
502
slapi_rwlock_wrlock(cb->config.rwl_config_lock);
504
for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
505
config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
506
if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
508
charray_free(cb->config.chainable_components);
509
cb->config.chainable_components=NULL;
512
charray_add(&cb->config.chainable_components,
513
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
514
} else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
515
charray_add(&cb->config.chainable_components,
516
slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
517
} else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
518
attr_val = slapi_dn_normalize(slapi_ch_strdup(config_attr_value));
519
charray_remove(cb->config.chainable_components, attr_val, 0 /* freeit */);
520
slapi_ch_free_string(&attr_val);
523
if (NULL == mods[i]->mod_bvalues) {
524
charray_free(cb->config.chainable_components);
525
cb->config.chainable_components=NULL;
528
slapi_rwlock_unlock(cb->config.rwl_config_lock);
530
534
*returncode=LDAP_SUCCESS;
531
536
return SLAPI_DSE_CALLBACK_OK;