~ubuntu-branches/ubuntu/maverick/openldap/maverick-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/back-bdb/init.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Steve Langasek, Mathias Gug
  • Date: 2009-02-18 18:44:00 UTC
  • mfrom: (1.1.2 upstream) (0.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20090218184400-zw4mjse9eywt5566
Tags: 2.4.14-0ubuntu1
[ Steve Langasek ]
* New upstream version
  - Fixes a bug with the pcache overlay not returning cached entries
    (closes: #497697)
  - Update evolution-ntlm patch to apply to current Makefiles.
  - (tentatively) drop gnutls-ciphers, since this bug was reported to be
    fixed upstream in 2.4.8.  The fix applied in 2.4.8 didn't match the
    patch from the bug report, so this should be watched for regressions.
* Build against db4.7 instead of db4.2 at last!  Closes: #421946.
* Build with --disable-ndb, to avoid a misbuild when libmysqlclient is
  installed in the build environment.
* New patch, no-crlcheck-for-gnutls, to fix a build failure when using
  --with-tls=gnutls.

[ Mathias Gug ]
* Merge from debian unstable, remaining changes:
  - debian/apparmor-profile: add AppArmor profile
  - debian/slapd.postinst: Reload AA profile on configuration
  - updated debian/slapd.README.Debian for note on AppArmor
  - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6
  - debian/control: Conflicts with apparmor-profiles << 2.1+1075-0ubuntu4
    to make sure that if earlier version of apparmour-profiles gets
    installed it won't overwrite our profile.
  - Modify Maintainer value to match the DebianMaintainerField
    speficication.
  - follow ApparmorProfileMigration and force apparmor compalin mode on 
    some upgrades (LP: #203529)
  - debian/slapd.dirs: add etc/apparmor.d/force-complain
  - debian/slapd.preinst: create symlink for force-complain on pre-feisty
    upgrades, upgrades where apparmor-profiles profile is unchanged (ie
    non-enforcing) and upgrades where apparmor profile does not exist.
  - debian/slapd.postrm: remove symlink in force-complain/ on purge
  - debian/patches/fix-ucred-libc due to changes how newer glibc handle
    the ucred struct now.
  - debian/control:
    - Build-depend on libltdl7-dev rather then libltdl3-dev.
  - debian/patches/autogen.sh:
    - Call libtoolize with the --install option to install config.{guess,sub}
      files.
  - Don't use local statement in config script as it fails if /bin/sh
    points to bash (LP: #286063).
  - Disable the testsuite on hppa. Allows building of packages on this
    architecture again, once this package is in the archive.
    LP: #288908.
  - debian/slapd.postinst, debian/slapd.script-common: set correct ownership
    and permissions on /var/lib/ldap, /etc/ldap/slapd.d (group readable) and
    /var/run/slapd (world readable). (LP: #257667).
  - debian/patches/nssov-build, debian/rules: 
    Build and package the nss overlay.
    debian/schema/misc.ldif: add ldif file for the misc schema, which defines
    rfc822MailMember (required by the nss overlay).
  - debian/{control,rules}: enable PIE hardening
  - Use cn=config as the default configuration backend instead of 
    slapd.conf. Migrate slapd.conf  file to /etc/ldap/slapd.d/ on upgrade
    asking the end user to enter a new password to control the access to the
    cn=config tree.
* debian/patches/corrupt-contextCSN: The contextCSN can get corrupted at
  times. (ITS: #5947)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* init.c - initialize bdb backend */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/init.c,v 1.247.2.11 2008/02/11 23:26:45 kurt Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/init.c,v 1.247.2.17 2009/01/22 00:01:05 kurt Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
 
 * Copyright 2000-2008 The OpenLDAP Foundation.
 
5
 * Copyright 2000-2009 The OpenLDAP Foundation.
6
6
 * All rights reserved.
7
7
 *
8
8
 * Redistribution and use in source and binary forms, with or without
61
61
 
62
62
        /* DBEnv parameters */
63
63
        bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
64
 
        bdb->bi_dbenv_xflags = 0;
 
64
        bdb->bi_dbenv_xflags = DB_TIME_NOTGRANTED;
65
65
        bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
66
66
 
67
67
        bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
168
168
                        be->be_suffix[0].bv_val, 0, 0 );
169
169
                return -1;
170
170
        }
 
171
        if ( rc == ALOCK_CLEAN )
 
172
                be->be_flags |= SLAP_DBFLAG_CLEAN;
171
173
 
172
174
        /*
173
175
         * The DB_CONFIG file may have changed. If so, recover the
416
418
                        }
417
419
                }
418
420
 
 
421
                if( bdb->bi_flags & BDB_CHKSUM ) {
 
422
                        rc = db->bdi_db->set_flags( db->bdi_db, DB_CHKSUM );
 
423
                        if ( rc ) {
 
424
                                snprintf(cr->msg, sizeof(cr->msg),
 
425
                                        "database \"%s\": db set_flags(DB_CHKSUM)(%s) failed: %s (%d).",
 
426
                                        be->be_suffix[0].bv_val, 
 
427
                                        bdb->bi_dbenv_home, db_strerror(rc), rc );
 
428
                                Debug( LDAP_DEBUG_ANY,
 
429
                                        LDAP_XSTRING(bdb_db_open) ": %s\n",
 
430
                                        cr->msg, 0, 0 );
 
431
                                goto fail;
 
432
                        }
 
433
                }
 
434
 
 
435
                rc = bdb_db_findsize( bdb, (struct berval *)&bdbi_databases[i].name );
 
436
 
419
437
                if( i == BDB_ID2ENTRY ) {
 
438
                        if ( !rc ) rc = BDB_ID2ENTRY_PAGESIZE;
 
439
                        rc = db->bdi_db->set_pagesize( db->bdi_db, rc );
 
440
 
420
441
                        if ( slapMode & SLAP_TOOL_MODE )
421
442
                                db->bdi_db->mpf->set_priority( db->bdi_db->mpf,
422
443
                                        DB_PRIORITY_VERY_LOW );
423
444
 
424
 
                        rc = db->bdi_db->set_pagesize( db->bdi_db,
425
 
                                BDB_ID2ENTRY_PAGESIZE );
426
445
                        if ( slapMode & SLAP_TOOL_READMAIN ) {
427
446
                                flags |= DB_RDONLY;
428
447
                        } else {
429
448
                                flags |= DB_CREATE;
430
449
                        }
431
450
                } else {
 
451
                        /* Use FS default size if not configured */
 
452
                        if ( rc )
 
453
                                rc = db->bdi_db->set_pagesize( db->bdi_db, rc );
 
454
 
432
455
                        rc = db->bdi_db->set_flags( db->bdi_db, 
433
456
                                DB_DUP | DB_DUPSORT );
434
457
#ifndef BDB_HIER
446
469
                                flags |= DB_CREATE;
447
470
                        }
448
471
#endif
449
 
                        rc = db->bdi_db->set_pagesize( db->bdi_db,
450
 
                                BDB_PAGESIZE );
451
472
                }
452
473
 
453
474
#ifdef HAVE_EBCDIC
503
524
        }
504
525
 
505
526
        if ( !quick ) {
506
 
#if DB_VERSION_FULL >= 0x04060012
507
 
                u_int32_t lid;
508
 
                XLOCK_ID(bdb->bi_dbenv, &lid);
509
 
                __lock_getlocker(bdb->bi_dbenv->lk_handle, lid, 0, &bdb->bi_cache.c_locker);
510
 
#else
511
 
                XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
512
 
#endif
 
527
                TXN_BEGIN(bdb->bi_dbenv, NULL, &bdb->bi_cache.c_txn, DB_READ_COMMITTED | DB_TXN_NOWAIT);
513
528
        }
514
529
 
515
530
        entry_prealloc( bdb->bi_cache.c_maxsize );
517
532
 
518
533
        /* setup for empty-DN contexts */
519
534
        if ( BER_BVISEMPTY( &be->be_nsuffix[0] )) {
520
 
                rc = bdb_id2entry( be, NULL, 0, 0, &e );
 
535
                rc = bdb_id2entry( be, NULL, 0, &e );
521
536
        }
522
537
        if ( !e ) {
523
538
                e = entry_alloc();
569
584
        ber_bvarray_free( bdb->bi_db_config );
570
585
        bdb->bi_db_config = NULL;
571
586
 
 
587
        if( bdb->bi_dbenv ) {
 
588
                /* Free cache locker if we enabled locking.
 
589
                 * TXNs must all be closed before DBs...
 
590
                 */
 
591
                if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_cache.c_txn ) {
 
592
                        TXN_ABORT( bdb->bi_cache.c_txn );
 
593
                        bdb->bi_cache.c_txn = NULL;
 
594
                }
 
595
                bdb_reader_flush( bdb->bi_dbenv );
 
596
        }
 
597
 
572
598
        while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
573
599
                db = bdb->bi_databases[bdb->bi_ndatabases];
574
600
                rc = db->bdi_db->close( db->bdi_db, 0 );
599
625
 
600
626
        /* close db environment */
601
627
        if( bdb->bi_dbenv ) {
602
 
                /* Free cache locker if we enabled locking */
603
 
                if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_cache.c_locker ) {
604
 
#if DB_VERSION_FULL >= 0x04060012
605
 
                        XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker->id);
606
 
#else
607
 
                        XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
608
 
#endif
609
 
                        bdb->bi_cache.c_locker = 0;
610
 
                }
611
 
#ifdef BDB_REUSE_LOCKERS
612
 
                bdb_locker_flush( bdb->bi_dbenv );
613
 
#endif
614
628
                /* force a checkpoint, but not if we were ReadOnly,
615
629
                 * and not in Quick mode since there are no transactions there.
616
630
                 */
651
665
{
652
666
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
653
667
 
 
668
        /* stop and remove checkpoint task */
 
669
        if ( bdb->bi_txn_cp_task ) {
 
670
                struct re_s *re = bdb->bi_txn_cp_task;
 
671
                bdb->bi_txn_cp_task = NULL;
 
672
                ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
 
673
                if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ) )
 
674
                        ldap_pvt_runqueue_stoptask( &slapd_rq, re );
 
675
                ldap_pvt_runqueue_remove( &slapd_rq, re );
 
676
                ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
 
677
        }
 
678
 
654
679
        /* monitor handling */
655
680
        (void)bdb_monitor_db_destroy( be );
656
681
 
745
770
        db_env_set_func_free( ber_memfree );
746
771
        db_env_set_func_malloc( (db_malloc *)ber_memalloc );
747
772
        db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
748
 
#ifndef NO_THREAD
 
773
#if !defined(NO_THREAD) && DB_VERSION_FULL <= 0x04070000
749
774
        /* This is a no-op on a NO_THREAD build. Leave the default
750
775
         * alone so that BDB will sleep on interprocess conflicts.
 
776
         * Don't bother on BDB 4.7...
751
777
         */
752
778
        db_env_set_func_yield( ldap_pvt_thread_yield );
753
779
#endif