mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-29 12:44:53 +01:00
Stop iterating over ACLs if we've already determined we
will print them (i.e., number of successful calls to acl_get_entry() exceeds 3). This makes O(1) what was O(num_TYPE_ACCESS_ACLs). This is a slightly modified version of submitter's patch. PR: bin/65042 Submitted by: Christian S.J. Peron <maneo@bsdpro.com>
This commit is contained in:
parent
fdcac92868
commit
263377339c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127795
@ -694,11 +694,17 @@ aclmode(char *buf, const FTSENT *p, int *haveacls)
|
|||||||
*haveacls = 1;
|
*haveacls = 1;
|
||||||
if ((facl = acl_get_file(name, ACL_TYPE_ACCESS)) != NULL) {
|
if ((facl = acl_get_file(name, ACL_TYPE_ACCESS)) != NULL) {
|
||||||
if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) {
|
if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) {
|
||||||
entries = 0;
|
entries = 1;
|
||||||
do
|
while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1)
|
||||||
entries++;
|
if (++entries > 3)
|
||||||
while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1);
|
break;
|
||||||
if (entries != 3)
|
/*
|
||||||
|
* POSIX.1e requires that ACLs of type ACL_TYPE_ACCESS
|
||||||
|
* must have at least three entries (owner, group,
|
||||||
|
* and other). So anything with more than 3 ACLs looks
|
||||||
|
* interesting to us.
|
||||||
|
*/
|
||||||
|
if (entries > 3)
|
||||||
buf[10] = '+';
|
buf[10] = '+';
|
||||||
}
|
}
|
||||||
acl_free(facl);
|
acl_free(facl);
|
||||||
|
Loading…
Reference in New Issue
Block a user