[Fedora-directory-commits] ldapserver/ldap/servers/plugins/acl acleffectiverights.c, 1.10, 1.11

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Thu Jul 31 17:25:39 UTC 2008


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/acl
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30103

Modified Files:
	acleffectiverights.c 
Log Message:
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)".



Index: acleffectiverights.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/acl/acleffectiverights.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- acleffectiverights.c	28 Jul 2008 15:49:28 -0000	1.10
+++ acleffectiverights.c	31 Jul 2008 17:25:37 -0000	1.11
@@ -811,6 +811,7 @@
 	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 @@
 		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 @@
 		}
 		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 @@
 		}
 		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 @@
 		}
 		charray_free(attrs);
 	}
+	if (notfirst)
+	{
+		slapi_ch_free_string(&object);
+	}
 	slapi_ch_free_string(&superior);
 	siz += 18; /* objectclass: top\n\0 */
 	len = strlen(templateentry);




More information about the Fedora-directory-commits mailing list