~ubuntu-branches/ubuntu/wily/389-ds-base/wily-proposed

« back to all changes in this revision

Viewing changes to ldap/servers/plugins/replication/repl5_replica_config.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-07-08 15:50:11 UTC
  • mto: (19.1.1 experimental) (0.3.1)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20140708155011-48naeyka2x89ew8g
Tags: upstream-1.3.2.19
ImportĀ upstreamĀ versionĀ 1.3.2.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
        if (*returncode != LDAP_SUCCESS)
351
351
            break;
352
352
 
353
 
        for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++)
 
353
        for (i = 0; mods && (mods[i] && (LDAP_SUCCESS == rc)); i++)
354
354
                {
355
355
            if (*returncode != LDAP_SUCCESS)
356
356
                break;
374
374
            else if ((mods[i]->mod_op & LDAP_MOD_DELETE) || mods[i]->mod_bvalues == NULL
375
375
                     || mods[i]->mod_bvalues[0]->bv_val == NULL)
376
376
            {
377
 
                /* currently, you can only remove referral,
378
 
                                   legacy consumer or bind dn attribute */
 
377
                /*
 
378
                 *  Where possible/allowed return replica config settings to their
 
379
                 *  default values.
 
380
                 */
379
381
                if (strcasecmp (config_attr, attr_replicaBindDn) == 0)
380
382
                {
381
383
                                    *returncode = replica_config_change_updatedn (r, mods[i], errortext, apply_mods);
398
400
                         strcasecmp (config_attr, type_replicaAbortCleanRUV) == 0)
399
401
                {
400
402
                    /*
401
 
                     * Only allow the deletion of the cleanAllRUV config attributes, and the
402
 
                     * protocol timeout.
 
403
                     * Nothing to do in this case, allow it, and continue.
403
404
                     */
404
405
                    continue;
405
406
                }
406
407
                else if (strcasecmp (config_attr, type_replicaProtocolTimeout) == 0 )
407
408
                {
408
 
                        replica_set_protocol_timeout(r, DEFAULT_PROTOCOL_TIMEOUT);
 
409
                    if (apply_mods)
 
410
                        replica_set_protocol_timeout(r, DEFAULT_PROTOCOL_TIMEOUT);
 
411
                }
 
412
                else if(strcasecmp (config_attr, type_replicaBackoffMin) == 0 )
 
413
                {
 
414
                    if (apply_mods)
 
415
                        replica_set_backoff_min(r, PROTOCOL_BACKOFF_MINIMUM);
 
416
                }
 
417
                else if (strcasecmp (config_attr, type_replicaBackoffMax) == 0 )
 
418
                {
 
419
                    if (apply_mods)
 
420
                        replica_set_backoff_max(r, PROTOCOL_BACKOFF_MAXIMUM);
409
421
                }
410
422
                else
411
423
                {
417
429
            else    /* modify an attribute */
418
430
            {
419
431
                config_attr_value = (char *) mods[i]->mod_bvalues[0]->bv_val;
 
432
                if (NULL == config_attr_value) {
 
433
                    *returncode = LDAP_UNWILLING_TO_PERFORM;
 
434
                    PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE, "attribute %s value is NULL.\n",
 
435
                                 config_attr);
 
436
                    slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n",
 
437
                                    errortext);
 
438
                    break;
 
439
                }
420
440
 
421
441
                if (strcasecmp (config_attr, attr_replicaBindDn) == 0)
422
442
                            {
424
444
                }
425
445
                else if (strcasecmp (config_attr, attr_replicaType) == 0)
426
446
                            {
 
447
                        slapi_ch_free_string(&new_repl_type);
427
448
                                        new_repl_type = slapi_ch_strdup(config_attr_value);
428
449
                }
429
450
                else if (strcasecmp (config_attr, attr_replicaId) == 0)
430
451
                            {
 
452
                        slapi_ch_free_string(&new_repl_id);
431
453
                                        new_repl_id = slapi_ch_strdup(config_attr_value);
432
454
                }
433
455
                else if (strcasecmp (config_attr, attr_flags) == 0)
456
478
                }
457
479
                                else if (strcasecmp (config_attr, type_replicaPurgeDelay) == 0)
458
480
                                {
459
 
                                        if (apply_mods && config_attr_value && config_attr_value[0])
 
481
                                        if (apply_mods && config_attr_value[0])
460
482
                                        {
461
483
                                                PRUint32 delay;
462
484
                                                if (isdigit (config_attr_value[0]))
470
492
                                }
471
493
                                else if (strcasecmp (config_attr, type_replicaTombstonePurgeInterval) == 0)
472
494
                                {
473
 
                                        if (apply_mods && config_attr_value && config_attr_value[0])
 
495
                                        if (apply_mods && config_attr_value[0])
474
496
                                        {
475
497
                                                long interval;
476
498
                                                interval = atol (config_attr_value);
479
501
                                }
480
502
                else if (strcasecmp (config_attr, type_replicaLegacyConsumer) == 0)
481
503
                {
482
 
                    if (apply_mods)
 
504
                    if (apply_mods && config_attr_value[0])
483
505
                    {
484
506
                        PRBool legacy = (strcasecmp (config_attr_value, "on") == 0) ||
485
507
                                        (strcasecmp (config_attr_value, "true") == 0) ||
498
520
                else if (strcasecmp (config_attr, type_replicaProtocolTimeout) == 0 ){
499
521
                    if (apply_mods)
500
522
                    {
501
 
                        long ptimeout = 0;
 
523
                        PRUint64 ptimeout = 0;
502
524
 
503
 
                        if(config_attr_value){
504
 
                            ptimeout = atol(config_attr_value);
505
 
                        }
 
525
                        ptimeout = atoll(config_attr_value);
506
526
 
507
527
                        if(ptimeout <= 0){
508
528
                            *returncode = LDAP_UNWILLING_TO_PERFORM;
509
529
                            PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
510
530
                                         "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
511
 
                                         config_attr, config_attr_value ? config_attr_value : "");
 
531
                                         config_attr, config_attr_value);
512
532
                            slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
513
533
                            break;
514
534
                        }
515
535
                        replica_set_protocol_timeout(r, ptimeout);
516
536
                    }
517
537
                }
 
538
                else if(strcasecmp (config_attr, type_replicaBackoffMin) == 0 )
 
539
                {
 
540
                    if (apply_mods)
 
541
                    {
 
542
                        PRUint64 val = atoll(config_attr_value);
 
543
 
 
544
                        if(val <= 0){
 
545
                            *returncode = LDAP_UNWILLING_TO_PERFORM;
 
546
                            PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
 
547
                                    "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
 
548
                                    config_attr, config_attr_value);
 
549
                            slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
 
550
                            break;
 
551
                        }
 
552
                        replica_set_backoff_min(r, val);
 
553
                    }
 
554
                }
 
555
                else if (strcasecmp (config_attr, type_replicaBackoffMax) == 0 )
 
556
                {
 
557
                    if (apply_mods)
 
558
                    {
 
559
                        PRUint64 val = atoll(config_attr_value);
 
560
 
 
561
                        if(val <= 0){
 
562
                            *returncode = LDAP_UNWILLING_TO_PERFORM;
 
563
                            PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
 
564
                                    "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
 
565
                                    config_attr, config_attr_value);
 
566
                            slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
 
567
                            break;
 
568
                        }
 
569
                        replica_set_backoff_max(r, val);
 
570
                    }
 
571
                }
518
572
                else
519
573
                {
520
574
                    *returncode = LDAP_UNWILLING_TO_PERFORM;
628
682
        if (*returncode != LDAP_SUCCESS)
629
683
            break;
630
684
 
631
 
        for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++)
 
685
        for (i = 0; mods && (mods[i] && (LDAP_SUCCESS == rc)); i++)
632
686
        {
633
687
            if (*returncode != LDAP_SUCCESS)
634
688
                break;
1151
1205
    }
1152
1206
 
1153
1207
    PR_snprintf (fName, MAXPATHLEN, "%s/%s.ldif", clDir, replica_get_name (replica));
1154
 
    slapi_ch_free_string (&clDir);
1155
 
 
1156
1208
    slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
1157
1209
                    "Beginning changelog export of replica \"%s\"\n",
1158
1210
                    replica_get_name(replica));
1171
1223
        rc = LDAP_OPERATIONS_ERROR;
1172
1224
    }
1173
1225
bail:
 
1226
    slapi_ch_free_string (&clDir);
 
1227
 
1174
1228
    return rc;
1175
1229
}
1176
1230
 
1226
1280
                    "Beginning changelog import of replica \"%s\"\n",
1227
1281
                    replica_get_name(replica));
1228
1282
    imprc = cl5ImportLDIF (clDir, fName, rlist);
1229
 
    slapi_ch_free_string (&clDir);
1230
1283
    if (CL5_SUCCESS == imprc)
1231
1284
    {
1232
1285
        slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
1256
1309
            config.dir?config.dir:"null config dir");
1257
1310
        rc = LDAP_OPERATIONS_ERROR;
1258
1311
    }
 
1312
 
1259
1313
bail:
 
1314
    slapi_ch_free_string(&clDir);
1260
1315
    changelog5_config_done(&config);
 
1316
 
1261
1317
    /* if cl5ImportLDIF returned an error, report it first. */
1262
1318
    return imprc?imprc:rc;
1263
1319
}
2224
2280
    rc = ldap_modify_ext_s( ld, repl_dn, mods, NULL, NULL);
2225
2281
 
2226
2282
    if(rc != LDAP_SUCCESS){
 
2283
        char *hostname = agmt_get_hostname(agmt);
 
2284
 
2227
2285
        cleanruv_log(clean_data->task, CLEANALLRUV_ID, "Failed to add CLEANRUV task (%s) to replica "
2228
2286
            "(%s).  You will need to manually run the CLEANRUV task on this replica (%s) error (%d)",
2229
 
            repl_dn, agmt_get_long_name(agmt), agmt_get_hostname(agmt), rc);
 
2287
            repl_dn, agmt_get_long_name(agmt), hostname, rc);
 
2288
        slapi_ch_free_string(&hostname);
2230
2289
    }
2231
2290
    slapi_ch_free_string(&repl_dn);
2232
2291
    slapi_sdn_free(&sdn);