[Fedora-directory-commits] ldapserver/ldap/servers/slapd filtercmp.c, 1.4, 1.5
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15834
Modified Files:
filtercmp.c
Log Message:
Bug(s) fixed: 165641
Bug Description: ./ns-slapd crashes on bind containing invalid dn and password
Reviewed by: Noriko (Thanks!)
Branch: HEAD
Fix Description: It's really crashing on the search request. The problem is that the server assumes all strings are encoded in utf8 format, since that is the only encoding allowed by the LDAP standards. Non-utf8 works in most places except the function slapi_utf8StrToLower(), which returns NULL given a string of non-utf8 bytes. The fix for this particular problem is to check for a NULL return value and handle accordingly.
The real solution to this problem would be for the server to check for valid utf8 strings in _all_ LDAP data, according to the syntax of the attribute (e.g. for binary or octet string syntax data, and other binary formats, all bets are off, but then we shouldn't be doing strtolower on these blobs either).
And, while we're at it, add data validation based on syntax for _all_ attributes e.g. in a pre-op.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: filtercmp.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/filtercmp.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- filtercmp.c 19 Apr 2005 22:07:36 -0000 1.4
+++ filtercmp.c 30 Aug 2005 21:21:19 -0000 1.5
@@ -64,7 +64,8 @@
unsigned char *normstr;
normstr = slapi_utf8StrToLower((unsigned char *)data);
- hash = addhash(hash, normstr, strlen((char *)normstr));
+ hash = addhash(hash, normstr,
+ normstr ? strlen((char *)normstr) : 0);
if ((char *)normstr != data)
slapi_ch_free((void **)&normstr);
return hash;
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldbm_attr.c, 1.5, 1.5.2.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15763/ldapserver/ldap/servers/slapd/back-ldbm
Modified Files:
Tag: Directory71RtmBranch
ldbm_attr.c
Log Message:
Bug(s) fixed: 165641
Bug Description: ./ns-slapd crashes on bind containing invalid dn and password
Reviewed by: Noriko (Thanks!)
Branch: Directory71RtmBranch
Fix Description: It's really crashing on the search request. The problem is that the server assumes all strings are encoded in utf8 format, since that is the only encoding allowed by the LDAP standards. Non-utf8 works in most places except the function slapi_utf8StrToLower(), which returns NULL given a string of non-utf8 bytes. The fix for this particular problem is to check for a NULL return value and handle accordingly.
The real solution to this problem would be for the server to check for valid utf8 strings in _all_ LDAP data, according to the syntax of the attribute (e.g. for binary or octet string syntax data, and other binary formats, all bets are off, but then we shouldn't be doing strtolower on these blobs either).
And, while we're at it, add data validation based on syntax for _all_ attributes e.g. in a pre-op.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: ldbm_attr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_attr.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- ldbm_attr.c 19 Apr 2005 22:07:38 -0000 1.5
+++ ldbm_attr.c 30 Aug 2005 21:16:14 -0000 1.5.2.1
@@ -632,7 +632,7 @@
if ( NULL != fstr ) {
char *lc_fstr = (char *)slapi_utf8StrToLower( (unsigned char *)fstr );
- if (string_find(lc_fstr,"subordinates")) {
+ if (lc_fstr && string_find(lc_fstr,"subordinates")) {
Slapi_Filter *f = NULL;
/* Look for special filters we want to leave alone */
if (0 == strcmp(lc_fstr, "(&(numsubordinates=*)(numsubordinates>=1))" )) {
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd filtercmp.c, 1.4, 1.4.2.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15763/ldapserver/ldap/servers/slapd
Modified Files:
Tag: Directory71RtmBranch
filtercmp.c
Log Message:
Bug(s) fixed: 165641
Bug Description: ./ns-slapd crashes on bind containing invalid dn and password
Reviewed by: Noriko (Thanks!)
Branch: Directory71RtmBranch
Fix Description: It's really crashing on the search request. The problem is that the server assumes all strings are encoded in utf8 format, since that is the only encoding allowed by the LDAP standards. Non-utf8 works in most places except the function slapi_utf8StrToLower(), which returns NULL given a string of non-utf8 bytes. The fix for this particular problem is to check for a NULL return value and handle accordingly.
The real solution to this problem would be for the server to check for valid utf8 strings in _all_ LDAP data, according to the syntax of the attribute (e.g. for binary or octet string syntax data, and other binary formats, all bets are off, but then we shouldn't be doing strtolower on these blobs either).
And, while we're at it, add data validation based on syntax for _all_ attributes e.g. in a pre-op.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: filtercmp.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/filtercmp.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- filtercmp.c 19 Apr 2005 22:07:36 -0000 1.4
+++ filtercmp.c 30 Aug 2005 21:16:13 -0000 1.4.2.1
@@ -64,7 +64,8 @@
unsigned char *normstr;
normstr = slapi_utf8StrToLower((unsigned char *)data);
- hash = addhash(hash, normstr, strlen((char *)normstr));
+ hash = addhash(hash, normstr,
+ normstr ? strlen((char *)normstr) : 0);
if ((char *)normstr != data)
slapi_ch_free((void **)&normstr);
return hash;
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd saslbind.c, 1.9, 1.10
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12077
Modified Files:
saslbind.c
Log Message:
Bug(s) fixed: 166229
Bug Description: slapd crashes during SASL authentication
Reviewed by: Noriko (Thanks!)
Branch: HEAD
Fix Description: I could not reproduce the crash. I tried several different ways - no password in entry, empty password in entry, SSHA hashed password in entry - no crashes. No useful information from the FDS bug reporter either. In fact I found that SASL Digest-MD5 was not working at all. We needed to use the SASL_AUX_PASSWORD_PROP define instead of hardcoding "userpassword" - I guess sasl is case sensitive. I also fixed some missing new lines in log messages.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: saslbind.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/saslbind.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- saslbind.c 19 Apr 2005 22:07:37 -0000 1.9
+++ saslbind.c 29 Aug 2005 22:11:05 -0000 1.10
@@ -136,7 +136,7 @@
{
switch (level) {
case SASL_LOG_ERR: /* log unusual errors (default) */
- slapi_log_error(SLAPI_LOG_FATAL, "sasl", "%s", message);
+ slapi_log_error(SLAPI_LOG_FATAL, "sasl", "%s\n", message);
break;
case SASL_LOG_FAIL: /* log all authentication failures */
@@ -146,7 +146,7 @@
case SASL_LOG_TRACE: /* traces of internal protocols */
case SASL_LOG_PASS: /* traces of internal protocols, including
* passwords */
- LDAPDebug(LDAP_DEBUG_ANY, "sasl(%d): %s", level, message, 0);
+ LDAPDebug(LDAP_DEBUG_ANY, "sasl(%d): %s\n", level, message, 0);
break;
case SASL_LOG_NONE: /* don't log anything */
@@ -446,7 +446,12 @@
clear = pw;
if (clear) {
- if (prop_set(propctx, "userpassword", clear, -1) != 0) {
+ if (prop_set(propctx, SASL_AUX_PASSWORD_PROP, clear, -1) != 0) {
+ /* Failure is benign here because some mechanisms don't support this property */
+ /*LDAPDebug(LDAP_DEBUG_TRACE, "prop_set(userpassword) failed\n", 0, 0, 0);
+ goto fail */ ;
+ }
+ if (prop_set(propctx, SASL_AUX_PASSWORD, clear, -1) != 0) {
/* Failure is benign here because some mechanisms don't support this property */
/*LDAPDebug(LDAP_DEBUG_TRACE, "prop_set(userpassword) failed\n", 0, 0, 0);
goto fail */ ;
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd saslbind.c, 1.9, 1.9.2.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11994/ldapserver/ldap/servers/slapd
Modified Files:
Tag: Directory71RtmBranch
saslbind.c
Log Message:
Bug(s) fixed: 166229
Bug Description: slapd crashes during SASL authentication
Reviewed by: Noriko (Thanks!)
Branch: Directory71RtmBranch
Fix Description: I could not reproduce the crash. I tried several different ways - no password in entry, empty password in entry, SSHA hashed password in entry - no crashes. No useful information from the FDS bug reporter either. In fact I found that SASL Digest-MD5 was not working at all. We needed to use the SASL_AUX_PASSWORD_PROP define instead of hardcoding "userpassword" - I guess sasl is case sensitive. I also fixed some missing new lines in log messages.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: saslbind.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/saslbind.c,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- saslbind.c 19 Apr 2005 22:07:37 -0000 1.9
+++ saslbind.c 29 Aug 2005 22:06:25 -0000 1.9.2.1
@@ -136,7 +136,7 @@
{
switch (level) {
case SASL_LOG_ERR: /* log unusual errors (default) */
- slapi_log_error(SLAPI_LOG_FATAL, "sasl", "%s", message);
+ slapi_log_error(SLAPI_LOG_FATAL, "sasl", "%s\n", message);
break;
case SASL_LOG_FAIL: /* log all authentication failures */
@@ -146,7 +146,7 @@
case SASL_LOG_TRACE: /* traces of internal protocols */
case SASL_LOG_PASS: /* traces of internal protocols, including
* passwords */
- LDAPDebug(LDAP_DEBUG_ANY, "sasl(%d): %s", level, message, 0);
+ LDAPDebug(LDAP_DEBUG_ANY, "sasl(%d): %s\n", level, message, 0);
break;
case SASL_LOG_NONE: /* don't log anything */
@@ -446,7 +446,12 @@
clear = pw;
if (clear) {
- if (prop_set(propctx, "userpassword", clear, -1) != 0) {
+ if (prop_set(propctx, SASL_AUX_PASSWORD_PROP, clear, -1) != 0) {
+ /* Failure is benign here because some mechanisms don't support this property */
+ /*LDAPDebug(LDAP_DEBUG_TRACE, "prop_set(userpassword) failed\n", 0, 0, 0);
+ goto fail */ ;
+ }
+ if (prop_set(propctx, SASL_AUX_PASSWORD, clear, -1) != 0) {
/* Failure is benign here because some mechanisms don't support this property */
/*LDAPDebug(LDAP_DEBUG_TRACE, "prop_set(userpassword) failed\n", 0, 0, 0);
goto fail */ ;
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/admin/src create_instance.c, 1.19, 1.20
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22201
Modified Files:
create_instance.c
Log Message:
Bug(s) fixed: 151678
Bug Description: new instance creation creates error aci (2 types in RDN)
Reviewed by: Nathan (Thanks!)
Fix Description: This only seems to occur when logging in to the console as a user other than the Console Admin user (e.g. as Directory Manager in my tests). We need the Console Admin DN or user id to construct the ACIs. This value is held in the suitespot3x_uid form parameter. I had removed it while working on this bug or a related bug earlier, but now that I've added it back, everything seems to be working again.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: create_instance.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/create_instance.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- create_instance.c 14 Jun 2005 15:44:18 -0000 1.19
+++ create_instance.c 26 Aug 2005 19:41:40 -0000 1.20
@@ -4672,6 +4672,7 @@
return 1;
}
+ cf->suitespot3x_uid = ds_a_get_cgi_var("suitespot3x_uid", NULL, NULL);
cf->cfg_sspt = ds_a_get_cgi_var("cfg_sspt", NULL, NULL);
cf->cfg_sspt_uid = ds_a_get_cgi_var("cfg_sspt_uid", NULL, NULL);
if (cf->cfg_sspt_uid && *(cf->cfg_sspt_uid) &&
18 years, 8 months
[Fedora-directory-commits] console build.properties, 1.1.1.1, 1.2 build.xml, 1.1.1.1, 1.2
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/console
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21491
Modified Files:
build.properties build.xml
Log Message:
166877 - Changed console version to 7.1 and changed consolesdk naming to plain console in the Ant build files.
Index: build.properties
===================================================================
RCS file: /cvs/dirsec/console/build.properties,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- build.properties 18 Jul 2005 00:34:05 -0000 1.1.1.1
+++ build.properties 26 Aug 2005 19:11:40 -0000 1.2
@@ -21,8 +21,8 @@
lang=en
-consolesdk.root=..
-consolesdk.version=70
+console.root=..
+console.version=71
mcc.core=mcc
mcc.name=${mcc.core}${consolesdk.version}
Index: build.xml
===================================================================
RCS file: /cvs/dirsec/console/build.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- build.xml 18 Jul 2005 00:34:05 -0000 1.1.1.1
+++ build.xml 26 Aug 2005 19:11:40 -0000 1.2
@@ -19,12 +19,12 @@
END COPYRIGHT BLOCK
-->
-<project name="consolesdk" default="dist" basedir=".">
+<project name="console" default="dist" basedir=".">
<!-- Load properties -->
<property file="build.properties"/>
<!-- Paths -->
- <property name="built.dir" value="${consolesdk.root}/built"/>
+ <property name="built.dir" value="${console.root}/built"/>
<property name="package.dir" value="${built.dir}/package"/>
<property name="lib.dir" value="${package.dir}/lib"/>
<property name="dist.dir" value="${package.dir}/java"/>
@@ -32,7 +32,7 @@
<property name="jars.dir" value="${dist.dir}/jars"/>
<property name="built.classdir" value="${built.dir}/classes"/>
<property name="javadoc.dir" value="${built.dir}/doc"/>
- <property name="imports.dir" value="${consolesdk.root}/imports"/>
+ <property name="imports.dir" value="${console.root}/imports"/>
<property name="java.src.dir" value="src"/>
<!-- Prepare -->
@@ -64,7 +64,7 @@
<available file="${imports.dir}/nspr/${nspr.import}" property="nspr.import.exists"/>
<!-- Construct classpath -->
- <path id="consolesdk.classpath">
+ <path id="console.classpath">
<pathelement location="${imports.dir}/ldapjdk/${ldapjdk.import}"/>
<pathelement location="${imports.dir}/jss/${jss.jar.import}"/>
</path>
@@ -125,7 +125,7 @@
optimize="${compile.optimize}"
verbose="no"
excludes="**/CVS/**">
- <classpath refid="consolesdk.classpath" />
+ <classpath refid="console.classpath" />
</javac>
</target>
@@ -238,15 +238,15 @@
<chmod file="${package.dir}/startconsole" perm="755"/>
<!-- Create a bundle of the Console -->
- <tar destfile="${built.dir}/consolesdk${consolesdk.version}.tar.gz"
+ <tar destfile="${built.dir}/console${console.version}.tar.gz"
compression="gzip">
<tarfileset dir="${package.dir}"
- prefix="consolesdk${consolesdk.version}"
+ prefix="console${console.version}"
mode="755">
<include name="startconsole"/>
</tarfileset>
<tarfileset dir="${package.dir}"
- prefix="consolesdk${consolesdk.version}">
+ prefix="console${console.version}">
<include name="**"/>
<exclude name="startconsole"/>
</tarfileset>
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/admin/src create_instance.c, 1.18, 1.18.2.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20066
Modified Files:
Tag: Directory71RtmBranch
create_instance.c
Log Message:
Bug(s) fixed: 151678
Bug Description: new instance creation creates error aci (2 types in RDN)
Reviewed by: Nathan (Thanks!)
Fix Description: This only seems to occur when logging in to the console as a user other than the Console Admin user (e.g. as Directory Manager in my tests). We need the Console Admin DN or user id to construct the ACIs. This value is held in the suitespot3x_uid form parameter. I had removed it while working on this bug or a related bug earlier, but now that I've added it back, everything seems to be working again.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: create_instance.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/create_instance.c,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -r1.18 -r1.18.2.1
--- create_instance.c 17 May 2005 23:07:12 -0000 1.18
+++ create_instance.c 26 Aug 2005 18:51:50 -0000 1.18.2.1
@@ -4662,6 +4662,7 @@
return 1;
}
+ cf->suitespot3x_uid = ds_a_get_cgi_var("suitespot3x_uid", NULL, NULL);
cf->cfg_sspt = ds_a_get_cgi_var("cfg_sspt", NULL, NULL);
cf->cfg_sspt_uid = ds_a_get_cgi_var("cfg_sspt_uid", NULL, NULL);
if (cf->cfg_sspt_uid && *(cf->cfg_sspt_uid) &&
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldbm_delete.c, 1.4, 1.4.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15129
Modified Files:
Tag: Directory71RtmBranch
ldbm_delete.c
Log Message:
165862 - Deleting an entry needs to set BE_INDEX_EQUALITY to remove the entrydn index
Index: ldbm_delete.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_delete.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- ldbm_delete.c 19 Apr 2005 22:07:38 -0000 1.4
+++ ldbm_delete.c 26 Aug 2005 15:52:04 -0000 1.4.2.1
@@ -401,7 +401,7 @@
}
}
/* delete from attribute indexes */
- addordel_flags = BE_INDEX_DEL|BE_INDEX_PRESENCE;
+ addordel_flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
if (delete_tombstone_entry)
{
addordel_flags |= BE_INDEX_TOMBSTONE; /* tell index code we are deleting a tombstone */
18 years, 8 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm back-ldbm.h, 1.5, 1.5.2.1 index.c, 1.5, 1.5.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15039/back-ldbm
Modified Files:
Tag: Directory71RtmBranch
back-ldbm.h index.c
Log Message:
164843, 166012, 165827 - Indexing code now deals with attribute subtypes correctly.
Index: back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- back-ldbm.h 25 Apr 2005 16:24:23 -0000 1.5
+++ back-ldbm.h 26 Aug 2005 15:44:36 -0000 1.5.2.1
@@ -637,6 +637,7 @@
#define BE_INDEX_PRESENCE 4 /* (w/DEL) remove the presence index */
#define BE_INDEX_TOMBSTONE 8 /* Index entry as a tombstone */
#define BE_INDEX_DONT_ENCRYPT 16 /* Disable any encryption if this flag is set */
+#define BE_INDEX_EQUALITY 32 /* (w/DEL) remove the equality index */
/* Name of attribute type used for binder-based look through limit */
#define LDBM_LOOKTHROUGHLIMIT_AT "nsLookThroughLimit"
Index: index.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/index.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- index.c 19 Apr 2005 22:07:38 -0000 1.5
+++ index.c 26 Aug 2005 15:44:36 -0000 1.5.2.1
@@ -453,35 +453,120 @@
)
{
int rc = 0;
- int i;
- Slapi_Attr *attr;
+ int i, j;
ID id = olde->ep_id;
- Slapi_Value **svals = NULL;
+ int flags = 0;
+ char buf[SLAPD_TYPICAL_ATTRIBUTE_NAME_MAX_LENGTH];
+ char *basetype = NULL;
+ char *tmp = NULL;
+ Slapi_Attr *curr_attr = NULL;
+ Slapi_ValueSet *all_vals = NULL;
+ Slapi_ValueSet *mod_vals = NULL;
+ Slapi_Value **evals = NULL; /* values that still exist after a
+ * delete.
+ */
+ Slapi_Value **mods_valueArray = NULL; /* values that are specified in this
+ * operation.
+ */
+ Slapi_Value **deleted_valueArray = NULL; /* values whose index entries
+ * should be deleted.
+ */
for ( i = 0; mods[i] != NULL; i++ ) {
+ /* Get base attribute type */
+ basetype = buf;
+ tmp = slapi_attr_basetype(mods[i]->mod_type, buf, sizeof(buf));
+ if(tmp != NULL) {
+ basetype = tmp; /* basetype was malloc'd */
+ }
+
+ /* Get a list of all remaining values for the base type
+ * and any present subtypes.
+ */
+ all_vals = slapi_valueset_new();
+
+ for (curr_attr = newe->ep_entry->e_attrs; curr_attr != NULL; curr_attr = curr_attr->a_next) {
+ if (slapi_attr_type_cmp( basetype, curr_attr->a_type, SLAPI_TYPE_CMP_BASE ) == 0) {
+ valueset_add_valuearray(all_vals, attr_get_present_values(curr_attr));
+ }
+ }
+
+ evals = valueset_get_valuearray(all_vals);
+
+ /* Get a list of all values specified in the operation.
+ */
+ if ( mods[i]->mod_bvalues != NULL ) {
+ valuearray_init_bervalarray(mods[i]->mod_bvalues,
+ &mods_valueArray);
+ }
+
switch ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ) {
case LDAP_MOD_REPLACE:
+ flags = BE_INDEX_DEL;
+ /* Get a list of all values being deleted.
+ */
+ mod_vals = slapi_valueset_new();
+
+ for (curr_attr = olde->ep_entry->e_attrs; curr_attr != NULL; curr_attr = curr_attr->a_next) {
+ if (slapi_attr_type_cmp( mods[i]->mod_type, curr_attr->a_type, SLAPI_TYPE_CMP_EXACT ) == 0) {
+ valueset_add_valuearray(mod_vals, attr_get_present_values(curr_attr));
+ }
+ }
+
+ deleted_valueArray = valueset_get_valuearray(mod_vals);
+
+ /* If subtypes exist, don't remove the presence
+ * index.
+ */
+ if ( evals != NULL && deleted_valueArray != NULL) {
+ /* evals will contain the new value that is being
+ * added as part of the replace operation if one
+ * was specified. We must remove this value from
+ * evals to know if any subtypes are present.
+ */
+ slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &curr_attr );
+ if ( mods_valueArray != NULL ) {
+ for ( j = 0; mods_valueArray[j] != NULL; j++ ) {
+ valuearray_remove_value(curr_attr, evals, mods_valueArray[j]);
+ }
+ }
+
+ /* Search evals for the values being deleted. If
+ * they don't exist, delete the equality index.
+ */
+ for ( j = 0; deleted_valueArray[j] != NULL; j++ ) {
+ if (valuearray_find(curr_attr, evals, deleted_valueArray[j]) == -1) {
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
+ } else {
+ /* Remove duplicate value from deleted value array */
+ valuearray_remove_value(curr_attr, deleted_valueArray, deleted_valueArray[j]);
+ j--;
+ }
+ }
+ } else {
+ flags |= BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
+ }
+
/* We need to first remove the old values from the
- * index. */
- if ( slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &attr ) == 0 &&
- (svals = attr_get_present_values(attr)) != NULL ) {
+ * index, if any. */
+ if (deleted_valueArray) {
index_addordel_values_sv( be, mods[i]->mod_type,
- svals, NULL, id,
- BE_INDEX_DEL|BE_INDEX_PRESENCE,
- txn );
+ deleted_valueArray, evals, id,
+ flags, txn );
}
+
+ /* Free valuearray */
+ slapi_valueset_free(mod_vals);
case LDAP_MOD_ADD:
- if ( mods[i]->mod_bvalues == NULL ) {
+ if ( mods_valueArray == NULL ) {
rc = 0;
} else {
- Slapi_Value **mods_valueArray = NULL;
- valuearray_init_bervalarray(mods[i]->mod_bvalues,
- &mods_valueArray);
rc = index_addordel_values_sv( be,
mods[i]->mod_type,
mods_valueArray, NULL,
id, BE_INDEX_ADD, txn );
- valuearray_free(&mods_valueArray);
}
break;
@@ -489,44 +574,92 @@
if ( (mods[i]->mod_bvalues == NULL) ||
(mods[i]->mod_bvalues[0] == NULL) ) {
rc = 0;
- /* if no value are specified all the values will
- * be suppressed -> remove the presence index
+ flags = BE_INDEX_DEL;
+
+ /* Get a list of all values that are being
+ * deleted.
+ */
+ mod_vals = slapi_valueset_new();
+
+ for (curr_attr = olde->ep_entry->e_attrs; curr_attr != NULL; curr_attr = curr_attr->a_next) {
+ if (slapi_attr_type_cmp( mods[i]->mod_type, curr_attr->a_type, SLAPI_TYPE_CMP_EXACT ) == 0) {
+ valueset_add_valuearray(mod_vals, attr_get_present_values(curr_attr));
+ }
+ }
+
+ deleted_valueArray = valueset_get_valuearray(mod_vals);
+
+ /* If subtypes exist, don't remove the
+ * presence index.
*/
- if ( slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &attr ) == 0 &&
- (svals = attr_get_present_values(attr)) != NULL ) {
- index_addordel_values_sv( be, mods[i]->mod_type,
- svals, NULL, id, BE_INDEX_DEL|BE_INDEX_PRESENCE, txn);
+ if (evals != NULL) {
+ for (curr_attr = newe->ep_entry->e_attrs; (curr_attr != NULL);
+ curr_attr = curr_attr->a_next) {
+ if (slapi_attr_type_cmp( basetype, curr_attr->a_type, SLAPI_TYPE_CMP_BASE ) == 0) {
+ /* Check if the any values being deleted
+ * also exist in a subtype.
+ */
+ for ( j=0; deleted_valueArray[j] != NULL; j++) {
+ if ( valuearray_find(curr_attr, evals, deleted_valueArray[j]) == -1 ) {
+ /* If the equality flag isn't already set, set it */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
+ } else {
+ /* Remove duplicate value from the mod list */
+ valuearray_remove_value(curr_attr, deleted_valueArray, deleted_valueArray[j]);
+ j--;
+ }
+ }
+ }
+ }
+ } else {
+ flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
}
+
+ /* Update the index */
+ index_addordel_values_sv( be, mods[i]->mod_type,
+ deleted_valueArray, evals, id, flags, txn);
+
+ slapi_valueset_free(mod_vals);
} else {
+
/* determine if the presence key should be
* removed (are we removing the last value
* for this attribute?)
*/
- int flags = BE_INDEX_DEL;
- Slapi_Value ** svals = NULL;
- Slapi_Value **mods_valueArray = NULL;
-
- valuearray_init_bervalarray(mods[i]->mod_bvalues,
- &mods_valueArray);
-
- if (slapi_entry_attr_find(newe->ep_entry,
- mods[i]->mod_type, &attr) == 0) {
- svals = attr_get_present_values(attr);
+ if (evals == NULL || evals[0] == NULL) {
+ flags = BE_INDEX_DEL|BE_INDEX_PRESENCE;
+ } else {
+ flags = BE_INDEX_DEL;
}
- if (svals == NULL || svals[0] == NULL) {
- flags |= BE_INDEX_PRESENCE;
- }
+ /* If the same value doesn't exist in a subtype, set
+ * BE_INDEX_EQUALITY flag so the equality index is
+ * removed.
+ */
+ slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &curr_attr);
+ for (j = 0; mods_valueArray[j] != NULL; j++ ) {
+ if ( valuearray_find(curr_attr, evals, mods_valueArray[j]) == -1 ) {
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
+ }
+ }
- rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ rc = index_addordel_values_sv( be, basetype,
mods_valueArray,
- svals, id, flags, txn );
- valuearray_free(&mods_valueArray);
+ evals, id, flags, txn );
}
rc = 0;
break;
}
+ /* free memory */
+ slapi_ch_free((void **)&tmp);
+ valuearray_free(&mods_valueArray);
+ slapi_valueset_free(all_vals);
+
if ( rc != 0 ) {
ldbm_nasty(errmsg, 1040, rc);
return( rc );
@@ -1595,7 +1728,11 @@
/*
* equality index entry
*/
- if ( ai->ai_indexmask & INDEX_EQUALITY ) {
+ if (( ai->ai_indexmask & INDEX_EQUALITY ) &&
+ (flags & (BE_INDEX_ADD|BE_INDEX_EQUALITY))) {
+ /* on delete, only remove the equality index if the
+ * BE_INDEX_EQUALITY flag is set.
+ */
slapi_call_syntax_values2keys_sv( ai->ai_plugin, vals, &ivals,
LDAP_FILTER_EQUALITY );
18 years, 8 months