From bcc0dc3dc7e7c5dfdfe654c9df6e23271fdace7c Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Fri, 2 Nov 2001 15:16:59 +0000 Subject: [PATCH] Merge from POSIX.1e Capabilities development tree: o POSIX.1e capabilities authorize overriding of VEXEC for VDIR based on CAP_DAC_READ_SEARCH, but of !VDIR based on CAP_DAC_EXECUTE. Add appropriate conditionals to vaccess() to take that into account. o Synchronization cap_check_xxx() -> cap_check() change. Obtained from: TrustedBSD Project --- sys/kern/vfs_subr.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index bebb3194a2a9..2b822e95cd95 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3006,20 +3006,31 @@ privcheck: * or the request type onto the cap_granted mask. */ cap_granted = 0; - if ((acc_mode & VEXEC) && ((dac_granted & VEXEC) == 0) && - !cap_check_xxx(cred, NULL, CAP_DAC_EXECUTE, PRISON_ROOT)) - cap_granted |= VEXEC; + + if (type == VDIR) { + /* + * For directories, use CAP_DAC_READ_SEARCH to satisfy + * VEXEC requests, instead of CAP_DAC_EXECUTE. + */ + if ((acc_mode & VEXEC) && ((dac_granted & VEXEC) == 0) && + !cap_check(cred, NULL, CAP_DAC_READ_SEARCH, PRISON_ROOT)) + cap_granted |= VEXEC; + } else { + if ((acc_mode & VEXEC) && ((dac_granted & VEXEC) == 0) && + !cap_check(cred, NULL, CAP_DAC_EXECUTE, PRISON_ROOT)) + cap_granted |= VEXEC; + } if ((acc_mode & VREAD) && ((dac_granted & VREAD) == 0) && - !cap_check_xxx(cred, NULL, CAP_DAC_READ_SEARCH, PRISON_ROOT)) + !cap_check(cred, NULL, CAP_DAC_READ_SEARCH, PRISON_ROOT)) cap_granted |= VREAD; if ((acc_mode & VWRITE) && ((dac_granted & VWRITE) == 0) && - !cap_check_xxx(cred, NULL, CAP_DAC_WRITE, PRISON_ROOT)) + !cap_check(cred, NULL, CAP_DAC_WRITE, PRISON_ROOT)) cap_granted |= VWRITE; if ((acc_mode & VADMIN) && ((dac_granted & VADMIN) == 0) && - !cap_check_xxx(cred, NULL, CAP_FOWNER, PRISON_ROOT)) + !cap_check(cred, NULL, CAP_FOWNER, PRISON_ROOT)) cap_granted |= VADMIN; if ((acc_mode & (cap_granted | dac_granted)) == acc_mode) {