~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to contrib/slapd-modules/autogroup/autogroup.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-09-07 13:41:10 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090907134110-rsnlhy8b0r21p9bg
Tags: 2.4.18-0ubuntu1
* New upstream release: (LP: #419515):
  + pcache overlay supports disconnected mode.
* Fix nss overlay load (LP: #417163).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* autogroup.c - automatic group overlay */
2
 
/* $OpenLDAP: pkg/ldap/contrib/slapd-modules/autogroup/autogroup.c,v 1.2.2.2 2008/11/10 19:57:30 quanah Exp $ */
3
 
/*
4
 
 * Copyright 2007 Michał Szulczyński.
 
2
/* $OpenLDAP: pkg/ldap/contrib/slapd-modules/autogroup/autogroup.c,v 1.2.2.4 2009/08/17 21:48:56 quanah Exp $ */
 
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 
4
 *
 
5
 * Copyright 2007-2009 The OpenLDAP Foundation.
 
6
 * Portions Copyright 2007 Michał Szulczyński.
 
7
 * Portions Copyright 2009 Howard Chu.
5
8
 * All rights reserved.
6
9
 *
7
10
 * Redistribution and use in source and binary forms, with or without
12
15
 * top-level directory of the distribution or, alternatively, at
13
16
 * <http://www.OpenLDAP.org/license.html>.
14
17
 */
 
18
/* ACKNOWLEDGEMENTS:
 
19
 * This work was initially developed by Michał Szulczyński for inclusion in
 
20
 * OpenLDAP Software.  Additional significant contributors include:
 
21
 *   Howard Chu
 
22
 */
15
23
 
16
24
#include "portable.h"
17
25
 
238
246
static int
239
247
autogroup_member_search_modify_cb( Operation *op, SlapReply *rs )
240
248
{
241
 
        slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;
242
 
 
243
249
        assert( op->o_tag == LDAP_REQ_SEARCH );
244
250
 
245
251
        if ( rs->sr_type == REP_SEARCH ) {
246
252
                autogroup_ga_t          *agg = (autogroup_ga_t *)op->o_callback->sc_private;
247
253
                autogroup_entry_t       *age = agg->agg_group;
248
 
                Operation               o = *op;
249
254
                Modifications           *modlist;
250
 
                SlapReply               sreply = {REP_RESULT};
251
 
                const char              *text = NULL;
252
 
                char                    textbuf[1024];
253
255
                struct berval           vals[ 2 ], nvals[ 2 ];
254
 
                slap_callback           cb = { NULL, slap_null_cb, NULL, NULL };
255
256
 
256
257
                Debug(LDAP_DEBUG_TRACE, "==> autogroup_member_search_modify_cb <%s>\n",
257
258
                        rs->sr_entry ? rs->sr_entry->e_name.bv_val : "UNKNOWN_DN", 0, 0);
508
509
static int
509
510
autogroup_group_add_cb( Operation *op, SlapReply *rs )
510
511
{
511
 
        slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;
512
 
 
513
512
        assert( op->o_tag == LDAP_REQ_SEARCH );
514
513
 
515
 
 
516
514
        if ( rs->sr_type == REP_SEARCH ) {
517
515
                autogroup_sc_t          *ags = (autogroup_sc_t *)op->o_callback->sc_private;
518
516
 
538
536
        autogroup_def_t         *agd = agi->agi_def;
539
537
        autogroup_entry_t       *age = agi->agi_entry;
540
538
        autogroup_filter_t      *agf;
541
 
        Attribute               *a;
542
539
        int                     rc = 0;
543
540
 
544
541
        Debug( LDAP_DEBUG_TRACE, "==> autogroup_add_entry <%s>\n", 
652
649
{
653
650
        slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;
654
651
        autogroup_info_t                *agi = (autogroup_info_t *)on->on_bi.bi_private;
655
 
        autogroup_def_t         *agd = agi->agi_def;
656
652
        autogroup_entry_t       *age = agi->agi_entry,
657
653
                                *age_prev, *age_next;
658
654
        autogroup_filter_t      *agf;
683
679
                        dnMatch( &match, 0, NULL, NULL, &e->e_nname, &age->age_ndn );
684
680
 
685
681
                        if ( match == 0 ) {
686
 
                                autogroup_filter_t      *agf = age->age_filter,
687
 
                                                        *agf_next;
688
 
 
689
682
                                autogroup_delete_group( agi, age );
690
683
                                break;
691
684
                        }
1266
1259
                        autogroup_entry_t       *age_next, *age_prev;
1267
1260
                        autogroup_filter_t      *agf,
1268
1261
                                                *agf_next;
1269
 
                        struct berval           *bv;
1270
1262
 
1271
1263
                        ldap_pvt_thread_mutex_lock( &agi->agi_mutex );
1272
1264
 
1446
1438
        BackendDB       *be,
1447
1439
        ConfigReply     *cr )
1448
1440
{
1449
 
        slap_overinst                   *on = (slap_overinst *) be->bd_info,
1450
 
                                *on_bd;
 
1441
        slap_overinst                   *on = (slap_overinst *) be->bd_info;
1451
1442
        autogroup_info_t                *agi = on->on_bi.bi_private;
1452
1443
        autogroup_def_t         *agd;
1453
1444
        autogroup_sc_t          ags;
1458
1449
        void                            *thrctx = ldap_pvt_thread_pool_context();
1459
1450
        Connection                      conn = { 0 };
1460
1451
        OperationBuffer         opbuf;
1461
 
        BerValue                bv;
1462
 
        char                    *ptr;
1463
 
        int                     rc = 0;
1464
1452
 
1465
1453
        Debug( LDAP_DEBUG_TRACE, "==> autogroup_db_open\n", 0, 0, 0);
1466
1454
 
1482
1470
        op->ors_slimit = SLAP_NO_LIMIT;
1483
1471
        op->ors_attrs =  slap_anlist_no_attrs;
1484
1472
 
1485
 
        op->o_bd = select_backend(&op->o_req_ndn, 0);
1486
 
 
1487
 
        ldap_pvt_thread_mutex_lock( &agi->agi_mutex );
 
1473
        op->o_bd = be;
 
1474
        op->o_bd->bd_info = (BackendInfo *)on->on_info;
 
1475
 
 
1476
        ags.ags_info = agi;
 
1477
        cb.sc_private = &ags;
 
1478
        cb.sc_response = autogroup_group_add_cb;
 
1479
        cb.sc_cleanup = NULL;
 
1480
        cb.sc_next = NULL;
 
1481
 
 
1482
        op->o_callback = &cb;
 
1483
 
1488
1484
        for (agd = agi->agi_def ; agd ; agd = agd->agd_next) {
1489
1485
 
1490
1486
                autogroup_build_def_filter(agd, op);
1491
1487
 
1492
 
 
1493
 
                ags.ags_info = agi;
1494
1488
                ags.ags_def = agd;
1495
 
                cb.sc_private = &ags;
1496
 
                cb.sc_response = autogroup_group_add_cb;
1497
 
                cb.sc_cleanup = NULL;
1498
 
                cb.sc_next = NULL;
1499
 
 
1500
 
                op->o_callback = &cb;
1501
 
 
1502
 
                op->o_bd->bd_info = (BackendInfo *)on->on_info;
 
1489
 
1503
1490
                op->o_bd->be_search( op, &rs );
1504
 
                op->o_bd->bd_info = (BackendInfo *)on;
1505
1491
 
1506
1492
                filter_free_x( op, op->ors_filter, 1 );
1507
1493
                op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
1508
1494
        }               
1509
 
        ldap_pvt_thread_mutex_unlock( &agi->agi_mutex );
1510
1495
 
1511
1496
        return 0;
1512
1497
}