mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-29 16:44:03 +00:00
O_EXEC flag is not part of the O_ACCMODE mask, check it separately.
If O_EXEC is provided don't require CAP_READ/CAP_WRITE, as O_EXEC is mutually exclusive to O_RDONLY/O_WRONLY/O_RDWR. Without this change CAP_FEXECVE capability right is not enforced. Sponsored by: FreeBSD Foundation MFC after: 3 days
This commit is contained in:
parent
0a54471901
commit
1159429db8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240927
@ -1006,22 +1006,20 @@ flags_to_rights(int flags)
|
||||
{
|
||||
cap_rights_t rights = 0;
|
||||
|
||||
switch ((flags & O_ACCMODE)) {
|
||||
case O_RDONLY:
|
||||
rights |= CAP_READ;
|
||||
break;
|
||||
|
||||
case O_RDWR:
|
||||
rights |= CAP_READ;
|
||||
/* fall through */
|
||||
|
||||
case O_WRONLY:
|
||||
rights |= CAP_WRITE;
|
||||
break;
|
||||
|
||||
case O_EXEC:
|
||||
if (flags & O_EXEC) {
|
||||
rights |= CAP_FEXECVE;
|
||||
break;
|
||||
} else {
|
||||
switch ((flags & O_ACCMODE)) {
|
||||
case O_RDONLY:
|
||||
rights |= CAP_READ;
|
||||
break;
|
||||
case O_RDWR:
|
||||
rights |= CAP_READ;
|
||||
/* FALLTHROUGH */
|
||||
case O_WRONLY:
|
||||
rights |= CAP_WRITE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & O_CREAT)
|
||||
|
Loading…
Reference in New Issue
Block a user