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

« back to all changes in this revision

Viewing changes to servers/slapd/back-bdb/modify.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
/* modify.c - bdb backend modify routine */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/modify.c,v 1.156.2.11 2008/05/01 21:39:35 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/modify.c,v 1.156.2.16 2009/02/05 19:35:54 quanah 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
27
27
        BER_BVNULL
28
28
};
29
29
 
 
30
static void
 
31
bdb_modify_idxflags(
 
32
        Operation *op,
 
33
        AttributeDescription *desc,
 
34
        int got_delete,
 
35
        Attribute *newattrs,
 
36
        Attribute *oldattrs )
 
37
{
 
38
        struct berval   ix_at;
 
39
        AttrInfo        *ai;
 
40
 
 
41
        /* check if modified attribute was indexed
 
42
         * but not in case of NOOP... */
 
43
        ai = bdb_index_mask( op->o_bd, desc, &ix_at );
 
44
        if ( ai ) {
 
45
                if ( got_delete ) {
 
46
                        Attribute       *ap;
 
47
                        struct berval   ix2;
 
48
 
 
49
                        ap = attr_find( oldattrs, desc );
 
50
                        if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
 
51
 
 
52
                        /* Find all other attrs that index to same slot */
 
53
                        for ( ap = newattrs; ap; ap = ap->a_next ) {
 
54
                                ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 );
 
55
                                if ( ai && ix2.bv_val == ix_at.bv_val )
 
56
                                        ap->a_flags |= SLAP_ATTR_IXADD;
 
57
                        }
 
58
 
 
59
                } else {
 
60
                        Attribute       *ap;
 
61
 
 
62
                        ap = attr_find( newattrs, desc );
 
63
                        if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
 
64
                }
 
65
        }
 
66
}
 
67
 
30
68
int bdb_modify_internal(
31
69
        Operation *op,
32
70
        DB_TXN *tid,
43
81
        Attribute       *ap;
44
82
        int                     glue_attr_delete = 0;
45
83
        int                     got_delete;
46
 
        AttrInfo *ai;
47
84
 
48
85
        Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n",
49
86
                e->e_id, e->e_dn, 0);
89
126
        }
90
127
 
91
128
        for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
92
 
                struct berval ix_at;
93
129
                mod = &ml->sml_mod;
94
130
                got_delete = 0;
95
131
 
202
238
 
203
239
                if ( glue_attr_delete ) e->e_ocflags = 0;
204
240
 
 
241
 
205
242
                /* check if modified attribute was indexed
206
243
                 * but not in case of NOOP... */
207
 
                ai = bdb_index_mask( op->o_bd, mod->sm_desc, &ix_at );
208
 
                if ( ai && !op->o_noop ) {
209
 
                        if ( got_delete ) {
210
 
                                struct berval ix2;
211
 
 
212
 
                                ap = attr_find( save_attrs, mod->sm_desc );
213
 
                                if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
214
 
 
215
 
                                /* Find all other attrs that index to same slot */
216
 
                                for ( ap = e->e_attrs; ap; ap=ap->a_next ) {
217
 
                                        ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 );
218
 
                                        if ( ai && ix2.bv_val == ix_at.bv_val )
219
 
                                                ap->a_flags |= SLAP_ATTR_IXADD;
220
 
                                }
221
 
                        } else {
222
 
                                ap = attr_find( e->e_attrs, mod->sm_desc );
223
 
                                if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
224
 
                        }
 
244
                if ( !op->o_noop ) {
 
245
                        bdb_modify_idxflags( op, mod->sm_desc, got_delete, e->e_attrs, save_attrs );
225
246
                }
226
247
        }
227
248
 
228
249
        /* check that the entry still obeys the schema */
229
 
        rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0,
 
250
        ap = NULL;
 
251
        rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0, &ap,
230
252
                text, textbuf, textlen );
231
253
        if ( rc != LDAP_SUCCESS || op->o_noop ) {
232
254
                attrs_free( e->e_attrs );
246
268
                return rc;
247
269
        }
248
270
 
 
271
        /* structuralObjectClass modified! */
 
272
        if ( ap ) {
 
273
                assert( ap->a_desc == slap_schema.si_ad_structuralObjectClass );
 
274
                if ( !op->o_noop ) {
 
275
                        bdb_modify_idxflags( op, slap_schema.si_ad_structuralObjectClass,
 
276
                                1, e->e_attrs, save_attrs );
 
277
                }
 
278
        }
 
279
 
249
280
        /* update the indices of the modified attributes */
250
281
 
251
282
        /* start with deleting the old index entries */
287
318
                                rc = bdb_index_values( op, tid, ap->a_desc,
288
319
                                        vals, e->e_id, SLAP_INDEX_DELETE_OP );
289
320
                                if ( rc != LDAP_SUCCESS ) {
 
321
                                        Debug( LDAP_DEBUG_ANY,
 
322
                                                "%s: attribute \"%s\" index delete failure\n",
 
323
                                                op->o_log_prefix, ap->a_desc->ad_cname.bv_val, 0 );
290
324
                                        attrs_free( e->e_attrs );
291
325
                                        e->e_attrs = save_attrs;
292
 
                                        Debug( LDAP_DEBUG_ANY,
293
 
                                                   "Attribute index delete failure",
294
 
                                                   0, 0, 0 );
295
326
                                        return rc;
296
327
                                }
297
328
                        }
306
337
                                ap->a_nvals,
307
338
                                e->e_id, SLAP_INDEX_ADD_OP );
308
339
                        if ( rc != LDAP_SUCCESS ) {
 
340
                                Debug( LDAP_DEBUG_ANY,
 
341
                                       "%s: attribute \"%s\" index add failure\n",
 
342
                                        op->o_log_prefix, ap->a_desc->ad_cname.bv_val, 0 );
309
343
                                attrs_free( e->e_attrs );
310
344
                                e->e_attrs = save_attrs;
311
 
                                Debug( LDAP_DEBUG_ANY,
312
 
                                       "Attribute index add failure",
313
 
                                       0, 0, 0 );
314
345
                                return rc;
315
346
                        }
316
347
                }
330
361
        char textbuf[SLAP_TEXT_BUFLEN];
331
362
        size_t textlen = sizeof textbuf;
332
363
        DB_TXN  *ltid = NULL, *lt2;
333
 
        struct bdb_op_info opinfo = {0};
 
364
        struct bdb_op_info opinfo = {{{ 0 }}};
334
365
        Entry           dummy = {0};
335
366
        int                     fakeroot = 0;
336
367
 
337
 
        BDB_LOCKER      locker = 0;
338
368
        DB_LOCK         lock;
339
369
 
340
370
        int             num_retries = 0;
438
468
                goto return_results;
439
469
        }
440
470
 
441
 
        locker = TXN_ID ( ltid );
442
 
 
443
471
        opinfo.boi_oe.oe_key = bdb;
444
472
        opinfo.boi_txn = ltid;
445
473
        opinfo.boi_err = 0;
448
476
 
449
477
        /* get entry or ancestor */
450
478
        rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
451
 
                locker, &lock );
 
479
                &lock );
452
480
 
453
481
        if ( rs->sr_err != 0 ) {
454
482
                Debug( LDAP_DEBUG_TRACE,
655
683
                        attrs_free( dummy.e_attrs );
656
684
 
657
685
                } else {
658
 
                        rc = bdb_cache_modify( bdb, e, dummy.e_attrs, locker, &lock );
 
686
                        rc = bdb_cache_modify( bdb, e, dummy.e_attrs, ltid, &lock );
659
687
                        switch( rc ) {
660
688
                        case DB_LOCK_DEADLOCK:
661
689
                        case DB_LOCK_NOTGRANTED: