[PATCH] Attribute modify order in lib/smbldap.c smbldap_make_mod()

Petri Asikainen paca at sci.fi
Thu Dec 18 09:47:48 GMT 2003


This patch will change order how attributes are modified from:
add, delete
to:
delete, add.

This is needed to update single valued attributes in Novell NDS.
This should not harm anyone else.

Cheers,

Petri



-------------- next part --------------
*** samba-3.0.1/source/lib/smbldap.c	Sun Dec 14 08:20:52 2003
--- samba-3.0.1/source/lib/ssmbldap.c	Thu Dec 18 06:56:49 2003
***************
*** 438,451 ****
  	   the old value, should it exist. */
  
  	if ((newval != NULL) && (strlen(newval) > 0)) {
! 		smbldap_set_mod(mods, LDAP_MOD_ADD, attribute, newval);
! 	}
  
! 	if (!existed) {
! 		/* There has been no value before, so don't delete it.
! 		   Here's a possible race: We might end up with
! 		   duplicate attributes */
! 		return;
  	}
  
  	/* By deleting exactly the value we found in the entry this
--- 438,459 ----
  	   the old value, should it exist. */
  
  	if ((newval != NULL) && (strlen(newval) > 0)) {
! 		if (existed) {
! 		        /* There has been no value before, so don't delete it.
! 			 * Here's a possible race: We might end up with
! 			 * duplicate attributes */
! 			/* By deleting exactly the value we found in the entry this
! 			 * should be race-free in the sense that the LDAP-Server will
! 			 * deny the complete operation if somebody changed the
! 			 * attribute behind our back. */
! 			/* This will also allow modifying single valued attributes 
! 			 * in Novell NDS. In NDS you have to first remove attribute and then
! 			 * you could add new value */
  
! 	                 smbldap_set_mod(mods, LDAP_MOD_DELETE, attribute, oldval);
! 	        }
! 
! 		smbldap_set_mod(mods, LDAP_MOD_ADD, attribute, newval);
  	}
  
  	/* By deleting exactly the value we found in the entry this
***************
*** 453,459 ****
  	   deny the complete operation if somebody changed the
  	   attribute behind our back. */
  
- 	smbldap_set_mod(mods, LDAP_MOD_DELETE, attribute, oldval);
  }
  
  /**********************************************************************
--- 461,466 ----


More information about the samba-technical mailing list