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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-02-18 18:44:00 UTC
  • mfrom: (0.1.1 upstream)
  • mto: (0.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20090218184400-xmj1e22xo7i50ar6
Tags: upstream-2.4.14
ImportĀ upstreamĀ versionĀ 2.4.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* add.c - ldap BerkeleyDB back-end add routine */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/add.c,v 1.152.2.10 2008/05/01 21:39:35 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/add.c,v 1.152.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
32
32
        size_t textlen = sizeof textbuf;
33
33
        AttributeDescription *children = slap_schema.si_ad_children;
34
34
        AttributeDescription *entry = slap_schema.si_ad_entry;
35
 
        DB_TXN          *ltid = NULL, *lt2;
 
35
        DB_TXN          *ltid = NULL, *lt2, *rtxn;
36
36
        ID eid = NOID;
37
 
        struct bdb_op_info opinfo = {0};
 
37
        struct bdb_op_info opinfo = {{{ 0 }}};
38
38
        int subentry;
39
 
        BDB_LOCKER      locker = 0, rlocker = 0;
40
39
        DB_LOCK         lock;
41
40
 
42
41
        int             num_retries = 0;
95
94
 
96
95
        /* check entry's schema */
97
96
        rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL,
98
 
                get_relax(op), 1, &rs->sr_text, textbuf, textlen );
 
97
                get_relax(op), 1, NULL, &rs->sr_text, textbuf, textlen );
99
98
        if ( rs->sr_err != LDAP_SUCCESS ) {
100
99
                Debug( LDAP_DEBUG_TRACE,
101
100
                        LDAP_XSTRING(bdb_add) ": entry failed schema check: "
113
112
                goto return_results;
114
113
        }
115
114
 
 
115
        if ( get_assert( op ) &&
 
116
                ( test_filter( op, op->ora_e, get_assertion( op )) != LDAP_COMPARE_TRUE ))
 
117
        {
 
118
                rs->sr_err = LDAP_ASSERTION_FAILED;
 
119
                goto return_results;
 
120
        }
 
121
 
116
122
        subentry = is_entry_subentry( op->oq_add.rs_e );
117
123
 
118
 
        /* Get our thread locker ID */
119
 
        rs->sr_err = LOCK_ID( bdb->bi_dbenv, &rlocker );
 
124
        /* Get our reader TXN */
 
125
        rs->sr_err = bdb_reader_get( op, bdb->bi_dbenv, &rtxn );
120
126
 
121
127
        if( 0 ) {
122
128
retry:  /* transaction retry */
157
163
                goto return_results;
158
164
        }
159
165
 
160
 
        locker = TXN_ID ( ltid );
161
 
 
162
166
        opinfo.boi_oe.oe_key = bdb;
163
167
        opinfo.boi_txn = ltid;
164
168
        opinfo.boi_err = 0;
176
180
 
177
181
        /* get entry or parent */
178
182
        rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei,
179
 
                1, locker, &lock );
 
183
                1, &lock );
180
184
        switch( rs->sr_err ) {
181
185
        case 0:
182
186
                rs->sr_err = LDAP_ALREADY_EXISTS;
302
306
                goto return_results;;
303
307
        }
304
308
 
 
309
        /* 
 
310
         * Check ACL for attribute write access
 
311
         */
 
312
        if (!acl_check_modlist(op, oe, op->ora_modlist)) {
 
313
                switch( opinfo.boi_err ) {
 
314
                case DB_LOCK_DEADLOCK:
 
315
                case DB_LOCK_NOTGRANTED:
 
316
                        goto retry;
 
317
                }
 
318
 
 
319
                Debug( LDAP_DEBUG_TRACE,
 
320
                        LDAP_XSTRING(bdb_add) ": no write access to attribute\n",
 
321
                        0, 0, 0 );
 
322
                rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 
323
                rs->sr_text = "no write access to attribute";
 
324
                goto return_results;;
 
325
        }
 
326
 
305
327
        if ( eid == NOID ) {
306
328
                rs->sr_err = bdb_next_id( op->o_bd, &eid );
307
329
                if( rs->sr_err != 0 ) {
428
450
                        nrdn = op->ora_e->e_nname;
429
451
                }
430
452
 
431
 
                /* Use the thread locker here, outside the txn */
432
 
                bdb_cache_add( bdb, ei, op->ora_e, &nrdn, rlocker, &lock );
 
453
                /* Use the reader txn here, outside the add txn */
 
454
                bdb_cache_add( bdb, ei, op->ora_e, &nrdn, rtxn, &lock );
433
455
 
434
456
                if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
435
457
                        rs->sr_text = "txn_commit failed";