~ubuntu-branches/ubuntu/karmic/openldap/karmic-updates

« back to all changes in this revision

Viewing changes to debian/patches/its6077-uniqueness-overlay

  • 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
 
# Description: Fixes some issues with the uniqueness overlay.
2
 
#              ITS 6077 fixed in openldap > 2.4.17.
3
 
# Upstream: http://www.openldap.org/its/index.cgi/Software%20Bugs?id=6077
4
 
# Patch: http://lists.alioth.debian.org/pipermail/pkg-openldap-devel/2009-July/003409.html
5
 
 
6
 
--- openldap-2.4.17/servers/slapd/overlays/unique.c     21 Jan 2009 23:40:40 -0000      1.41
7
 
+++ openldap-2.4.17/servers/slapd/overlays/unique.c     24 Jul 2009 20:00:53 -0000      1.42
8
 
@@ -47,6 +47,7 @@ typedef struct unique_domain_uri_s {
9
 
        struct berval dn;
10
 
        struct berval ndn;
11
 
        struct berval filter;
12
 
+       Filter *f;
13
 
        struct unique_attrs_s *attrs;
14
 
        int scope;
15
 
 } unique_domain_uri;
16
 
@@ -141,6 +142,7 @@ unique_free_domain_uri ( unique_domain_u
17
 
                ch_free ( uri->dn.bv_val );
18
 
                ch_free ( uri->ndn.bv_val );
19
 
                ch_free ( uri->filter.bv_val );
20
 
+               filter_free( uri->f );
21
 
                attr = uri->attrs;
22
 
                while ( attr ) {
23
 
                        next_attr = attr->next;
24
 
@@ -214,6 +216,13 @@ unique_new_domain_uri ( unique_domain_ur
25
 
                        rc = ARG_BAD_CONF;
26
 
                        goto exit;
27
 
                }
28
 
+
29
 
+               if ( BER_BVISNULL( &be->be_rootndn ) || BER_BVISEMPTY( &be->be_rootndn ) ) {
30
 
+                       Debug( LDAP_DEBUG_ANY,
31
 
+                               "slapo-unique needs a rootdn; "
32
 
+                               "backend <%s> has none, YMMV.\n",
33
 
+                               be->be_nsuffix[0].bv_val, 0, 0 );
34
 
+               }
35
 
        }
36
 
 
37
 
        attr_str = url_desc->lud_attrs;
38
 
@@ -247,17 +256,16 @@ unique_new_domain_uri ( unique_domain_ur
39
 
        }
40
 
 
41
 
        if (url_desc->lud_filter) {
42
 
-               Filter *f = str2filter( url_desc->lud_filter );
43
 
+               uri->f = str2filter( url_desc->lud_filter );
44
 
                char *ptr;
45
 
-               if ( !f ) {
46
 
+               if ( !uri->f ) {
47
 
                        snprintf( c->cr_msg, sizeof( c->cr_msg ),
48
 
                                  "unique: bad filter");
49
 
                        rc = ARG_BAD_CONF;
50
 
                        goto exit;
51
 
                }
52
 
                /* make sure the strfilter is in normal form (ITS#5581) */
53
 
-               filter2bv( f, &uri->filter );
54
 
-               filter_free( f );
55
 
+               filter2bv( uri->f, &uri->filter );
56
 
                ptr = strstr( uri->filter.bv_val, "(?=" /*)*/ );
57
 
                if ( ptr != NULL && ptr <= ( uri->filter.bv_val - STRLENOF( "(?=" /*)*/ ) + uri->filter.bv_len ) )
58
 
                {
59
 
@@ -459,6 +467,13 @@ unique_cf_base( ConfigArgs *c )
60
 
                abort();
61
 
        }
62
 
 
63
 
+       if ( rc ) {
64
 
+               ch_free( c->value_dn.bv_val );
65
 
+               BER_BVZERO( &c->value_dn );
66
 
+               ch_free( c->value_ndn.bv_val );
67
 
+               BER_BVZERO( &c->value_ndn );
68
 
+       }
69
 
+
70
 
        return rc;
71
 
 }
72
 
 
73
 
@@ -1071,6 +1086,17 @@ unique_add(
74
 
                             && !dnIsSuffix( &op->o_req_ndn, &uri->ndn ))
75
 
                                continue;
76
 
 
77
 
+                       if ( uri->f ) {
78
 
+                               if ( test_filter( NULL, op->ora_e, uri->f )
79
 
+                                       == LDAP_COMPARE_FALSE )
80
 
+                               {
81
 
+                                       Debug( LDAP_DEBUG_TRACE,
82
 
+                                               "==> unique_add_skip<%s>\n",
83
 
+                                               op->o_req_dn.bv_val, 0, 0 );
84
 
+                                       continue;
85
 
+                               }
86
 
+                       }
87
 
+
88
 
                        if(!(a = op->ora_e->e_attrs)) {
89
 
                                op->o_bd->bd_info = (BackendInfo *) on->on_info;
90
 
                                send_ldap_error(op, rs, LDAP_INVALID_SYNTAX,
91
 
--- openldap-2.4.17/tests/scripts/test024-unique        21 Jan 2009 23:40:45 -0000      1.14
92
 
+++ openldap-2.4.17/tests/scripts/test024-unique        24 Jul 2009 20:00:53 -0000      1.15
93
 
@@ -425,6 +425,7 @@ dn: olcOverlay={0}unique,olcDatabase={1}
94
 
 changetype: modify
95
 
 add: olcUniqueURI
96
 
 olcUniqueURI: ldap:///?sn?sub?(cn=e*)
97
 
+olcUniqueURI: ldap:///?uid?sub?(cn=edgar)
98
 
 -
99
 
 delete: olcUniqueURI
100
 
 olcUniqueURI: ldap:///?description?one
101
 
@@ -445,6 +446,7 @@ objectClass: olcUniqueConfig
102
 
 olcOverlay: {0}unique
103
 
 olcUniqueURI: ldap:///?employeeNumber,displayName?sub
104
 
 olcUniqueURI: ldap:///?sn?sub?(cn=e*)
105
 
+olcUniqueURI: ldap:///?uid?sub?(cn=edgar)
106
 
 
107
 
 EOF
108
 
 diff $TESTDIR/third-config.ldif $TESTDIR/third-reference.ldif > /dev/null 2>&1
109
 
@@ -473,6 +475,24 @@ if test $RC != 0 ; then
110
 
        exit -1
111
 
 fi
112
 
 
113
 
+echo "Adding a record unique in all domains because of filter conditions "
114
 
+$LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
115
 
+        $TESTOUT 2>&1 << EOF
116
 
+dn: uid=empty,ou=users,o=unique
117
 
+objectClass: inetOrgPerson
118
 
+uid: edgar
119
 
+cn: empty
120
 
+sn: empty
121
 
+EOF
122
 
+
123
 
+RC=$?
124
 
+if test $RC != 0 ; then
125
 
+       echo "spurious unique error ($RC)!"
126
 
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
127
 
+       exit -1
128
 
+fi
129
 
+
130
 
+
131
 
 echo "Adding a record unique in one domain, non-unique in the filtered domain..."
132
 
 
133
 
 $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \