ignore undefined attrs (ITS#6600, based on patch by Jonathan CLARKE)

This commit is contained in:
Pierangelo Masarati 2010-09-07 02:03:23 +00:00
parent c78014bc5d
commit c405143a0a
3 changed files with 67 additions and 18 deletions

View File

@ -3122,19 +3122,30 @@ get_attr_set(
query_manager* qm, query_manager* qm,
int num ) int num )
{ {
int i; int i = 0;
int count = 0; int count = 0;
if ( attrs ) { if ( attrs ) {
for ( ; attrs[count].an_name.bv_val; count++ ); for ( ; attrs[i].an_name.bv_val; i++ ) {
/* only count valid attribute names
* (searches ignore others, this overlay does the same) */
if ( attrs[i].an_desc ) {
count++;
}
}
} }
/* recognize a single "*" or a "1.1" */ /* recognize default or explicit single "*" */
if ( count == 0 ) { if ( ! attrs ||
( i == 1 && bvmatch( &attrs[0].an_name, slap_bv_all_user_attrs ) ) )
{
count = 1; count = 1;
attrs = slap_anlist_all_user_attributes; attrs = slap_anlist_all_user_attributes;
} else if ( count == 1 && bvmatch( &attrs[0].an_name, slap_bv_no_attrs ) ) { /* recognize implicit (no valid attributes) or explicit single "1.1" */
} else if ( count == 0 ||
( i == 1 && bvmatch( &attrs[0].an_name, slap_bv_no_attrs ) ) )
{
count = 0; count = 0;
attrs = NULL; attrs = NULL;
} }
@ -3155,6 +3166,8 @@ get_attr_set(
} }
for ( a2 = attrs; a2->an_name.bv_val; a2++ ) { for ( a2 = attrs; a2->an_name.bv_val; a2++ ) {
if ( !a2->an_desc && !bvmatch( &a2->an_name, slap_bv_all_user_attrs ) ) continue;
if ( !an_find( qm->attr_sets[i].attrs, &a2->an_name ) ) { if ( !an_find( qm->attr_sets[i].attrs, &a2->an_name ) ) {
found = 0; found = 0;
break; break;

View File

@ -189,7 +189,11 @@ dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
dc=com dc=com
mail: bjensen@mailgw.example.com mail: bjensen@mailgw.example.com
# Query 10: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid # Query 10: filter:(|(cn=All Staff)(sn=All Staff)) attrs:sn cn title uid undefinedAttr
dn: cn=All Staff,ou=Groups,dc=example,dc=com
cn: All Staff
# Query 11: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid
dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
cn: James A Jones 1 cn: James A Jones 1
cn: James Jones cn: James Jones
@ -207,7 +211,7 @@ sn: Doe
uid: jjones uid: jjones
title: Senior Manager, Information Technology Division title: Senior Manager, Information Technology Division
# Query 11: filter:(sn=Smith) attrs:cn sn title uid # Query 12: filter:(sn=Smith) attrs:cn sn title uid
dn: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com dn: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
cn: Jennifer Smith cn: Jennifer Smith
cn: Jen Smith cn: Jen Smith
@ -215,7 +219,7 @@ sn: Smith
uid: jen uid: jen
title: Telemarketer, UM Alumni Association title: Telemarketer, UM Alumni Association
# Query 12: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid # Query 13: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid
dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
=com =com
cn: Bjorn Jensen cn: Bjorn Jensen
@ -225,7 +229,7 @@ postalAddress: Info Tech Division $ 535 W. William St. $ Anytown, MI 48103
mail: bjorn@mailgw.example.com mail: bjorn@mailgw.example.com
telephoneNumber: +1 313 555 0355 telephoneNumber: +1 313 555 0355
# Query 13: filter:(mail=jaj@mail.alumni.example.com) attrs:cn sn title uid # Query 14: filter:(mail=jaj@mail.alumni.example.com) attrs:cn sn title uid
dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
cn: James A Jones 1 cn: James A Jones 1
cn: James Jones cn: James Jones
@ -234,7 +238,7 @@ sn: Jones
uid: jaj uid: jaj
title: Mad Cow Researcher, UM Alumni Association title: Mad Cow Researcher, UM Alumni Association
# Query 14: filter:(mail=*example.com) attrs:cn sn title uid # Query 15: filter:(mail=*example.com) attrs:cn sn title uid
dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
dc=com dc=com
cn: Barbara Jensen cn: Barbara Jensen
@ -243,8 +247,12 @@ sn:: IEplbnNlbiA=
uid: bjensen uid: bjensen
title: Mythical Manager, Research Systems title: Mythical Manager, Research Systems
# Query 15: filter:(uid=b*) attrs:mail # Query 16: filter:(uid=b*) attrs:mail
dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
dc=com dc=com
mail: bjensen@mailgw.example.com mail: bjensen@mailgw.example.com
# Query 17: filter:(|(cn=All Staff)(sn=All Staff)) attrs:sn cn title uid undefinedAttr
dn: cn=All Staff,ou=Groups,dc=example,dc=com
cn: All Staff

View File

@ -295,10 +295,24 @@ case $RC in
;; ;;
esac esac
CNT=`expr $CNT + 1`
FILTER="(|(cn=All Staff)(sn=All Staff))"
ATTRS="sn cn title uid undefinedAttr"
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
FIRST=$CNT FIRST=$CNT
# queries 2-6,8-9 are cacheable # queries 2-6,8-10 are cacheable
CACHEABILITY=011111011 CACHEABILITY=0111110111
grep CACHEABLE $LOG2 | awk '{ grep CACHEABLE $LOG2 | awk '{
if ($2 == "NOT") if ($2 == "NOT")
printf "Query %d not cacheable\n",NR printf "Query %d not cacheable\n",NR
@ -431,11 +445,25 @@ case $RC in
;; ;;
esac esac
#queries 10-12,15 are answerable, 13-14 are not CNT=`expr $CNT + 1`
#actually, 12 would be answerable, but since 8 made mail=*example.com FILTER="(|(cn=All Staff)(sn=All Staff))"
ATTRS="sn cn title uid undefinedAttr"
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
#queries 11-13,16-17 are answerable, 14-15 are not
#actually, 14 would be answerable, but since 8 made mail=*example.com
#not answerable because of sizelimit, queries contained in it are no longer #not answerable because of sizelimit, queries contained in it are no longer
#answerable as well #answerable as well
ANSWERABILITY=111001 ANSWERABILITY=1110011
grep ANSWERABLE $LOG2 | awk "BEGIN {FIRST=$FIRST}"'{ grep ANSWERABLE $LOG2 | awk "BEGIN {FIRST=$FIRST}"'{
if (NR > FIRST) { if (NR > FIRST) {
if ($2 == "NOT") if ($2 == "NOT")
@ -462,9 +490,9 @@ else
fi fi
echo "Filtering ldapsearch results..." echo "Filtering ldapsearch results..."
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT $LDIFFILTER -s ldif=a < $SEARCHOUT > $SEARCHFLT
echo "Filtering original ldif..." echo "Filtering original ldif..."
$LDIFFILTER < $PROXYCACHEOUT > $LDIFFLT $LDIFFILTER -s ldif=a < $PROXYCACHEOUT > $LDIFFLT
echo "Comparing filter output..." echo "Comparing filter output..."
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT $CMP $SEARCHFLT $LDIFFLT > $CMPOUT