~ubuntu-branches/debian/experimental/389-ds-base/experimental

« back to all changes in this revision

Viewing changes to ldap/servers/plugins/chainingdb/cb_config.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-07-08 15:50:11 UTC
  • mfrom: (0.2.2)
  • Revision ID: package-import@ubuntu.com-20140708155011-r66lvtioamqwaype
Tags: 1.3.2.19-1
* New upstream release.
* admin_scripts.diff: Updated to fix more bashisms.
* watch: Update the url.
* Install failedbinds.py and logregex.py scripts.
* init: Use status from init-functions.
* control: Update my email.

Show diffs side-by-side

added added

removed removed

Lines of Context:
380
380
 
381
381
        slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
382
382
 
383
 
        for (i = 0; mods[i] ; i++) {
 
383
        for (i = 0; mods && mods[i] ; i++) {
384
384
                attr_name = mods[i]->mod_type;
385
385
 
386
386
                if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
404
404
cb_config_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, 
405
405
        char *returntext, void *arg) 
406
406
{
407
 
        LDAPMod         **mods;
 
407
        LDAPMod         **mods;
408
408
        char            *attr_name;
409
409
        int             i,j;
410
 
        cb_backend      *cb = (cb_backend *) arg;
 
410
        cb_backend      *cb = (cb_backend *) arg;
411
411
 
412
412
        CB_ASSERT (cb!=NULL);
413
413
 
414
 
        slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
 
414
        slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
415
415
 
416
 
        for (i = 0; mods[i] ; i++) {
 
416
        for (i = 0; mods && mods[i] ; i++) {
417
417
                attr_name = mods[i]->mod_type;
418
418
 
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;
421
421
                        int done=0;
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;
429
429
                                }
430
430
 
431
 
                                if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
 
431
                                if(SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
432
432
                                        if (!done) {
433
433
                                                cb_unregister_all_supported_control(cb);
434
434
                                                done=1;
435
435
                                        }
436
436
                                        cb_register_supported_control(cb,config_attr_value,0);
437
 
                                } else
 
437
                                } else {
438
438
                                if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
439
 
                                        cb_register_supported_control(cb,config_attr_value,0);
440
 
                                } else 
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);
 
440
                                } else {
 
441
                                        if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
 
442
                                                cb_unregister_supported_control(cb,config_attr_value,0);
 
443
                                        }
 
444
                                }
443
445
                                }
444
446
                        }
445
 
                        if (NULL == mods[i]->mod_bvalues)
 
447
                        if (NULL == mods[i]->mod_bvalues){
446
448
                                cb_unregister_all_supported_control(cb);
447
 
                } else
448
 
                if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_DEBUG )) {
449
 
                        /* assume single-valued */
450
 
                        if (mods[i]->mod_op & LDAP_MOD_DELETE)
451
 
                                cb_set_debug(0);
452
 
                        else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op))
453
 
                                cb_set_debug(1);
454
 
                } else
455
 
                if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINING_COMPONENTS )) {
456
 
                        char * config_attr_value;
457
 
                        int done=0;
458
 
 
459
 
                        slapi_rwlock_wrlock(cb->config.rwl_config_lock);
460
 
 
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)) {
464
 
                                        if (!done) {
465
 
                                                charray_free(cb->config.chaining_components);
466
 
                                                cb->config.chaining_components=NULL;
467
 
                                                done=1;
468
 
                                        }
469
 
                                        /* XXXSD assume dn. Normalize it */
470
 
                                        charray_add(&cb->config.chaining_components,
471
 
                                                slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
472
 
                                } else
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)));
476
 
                                } else
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)),
480
 
                                                0 /* freeit */);
481
 
                                }
482
 
                        }
483
 
                        if (NULL == mods[i]->mod_bvalues) {
484
 
                                charray_free(cb->config.chaining_components);
485
 
                                cb->config.chaining_components=NULL;
486
 
                        }
487
 
 
488
 
                        slapi_rwlock_unlock(cb->config.rwl_config_lock);
489
 
                } else
490
 
                if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINABLE_COMPONENTS )) {
491
 
                        char * config_attr_value;
492
 
                        int done=0;
493
 
 
494
 
                        slapi_rwlock_wrlock(cb->config.rwl_config_lock);
495
 
 
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)) {
499
 
                                        if (!done) {
500
 
                                                charray_free(cb->config.chainable_components);
501
 
                                                cb->config.chainable_components=NULL;
502
 
                                                done=1;
503
 
                                        }
504
 
                                        charray_add(&cb->config.chainable_components,
505
 
                                                slapi_dn_normalize(slapi_ch_strdup(config_attr_value)
506
 
));
507
 
                                } else
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)
511
 
));
512
 
                                } else
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)
516
 
),
517
 
                                                                                                0 /* freeit */);
518
 
                                }
519
 
                        }
520
 
                        if (NULL == mods[i]->mod_bvalues) {
521
 
                                charray_free(cb->config.chainable_components);
522
 
                                cb->config.chainable_components=NULL;
523
 
                        }
524
 
 
525
 
                        slapi_rwlock_unlock(cb->config.rwl_config_lock);
526
 
                }
527
 
 
528
 
 
 
449
                        }
 
450
                } else {
 
451
                        if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_DEBUG )) {
 
452
                                /* assume single-valued */
 
453
                                if (mods[i]->mod_op & LDAP_MOD_DELETE){
 
454
                                        cb_set_debug(0);
 
455
                                } else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
 
456
                                        cb_set_debug(1);
 
457
                                }
 
458
                        } else {
 
459
                                if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINING_COMPONENTS )) {
 
460
                                        char * config_attr_value;
 
461
                                        int done=0;
 
462
 
 
463
                                        slapi_rwlock_wrlock(cb->config.rwl_config_lock);
 
464
 
 
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)) {
 
468
                                                        if (!done) {
 
469
                                                                charray_free(cb->config.chaining_components);
 
470
                                                                cb->config.chaining_components=NULL;
 
471
                                                                done=1;
 
472
                                                        }
 
473
                                                        /* XXXSD assume dn. Normalize it */
 
474
                                                        charray_add(&cb->config.chaining_components,
 
475
                                                                slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
 
476
                                                } else {
 
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)));
 
480
                                                        } else {
 
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);
 
486
                                                                }
 
487
                                                        }
 
488
                                                }
 
489
                                        }
 
490
                                        if (NULL == mods[i]->mod_bvalues) {
 
491
                                                charray_free(cb->config.chaining_components);
 
492
                                                cb->config.chaining_components=NULL;
 
493
                                        }
 
494
 
 
495
                                        slapi_rwlock_unlock(cb->config.rwl_config_lock);
 
496
                                } else {
 
497
                                        if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINABLE_COMPONENTS )) {
 
498
                                                char *config_attr_value;
 
499
                                                char *attr_val;
 
500
                                                int done=0;
 
501
 
 
502
                                                slapi_rwlock_wrlock(cb->config.rwl_config_lock);
 
503
 
 
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)) {
 
507
                                                                if (!done) {
 
508
                                                                        charray_free(cb->config.chainable_components);
 
509
                                                                        cb->config.chainable_components=NULL;
 
510
                                                                        done=1;
 
511
                                                                }
 
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);
 
521
                                                        }
 
522
                                                }
 
523
                                                if (NULL == mods[i]->mod_bvalues) {
 
524
                                                        charray_free(cb->config.chainable_components);
 
525
                                                        cb->config.chainable_components=NULL;
 
526
                                                }
 
527
 
 
528
                                                slapi_rwlock_unlock(cb->config.rwl_config_lock);
 
529
                                        }
 
530
                                }
 
531
                        }
 
532
                }
529
533
        }
530
534
        *returncode=LDAP_SUCCESS;
 
535
 
531
536
        return SLAPI_DSE_CALLBACK_OK;
532
537
}
533
538