[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: slapd dies when using SLAPI plugins (ITS#3924)



--19701020
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline


Sam,

>The good news: when I try to change the userPassword of a given user,
>slapd doesn't die anymore. The preoperation plugin (password strength
>check) and the postoperation plugin (password synchronization to other
>directory via P-synch server) work! The password of the user on the other
>directory is actually synchronized.
>
>The bad news: on the OpenLDAP server, the userPassword is actually not
>changed.

I think I see the problem, can you try the following fix? (Ignore
the unrelated in slapi_dn_parent()).

cheers,

-- Luke


--19701020
Content-Type: text/plain; name="slapi.diff"; x-unix-mode=0644
Content-Disposition: attachment; filename="slapi.diff"

Index: slapi/proto-slapi.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapi/proto-slapi.h,v
retrieving revision 1.45
diff -u -r1.45 proto-slapi.h
--- slapi/proto-slapi.h	8 Aug 2005 11:26:02 -0000	1.45
+++ slapi/proto-slapi.h	9 Aug 2005 03:23:32 -0000
@@ -26,7 +26,7 @@
 LDAP_BEGIN_DECL
 
 /* slapi_utils.c */
-LDAP_SLAPI_F (LDAPMod **) slapi_int_modifications2ldapmods LDAP_P(( Modifications ** ));
+LDAP_SLAPI_F (LDAPMod **) slapi_int_modifications2ldapmods LDAP_P(( Modifications * ));
 LDAP_SLAPI_F (Modifications *) slapi_int_ldapmods2modifications LDAP_P(( LDAPMod ** ));
 LDAP_SLAPI_F (int) slapi_int_count_controls LDAP_P(( LDAPControl **ctrls ));
 LDAP_SLAPI_F (char **) slapi_get_supported_extended_ops LDAP_P((void));
Index: slapi/slapi_pblock.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapi/slapi_pblock.c,v
retrieving revision 1.56
diff -u -r1.56 slapi_pblock.c
--- slapi/slapi_pblock.c	8 Aug 2005 07:33:02 -0000	1.56
+++ slapi/slapi_pblock.c	9 Aug 2005 03:23:33 -0000
@@ -607,7 +607,7 @@
 				rc = PBLOCK_ERROR;
 				break;
 			}
-			mods = slapi_int_modifications2ldapmods( &pb->pb_op->orm_modlist );
+			mods = slapi_int_modifications2ldapmods( pb->pb_op->orm_modlist );
 			pblock_set_default( pb, param, (void *)mods );
 		}
 		*((LDAPMod ***)value) = mods;
Index: slapi/slapi_utils.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapi/slapi_utils.c,v
retrieving revision 1.181
diff -u -r1.181 slapi_utils.c
--- slapi/slapi_utils.c	9 Aug 2005 01:39:12 -0000	1.181
+++ slapi/slapi_utils.c	9 Aug 2005 03:23:34 -0000
@@ -903,6 +903,7 @@
 {
 	struct berval	dn, prettyDN;
 	struct berval	parentDN;
+	char		*ret;
 
 	if ( _dn == NULL ) {
 		return NULL;
@@ -921,13 +922,15 @@
 
 	dnParent( &prettyDN, &parentDN ); /* in-place */
 
-	slapi_ch_free( (void **)&prettyDN.bv_val );
-
 	if ( parentDN.bv_len == 0 ) {
+		slapi_ch_free_string( &prettyDN.bv_val );
 		return NULL;
 	}
 
-	return slapi_ch_strdup( parentDN.bv_val );
+	ret = slapi_ch_strdup( parentDN.bv_val );
+	slapi_ch_free_string( &prettyDN.bv_val );
+
+	return ret;
 }
 
 int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *ldn )
@@ -2691,20 +2694,14 @@
 
 /*
  * Synthesise an LDAPMod array from a Modifications list to pass
- * to SLAPI. This synthesis is destructive and as such the 
- * Modifications list may not be used after calling this 
- * function.
- * 
- * This function must also be called before slap_mods_check().
+ * to SLAPI.
  */
-LDAPMod **slapi_int_modifications2ldapmods( Modifications **pmodlist )
+LDAPMod **slapi_int_modifications2ldapmods( Modifications *modlist )
 {
-	Modifications *ml, *modlist;
+	Modifications *ml;
 	LDAPMod **mods, *modp;
 	int i, j;
 
-	modlist = *pmodlist;
-
 	for( i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next )
 		;
 
@@ -2731,14 +2728,9 @@
 			for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) {
 				modp->mod_bvalues[j] = (struct berval *)slapi_ch_malloc(
 						sizeof(struct berval) );
-				/* Take ownership of original values. */
-				modp->mod_bvalues[j]->bv_len = ml->sml_values[j].bv_len;
-				modp->mod_bvalues[j]->bv_val = ml->sml_values[j].bv_val;
-				ml->sml_values[j].bv_len = 0;
-				ml->sml_values[j].bv_val = NULL;
+				ber_dupbv( modp->mod_bvalues[j], &ml->sml_values[j] );
 			}
 			modp->mod_bvalues[j] = NULL;
-			slapi_ch_free( (void **)&ml->sml_values );
 		} else {
 			modp->mod_bvalues = NULL;
 		}
@@ -2747,9 +2739,6 @@
 
 	mods[i] = NULL;
 
-	slap_mods_free( modlist, 1 );
-	*pmodlist = NULL;
-
 	return mods;
 }
 

--19701020
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline

--

--19701020--