mirror of
https://github.com/RGBCube/serenity
synced 2025-07-04 14:07:35 +00:00
Kernel: Support chdir() to a directory that's executable but not readable.
Also the superuser should be allowed to resolve any possible path without getting tripped up by EACCES.
This commit is contained in:
parent
4f9b6a88a6
commit
f75eb9af16
3 changed files with 19 additions and 8 deletions
|
@ -290,6 +290,19 @@ KResult VFS::access(const String& path, int mode, Inode& base)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResultOr<Retained<Inode>> VFS::open_directory(const String& path, Inode& base)
|
||||
{
|
||||
auto inode_or_error = resolve_path_to_inode(path, base);
|
||||
if (inode_or_error.is_error())
|
||||
return inode_or_error.error();
|
||||
auto inode = inode_or_error.value();
|
||||
if (!inode->is_directory())
|
||||
return KResult(-ENOTDIR);
|
||||
if (!inode->metadata().may_execute(*current) && !current->is_superuser())
|
||||
return KResult(-EACCES);
|
||||
return Retained<Inode>(*inode);
|
||||
}
|
||||
|
||||
KResult VFS::chmod(Inode& inode, mode_t mode)
|
||||
{
|
||||
if (inode.fs().is_readonly())
|
||||
|
@ -554,7 +567,7 @@ KResultOr<InodeIdentifier> VFS::resolve_path(const String& path, InodeIdentifier
|
|||
#endif
|
||||
return KResult(-ENOTDIR);
|
||||
}
|
||||
if (!metadata.may_execute(*current))
|
||||
if (!metadata.may_execute(*current) && !current->is_superuser())
|
||||
return KResult(-EACCES);
|
||||
auto parent = crumb_id;
|
||||
crumb_id = crumb_inode->lookup(part);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue