kernel: Return EACCES when trying to chdir to an unaccessible directory

This commit is contained in:
apio 2023-05-26 20:49:13 +02:00
parent cba0a23db9
commit d89a823924
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -14,6 +14,7 @@ Result<u64> sys_chdir(Registers*, SyscallArgs args)
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth));
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
if (!VFS::can_execute(inode, current->auth)) return err(EACCES);
inode->add_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));
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();