~ubuntu-branches/ubuntu/oneiric/openldap/oneiric

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-05-08 16:34:09 UTC
  • mfrom: (1.1.8 upstream) (0.3.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110508163409-yjop2tgwy54fi0tm
Tags: 2.4.25-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Install a default DIT (LP: #442498).
  - Document cn=config in README file (LP: #370784).
  - remaining changes:
    + AppArmor support:
      - debian/apparmor-profile: add AppArmor profile
      - use dh_apparmor:
        - debian/rules: use dh_apparmor
        - debian/control: Build-Depends on debhelper 7.4.20ubuntu5
      - updated debian/slapd.README.Debian for note on AppArmor
      - debian/slapd.dirs: add etc/apparmor.d/force-complain
    + Enable GSSAPI support (LP: #495418):
      - debian/patches/gssapi.diff, thanks to Jerry Carter (Likewise):
        - Add --with-gssapi support
        - Make guess_service_principal() more robust when determining
          principal
      - debian/patches/series: apply gssapi.diff patch.
      - debian/configure.options: Configure with --with-gssapi
      - debian/control: Added libkrb5-dev as a build depend
    + debian/rules: Enable -DLDAP_CONNECTIONLESS to build CLDAP (UDP) support
      in the openldap library, as required by Likewise-Open (LP: #390579)
    + Don't build smbk5pwd overlay since it uses heimdal instead of krb5:
      - debian/control: 
        - remove build-dependency on heimdal-dev.
        - remove slapd-smbk5pwd binary package.
      - debian/rules: don't build smbk5pwd slapd module.
    + debian/{control,rules}: enable PIE hardening
    + ufw support (LP: #423246):
      - debian/control: suggest ufw.
      - debian/rules: install ufw profile.
      - debian/slapd.ufw.profile: add ufw profile.
    + Enable nssoverlay:
      - debian/patches/nssov-build, debian/series, debian/rules: 
        Apply, build and package the nss overlay.
      - debian/schema/extra/misc.ldif: add ldif file for the misc schema
        which defines rfc822MailMember (required by the nss overlay).
    + debian/rules, debian/schema/extra/: 
      Fix configure rule to supports extra schemas shipped as part
      of the debian/schema/ directory.
    + debian/rules, debian/slapd.py: Add apport hook. (LP: #610544)
    + debian/slapd.init.ldif: don't set olcRootDN since it's not defined in
      neither the default DIT nor via an Authn mapping.
    + debian/slapd.scripts-common: adjust minimum version that triggers a
      database upgrade. Upgrade from maverick shouldn't trigger database
      upgrade (which would happen with the version used in Debian).
    + debian/slapd.scripts-common: add slapcat_opts to local variables.
      Remove unused variable new_conf.
    + debian/slapd.script-common: Fix package reconfiguration.
      - Fix backup directory naming for multiple reconfiguration.
    + debian/slapd.default, debian/slapd.README.Debian: 
      use the new configuration style.
    + Install nss overlay (LP: #675391):
      - debian/rules: run install target for nssov module.
      - debian/patches/nssov-build: fix patch to install schema in /etc/ldap/schema
    + debian/patches/gssapi.diff:
      - Update patch so that likewise-open is usuable again. (LP: #661547)
    + debian/patches/service-operational-before-detach: New patch replacing old one
      of the same name as previous could cause database corruption based on upstream commits.
      (LP: #727973)
     + Dropped:
       - debian/patches/gold: Use the debian version instead
       - debian/patches/CVE-2011-1024: Fixed upstream
       - debian/patches/CVE-2011-1025: Fixed upstream
       - debian/patches/CVE-2011-1081: Fixed upstream 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* dn2id.c - routines to deal with the dn2id index */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/dn2id.c,v 1.137.2.23 2010/06/23 15:57:26 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/dn2id.c,v 1.137.2.26 2011/01/26 23:23:31 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
 
 * Copyright 2000-2010 The OpenLDAP Foundation.
 
5
 * Copyright 2000-2011 The OpenLDAP Foundation.
6
6
 * All rights reserved.
7
7
 *
8
8
 * Redistribution and use in source and binary forms, with or without
23
23
#include "idl.h"
24
24
#include "lutil.h"
25
25
 
26
 
#define bdb_dn2id_lock                                  BDB_SYMBOL(dn2id_lock)
27
 
 
28
 
static int
29
 
bdb_dn2id_lock( struct bdb_info *bdb, struct berval *dn,
30
 
        int rw, DB_TXN *txn, DB_LOCK *lock )
31
 
{
32
 
        int       rc;
33
 
        DBT       lockobj;
34
 
        int       db_rw;
35
 
 
36
 
        if (!txn)
37
 
                return 0;
38
 
 
39
 
        if (rw)
40
 
                db_rw = DB_LOCK_WRITE;
41
 
        else
42
 
                db_rw = DB_LOCK_READ;
43
 
 
44
 
        lockobj.data = dn->bv_val;
45
 
        lockobj.size = dn->bv_len;
46
 
 
47
 
        rc = LOCK_GET(bdb->bi_dbenv, TXN_ID(txn), DB_LOCK_NOWAIT,
48
 
                                        &lockobj, db_rw, lock);
49
 
        return rc;
50
 
}
51
 
 
52
26
#ifndef BDB_HIER
53
27
int
54
28
bdb_dn2id_add(
177
151
        DB *db = bdb->bi_dn2id->bdi_db;
178
152
        char            *buf;
179
153
        DBT             key;
180
 
        DB_LOCK lock;
181
154
        struct berval   pdn, ptr;
182
155
        int             rc;
183
156
 
195
168
        AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
196
169
        ptr.bv_val[ptr.bv_len] = '\0';
197
170
 
198
 
        /* We hold this lock until the TXN completes */
199
 
        rc = bdb_dn2id_lock( bdb, &e->e_nname, 1, txn, &lock );
200
 
        if ( rc ) goto done;
201
 
 
202
171
        /* delete it */
203
172
        rc = db->del( db, txn, &key, 0 );
204
173
        if( rc != 0 ) {
281
250
        struct berval   *dn,
282
251
        EntryInfo *ei,
283
252
        DB_TXN *txn,
284
 
        DB_LOCK *lock )
 
253
        DBC **cursor )
285
254
{
286
255
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
287
256
        DB *db = bdb->bi_dn2id->bdi_db;
288
 
        DBC     *cursor;
289
257
        int             rc;
290
258
        DBT             key, data;
291
259
        ID              nid;
304
272
        data.ulen = sizeof(ID);
305
273
        data.flags = DB_DBT_USERMEM;
306
274
 
307
 
        rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
308
 
        if ( rc ) goto func_leave;
309
 
 
310
 
        rc = bdb_dn2id_lock( bdb, dn, 0, txn, lock );
311
 
        if ( rc ) goto nolock;
 
275
        rc = db->cursor( db, txn, cursor, bdb->bi_db_opflags );
312
276
 
313
277
        /* fetch it */
314
 
        rc = cursor->c_get( cursor, &key, &data, DB_SET );
315
 
 
316
 
nolock:
317
 
        cursor->c_close( cursor );
318
 
func_leave:
 
278
        if ( !rc )
 
279
                rc = (*cursor)->c_get( *cursor, &key, &data, DB_SET );
319
280
 
320
281
        if( rc != 0 ) {
321
282
                Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n",
652
613
        int rc;
653
614
        ID      nid;
654
615
        unsigned char dlen[2];
655
 
        DB_LOCK lock;
656
616
 
657
617
        Debug( LDAP_DEBUG_TRACE, "=> hdb_dn2id_delete 0x%lx: \"%s\"\n",
658
618
                e->e_id, e->e_ndn, 0 );
682
642
        rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
683
643
        if ( rc ) goto func_leave;
684
644
 
685
 
        /* We hold this lock until the TXN completes */
686
 
        rc = bdb_dn2id_lock( bdb, &e->e_nname, 1, txn, &lock );
687
 
        if ( rc ) goto nolock;
688
 
 
689
645
        /* Delete our ID from the parent's list */
690
646
        rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE );
691
647
        if ( rc == 0 ) {
707
663
                        rc = cursor->c_del( cursor, 0 );
708
664
        }
709
665
 
710
 
nolock:
711
666
        cursor->c_close( cursor );
712
667
func_leave:
713
668
        op->o_tmpfree( d, op->o_tmpmemctx );
745
700
        struct berval   *in,
746
701
        EntryInfo       *ei,
747
702
        DB_TXN *txn,
748
 
        DB_LOCK *lock )
 
703
        DBC **cursor )
749
704
{
750
705
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
751
706
        DB *db = bdb->bi_dn2id->bdi_db;
752
707
        DBT             key, data;
753
 
        DBC     *cursor;
754
708
        int             rc = 0, nrlen;
755
709
        diskNode *d;
756
710
        char    *ptr;
776
730
        data.dlen = data.ulen;
777
731
        data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
778
732
 
779
 
        rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
 
733
        rc = db->cursor( db, txn, cursor, bdb->bi_db_opflags );
780
734
        if ( rc ) return rc;
781
735
 
782
736
        d = op->o_tmpalloc( data.size * 3, op->o_tmpmemctx );
788
742
        *ptr = '\0';
789
743
        data.data = d;
790
744
 
791
 
        rc = bdb_dn2id_lock( bdb, in, 0, txn, lock );
792
 
        if ( rc ) goto func_leave;
793
 
 
794
 
        rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE );
 
745
        rc = (*cursor)->c_get( *cursor, &key, &data, DB_GET_BOTH_RANGE );
795
746
        if ( rc == 0 && (dlen[1] != d->nrdnlen[1] || dlen[0] != d->nrdnlen[0] ||
796
747
                strncmp( d->nrdn, in->bv_val, nrlen ))) {
797
748
                rc = DB_NOTFOUND;
808
759
                        /* FIXME: do we need to lock the parent
809
760
                         * entryinfo? Seems safe...
810
761
                         */
811
 
                        cursor->c_count( cursor, &dkids, 0 );
 
762
                        (*cursor)->c_count( *cursor, &dkids, 0 );
812
763
                        ei->bei_parent->bei_dkids = dkids;
813
764
                }
814
765
        }
815
766
 
816
 
func_leave:
817
 
        cursor->c_close( cursor );
818
767
        op->o_tmpfree( d, op->o_tmpmemctx );
819
768
        if( rc != 0 ) {
820
769
                Debug( LDAP_DEBUG_TRACE, "<= hdb_dn2id: get failed: %s (%d)\n",