summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-10-26 11:29:53 -0400
committerSimo Sorce <ssorce@redhat.com>2010-10-28 07:58:31 -0400
commit99a7f83c3c123554ca7279ec97abddd717f5ee70 (patch)
treedd47699569c172743eb0df28064f32846618cd17 /daemons
parent2a141bf2c12ae0f9a54e130e7f149d2ba7997942 (diff)
downloadfreeipa-99a7f83c3c123554ca7279ec97abddd717f5ee70.tar.gz
freeipa-99a7f83c3c123554ca7279ec97abddd717f5ee70.tar.xz
freeipa-99a7f83c3c123554ca7279ec97abddd717f5ee70.zip
ipa_uuid: Handle generation of the uuid when it is a RDN
Diffstat (limited to 'daemons')
-rw-r--r--daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c60
1 files changed, 50 insertions, 10 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
index eb5b40d7..c0fde90f 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -987,17 +987,13 @@ static int ipauuid_pre_op(Slapi_PBlock *pb, int modtype)
bv = slapi_mod_get_first_value(smod);
/* If we have a value, see if it's the magic value. */
if (bv) {
- int len = strlen(cfgentry->generate);
- if (len == bv->bv_len) {
- if (!slapi_UTF8NCASECMP(bv->bv_val,
- cfgentry->generate,
- len)) {
- generate = true;
+ if (!slapi_UTF8CASECMP(bv->bv_val,
+ cfgentry->generate)) {
+ generate = true;
- /* also remove this mod, as we will add
- * it again later */
- slapi_mod_remove_value(next_mod);
- }
+ /* also remove this mod, as we will add
+ * it again later */
+ slapi_mod_remove_value(next_mod);
}
} else {
/* This is a replace with no new values, so we need
@@ -1054,8 +1050,52 @@ static int ipauuid_pre_op(Slapi_PBlock *pb, int modtype)
/* do the mod */
if (LDAP_CHANGETYPE_ADD == modtype) {
+ Slapi_DN *sdn;
+ Slapi_RDN *rdn;
+ char *attr;
+ char *nrdn;
+
/* add - set in entry */
slapi_entry_attr_set_charptr(e, cfgentry->attr, new_value);
+
+ /* check to see if we need to change the RDN too */
+ rdn = slapi_rdn_new();
+ if (!rdn) {
+ LOG_OOM();
+ ret = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
+ sdn = slapi_sdn_new_dn_byval(dn);
+ if (!sdn) {
+ LOG_OOM();
+ ret = LDAP_OPERATIONS_ERROR;
+ slapi_rdn_free(&rdn);
+ goto done;
+ }
+ slapi_rdn_set_sdn(rdn, sdn);
+ ret = slapi_rdn_contains_attr(rdn, cfgentry->attr, &attr);
+ slapi_rdn_done(rdn);
+ if (ret == 1) {
+ /* no need to recheck if it is valid, it will be handled
+ * later by checking the value in the entry */
+ nrdn = slapi_ch_smprintf("%s=%s",
+ cfgentry->attr, new_value);
+ if (!nrdn) {
+ LOG_OOM();
+ ret = LDAP_OPERATIONS_ERROR;
+ slapi_rdn_free(&rdn);
+ slapi_sdn_free(&sdn);
+ goto done;
+ }
+
+ slapi_rdn_set_dn(rdn, nrdn);
+ slapi_ch_free_string(&nrdn);
+ slapi_sdn_set_rdn(sdn, rdn);
+ slapi_entry_set_sdn(e, sdn);
+ }
+ slapi_rdn_free(&rdn);
+ slapi_sdn_free(&sdn);
+
} else {
/* mod - add to mods */
slapi_mods_add_string(smods, LDAP_MOD_REPLACE,