diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2008-07-31 17:25:37 +0000 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2008-07-31 17:25:37 +0000 |
commit | d8e44a8103bbd02010a53e528a0349abcb53e167 (patch) | |
tree | 5d10318adb47661779425d36ece76b283b53deff | |
parent | 0efccdb3791412040c671b6c41294d93289e6f73 (diff) | |
download | ds-d8e44a8103bbd02010a53e528a0349abcb53e167.tar.gz ds-d8e44a8103bbd02010a53e528a0349abcb53e167.tar.xz ds-d8e44a8103bbd02010a53e528a0349abcb53e167.zip |
Resolves: #457156
Summary: GER: allow GER for non-existing entries (phase 2) (comment #3)
Description: get the target dn from the pblock and add it to the template entry
dn if available. Plus a memory leak was found and fixed at the same time.
Following the suggestion from Nathan, the "dummy" attributes are replaced with
"(template_attribute)".
-rw-r--r-- | ldap/servers/plugins/acl/acleffectiverights.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c index 8353aef7..18f04681 100644 --- a/ldap/servers/plugins/acl/acleffectiverights.c +++ b/ldap/servers/plugins/acl/acleffectiverights.c @@ -811,6 +811,7 @@ _ger_generate_template_entry ( char *object = NULL; char *superior = NULL; char *p = NULL; + char *dn = NULL; int siz = 0; int len = 0; int i = 0; @@ -826,6 +827,8 @@ _ger_generate_template_entry ( rc = LDAP_SUCCESS; goto bailout; } + /* get the target dn where the template entry is located */ + slapi_pblock_get( pb, SLAPI_TARGET_DN, &dn ); for (i = 0; gerattrs && gerattrs[i]; i++) { object = strchr(gerattrs[i], '@'); @@ -855,14 +858,23 @@ _ger_generate_template_entry ( } else { - /* <*attrp>: dummy\n\0 */ - siz += strlen(attrs[i]) + 4 + 5; + /* <*attrp>: (template_attribute)\n\0 */ + siz += strlen(attrs[i]) + 4 + 20; } } - siz += 32 + strlen(object); /* dn: cn=<template_name>\n\0 */ + if (dn) + { + /* dn: cn=<template_name>,<dn>\n\0 */ + siz += 32 + strlen(object) + strlen(dn); + } + else + { + /* dn: cn=<template_name>\n\0 */ + siz += 32 + strlen(object); + } templateentry = (char *)slapi_ch_malloc(siz); PR_snprintf(templateentry, siz, - "dn: cn=template_%s_objectclass\n", object); + "dn: cn=template_%s_objectclass%s%s\n", object, dn?",":"", dn?dn:""); for (--i; i >= 0; i--) { len = strlen(templateentry); @@ -873,7 +885,7 @@ _ger_generate_template_entry ( } else { - PR_snprintf(p, siz - len, "%s: dummy\n", attrs[i]); + PR_snprintf(p, siz - len, "%s: (template_attribute)\n", attrs[i]); } } charray_free(attrs); @@ -909,6 +921,10 @@ _ger_generate_template_entry ( } charray_free(attrs); } + if (notfirst) + { + slapi_ch_free_string(&object); + } slapi_ch_free_string(&superior); siz += 18; /* objectclass: top\n\0 */ len = strlen(templateentry); |