mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-18 16:21:52 +00:00
Kernel+LibC+LibCore+UserspaceEmulator: Implement faccessat(2)
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
This commit is contained in:
parent
fa692e13f9
commit
2a502fe232
Notes:
sideshowbarker
2024-07-17 06:09:44 +09:00
Author: https://github.com/sin-ack
Commit: 2a502fe232
Pull-request: https://github.com/SerenityOS/serenity/pull/15428
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/BertalanD
Reviewed-by: https://github.com/linusg
Reviewed-by: https://github.com/timschumi
13 changed files with 89 additions and 39 deletions
|
@ -523,24 +523,26 @@ ErrorOr<void> VirtualFileSystem::mkdir(Credentials const& credentials, StringVie
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> VirtualFileSystem::access(Credentials const& credentials, StringView path, int mode, Custody& base)
|
||||
ErrorOr<void> VirtualFileSystem::access(Credentials const& credentials, StringView path, int mode, Custody& base, AccessFlags access_flags)
|
||||
{
|
||||
auto custody = TRY(resolve_path(credentials, path, base));
|
||||
auto should_follow_symlinks = !has_flag(access_flags, AccessFlags::DoNotFollowSymlinks);
|
||||
auto custody = TRY(resolve_path(credentials, path, base, nullptr, should_follow_symlinks ? 0 : O_NOFOLLOW_NOERROR));
|
||||
|
||||
auto& inode = custody->inode();
|
||||
auto metadata = inode.metadata();
|
||||
auto use_effective_ids = has_flag(access_flags, AccessFlags::EffectiveAccess) ? UseEffectiveIDs::Yes : UseEffectiveIDs::No;
|
||||
if (mode & R_OK) {
|
||||
if (!metadata.may_read(credentials, UseEffectiveIDs::No))
|
||||
if (!metadata.may_read(credentials, use_effective_ids))
|
||||
return EACCES;
|
||||
}
|
||||
if (mode & W_OK) {
|
||||
if (!metadata.may_write(credentials, UseEffectiveIDs::No))
|
||||
if (!metadata.may_write(credentials, use_effective_ids))
|
||||
return EACCES;
|
||||
if (custody->is_readonly())
|
||||
return EROFS;
|
||||
}
|
||||
if (mode & X_OK) {
|
||||
if (!metadata.may_execute(credentials, UseEffectiveIDs::No))
|
||||
if (!metadata.may_execute(credentials, use_effective_ids))
|
||||
return EACCES;
|
||||
}
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue