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

« back to all changes in this revision

Viewing changes to servers/slapd/back-ndb/bind.cpp

  • 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
/* bind.cpp - ndb backend bind routine */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-ndb/bind.cpp,v 1.3.2.2 2009/01/22 00:01:09 kurt Exp $ */
 
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 
4
 *
 
5
 * Copyright 2008-2009 The OpenLDAP Foundation.
 
6
 * All rights reserved.
 
7
 *
 
8
 * Redistribution and use in source and binary forms, with or without
 
9
 * modification, are permitted only as authorized by the OpenLDAP
 
10
 * Public License.
 
11
 *
 
12
 * A copy of this license is available in the file LICENSE in the
 
13
 * top-level directory of the distribution or, alternatively, at
 
14
 * <http://www.OpenLDAP.org/license.html>.
 
15
 */
 
16
/* ACKNOWLEDGEMENTS:
 
17
 * This work was initially developed by Howard Chu for inclusion
 
18
 * in OpenLDAP Software. This work was sponsored by MySQL.
 
19
 */
 
20
 
 
21
#include "portable.h"
 
22
 
 
23
#include <stdio.h>
 
24
#include <ac/string.h>
 
25
#include <ac/unistd.h>
 
26
 
 
27
#include "back-ndb.h"
 
28
 
 
29
extern "C" int
 
30
ndb_back_bind( Operation *op, SlapReply *rs )
 
31
{
 
32
        struct ndb_info *ni = (struct ndb_info *) op->o_bd->be_private;
 
33
        Entry           e = {0};
 
34
        Attribute       *a;
 
35
 
 
36
        AttributeDescription *password = slap_schema.si_ad_userPassword;
 
37
 
 
38
        NdbArgs NA;
 
39
 
 
40
        Debug( LDAP_DEBUG_ARGS,
 
41
                "==> " LDAP_XSTRING(ndb_back_bind) ": dn: %s\n",
 
42
                op->o_req_dn.bv_val, 0, 0);
 
43
 
 
44
        /* allow noauth binds */
 
45
        switch ( be_rootdn_bind( op, NULL ) ) {
 
46
        case SLAP_CB_CONTINUE:
 
47
                break;
 
48
 
 
49
        default:
 
50
                return rs->sr_err;
 
51
        }
 
52
 
 
53
        /* Get our NDB handle */
 
54
        rs->sr_err = ndb_thread_handle( op, &NA.ndb );
 
55
 
 
56
        e.e_name = op->o_req_dn;
 
57
        e.e_nname = op->o_req_ndn;
 
58
        NA.e = &e;
 
59
 
 
60
dn2entry_retry:
 
61
        NA.txn = NA.ndb->startTransaction();
 
62
        rs->sr_text = NULL;
 
63
        if( !NA.txn ) {
 
64
                Debug( LDAP_DEBUG_TRACE,
 
65
                        LDAP_XSTRING(ndb_back_bind) ": startTransaction failed: %s (%d)\n",
 
66
                        NA.ndb->getNdbError().message, NA.ndb->getNdbError().code, 0 );
 
67
                rs->sr_err = LDAP_OTHER;
 
68
                rs->sr_text = "internal error";
 
69
                goto done;
 
70
        }
 
71
 
 
72
        /* get entry */
 
73
        {
 
74
                NdbRdns rdns;
 
75
                rdns.nr_num = 0;
 
76
                NA.rdns = &rdns;
 
77
                NA.ocs = NULL;
 
78
                rs->sr_err = ndb_entry_get_info( op, &NA, 0, NULL );
 
79
        }
 
80
        switch(rs->sr_err) {
 
81
        case 0:
 
82
                break;
 
83
        case LDAP_NO_SUCH_OBJECT:
 
84
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
 
85
                goto done;
 
86
        case LDAP_BUSY:
 
87
                rs->sr_text = "ldap_server_busy";
 
88
                goto done;
 
89
#if 0
 
90
        case DB_LOCK_DEADLOCK:
 
91
        case DB_LOCK_NOTGRANTED:
 
92
                goto dn2entry_retry;
 
93
#endif
 
94
        default:
 
95
                rs->sr_err = LDAP_OTHER;
 
96
                rs->sr_text = "internal error";
 
97
                goto done;
 
98
        }
 
99
 
 
100
        rs->sr_err = ndb_entry_get_data( op, &NA, 0 );
 
101
        ber_bvarray_free_x( NA.ocs, op->o_tmpmemctx );
 
102
        ber_dupbv( &op->oq_bind.rb_edn, &e.e_name );
 
103
 
 
104
        /* check for deleted */
 
105
        if ( is_entry_subentry( &e ) ) {
 
106
                /* entry is an subentry, don't allow bind */
 
107
                Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0,
 
108
                        0, 0 );
 
109
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
 
110
                goto done;
 
111
        }
 
112
 
 
113
        if ( is_entry_alias( &e ) ) {
 
114
                /* entry is an alias, don't allow bind */
 
115
                Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
 
116
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
 
117
                goto done;
 
118
        }
 
119
 
 
120
        if ( is_entry_referral( &e ) ) {
 
121
                Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
 
122
                        0, 0 );
 
123
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
 
124
                goto done;
 
125
        }
 
126
 
 
127
        switch ( op->oq_bind.rb_method ) {
 
128
        case LDAP_AUTH_SIMPLE:
 
129
                a = attr_find( e.e_attrs, password );
 
130
                if ( a == NULL ) {
 
131
                        rs->sr_err = LDAP_INVALID_CREDENTIALS;
 
132
                        goto done;
 
133
                }
 
134
 
 
135
                if ( slap_passwd_check( op, &e, a, &op->oq_bind.rb_cred,
 
136
                                        &rs->sr_text ) != 0 )
 
137
                {
 
138
                        /* failure; stop front end from sending result */
 
139
                        rs->sr_err = LDAP_INVALID_CREDENTIALS;
 
140
                        goto done;
 
141
                }
 
142
                        
 
143
                rs->sr_err = 0;
 
144
                break;
 
145
 
 
146
        default:
 
147
                assert( 0 ); /* should not be reachable */
 
148
                rs->sr_err = LDAP_STRONG_AUTH_NOT_SUPPORTED;
 
149
                rs->sr_text = "authentication method not supported";
 
150
        }
 
151
 
 
152
done:
 
153
        NA.txn->close();
 
154
        if ( e.e_attrs ) {
 
155
                attrs_free( e.e_attrs );
 
156
                e.e_attrs = NULL;
 
157
        }
 
158
        if ( rs->sr_err ) {
 
159
                send_ldap_result( op, rs );
 
160
        }
 
161
        /* front end will send result on success (rs->sr_err==0) */
 
162
        return rs->sr_err;
 
163
}