wasi-common: fix fdstat of dirfd

the fdstat of a dirfd needs to include both the file and dir rights in
the inheriting field.

The wasi-libc path_open bases the base rights of child directories off
the inheriting rights of the parent, so if we only put file rights in
there, opening a child directory will not have any directory operations
permitted.

Fixes https://github.com/bytecodealliance/wasmtime/issues/2638
This commit is contained in:
Pat Hickey
2021-02-09 15:43:52 -08:00
committed by Dan Gohman
parent ab811d7445
commit c9d8ed03c9

View File

@@ -1112,7 +1112,7 @@ impl From<&FdStat> for types::Fdstat {
impl From<&DirFdStat> for types::Fdstat { impl From<&DirFdStat> for types::Fdstat {
fn from(dirstat: &DirFdStat) -> types::Fdstat { fn from(dirstat: &DirFdStat) -> types::Fdstat {
let fs_rights_base = types::Rights::from(&dirstat.dir_caps); let fs_rights_base = types::Rights::from(&dirstat.dir_caps);
let fs_rights_inheriting = types::Rights::from(&dirstat.file_caps); let fs_rights_inheriting = types::Rights::from(&dirstat.file_caps) | fs_rights_base;
types::Fdstat { types::Fdstat {
fs_filetype: types::Filetype::Directory, fs_filetype: types::Filetype::Directory,
fs_rights_base, fs_rights_base,