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

« back to all changes in this revision

Viewing changes to servers/slapd/overlays/ppolicy.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
 
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/ppolicy.c,v 1.75.2.14 2008/07/10 00:55:07 quanah Exp $ */
 
1
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/ppolicy.c,v 1.75.2.20 2009/01/22 00:01:12 kurt Exp $ */
2
2
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3
3
 *
4
 
 * Copyright 2004-2008 The OpenLDAP Foundation.
 
4
 * Copyright 2004-2009 The OpenLDAP Foundation.
5
5
 * Portions Copyright 2004-2005 Howard Chu, Symas Corporation.
6
6
 * Portions Copyright 2004 Hewlett-Packard Company.
7
7
 * All rights reserved.
362
362
static const char ppolicy_ctrl_oid[] = LDAP_CONTROL_PASSWORDPOLICYRESPONSE;
363
363
 
364
364
static LDAPControl *
365
 
create_passcontrol( int exptime, int grace, LDAPPasswordPolicyError err )
 
365
create_passcontrol( Operation *op, int exptime, int grace, LDAPPasswordPolicyError err )
366
366
{
367
 
        char berbuf[LBER_ELEMENT_SIZEOF], bb2[LBER_ELEMENT_SIZEOF];
368
 
        BerElement *ber = (BerElement *)berbuf, *b2 = (BerElement *)bb2;
369
 
        LDAPControl *c;
 
367
        BerElementBuffer berbuf, bb2;
 
368
        BerElement *ber = (BerElement *) &berbuf, *b2 = (BerElement *) &bb2;
 
369
        LDAPControl c = { 0 }, *cp;
370
370
        struct berval bv;
371
371
 
372
 
        c = ch_calloc( sizeof( LDAPControl ), 1 );
373
 
        if ( c == NULL ) {
374
 
                return NULL;
375
 
        }
376
 
        c->ldctl_oid = (char *)ppolicy_ctrl_oid;
377
 
        c->ldctl_iscritical = 0;
378
 
        BER_BVZERO( &c->ldctl_value );
 
372
        BER_BVZERO( &c.ldctl_value );
379
373
 
380
374
        ber_init2( ber, NULL, LBER_USE_DER );
381
375
        ber_printf( ber, "{" /*}*/ );
401
395
        }
402
396
        ber_printf( ber, /*{*/ "N}" );
403
397
 
404
 
        if (ber_flatten2( ber, &(c->ldctl_value), 1 ) == LBER_DEFAULT) {
405
 
                ch_free(c);
406
 
                c = NULL;
 
398
        if (ber_flatten2( ber, &c.ldctl_value, 0 ) == -1) {
 
399
                return NULL;
407
400
        }
 
401
        cp = op->o_tmpalloc( sizeof( LDAPControl ) + c.ldctl_value.bv_len, op->o_tmpmemctx );
 
402
        cp->ldctl_oid = (char *)ppolicy_ctrl_oid;
 
403
        cp->ldctl_iscritical = 0;
 
404
        cp->ldctl_value.bv_val = (char *)&cp[1];
 
405
        cp->ldctl_value.bv_len = c.ldctl_value.bv_len;
 
406
        AC_MEMCPY( cp->ldctl_value.bv_val, c.ldctl_value.bv_val, c.ldctl_value.bv_len );
408
407
        (void)ber_free_buf(ber);
409
 
        return c;
 
408
        
 
409
        return cp;
410
410
}
411
411
 
412
412
static LDAPControl **
678
678
{
679
679
        char *ptr;
680
680
        struct berval nv, npw;
681
 
        int i, j;
 
681
        ber_len_t i, j;
682
682
        
683
683
        assert (bv && (bv->bv_len > 0) && (bv->bv_val) && oldtime && oldpw );
684
684
 
854
854
 
855
855
        for ( n = 0; rs->sr_ctrls[n]; n++ ) {
856
856
                if ( rs->sr_ctrls[n]->ldctl_oid == ppolicy_ctrl_oid ) {
857
 
                        ch_free( rs->sr_ctrls[n]->ldctl_value.bv_val );
858
 
                        ch_free( rs->sr_ctrls[n] );
 
857
                        op->o_tmpfree( rs->sr_ctrls[n], op->o_tmpmemctx );
859
858
                        rs->sr_ctrls[n] = (LDAPControl *)(-1);
860
859
                        break;
861
860
                }
1138
1137
                if ( ppb->pErr == PP_accountLocked && !pi->use_lockout ) {
1139
1138
                        ppb->pErr = PP_noError;
1140
1139
                }
1141
 
                ctrl = create_passcontrol( warn, ngut, ppb->pErr );
 
1140
                ctrl = create_passcontrol( op, warn, ngut, ppb->pErr );
1142
1141
                ppb->oldctrls = add_passcontrol( op, rs, ctrl );
1143
1142
                op->o_callback->sc_cleanup = ppolicy_ctrls_cleanup;
1144
1143
        }
1251
1250
                        "connection restricted to password changing only\n", 0, 0, 0);
1252
1251
                if ( send_ctrl ) {
1253
1252
                        LDAPControl *ctrl = NULL;
1254
 
                        ctrl = create_passcontrol( -1, -1, PP_changeAfterReset );
 
1253
                        ctrl = create_passcontrol( op, -1, -1, PP_changeAfterReset );
1255
1254
                        oldctrls = add_passcontrol( op, rs, ctrl );
1256
1255
                }
1257
1256
                op->o_bd->bd_info = (BackendInfo *)on->on_info;
1317
1316
                                op->o_bd->bd_info = (BackendInfo *)on->on_info;
1318
1317
                                if ( send_ctrl ) {
1319
1318
                                        LDAPControl *ctrl = NULL;
1320
 
                                        ctrl = create_passcontrol( -1, -1, pErr );
 
1319
                                        ctrl = create_passcontrol( op, -1, -1, pErr );
1321
1320
                                        oldctrls = add_passcontrol( op, rs, ctrl );
1322
1321
                                }
1323
1322
                                send_ldap_error( op, rs, rc, "Password fails quality checking policy" );
1406
1405
        struct berval           newpw = BER_BVNULL, oldpw = BER_BVNULL,
1407
1406
                                *bv, cr[2];
1408
1407
        LDAPPasswordPolicyError pErr = PP_noError;
 
1408
        LDAPControl             *ctrl = NULL;
1409
1409
        LDAPControl             **oldctrls = NULL;
 
1410
        int                     is_pwdexop = 0;
1410
1411
 
1411
1412
        op->o_bd->bd_info = (BackendInfo *)on->on_info;
1412
1413
        rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &e );
1526
1527
                                req_pwdexop_s *qpw = sc->sc_private;
1527
1528
                                newpw = qpw->rs_new;
1528
1529
                                oldpw = qpw->rs_old;
 
1530
                                is_pwdexop = 1;
1529
1531
                                break;
1530
1532
                        }
1531
1533
                }
2010
2012
        op->o_bd->bd_info = (BackendInfo *)on->on_info;
2011
2013
        be_entry_release_r( op, e );
2012
2014
        if ( send_ctrl ) {
2013
 
                LDAPControl *ctrl = NULL;
2014
 
 
2015
 
                ctrl = create_passcontrol( -1, -1, pErr );
 
2015
                ctrl = create_passcontrol( op, -1, -1, pErr );
2016
2016
                oldctrls = add_passcontrol( op, rs, ctrl );
2017
2017
        }
2018
2018
        send_ldap_result( op, rs );
2019
2019
        if ( send_ctrl ) {
2020
 
                ctrls_cleanup( op, rs, oldctrls );
 
2020
                if ( is_pwdexop ) {
 
2021
                        if ( rs->sr_flags & REP_CTRLS_MUSTBEFREED ) {
 
2022
                                op->o_tmpfree( oldctrls, op->o_tmpmemctx );
 
2023
                        }
 
2024
                        oldctrls = NULL;
 
2025
                        rs->sr_flags |= REP_CTRLS_MUSTBEFREED;
 
2026
 
 
2027
                } else {
 
2028
                        ctrls_cleanup( op, rs, oldctrls );
 
2029
                }
2021
2030
        }
2022
2031
        return rs->sr_err;
2023
2032
}
2085
2094
{
2086
2095
        slap_overinst *on = (slap_overinst *) be->bd_info;
2087
2096
 
 
2097
        if ( SLAP_ISGLOBALOVERLAY( be ) ) {
 
2098
                /* do not allow slapo-ppolicy to be global by now (ITS#5858) */
 
2099
                if ( cr ){
 
2100
                        snprintf( cr->msg, sizeof(cr->msg), 
 
2101
                                "slapo-ppolicy cannot be global" );
 
2102
                        fprintf( stderr, "%s\n", cr->msg );
 
2103
                }
 
2104
                return 1;
 
2105
        }
 
2106
 
2088
2107
        /* Has User Schema been initialized yet? */
2089
2108
        if ( !pwd_UsSchema[0].ad[0] ) {
2090
2109
                const char *err;