kernel: Return EACCES when trying to chdir to an unaccessible directory
This commit is contained in:
parent
cba0a23db9
commit
d89a823924
@ -14,6 +14,7 @@ Result<u64> sys_chdir(Registers*, SyscallArgs args)
|
|||||||
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth));
|
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth));
|
||||||
|
|
||||||
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
|
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
|
||||||
|
if (!VFS::can_execute(inode, current->auth)) return err(EACCES);
|
||||||
|
|
||||||
inode->add_handle();
|
inode->add_handle();
|
||||||
if (current->current_directory) current->current_directory->remove_handle();
|
if (current->current_directory) current->current_directory->remove_handle();
|
||||||
@ -28,6 +29,7 @@ Result<u64> sys_chdir(Registers*, SyscallArgs args)
|
|||||||
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth, current->current_directory));
|
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth, current->current_directory));
|
||||||
|
|
||||||
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
|
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
|
||||||
|
if (!VFS::can_execute(inode, current->auth)) return err(EACCES);
|
||||||
|
|
||||||
auto old_wdir = current->current_directory_path.view();
|
auto old_wdir = current->current_directory_path.view();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user