ldap/servers/plugins/posix-winsync/posix-group-func.c | 514 ++++++++----------
ldap/servers/plugins/posix-winsync/posix-winsync.c | 24
2 files changed, 259 insertions(+), 279 deletions(-)
New commits:
commit e3e81dbb3b5eaf3efb3c4b366e287d2ef8ee56e6
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 17:35:56 2012 -0400
Simplify program flow: change while loops to for
Reviewed by: rmeggins
(cherry picked from commit 26739f7cc97318a0b19fca6a0ede66b4faa5f677)
diff --git a/ldap/servers/plugins/posix-winsync/posix-winsync.c b/ldap/servers/plugins/posix-winsync/posix-winsync.c
index dc56475..6bdac20 100644
--- a/ldap/servers/plugins/posix-winsync/posix-winsync.c
+++ b/ldap/servers/plugins/posix-winsync/posix-winsync.c
@@ -565,7 +565,7 @@ posix_winsync_pre_ad_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry, Slap
slapi_attr_get_type(attr, &type);
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
"_pre_ad_mod_user_cb -- check modify type %s\n", type);
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (0 == slapi_attr_type_cmp(type, attr_map[i].ldap_attribute_name,
SLAPI_TYPE_CMP_SUBTYPE)) {
Slapi_Attr *ad_attr = NULL;
@@ -612,7 +612,6 @@ posix_winsync_pre_ad_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry, Slap
slapi_entry_get_dn_const(ds_entry));
}
- i++;
}
if (0 == slapi_attr_type_cmp(type, "nsAccountLock", SLAPI_TYPE_CMP_SUBTYPE))
sync_acct_disable(cbdata, rawentry, ds_entry, ACCT_DISABLE_TO_AD, NULL, smods,
@@ -654,7 +653,7 @@ posix_winsync_pre_ad_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry, Sla
slapi_attr_get_type(attr, &type);
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
"_pre_ad_mod_group_cb -- check modify type %s\n", type);
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (0 == slapi_attr_type_cmp(type, attr_map[i].ldap_attribute_name,
SLAPI_TYPE_CMP_SUBTYPE)) {
Slapi_Attr *ad_attr = NULL;
@@ -701,7 +700,6 @@ posix_winsync_pre_ad_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry, Sla
attr_map[i].windows_attribute_name,
slapi_entry_get_dn_const(ds_entry));
}
- i++;
}
}
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name, "_pre_ad_mod_group_cb -- step\n");
@@ -741,7 +739,7 @@ posix_winsync_pre_ds_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry, Slap
size_t i = 0;
slapi_attr_get_type(attr, &type);
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (0 == slapi_attr_type_cmp(type, attr_map[i].windows_attribute_name,
SLAPI_TYPE_CMP_SUBTYPE)) {
Slapi_Attr *local_attr = NULL;
@@ -775,7 +773,6 @@ posix_winsync_pre_ds_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry, Slap
slapi_ch_free((void**) &local_type);
/* what about if delete all values on windows ????? */
}
- i++;
}
}
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
@@ -857,7 +854,7 @@ posix_winsync_pre_ds_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry, Sla
size_t i = 0;
slapi_attr_get_type(attr, &type);
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (0 == slapi_attr_type_cmp(type, attr_map[i].windows_attribute_name,
SLAPI_TYPE_CMP_SUBTYPE)) {
Slapi_Attr *local_attr = NULL;
@@ -895,7 +892,6 @@ posix_winsync_pre_ds_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry, Sla
slapi_valueset_free(vs);
/* what about if delete all values on windows ???? */
}
- i++;
}
}
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
@@ -978,7 +974,7 @@ posix_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry, Slap
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name, "--> _pre_ds_add_user_cb -- "
"look for [%s] to new entry [%s]\n", type, slapi_entry_get_dn_const(ds_entry));
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (slapi_attr_type_cmp(attr_map[i].windows_attribute_name, type,
SLAPI_TYPE_CMP_SUBTYPE) == 0) {
Slapi_ValueSet *svs = NULL;
@@ -992,7 +988,6 @@ posix_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry, Slap
slapi_entry_get_dn_const(ds_entry));
posixval = PR_TRUE;
}
- i++;
}
}
if (posixval) {
@@ -1036,7 +1031,7 @@ posix_winsync_pre_ds_add_group_cb(void *cbdata, const Slapi_Entry *rawentry, Sla
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name, "--> _pre_ds_add_group_cb -- "
"look for [%s] to new entry [%s]\n", type, slapi_entry_get_dn_const(ds_entry));
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (slapi_attr_type_cmp(attr_map[i].windows_attribute_name, type,
SLAPI_TYPE_CMP_SUBTYPE) == 0) {
Slapi_ValueSet *svs = NULL;
@@ -1050,7 +1045,6 @@ posix_winsync_pre_ds_add_group_cb(void *cbdata, const Slapi_Entry *rawentry, Sla
slapi_entry_get_dn_const(ds_entry));
posixval = PR_TRUE;
}
- i++;
}
}
if (posixval) {
@@ -1130,7 +1124,7 @@ posix_winsync_pre_ad_mod_user_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
size_t i = 0;
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
"_pre_ad_mod_user_mods_cb -- check modify type %s\n", mod->mod_type);
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (0 == slapi_attr_type_cmp(mod->mod_type, attr_map[i].ldap_attribute_name,
SLAPI_TYPE_CMP_SUBTYPE)) {
Slapi_Mod *mysmod = slapi_mod_new();
@@ -1151,7 +1145,6 @@ posix_winsync_pre_ad_mod_user_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
slapi_mod_free(&ocsmod);
}
}
- i++;
}
if (0 == slapi_attr_type_cmp(mod->mod_type, "nsRoleDN", SLAPI_TYPE_CMP_SUBTYPE)) {
int dummy = 0;
@@ -1198,7 +1191,7 @@ posix_winsync_pre_ad_mod_group_mods_cb(void *cbdata, const Slapi_Entry *rawentry
size_t i = 0;
slapi_log_error(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
"_pre_ad_mod_group_mods_cb -- check modify type %s\n", mod->mod_type);
- while (attr_map[i].windows_attribute_name != NULL) {
+ for (; attr_map[i].windows_attribute_name != NULL; i++) {
if (0 == slapi_attr_type_cmp(mod->mod_type, attr_map[i].ldap_attribute_name,
SLAPI_TYPE_CMP_SUBTYPE)) {
Slapi_Mod *mysmod = slapi_mod_new();
@@ -1226,7 +1219,6 @@ posix_winsync_pre_ad_mod_group_mods_cb(void *cbdata, const Slapi_Entry *rawentry
attr_map[i].windows_attribute_name,
slapi_entry_get_dn_const(ds_entry));
}
- i++;
}
}
*modstosend = slapi_mods_get_ldapmods_passout(new_smods);
commit a0d5dc0f5fa7bb59a27f9536bb966cfe1d5020eb
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 17:29:45 2012 -0400
Fix logic errors: del_mod should be latched (might not be last mod), and avoid skipping add-mods (int value 0)
Reviewed by: rmeggins
(cherry picked from commit 137bd7fa824c294d1937f3ea1049af25bd5db89a)
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index 6a819e6..1403a89 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -230,7 +230,7 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
Slapi_Mod *smod = NULL;
Slapi_Mod *nextMod = slapi_mod_new();
- int del_mod = 0;
+ int del_mod = 0; /* Bool: was there a delete mod? */
char **smod_adduids = NULL;
char **smod_deluids = NULL;
@@ -243,13 +243,13 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
if (slapi_attr_types_equivalent(slapi_mod_get_type(smod), "uniqueMember")) {
struct berval *bv;
- del_mod = slapi_mod_get_operation(smod);
for (bv = slapi_mod_get_first_value(smod); bv;
bv = slapi_mod_get_next_value(smod)) {
Slapi_Value *sv = slapi_value_new();
slapi_value_init_berval(sv, bv); /* copies bv_val */
if (SLAPI_IS_MOD_DELETE(slapi_mod_get_operation(smod))) {
+ del_mod = 1;
slapi_ch_array_add(&smod_deluids,
slapi_ch_strdup(slapi_value_get_string(sv)));
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
@@ -267,11 +267,6 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
}
}
slapi_mod_free(&nextMod);
- if (!del_mod) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: no uniquemember mod, nothing to do<==\n");
- return 0;
- }
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
"modGroupMembership: entry is posixGroup\n");
@@ -285,7 +280,7 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
int doModify = false;
int j = 0;
- if (SLAPI_IS_MOD_DELETE(del_mod) || smod_deluids != NULL) {
+ if (del_mod || smod_deluids != NULL) {
do { /* Create a context to "break" from */
Slapi_Attr * mu_attr = NULL; /* Entry attributes */
rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
commit 0808f7ef69195d1c530359318e8291087a1630a3
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 17:17:21 2012 -0400
Simplify program flow: make adduids/moduids/deluids action blocks all similar
Reviewed by: rmeggins
(cherry picked from commit 1f3cd6fd38692c16db570f54aebffbb868e051de)
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index 2f9478e..6a819e6 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -385,29 +385,23 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
}
}
if (doModify) {
- if (adduids) {
- int i;
- for (i = 0; adduids[i]; i++) {
- if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", adduids[i])) {
- slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", adduids[i]);
- }
+ int i;
+ for (i = 0; adduids && adduids[i]; i++) {
+ if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", adduids[i])) {
+ slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", adduids[i]);
}
- } else {
- int i;
- for (i = 0; moduids && moduids[i]; i++) {
- if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", moduids[i])) {
- slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", moduids[i]);
- }
+ }
+ for (i = 0; moduids && moduids[i]; i++) {
+ if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", moduids[i])) {
+ slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", moduids[i]);
}
- slapi_ch_array_free(moduids);
- moduids = NULL;
- for (i = 0; deluids && deluids[i]; i++) {
- if (!smods_has_mod(smods, LDAP_MOD_DELETE, "memberUid", deluids[i])) {
- slapi_mods_add_string(smods, LDAP_MOD_DELETE, "memberUid",
- deluids[i]);
- }
+ }
+ for (i = 0; deluids && deluids[i]; i++) {
+ if (!smods_has_mod(smods, LDAP_MOD_DELETE, "memberUid", deluids[i])) {
+ slapi_mods_add_string(smods, LDAP_MOD_DELETE, "memberUid", deluids[i]);
}
}
+
if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN))
slapi_mods_dump(smods, "memberUid - mods dump");
*do_modify = 1;
commit 77eb7602e91d377dea82277a523a2724a502be78
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 17:14:03 2012 -0400
Simplify program flow: eliminate unnecessary continue
Reviewed by: rmeggins
(cherry picked from commit 0a3b950695037a4b9348d60edf1a7863be2e76b7)
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index d6b68c5..2f9478e 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -479,11 +479,9 @@ addGroupMembership(Slapi_Entry *entry, Slapi_Entry *ad_entry)
} else {
v = slapi_value_new_string(uid);
slapi_ch_free_string(&uid);
- if (slapi_attr_value_find(muid_attr, slapi_value_get_berval(v)) == 0) {
- slapi_value_free(&v);
- continue;
+ if (slapi_attr_value_find(muid_attr, slapi_value_get_berval(v)) != 0) {
+ slapi_valueset_add_value(newvs, v);
}
- slapi_valueset_add_value(newvs, v);
slapi_value_free(&v);
}
}
commit c9e9db7201cc602271eb3b876c242b46fe4c76ad
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 17:11:37 2012 -0400
Memory leaks: unmatched slapi_attr_get_valueset and slapi_value_new
Reviewed by: rmeggins
(cherry picked from commit 3a795db07cacd5a38483f666a1d27710285005f3)
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index dc8e7ce..d6b68c5 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -357,6 +357,7 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
"modGroupMembership: no attribute memberUid, add with %s \n",
uid_dn);
slapi_ch_array_add(&adduids, uid);
+ uid = NULL; /* adduids now owns uid */
doModify = true;
} else { /* Found a memberUid list, so modify */
Slapi_ValueSet *vs = NULL;
@@ -372,9 +373,13 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
slapi_ch_array_add(&moduids, uid);
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
"modGroupMembership: add to modlist %s\n", uid);
+ uid = NULL; /* adduids now owns uid */
+ /* have to clear out v otherwise slapi_value_free will also free uid */
+ slapi_value_init_berval(v, NULL);
doModify = true;
}
- /* slapi_value_free(&v); */
+ slapi_value_free(&v); /* also frees uid since it was a passin */
+ slapi_valueset_free(vs); vs = NULL;
}
}
}
commit a4ca0cc6b0d73871b01f6d823f959e07adb625a8
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 17:05:43 2012 -0400
Change "return"s in modGroupMembership to "break"s to avoid leaking
Reviewed by: rmeggins
(cherry picked from commit de62d7019ddb2d3d455420e1cb07815a81cd015e)
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index 5ae5abb..dc8e7ce 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -286,48 +286,50 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
int j = 0;
if (SLAPI_IS_MOD_DELETE(del_mod) || smod_deluids != NULL) {
- Slapi_Attr * mu_attr = NULL; /* Entry attributes */
- rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
- if (rc != 0 || mu_attr == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership end: attribute memberUid not found\n");
- return 0;
- }
- /* found attribute uniquemember */
- if (smod_deluids == NULL) { /* deletion of the last value, deletes the Attribut from entry complete, this operation has no value, so we must look by self */
- Slapi_Attr * um_attr = NULL; /* Entry attributes */
- Slapi_Value * uid_dn_value = NULL; /* Attribute values */
- int rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
- if (rc != 0 || um_attr == NULL) {
+ do { /* Create a context to "break" from */
+ Slapi_Attr * mu_attr = NULL; /* Entry attributes */
+ rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
+ if (rc != 0 || mu_attr == NULL) {
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership end: attribute uniquemember not found\n");
- return 0;
+ "modGroupMembership end: attribute memberUid not found\n");
+ break;
}
/* found attribute uniquemember */
- /* ...loop for value... */
- for (j = slapi_attr_first_value(um_attr, &uid_dn_value); j != -1;
- j = slapi_attr_next_value(um_attr, j, &uid_dn_value)) {
- slapi_ch_array_add(&smod_deluids,
- slapi_ch_strdup(slapi_value_get_string(uid_dn_value)));
+ if (smod_deluids == NULL) { /* deletion of the last value, deletes the Attribut from entry complete, this operation has no value, so we must look by self */
+ Slapi_Attr * um_attr = NULL; /* Entry attributes */
+ Slapi_Value * uid_dn_value = NULL; /* Attribute values */
+ int rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
+ if (rc != 0 || um_attr == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership end: attribute uniquemember not found\n");
+ break;
+ }
+ /* found attribute uniquemember */
+ /* ...loop for value... */
+ for (j = slapi_attr_first_value(um_attr, &uid_dn_value); j != -1;
+ j = slapi_attr_next_value(um_attr, j, &uid_dn_value)) {
+ slapi_ch_array_add(&smod_deluids,
+ slapi_ch_strdup(slapi_value_get_string(uid_dn_value)));
+ }
}
- }
- /* ...loop for value... */
- for (j = slapi_attr_first_value(mu_attr, &uid_value); j != -1;
- j = slapi_attr_next_value(mu_attr, j, &uid_value)) {
- /* remove from uniquemember: remove from memberUid also */
- const char *uid = NULL;
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: test dellist \n");
- uid = slapi_value_get_string(uid_value);
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: test dellist %s\n", uid);
- if (uid_in_set(uid, smod_deluids)) {
- slapi_ch_array_add(&deluids, slapi_ch_strdup(uid));
+ /* ...loop for value... */
+ for (j = slapi_attr_first_value(mu_attr, &uid_value); j != -1;
+ j = slapi_attr_next_value(mu_attr, j, &uid_value)) {
+ /* remove from uniquemember: remove from memberUid also */
+ const char *uid = NULL;
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: test dellist \n");
+ uid = slapi_value_get_string(uid_value);
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: add to dellist %s\n", uid);
- doModify = true;
+ "modGroupMembership: test dellist %s\n", uid);
+ if (uid_in_set(uid, smod_deluids)) {
+ slapi_ch_array_add(&deluids, slapi_ch_strdup(uid));
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: add to dellist %s\n", uid);
+ doModify = true;
+ }
}
- }
+ } while (false);
}
if (smod_adduids != NULL) { /* not MOD_DELETE */
const char *uid_dn = NULL;
commit d49035ccd6ac88c4ce4ebe2326e9bf362bd26086
Author: Ken Rossato <ken.rossato(a)redhat.com>
Date: Mon Aug 27 16:41:00 2012 -0400
Factorize into new isPosixGroup function
(cherry picked from commit a7804d90784ee5c5654acfebc6f53a378dec3b71)
Reviewed by: rmeggins
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index d4bbcfe..5ae5abb 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -186,231 +186,237 @@ smods_has_mod(Slapi_Mods *smods, int modtype, const char *type, const char *val)
}
int
+isPosixGroup(Slapi_Entry *entry)
+{
+ int rc = 0;
+ int i;
+ Slapi_Attr *obj_attr = NULL;
+ Slapi_Value *value = NULL;
+
+ rc = slapi_entry_attr_find(entry, "objectclass", &obj_attr);
+
+ if (rc != 0) {
+ return 0; /* Doesn't have any objectclasses */
+ }
+
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "add/mod-GroupMembership scan objectclasses\n");
+
+ for (
+ i = slapi_attr_first_value(obj_attr, &value);
+ i != -1;
+ i = slapi_attr_next_value(obj_attr, i, &value)
+ ) {
+ const char *oc = NULL;
+ oc = slapi_value_get_string(value);
+ if (strncasecmp(oc, "posixGroup", 11) == 0) {
+ return 1; /* Entry has objectclass posixGroup */
+ }
+ }
+
+ return 0; /* Doesn't have objectclass "posixGroup" */
+}
+
+int
modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
{
int rc = 0;
- Slapi_Attr * obj_attr = NULL; /* Entry attributes */
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME, "modGroupMembership: ==>\n");
- rc = slapi_entry_attr_find(entry, "objectclass", &obj_attr);
- if (rc == 0) { /* Found objectclasses, so... */
- int i;
- Slapi_Value * value = NULL; /* Attribute values */
+ if (!isPosixGroup(entry)) {
+ return 0;
+ }
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership scan objectclasses\n");
- for (i = slapi_attr_first_value(obj_attr, &value); i != -1;
- i = slapi_attr_next_value(obj_attr, i, &value)) {
- const char * oc = NULL;
-
- oc = slapi_value_get_string(value);
- if (strncasecmp(oc, "posixGroup", 11) == 0) { /* entry has objectclass posixGroup */
- Slapi_Mod *smod = NULL;
- Slapi_Mod *nextMod = slapi_mod_new();
- int del_mod = 0;
- char **smod_adduids = NULL;
- char **smod_deluids = NULL;
+ Slapi_Mod *smod = NULL;
+ Slapi_Mod *nextMod = slapi_mod_new();
+ int del_mod = 0;
+ char **smod_adduids = NULL;
+ char **smod_deluids = NULL;
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: posixGroup -> look for uniquemember\n");
- if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN))
- slapi_mods_dump(smods, "memberUid - mods dump - initial");
- for (smod = slapi_mods_get_first_smod(smods, nextMod); smod; smod
- = slapi_mods_get_next_smod(smods, nextMod)) {
- if (slapi_attr_types_equivalent(slapi_mod_get_type(smod), "uniqueMember")) {
- struct berval *bv;
-
- del_mod = slapi_mod_get_operation(smod);
- for (bv = slapi_mod_get_first_value(smod); bv;
- bv = slapi_mod_get_next_value(smod)) {
- Slapi_Value *sv = slapi_value_new();
-
- slapi_value_init_berval(sv, bv); /* copies bv_val */
- if (SLAPI_IS_MOD_DELETE(slapi_mod_get_operation(smod))) {
- slapi_ch_array_add(&smod_deluids,
- slapi_ch_strdup(slapi_value_get_string(sv)));
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: add to deluids %s\n",
- bv->bv_val);
- } else {
- slapi_ch_array_add(&smod_adduids,
- slapi_ch_strdup(slapi_value_get_string(sv)));
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: add to adduids %s\n",
- bv->bv_val);
- }
- slapi_value_free(&sv);
- }
- }
- }
- slapi_mod_free(&nextMod);
- if (!del_mod) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: posixGroup -> look for uniquemember\n");
+ if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN))
+ slapi_mods_dump(smods, "memberUid - mods dump - initial");
+ for (smod = slapi_mods_get_first_smod(smods, nextMod); smod; smod
+ = slapi_mods_get_next_smod(smods, nextMod)) {
+ if (slapi_attr_types_equivalent(slapi_mod_get_type(smod), "uniqueMember")) {
+ struct berval *bv;
+
+ del_mod = slapi_mod_get_operation(smod);
+ for (bv = slapi_mod_get_first_value(smod); bv;
+ bv = slapi_mod_get_next_value(smod)) {
+ Slapi_Value *sv = slapi_value_new();
+
+ slapi_value_init_berval(sv, bv); /* copies bv_val */
+ if (SLAPI_IS_MOD_DELETE(slapi_mod_get_operation(smod))) {
+ slapi_ch_array_add(&smod_deluids,
+ slapi_ch_strdup(slapi_value_get_string(sv)));
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: add to deluids %s\n",
+ bv->bv_val);
+ } else {
+ slapi_ch_array_add(&smod_adduids,
+ slapi_ch_strdup(slapi_value_get_string(sv)));
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: no uniquemember mod, nothing to do<==\n");
- return 0;
+ "modGroupMembership: add to adduids %s\n",
+ bv->bv_val);
}
+ slapi_value_free(&sv);
+ }
+ }
+ }
+ slapi_mod_free(&nextMod);
+ if (!del_mod) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: no uniquemember mod, nothing to do<==\n");
+ return 0;
+ }
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: entry is posixGroup\n");
+
+ Slapi_Attr * muid_attr = NULL; /* Entry attributes */
+ Slapi_Value * uid_value = NULL; /* Attribute values */
+
+ char **adduids = NULL;
+ char **moduids = NULL;
+ char **deluids = NULL;
+ int doModify = false;
+ int j = 0;
+
+ if (SLAPI_IS_MOD_DELETE(del_mod) || smod_deluids != NULL) {
+ Slapi_Attr * mu_attr = NULL; /* Entry attributes */
+ rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
+ if (rc != 0 || mu_attr == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership end: attribute memberUid not found\n");
+ return 0;
+ }
+ /* found attribute uniquemember */
+ if (smod_deluids == NULL) { /* deletion of the last value, deletes the Attribut from entry complete, this operation has no value, so we must look by self */
+ Slapi_Attr * um_attr = NULL; /* Entry attributes */
+ Slapi_Value * uid_dn_value = NULL; /* Attribute values */
+ int rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
+ if (rc != 0 || um_attr == NULL) {
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: entry is posixGroup\n");
+ "modGroupMembership end: attribute uniquemember not found\n");
+ return 0;
+ }
+ /* found attribute uniquemember */
+ /* ...loop for value... */
+ for (j = slapi_attr_first_value(um_attr, &uid_dn_value); j != -1;
+ j = slapi_attr_next_value(um_attr, j, &uid_dn_value)) {
+ slapi_ch_array_add(&smod_deluids,
+ slapi_ch_strdup(slapi_value_get_string(uid_dn_value)));
+ }
+ }
+ /* ...loop for value... */
+ for (j = slapi_attr_first_value(mu_attr, &uid_value); j != -1;
+ j = slapi_attr_next_value(mu_attr, j, &uid_value)) {
+ /* remove from uniquemember: remove from memberUid also */
+ const char *uid = NULL;
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: test dellist \n");
+ uid = slapi_value_get_string(uid_value);
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: test dellist %s\n", uid);
+ if (uid_in_set(uid, smod_deluids)) {
+ slapi_ch_array_add(&deluids, slapi_ch_strdup(uid));
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: add to dellist %s\n", uid);
+ doModify = true;
+ }
+ }
+ }
+ if (smod_adduids != NULL) { /* not MOD_DELETE */
+ const char *uid_dn = NULL;
- Slapi_Attr * muid_attr = NULL; /* Entry attributes */
- Slapi_Value * uid_value = NULL; /* Attribute values */
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: posixGroup -> look for uniquemember\n");
+ /* found attribute uniquemember */
+ for (j = 0; smod_adduids[j]; j++) {
+ static char *uid = NULL;
- char **adduids = NULL;
- char **moduids = NULL;
- char **deluids = NULL;
- int doModify = false;
- int j = 0;
+ uid_dn = smod_adduids[j];
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: perform user %s\n", uid_dn);
- if (SLAPI_IS_MOD_DELETE(del_mod) || smod_deluids != NULL) {
- Slapi_Attr * mu_attr = NULL; /* Entry attributes */
- rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
- if (rc != 0 || mu_attr == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership end: attribute memberUid not found\n");
- return 0;
- }
- /* found attribute uniquemember */
- if (smod_deluids == NULL) { /* deletion of the last value, deletes the Attribut from entry complete, this operation has no value, so we must look by self */
- Slapi_Attr * um_attr = NULL; /* Entry attributes */
- Slapi_Value * uid_dn_value = NULL; /* Attribute values */
- int rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
- if (rc != 0 || um_attr == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership end: attribute uniquemember not found\n");
- return 0;
- }
- /* found attribute uniquemember */
- /* ...loop for value... */
- for (j = slapi_attr_first_value(um_attr, &uid_dn_value); j != -1;
- j = slapi_attr_next_value(um_attr, j, &uid_dn_value)) {
- slapi_ch_array_add(&smod_deluids,
- slapi_ch_strdup(slapi_value_get_string(uid_dn_value)));
- }
- }
- /* ...loop for value... */
- for (j = slapi_attr_first_value(mu_attr, &uid_value); j != -1;
- j = slapi_attr_next_value(mu_attr, j, &uid_value)) {
- /* remove from uniquemember: remove from memberUid also */
- const char *uid = NULL;
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: test dellist \n");
- uid = slapi_value_get_string(uid_value);
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: test dellist %s\n", uid);
- if (uid_in_set(uid, smod_deluids)) {
- slapi_ch_array_add(&deluids, slapi_ch_strdup(uid));
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: add to dellist %s\n", uid);
- doModify = true;
- }
- }
- }
- if (smod_adduids != NULL) { /* not MOD_DELETE */
- const char *uid_dn = NULL;
+ uid = searchUid(uid_dn);
+ if (uid == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: uid not found for %s, cannot do anything\n",
+ uid_dn); /* member on longer on server, do nothing */
+ } else {
+ rc |= slapi_entry_attr_find(entry, "memberUid", &muid_attr);
+ if (rc != 0 || muid_attr == NULL) { /* Found no memberUid list, so create */
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: posixGroup -> look for uniquemember\n");
- /* found attribute uniquemember */
- for (j = 0; smod_adduids[j]; j++) {
- static char *uid = NULL;
-
- uid_dn = smod_adduids[j];
+ "modGroupMembership: no attribute memberUid, add with %s \n",
+ uid_dn);
+ slapi_ch_array_add(&adduids, uid);
+ doModify = true;
+ } else { /* Found a memberUid list, so modify */
+ Slapi_ValueSet *vs = NULL;
+ Slapi_Value *v = slapi_value_new();
+
+ slapi_value_init_string_passin(v, uid);
+ slapi_attr_get_valueset(muid_attr, &vs);
+ if (slapi_valueset_find(muid_attr, vs, v) != NULL) { /* already exist, all ok */
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: perform user %s\n", uid_dn);
-
- uid = searchUid(uid_dn);
-
- if (uid == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: uid not found for %s, cannot do anything\n",
- uid_dn); /* member on longer on server, do nothing */
- } else {
- rc |= slapi_entry_attr_find(entry, "memberUid", &muid_attr);
- if (rc != 0 || muid_attr == NULL) { /* Found no memberUid list, so create */
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: no attribute memberUid, add with %s \n",
- uid_dn);
- slapi_ch_array_add(&adduids, uid);
- doModify = true;
- } else { /* Found a memberUid list, so modify */
- Slapi_ValueSet *vs = NULL;
- Slapi_Value *v = slapi_value_new();
-
- slapi_value_init_string_passin(v, uid);
- slapi_attr_get_valueset(muid_attr, &vs);
- if (slapi_valueset_find(muid_attr, vs, v) != NULL) { /* already exist, all ok */
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: uid found in memberuid list %s nothing to do\n",
- uid);
- } else {
- slapi_ch_array_add(&moduids, uid);
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: add to modlist %s\n", uid);
- doModify = true;
- }
- slapi_valueset_free(vs);
- slapi_value_init_berval(v, NULL); /* otherwise we will try to free memory we do not own */
- slapi_value_free(&v);
- }
- }
- }
- }
- if (doModify) {
- if (adduids) {
- int i;
- for (i = 0; adduids[i]; i++) {
- if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", adduids[i])) {
- slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", adduids[i]);
- }
- }
+ "modGroupMembership: uid found in memberuid list %s nothing to do\n",
+ uid);
} else {
- int i;
- for (i = 0; moduids && moduids[i]; i++) {
- if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", moduids[i])) {
- slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", moduids[i]);
- }
- }
- slapi_ch_array_free(moduids);
- moduids = NULL;
- for (i = 0; deluids && deluids[i]; i++) {
- if (!smods_has_mod(smods, LDAP_MOD_DELETE, "memberUid", deluids[i])) {
- slapi_mods_add_string(smods, LDAP_MOD_DELETE, "memberUid",
- deluids[i]);
- }
- }
+ slapi_ch_array_add(&moduids, uid);
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: add to modlist %s\n", uid);
+ doModify = true;
}
- if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN))
- slapi_mods_dump(smods, "memberUid - mods dump");
- *do_modify = 1;
- posix_winsync_config_set_MOFTaskCreated();
-
- slapi_ch_array_free(smod_adduids);
- smod_adduids = NULL;
- slapi_ch_array_free(adduids);
- adduids = NULL;
- slapi_ch_array_free(smod_deluids);
- smod_deluids = NULL;
- slapi_ch_array_free(deluids);
- deluids = NULL;
- slapi_ch_array_free(moduids);
- moduids = NULL;
- break;
+ /* slapi_value_free(&v); */
}
- slapi_ch_array_free(smod_adduids);
- smod_adduids = NULL;
- slapi_ch_array_free(adduids);
- adduids = NULL;
- slapi_ch_array_free(smod_deluids);
- smod_deluids = NULL;
- slapi_ch_array_free(deluids);
- deluids = NULL;
- slapi_ch_array_free(moduids);
- moduids = NULL;
}
}
}
+ if (doModify) {
+ if (adduids) {
+ int i;
+ for (i = 0; adduids[i]; i++) {
+ if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", adduids[i])) {
+ slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", adduids[i]);
+ }
+ }
+ } else {
+ int i;
+ for (i = 0; moduids && moduids[i]; i++) {
+ if (!smods_has_mod(smods, LDAP_MOD_ADD, "memberUid", moduids[i])) {
+ slapi_mods_add_string(smods, LDAP_MOD_ADD, "memberUid", moduids[i]);
+ }
+ }
+ slapi_ch_array_free(moduids);
+ moduids = NULL;
+ for (i = 0; deluids && deluids[i]; i++) {
+ if (!smods_has_mod(smods, LDAP_MOD_DELETE, "memberUid", deluids[i])) {
+ slapi_mods_add_string(smods, LDAP_MOD_DELETE, "memberUid",
+ deluids[i]);
+ }
+ }
+ }
+ if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN))
+ slapi_mods_dump(smods, "memberUid - mods dump");
+ *do_modify = 1;
+ posix_winsync_config_set_MOFTaskCreated();
+ }
+ slapi_ch_array_free(smod_adduids);
+ smod_adduids = NULL;
+ slapi_ch_array_free(adduids);
+ adduids = NULL;
+ slapi_ch_array_free(smod_deluids);
+ smod_deluids = NULL;
+ slapi_ch_array_free(deluids);
+ deluids = NULL;
+ slapi_ch_array_free(moduids);
+ moduids = NULL;
+
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME, "modGroupMembership: <==\n");
return 0;
}
@@ -419,77 +425,65 @@ int
addGroupMembership(Slapi_Entry *entry, Slapi_Entry *ad_entry)
{
int rc = 0;
- Slapi_Attr * obj_attr = NULL; /* Entry attributes */
+ int i;
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME, "addGroupMembership: ==>\n");
- rc = slapi_entry_attr_find(entry, "objectclass", &obj_attr);
- if (rc == 0) { /* Found objectclasses, so... */
- int i;
- Slapi_Value * value = NULL; /* Attribute values */
+ if(!isPosixGroup(entry)) {
+ return 0;
+ }
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "addGroupMembership scan objectclasses\n");
- for (i = slapi_attr_first_value(obj_attr, &value); i != -1;
- i = slapi_attr_next_value(obj_attr, i, &value)) {
- Slapi_Attr * um_attr = NULL; /* Entry attributes uniquemember */
- Slapi_Attr * muid_attr = NULL; /* Entry attributes memebrof */
- Slapi_Value * uid_value = NULL; /* uniquemember Attribute values */
- const char * oc = NULL;
-
- oc = slapi_value_get_string(value);
- if (strncasecmp(oc, "posixGroup", 11) == 0) { /* entry has objectclass posixGroup */
- Slapi_ValueSet *newvs = NULL;
+ Slapi_Attr * um_attr = NULL; /* Entry attributes uniquemember */
+ Slapi_Attr * muid_attr = NULL; /* Entry attributes memebrof */
+ Slapi_Value * uid_value = NULL; /* uniquemember Attribute values */
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "addGroupMembership: posixGroup -> look for uniquemember\n");
- rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
- if (rc != 0 || um_attr == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "addGroupMembership end: attribute uniquemember not found\n");
- return 0;
- }
- /* found attribute uniquemember */
- rc = slapi_entry_attr_find(entry, "memberUid", &muid_attr);
- if (rc != 0 || muid_attr == NULL) { /* Found no memberUid list, so create */
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "addGroupMembership: no attribute memberUid\n");
- }
- newvs = slapi_valueset_new();
- /* ...loop for value... */
- for (i = slapi_attr_first_value(um_attr, &uid_value); i != -1;
- i = slapi_attr_next_value(um_attr, i, &uid_value)) {
- const char *uid_dn = NULL;
- static char *uid = NULL;
- Slapi_Value *v = NULL;
-
- uid_dn = slapi_value_get_string(uid_value);
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "addGroupMembership: perform member %s\n", uid_dn);
- uid = searchUid(uid_dn);
- if (uid == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "addGroupMembership: uid not found for %s, cannot do anything\n",
- uid_dn); /* member on longer on server, do nothing */
- } else {
- v = slapi_value_new_string(uid);
- slapi_ch_free_string(&uid);
- if (slapi_attr_value_find(muid_attr, slapi_value_get_berval(v)) == 0) {
- slapi_value_free(&v);
- continue;
- }
- slapi_valueset_add_value(newvs, v);
- slapi_value_free(&v);
- }
- }
- slapi_entry_add_valueset(entry, "memberUid", newvs);
- slapi_valueset_free(newvs);
- posix_winsync_config_get_MOFTaskCreated();
+ Slapi_ValueSet *newvs = NULL;
- break;
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "addGroupMembership: posixGroup -> look for uniquemember\n");
+ rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
+ if (rc != 0 || um_attr == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "addGroupMembership end: attribute uniquemember not found\n");
+ return 0;
+ }
+ /* found attribute uniquemember */
+ rc = slapi_entry_attr_find(entry, "memberUid", &muid_attr);
+ if (rc != 0 || muid_attr == NULL) { /* Found no memberUid list, so create */
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "addGroupMembership: no attribute memberUid\n");
+ }
+ newvs = slapi_valueset_new();
+ /* ...loop for value... */
+ for (i = slapi_attr_first_value(um_attr, &uid_value); i != -1;
+ i = slapi_attr_next_value(um_attr, i, &uid_value)) {
+ const char *uid_dn = NULL;
+ static char *uid = NULL;
+ Slapi_Value *v = NULL;
+
+ uid_dn = slapi_value_get_string(uid_value);
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "addGroupMembership: perform member %s\n", uid_dn);
+ uid = searchUid(uid_dn);
+ if (uid == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "addGroupMembership: uid not found for %s, cannot do anything\n",
+ uid_dn); /* member on longer on server, do nothing */
+ } else {
+ v = slapi_value_new_string(uid);
+ slapi_ch_free_string(&uid);
+ if (slapi_attr_value_find(muid_attr, slapi_value_get_berval(v)) == 0) {
+ slapi_value_free(&v);
+ continue;
}
+ slapi_valueset_add_value(newvs, v);
+ slapi_value_free(&v);
}
}
+ slapi_entry_add_valueset(entry, "memberUid", newvs);
+ slapi_valueset_free(newvs);
+ posix_winsync_config_get_MOFTaskCreated();
+
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME, "addGroupMembership: <==\n");
return 0;
}