It appears that the anonymous resource limits are not set if an explicit BIND is not performed. The anonymous limits are set when bind_credentials_set() or bind_credentials_set_nolock() is called, but these are only called from the bind code.
We need to be sure to set the limits for an anonymous user who does not perform an explicit bind.
So it turns out that this issue is occurring even when an anonymous BIND is performed. Some other code changes in bind.c must have broken the anonymous limits feature. I have a patch that makes anonymous limits take effect when an anonymous or unauthenticated BIND is performed.
Dealing with the case where no BIND operation is performed is going to take a bit more surgery. The way the server currently works is that when a BIND is performed, the limits are set if any bind-based resource limits exist (for real users or anonymous with my patch). When a search is processed in a backend, it uses any bind based resource limits if they are set, otherwise the global limits for that backend are used. To have the anonymous limits work when no bind is performed, we would have to set the anonymous limits for all connections when they are created. We would then need to clear these limits at the beginning of the bind code and allow them to either be reset or left blank for the backend global settings to take effect.
Created attachment 415519 [details]
The anonymous resource limits were not being properly set. This
patch ensures that the limits are set properly when an anonymous
or unauthenticated BIND operation is performed. It also sets the
anonymous limits when we do a read on a connection that has not
yet perfomed a BIND. These limits will be overwritten with any
default or user-based limits once a valid BIND is performed.
Thanks to Rich for his review! Pushed to master.
Counting objects: 13, done.
Delta compression using 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.43 KiB, done.
Total 7 (delta 5), reused 0 (delta 0)
ecb1e8a..55489b8 master -> master
verified - RHEL 4
1. Global sizelimit:
# ldapsearch -x -p 389 -h `hostname` -D "cn=Directory Manager" -w Secret123 -b "cn=config" | grep sizelimit
# ldapsearch -x -p 389 -h `hostname` -D "cn=Directory Manager" -w Secret123 -b "cn=config" | grep anonlimit
3. Limit on User:
# /usr/lib/mozldap6/ldapsearch -p 389 -h `hostname` -D "cn=Directory Manager" -w Secret123 -b "uid=jgalipea,ou=people,dc=example,dc=com" "(objectclass=*)" nssizelimit
4. anonymous bind search:
# /usr/lib/mozldap6/ldapsearch -p 389 -h `hostname` -b "dc=example,dc=com" "(objectclass=*)" cnversion: 1
dn: cn=Directory Administrators,dc=example,dc=com
cn: Directory Administrators
dn: ou=Special Users,dc=example,dc=com
ldap_search: Sizelimit exceeded