~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to servers/slapd/overlays/accesslog.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek, Updated debconf translations
  • Date: 2009-07-28 10:17:15 UTC
  • mfrom: (1.1.4 upstream) (0.2.2 sid)
  • mto: (0.2.4 sid)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20090728101715-epwmqmsk0d3h22k3
* New upstream version.
  - Fixes FTBFS on ia64 with -fPIE. Closes: #524770.
  - Fixes some TLS issues with GnuTLS.  Closes: #505191.
* Update priority of libldap-2.4-2 to match the archive override.
* Add the missing ldapexop and ldapurl tools to ldap-utils, as well as the
  ldapurl(1) manpage.  Thanks to Peter Marschall for the patch.
  Closes: #496749.
* Bump build-dependency on debhelper to 6 instead of 5, since that's
  what we're using.  Closes: #498116.
* Set the default SLAPD_SERVICES to ldap:/// ldapi:///, instead of using
  the built-in default of ldap:/// only.
* Build-depend on libltdl-dev | libltdl3-dev (>= 1.4.3), for the package
  name change.  Closes: #522965.

[ Updated debconf translations ]
* Spanish, thanks to Francisco Javier Cuadrado <fcocuadrado@gmail.com>.
  Closes: #521804.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* accesslog.c - log operations for audit/history purposes */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/accesslog.c,v 1.37.2.17 2008/05/01 20:37:48 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/accesslog.c,v 1.37.2.23 2009/03/05 18:26:47 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
 
 * Copyright 2005-2008 The OpenLDAP Foundation.
 
5
 * Copyright 2005-2009 The OpenLDAP Foundation.
6
6
 * Portions copyright 2004-2005 Symas Corporation.
7
7
 * All rights reserved.
8
8
 *
534
534
 
535
535
        if ( dd ) {
536
536
                len = snprintf( ptr, size, "%d+", dd );
537
 
                assert( len >= 0 && len < size );
 
537
                assert( len >= 0 && (unsigned) len < size );
538
538
                size -= len;
539
539
                ptr += len;
540
540
        }
541
541
        len = snprintf( ptr, size, "%02d:%02d", hh, mm );
542
 
        assert( len >= 0 && len < size );
 
542
        assert( len >= 0 && (unsigned) len < size );
543
543
        size -= len;
544
544
        ptr += len;
545
545
        if ( ss ) {
546
546
                len = snprintf( ptr, size, ":%02d", ss );
547
 
                assert( len >= 0 && len < size );
 
547
                assert( len >= 0 && (unsigned) len < size );
548
548
                size -= len;
549
549
                ptr += len;
550
550
        }
568
568
log_old_lookup( Operation *op, SlapReply *rs )
569
569
{
570
570
        purge_data *pd = op->o_callback->sc_private;
 
571
        Attribute *a;
571
572
 
572
573
        if ( rs->sr_type != REP_SEARCH) return 0;
573
574
 
574
575
        if ( slapd_shutdown ) return 0;
575
576
 
576
 
        /* Remember old CSN */
577
 
        if ( pd->csn.bv_val[0] == '\0' ) {
578
 
                Attribute *a = attr_find( rs->sr_entry->e_attrs,
579
 
                        slap_schema.si_ad_entryCSN );
580
 
                if ( a ) {
581
 
                        int len = a->a_vals[0].bv_len;
582
 
                        if ( len > pd->csn.bv_len )
583
 
                                len = pd->csn.bv_len;
 
577
        /* Remember max CSN: should always be the last entry
 
578
         * seen, since log entries are ordered chronologically...
 
579
         */
 
580
        a = attr_find( rs->sr_entry->e_attrs,
 
581
                slap_schema.si_ad_entryCSN );
 
582
        if ( a ) {
 
583
                ber_len_t len = a->a_vals[0].bv_len;
 
584
                if ( len > pd->csn.bv_len )
 
585
                        len = pd->csn.bv_len;
 
586
                if ( memcmp( a->a_vals[0].bv_val, pd->csn.bv_val, len ) > 0 ) {
584
587
                        AC_MEMCPY( pd->csn.bv_val, a->a_vals[0].bv_val, len );
585
588
                        pd->csn.bv_len = len;
586
589
                }
656
659
        if ( pd.used ) {
657
660
                int i;
658
661
 
 
662
                /* delete the expired entries */
659
663
                op->o_tag = LDAP_REQ_DELETE;
660
664
                op->o_callback = &nullsc;
661
665
                op->o_csn = pd.csn;
670
674
                }
671
675
                ch_free( pd.ndn );
672
676
                ch_free( pd.dn );
 
677
 
 
678
                {
 
679
                        Modifications mod;
 
680
                        struct berval bv[2];
 
681
                        /* update context's entryCSN to reflect oldest CSN */
 
682
                        mod.sml_numvals = 1;
 
683
                        mod.sml_values = bv;
 
684
                        bv[0] = pd.csn;
 
685
                        BER_BVZERO(&bv[1]);
 
686
                        mod.sml_nvalues = NULL;
 
687
                        mod.sml_desc = slap_schema.si_ad_entryCSN;
 
688
                        mod.sml_op = LDAP_MOD_REPLACE;
 
689
                        mod.sml_flags = SLAP_MOD_INTERNAL;
 
690
                        mod.sml_next = NULL;
 
691
 
 
692
                        op->o_tag = LDAP_REQ_MODIFY;
 
693
                        op->orm_modlist = &mod;
 
694
                        op->orm_no_opattrs = 1;
 
695
                        op->o_req_dn = li->li_db->be_suffix[0];
 
696
                        op->o_req_ndn = li->li_db->be_nsuffix[0];
 
697
                        op->o_no_schema_check = 1;
 
698
                        op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
 
699
                        op->o_bd->be_modify( op, &rs );
 
700
                        if ( mod.sml_next ) {
 
701
                                slap_mods_free( mod.sml_next, 1 );
 
702
                        }
 
703
                }
673
704
        }
674
705
 
675
706
        ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
902
933
        struct berval   *valp )
903
934
{
904
935
        struct berval   val, bv;
905
 
        int             i;
 
936
        ber_len_t               i;
906
937
        int             rc = LDAP_SUCCESS;
907
938
 
908
939
        assert( valp != NULL );
1124
1155
                }
1125
1156
                
1126
1157
                if ( !BER_BVISNULL( &ctrls[ i ]->ldctl_value ) ) {
1127
 
                        int     j;
 
1158
                        ber_len_t       j;
1128
1159
 
1129
1160
                        ptr = lutil_strcopy( ptr, " controlValue \"" );
1130
1161
                        for ( j = 0; j < ctrls[ i ]->ldctl_value.bv_len; j++ )
1369
1400
                attr_merge_one( e, ad_reqMessage, &bv, NULL );
1370
1401
        }
1371
1402
        bv.bv_len = snprintf( timebuf, sizeof( timebuf ), "%d", rs->sr_err );
1372
 
        if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
 
1403
        if ( bv.bv_len < sizeof( timebuf ) ) {
1373
1404
                bv.bv_val = timebuf;
1374
1405
                attr_merge_one( e, ad_reqResult, &bv, NULL );
1375
1406
        }
1520
1551
                                        i += a->a_numvals;
1521
1552
                                }
1522
1553
                        }
1523
 
                        vals = ch_malloc( (i + 1) * sizeof( struct berval ) );
1524
 
                        i = 0;
1525
 
                        for ( a=old->e_attrs; a; a=a->a_next ) {
1526
 
                                if ( a->a_vals && a->a_flags ) {
1527
 
                                        for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
1528
 
                                                accesslog_val2val( a->a_desc, b, 0, &vals[i] );
 
1554
                        if ( i ) {
 
1555
                                vals = ch_malloc( (i + 1) * sizeof( struct berval ) );
 
1556
                                i = 0;
 
1557
                                for ( a=old->e_attrs; a; a=a->a_next ) {
 
1558
                                        if ( a->a_vals && a->a_flags ) {
 
1559
                                                for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
 
1560
                                                        accesslog_val2val( a->a_desc, b, 0, &vals[i] );
 
1561
                                                }
1529
1562
                                        }
1530
1563
                                }
 
1564
                                vals[i].bv_val = NULL;
 
1565
                                vals[i].bv_len = 0;
 
1566
                                a = attr_alloc( ad_reqOld );
 
1567
                                a->a_numvals = i;
 
1568
                                a->a_vals = vals;
 
1569
                                a->a_nvals = vals;
 
1570
                                last_attr->a_next = a;
1531
1571
                        }
1532
 
                        vals[i].bv_val = NULL;
1533
 
                        vals[i].bv_len = 0;
1534
 
                        a = attr_alloc( ad_reqOld );
1535
 
                        a->a_numvals = i;
1536
 
                        a->a_vals = vals;
1537
 
                        a->a_nvals = vals;
1538
 
                        last_attr->a_next = a;
1539
1572
                }
1540
1573
                if ( logop == LOG_EN_MODIFY ) {
1541
1574
                        break;
1586
1619
                }
1587
1620
                bv.bv_val = timebuf;
1588
1621
                bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", rs->sr_nentries );
1589
 
                if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
 
1622
                if ( bv.bv_len < sizeof( timebuf ) ) {
1590
1623
                        attr_merge_one( e, ad_reqEntries, &bv, NULL );
1591
1624
                } /* else? */
1592
1625
 
1593
1626
                bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->ors_tlimit );
1594
 
                if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
 
1627
                if ( bv.bv_len < sizeof( timebuf ) ) {
1595
1628
                        attr_merge_one( e, ad_reqTimeLimit, &bv, NULL );
1596
1629
                } /* else? */
1597
1630
 
1598
1631
                bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->ors_slimit );
1599
 
                if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
 
1632
                if ( bv.bv_len < sizeof( timebuf ) ) {
1600
1633
                        attr_merge_one( e, ad_reqSizeLimit, &bv, NULL );
1601
1634
                } /* else? */
1602
1635
                break;
1604
1637
        case LOG_EN_BIND:
1605
1638
                bv.bv_val = timebuf;
1606
1639
                bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->o_protocol );
1607
 
                if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
 
1640
                if ( bv.bv_len < sizeof( timebuf ) ) {
1608
1641
                        attr_merge_one( e, ad_reqVersion, &bv, NULL );
1609
1642
                } /* else? */
1610
1643
                if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
1739
1772
                        int rc;
1740
1773
                        Entry *e;
1741
1774
 
1742
 
                        op->o_bd->bd_info = on->on_info->oi_orig;
 
1775
                        op->o_bd->bd_info = (BackendInfo *)on->on_info;
1743
1776
                        rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &e );
1744
1777
                        if ( e ) {
1745
1778
                                if ( test_filter( op, e, li->li_oldf ) == LDAP_COMPARE_TRUE )
1807
1840
        e = accesslog_entry( op, rs, LOG_EN_ABANDON, &op2 );
1808
1841
        bv.bv_val = buf;
1809
1842
        bv.bv_len = snprintf( buf, sizeof( buf ), "%d", op->orn_msgid );
1810
 
        if ( bv.bv_len >= 0 && bv.bv_len < sizeof( buf ) ) {
 
1843
        if ( bv.bv_len < sizeof( buf ) ) {
1811
1844
                attr_merge_one( e, ad_reqId, &bv, NULL );
1812
1845
        } /* else? */
1813
1846