Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv8842/ldapserver/ldap/servers/slapd
Modified Files:
add.c modutil.c slapi-plugin.h util.c
Log Message:
Resolves: bug 471068
Bug Description: winsync doesn't recognize some changes
Reviewed by: nkinder (Thanks!)
Fix Description: Before sending updates to AD, first check to see if the updates still
apply. For modify/add operations, check to make sure the value to add doesn't exist.
If it does, remove it from the list of values in the mod. If all values are removed, then
just skip the modify/add op altogether. For modify/del ops, check to see if the attribute
exists. If not, just skip the op. If it does exist, check to see if the values exist,
and remove the values from the mod/del op that do not exist anymore. If all values have
been removed, just skip the mod/del op.
I added a new slapi function - slapi_mod_init_valueset_byval - which will init a Slapi_Mod
and init the list of values using a valueset. Fortunately there was already a function
for converting a Slapi_Value** to a berval**.
I also fixed a few compiler warnings.
Platforms tested: RHEL5
Flag Day: no
Doc impact: yes - add new function to slapi docs
Index: add.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/add.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- add.c 5 Jan 2009 16:57:03 -0000 1.18
+++ add.c 9 Jan 2009 21:30:56 -0000 1.19
@@ -745,7 +745,7 @@
char *type[] = {SLAPI_ATTR_UNIQUEID, "modifytimestamp",
"createtimestamp",
"creatorsname", "modifiersname", 0};
- if (rdn = slapi_rdn_new()) {
+ if ((rdn = slapi_rdn_new())) {
slapi_rdn_init_dn(rdn, slapi_entry_get_dn_const(e));
for (i = 0; type[i] != NULL; i++) {
Index: modutil.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/modutil.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- modutil.c 10 Nov 2006 23:45:40 -0000 1.7
+++ modutil.c 9 Jan 2009 21:30:56 -0000 1.8
@@ -595,6 +595,21 @@
}
void
+slapi_mod_init_valueset_byval(Slapi_Mod *smod, int op, const char *type, const
Slapi_ValueSet *svs)
+{
+ PR_ASSERT(smod!=NULL);
+ slapi_mod_init(smod, 0);
+ slapi_mod_set_operation (smod, op);
+ slapi_mod_set_type (smod, type);
+ if (svs!=NULL) {
+ Slapi_Value **svary = valueset_get_valuearray(svs);
+ valuearray_get_bervalarray(svary, &smod->mod->mod_bvalues);
+ smod->num_values = slapi_valueset_count(svs);
+ smod->num_elements = smod->num_values + 1;
+ }
+}
+
+void
slapi_mod_free (Slapi_Mod **smod)
{
slapi_mod_done(*smod);
@@ -750,15 +765,16 @@
if (mod == NULL || mod->mod == NULL)
return 0;
- op = mod->mod->mod_op && ~LDAP_MOD_BVALUES;
+ op = mod->mod->mod_op;
- if (op != LDAP_MOD_ADD && op != LDAP_MOD_DELETE && op !=
LDAP_MOD_REPLACE)
+ if (!SLAPI_IS_MOD_ADD(op) && !SLAPI_IS_MOD_DELETE(op) &&
!SLAPI_IS_MOD_REPLACE(op))
return 0;
if (mod->mod->mod_type == NULL)
return 0;
- if (op != LDAP_MOD_DELETE && mod->num_values == 0)
+ /* add op must have at least 1 value */
+ if (SLAPI_IS_MOD_ADD(op) && (mod->num_values == 0))
return 0;
return 1;
Index: slapi-plugin.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-plugin.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- slapi-plugin.h 5 Dec 2008 22:41:52 -0000 1.36
+++ slapi-plugin.h 9 Jan 2009 21:30:56 -0000 1.37
@@ -573,6 +573,8 @@
void slapi_mod_init_byval(Slapi_Mod *smod, const LDAPMod *mod);
void slapi_mod_init_byref(Slapi_Mod *smod, LDAPMod *mod);
void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod);
+/* init a mod and set the mod values to be a copy of the given valueset */
+void slapi_mod_init_valueset_byval(Slapi_Mod *smod, int op, const char *type, const
Slapi_ValueSet *svs);
void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val);
void slapi_mod_remove_value(Slapi_Mod *smod);
struct berval *slapi_mod_get_first_value(Slapi_Mod *smod);
Index: util.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/util.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- util.c 7 Jan 2009 02:33:37 -0000 1.25
+++ util.c 9 Jan 2009 21:30:56 -0000 1.26
@@ -207,7 +207,6 @@
void
strcpy_unescape_value( char *d, const char *s )
{
- char *head = d;
int gotesc = 0;
const char *end = s + strlen(s);
for ( ; *s; s++ )
Show replies by date