capsicum: restore the cap_rights_contains symbol

It is expected to be provided by libc.

PR:		244033
Reported by:	 Jan Kokemueller
This commit is contained in:
Mateusz Guzik 2020-02-11 18:13:53 +00:00
parent 5d1277ca9a
commit 1b853b62f3
2 changed files with 28 additions and 1 deletions

View File

@ -394,3 +394,27 @@ cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src)
return (dst);
}
#ifndef _KERNEL
bool
cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little)
{
unsigned int i, n;
assert(CAPVER(big) == CAP_RIGHTS_VERSION_00);
assert(CAPVER(little) == CAP_RIGHTS_VERSION_00);
assert(CAPVER(big) == CAPVER(little));
n = CAPARSIZE(big);
assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX);
for (i = 0; i < n; i++) {
if ((big->cr_rights[i] & little->cr_rights[i]) !=
little->cr_rights[i]) {
return (false);
}
}
return (true);
}
#endif

View File

@ -344,7 +344,7 @@ cap_rights_t *cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
cap_rights_t *cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
void __cap_rights_sysinit(void *arg);
#ifdef _KERNEL
/*
* We only support one size to reduce branching.
*/
@ -390,6 +390,9 @@ cap_check_inline_transient(const cap_rights_t *havep, const cap_rights_t *needp)
return (1);
return (0);
}
#else
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
#endif
__END_DECLS
struct cap_rights_init_args {