From be22981d78d93b6fabe5fcc7dc3b85cc27119c76 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 22 Aug 2003 21:03:03 +0000 Subject: [PATCH] Add nameAndOptionalUID pretty routine... improves uniqueMember handling Should resolve ITS#2664. --- servers/slapd/schema_init.c | 83 ++++++++++++++++++++++++++++++- tests/data/acl.out.master | 19 ++++--- tests/data/modify.out.master | 14 +++--- tests/data/modrdn.out.master | 16 +++--- tests/data/modrdn.out.master.0 | 16 +++--- tests/data/search.out.master | 32 ++++++------ tests/data/slapd-acl.conf | 9 ++-- tests/data/test-glued.ldif | 16 +++--- tests/data/test-ordered-nocp.ldif | 16 +++--- tests/data/test-ordered.ldif | 16 +++--- tests/data/test.ldif | 16 +++--- tests/scripts/test003-search | 2 +- tests/scripts/test004-modify | 16 +++--- tests/scripts/test006-acls | 8 +-- 14 files changed, 182 insertions(+), 97 deletions(-) diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 056e085d0d..273398cda6 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -729,6 +729,87 @@ nameUIDValidate( return rc; } +int +nameUIDPretty( + Syntax *syntax, + struct berval *val, + struct berval *out, + void *ctx ) +{ + assert( val ); + assert( out ); + + +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ARGS, ">>> nameUIDPretty: <%s>\n", val->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, ">>> nameUIDPretty: <%s>\n", val->bv_val, 0, 0 ); +#endif + + if( val->bv_len == 0 ) { + ber_dupbv_x( out, val, ctx ); + + } else if ( val->bv_len > SLAP_LDAPDN_MAXLEN ) { + return LDAP_INVALID_SYNTAX; + + } else { + int rc; + struct berval dnval = *val; + struct berval uidval = { 0, NULL }; + + if( val->bv_val[val->bv_len-1] == 'B' + && val->bv_val[val->bv_len-2] == '\'' ) + { + uidval.bv_val=strrchr( val->bv_val, '#' ); + if( uidval.bv_val ) { + dnval.bv_len = uidval.bv_val - dnval.bv_val; + uidval.bv_len = val->bv_len - dnval.bv_len; + + uidval.bv_len--; + uidval.bv_val++; + } + } + + rc = dnPretty( syntax, &dnval, out, ctx ); + if( rc != LDAP_SUCCESS ) return rc; + + if( uidval.bv_val ) { + char *tmp = sl_realloc( out->bv_val, out->bv_len + uidval.bv_len + 2, ctx ); + int i, c, got1; + if( tmp == NULL ) { + ber_memfree_x( out->bv_val, ctx ); + return LDAP_OTHER; + } + + out->bv_val[out->bv_len++] = '#'; + + got1 = uidval.bv_len < sizeof("'0'B"); + for(i=0; ibv_val[out->bv_len++] = c; + break; + case '1': + got1 = 1; + default: + out->bv_val[out->bv_len++] = c; + } + } + + out->bv_val[out->bv_len] = '\0'; + } + } + +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ARGS, "<<< nameUIDPretty: <%s>\n", out->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<<< nameUIDPretty: <%s>\n", out->bv_val, 0, 0 ); +#endif + + return LDAP_SUCCESS; +} + static int uniqueMemberNormalize( slap_mask_t usage, @@ -2508,7 +2589,7 @@ static slap_syntax_defs_rec syntax_defs[] = { {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )", 0, NULL, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )", - 0, nameUIDValidate, NULL}, + 0, nameUIDValidate, nameUIDPretty }, {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )", 0, NULL, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )", diff --git a/tests/data/acl.out.master b/tests/data/acl.out.master index 430f4422df..60e3f28365 100644 --- a/tests/data/acl.out.master +++ b/tests/data/acl.out.master @@ -119,17 +119,16 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=People, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US +uniquemember: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michigan,c=US -member: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Mic - higan,c=US -ou: Groups dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Universi ty of Michigan,c=US diff --git a/tests/data/modify.out.master b/tests/data/modify.out.master index d66f9df2cc..e02147d783 100644 --- a/tests/data/modify.out.master +++ b/tests/data/modify.out.master @@ -117,14 +117,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US +uniquemember: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University + of Michigan,c=US +uniquemember: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michigan,c=US -member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Mic - higan,c=US -member: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Mic - higan,c=US dn: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michiga n,c=US diff --git a/tests/data/modrdn.out.master b/tests/data/modrdn.out.master index 9105cb3815..ae5444838b 100644 --- a/tests/data/modrdn.out.master +++ b/tests/data/modrdn.out.master @@ -120,14 +120,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=People, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=James A Jones II,ou=Information Technology Division,ou=People,o=Univ ersity of Michigan,c=US diff --git a/tests/data/modrdn.out.master.0 b/tests/data/modrdn.out.master.0 index e219831639..55ab5dea67 100644 --- a/tests/data/modrdn.out.master.0 +++ b/tests/data/modrdn.out.master.0 @@ -119,14 +119,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=People, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=James A Jones II,ou=Information Technology Division,ou=People,o=Univers ity of Michigan,c=US diff --git a/tests/data/search.out.master b/tests/data/search.out.master index fed8b0c806..5cbf70d4e1 100644 --- a/tests/data/search.out.master +++ b/tests/data/search.out.master @@ -89,14 +89,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectClass: groupOfUniqueNames +uniqueMember: cn=Manager,o=University of Michigan,c=US +uniqueMember: cn=Bjorn Jensen,OU=Information Technology Division,ou=PEOPLE,o=U + niversity of Michigan,c=US +uniqueMember: cn=James A Jones 2,ou=Information Technology Division,ou=PEOPLE, + o=University of Michigan,c=US +uniqueMember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michiga n,c=US @@ -226,14 +226,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=People, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=Manager,o=University of Michigan,c=US objectClass: person diff --git a/tests/data/slapd-acl.conf b/tests/data/slapd-acl.conf index 0eee54cdec..a066f06286 100644 --- a/tests/data/slapd-acl.conf +++ b/tests/data/slapd-acl.conf @@ -52,20 +52,21 @@ access to dn.children="ou=Alumni Association,ou=People,o=University of Michigan by dn.subtree="o=University of Michigan,c=US" +rs continue by * stop -access to attr=member +access to attr=member,uniquemember by dnattr=member selfwrite + by dnattr=uniquemember selfwrite by * read -access to attr=member filter=(mail=*edu) +access to attr=member,uniquemember filter=(mail=*edu) by * read -access to filter="(objectclass=groupofnames)" +access to filter="(&(objectclass=groupofnames)(objectClass=groupofuniquenames))" by dn.base="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US" =sc continue by dn.regex="^cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US$" +rw stop by * break access to dn.children="ou=Information Technology Division,ou=People,o=University of Michigan,c=US" - by group.exact="cn=ITD Staff,ou=Groups,o=University of Michigan,c=US" write + by group/groupOfUniqueNames/uniqueMember.exact="cn=ITD Staff,ou=Groups,o=University of Michigan,c=US" write by * read access to filter="(name=X*Y*Z)" diff --git a/tests/data/test-glued.ldif b/tests/data/test-glued.ldif index 356c3305f2..d5235d09d8 100644 --- a/tests/data/test-glued.ldif +++ b/tests/data/test-glued.ldif @@ -278,12 +278,12 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectClass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,OU=Information Technology Division,ou=PEOPLE,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=PEOPLE, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US diff --git a/tests/data/test-ordered-nocp.ldif b/tests/data/test-ordered-nocp.ldif index 2564e878a1..6a2b71573b 100644 --- a/tests/data/test-ordered-nocp.ldif +++ b/tests/data/test-ordered-nocp.ldif @@ -126,14 +126,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,OU=Information Technology Division,ou=PEOPLE,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=PEOPLE,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,OU=Information Technology Division,ou=PEOPLE,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=PEOPLE, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Mich igan,c=US diff --git a/tests/data/test-ordered.ldif b/tests/data/test-ordered.ldif index b2d329e335..74e479a0a0 100644 --- a/tests/data/test-ordered.ldif +++ b/tests/data/test-ordered.ldif @@ -145,14 +145,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,OU=Information Technology Division,ou=PEOPLE,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=PEOPLE,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,OU=Information Technology Division,ou=PEOPLE,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=PEOPLE, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Mich igan,c=US diff --git a/tests/data/test.ldif b/tests/data/test.ldif index 7b4961f593..a695e8a9e3 100644 --- a/tests/data/test.ldif +++ b/tests/data/test.ldif @@ -121,14 +121,14 @@ dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US owner: cn=Manager,o=University of Michigan,c=US description: All ITD Staff cn: ITD Staff -objectclass: groupofnames -member: cn=Manager,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=Univers - ity of Michigan,c=US -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=Univ - ersity of Michigan,c=US -member: cn=John Doe,ou=Information Technology Division,ou=People,o=University - of Michigan,c=US +objectclass: groupofuniquenames +uniquemember: cn=Manager,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=U + niversity of Michigan,c=US +uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=People, + o=University of Michigan,c=US +uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,o=Unive + rsity of Michigan,c=US dn: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michiga n,c=US diff --git a/tests/scripts/test003-search b/tests/scripts/test003-search index 49a3b8d724..af32f90541 100755 --- a/tests/scripts/test003-search +++ b/tests/scripts/test003-search @@ -73,7 +73,7 @@ fi echo "Testing OR searching..." $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \ - '(|(givenname=Xx*yY*Z)(cn=)(undef=*)(objectclass=groupofnames)(sn=jones)(member=cn=Manager,o=University of Michigan,c=US))' >> $SEARCHOUT 2>&1 + '(|(givenname=Xx*yY*Z)(cn=)(undef=*)(objectclass=groupofnames)(sn=jones)(member=cn=Manager,o=University of Michigan,c=US)(uniqueMember=cn=Manager,o=University of Michigan,c=US))' >> $SEARCHOUT 2>&1 RC=$? if test $RC != 0 ; then echo "ldapsearch failed ($RC)!" diff --git a/tests/scripts/test004-modify b/tests/scripts/test004-modify index 8a46a4a60d..a235b93ad9 100755 --- a/tests/scripts/test004-modify +++ b/tests/scripts/test004-modify @@ -91,13 +91,17 @@ drink: Mad Dog 20/20 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US changetype: modify -delete: member -member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=University of Michigan,c=US -member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US +delete: uniquemember +uniquemember: cn=James A Jones 2,ou=Information Technology Division, + ou=People,o=University of Michigan,c=US +uniquemember: cn=Bjorn Jensen,ou=Information Technology Division, + ou=People,o=University of Michigan,c=US - -add: member -member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Michigan,c=US -member: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michigan,c=US +add: uniquemember +uniquemember: cn=Dorothy Stevens,ou=Alumni Association, + ou=People,o=University of Michigan,c=US +uniquemember: cn=James A Jones 1,ou=Alumni Association, + ou=People,o=University of Michigan,c=US dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US changetype: modify diff --git a/tests/scripts/test006-acls b/tests/scripts/test006-acls index 5c81dbf992..70a3636f27 100755 --- a/tests/scripts/test006-acls +++ b/tests/scripts/test006-acls @@ -97,8 +97,8 @@ $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT -w jaj > \ version: 1 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US changetype: modify -add: member -member: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US +add: uniquemember +uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US EOMODS1 @@ -108,8 +108,8 @@ version: 1 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US changetype: modify -add: member -member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US +add: uniquemember +uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US EOMODS2 # -- 2.39.5