Kernel+LibC: Add O_EXEC, move exec permission checking to VFS::open()

O_EXEC is mentioned by POSIX, so let's have it. Currently, it is only used
inside the kernel to ensure the process has the right permissions when opening
an executable.
This commit is contained in:
Sergey Bugaev 2020-01-11 18:33:35 +03:00 committed by Andreas Kling
commit 2fcbb846fb
Notes: sideshowbarker 2024-07-19 10:11:50 +09:00
4 changed files with 7 additions and 4 deletions

View file

@ -215,6 +215,10 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
return KResult(-EISDIR);
should_truncate_file = options & O_TRUNC;
}
if (options & O_EXEC) {
if (!metadata.may_execute(current->process()))
return KResult(-EACCES);
}
if (metadata.is_device()) {
auto device = Device::get_device(metadata.major_device, metadata.minor_device);