Linux 4.10 compat: has_capability()

Stock kernels older than 4.10 do not export the has_capability()
function which is required by commit e59a377.  To avoid breaking
the build on older kernels revert to the safe legacy behavior and
return EACCES when privileges cannot be checked.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #10565
Closes #10573
This commit is contained in:
Brian Behlendorf
2020-07-19 09:56:21 -07:00
committed by GitHub
parent 8fbf432ae2
commit e862b7ecfc
5 changed files with 64 additions and 0 deletions
@@ -30,6 +30,18 @@
verify_runnable "both"
#
# The has_capability() function was first exported in the 4.10 Linux kernel
# then backported to some LTS kernels. Prior to this change there was no
# mechanism to perform the needed permission check. Therefore, this test
# is expected to fail on older kernels and is skipped.
#
if is_linux; then
if [[ $(linux_version) -lt $(linux_version "4.10") ]]; then
log_unsupported "Requires has_capability() kernel function"
fi
fi
function setup
{
# We can't delegate 'mount' privs under Linux: to avoid issues with
@@ -31,6 +31,18 @@
verify_runnable "both"
#
# The has_capability() function was first exported in the 4.10 Linux kernel
# then backported to some LTS kernels. Prior to this change there was no
# mechanism to perform the needed permission check. Therefore, this test
# is expected to fail on older kernels and is skipped.
#
if is_linux; then
if [[ $(linux_version) -lt $(linux_version "4.10") ]]; then
log_unsupported "Requires has_capability() kernel function"
fi
fi
function setup
{
# We can't delegate 'mount' privs under Linux: to avoid issues with