Author: mimir Date: 2004-08-11 15:46:33 +0000 (Wed, 11 Aug 2004) New Revision: 1722 WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/trunk/source&rev=1722&nolog=1 Log: Empty (zeroed) sid passed in update function argument means "do not change it". Also, more descriptive comment of ldap mod structure initialisation from trust password structure.
rafal Modified: trunk/source/passdb/pdb_ldap.c trunk/source/utils/pdbedit.c Changeset: Modified: trunk/source/passdb/pdb_ldap.c =================================================================== --- trunk/source/passdb/pdb_ldap.c 2004-08-11 09:34:30 UTC (rev 1721) +++ trunk/source/passdb/pdb_ldap.c 2004-08-11 15:46:33 UTC (rev 1722) @@ -3252,7 +3252,9 @@ /** - * Init LDAP structures passed to ldap calls from trust password structure. + * Init LDAP structures passed to ldap calls from trust password structure. Fill out + * every field if in case of new ldap entry (entry parameter is NULL) or only those + * that have changed, when compared to existing ldap entry (entry parameter is not NULL). * * @param ldap_state LDAP state structure required by ldap calls * @param entry LDAPMessage existing entry structure returned from ldap calls (if any) @@ -3319,10 +3321,16 @@ if (entry) { ret = smbldap_get_single_attribute(ldap_state->smbldap_state->ldap_struct, entry, attr_sid, attr_val, sizeof(attr_val)); - if (ret) - if (strncmp(sid_to_string(sidstr, sid), attr_val, sizeof(attr_val))) + if (ret) { + /* pattern of "empty sid compare" */ + DOM_SID empty; + memset(&empty, 0, sizeof(empty)); + + if (memcmp((void*)sid, (void*)&empty, sizeof(DOM_SID)) && + strncmp(sid_to_string(sidstr, sid), attr_val, sizeof(attr_val))) smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, entry, mod, attr_sid, sidstr); + } } else { smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, entry, mod, attr_sid, sidstr); Modified: trunk/source/utils/pdbedit.c =================================================================== --- trunk/source/utils/pdbedit.c 2004-08-11 09:34:30 UTC (rev 1721) +++ trunk/source/utils/pdbedit.c 2004-08-11 15:46:33 UTC (rev 1722) @@ -834,7 +834,8 @@ printf("Error: incorrect SID specified !\n"); return -1; } - } + } else + memset(&trust.private.domain_sid, 0, sizeof(trust.private.domain_sid)); /* flags */ trust.private.flags = (flag) ? trustpw_flag(flag) : 0;