Fix rights checks across the codebase.
* Fix path_open granting more rights than requested * Add missing rights checks in: fd_fdstat_set_flags, fd_filestat_get, poll_oneoff * Fix `open_scratch_directory` not requesting any rights. * Properly request needed rights in various tests * Add some extra trace-level logging * Remove a no-op restriction of rights to the ones returned by `determine_type_rights`. It was redundant, because `FdEntry:from` internally also called `determine_type_rights` and only dropped some of them.
This commit is contained in:
committed by
Dan Gohman
parent
5efa640e23
commit
f7f10c12b3
@@ -2,8 +2,15 @@ use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{create_file, open_scratch_directory};
|
||||
|
||||
const TEST_RIGHTS: wasi::Rights = wasi::RIGHTS_FD_READ
|
||||
| wasi::RIGHTS_PATH_LINK_SOURCE
|
||||
| wasi::RIGHTS_PATH_LINK_TARGET
|
||||
| wasi::RIGHTS_FD_FILESTAT_GET
|
||||
| wasi::RIGHTS_PATH_OPEN
|
||||
| wasi::RIGHTS_PATH_UNLINK_FILE;
|
||||
|
||||
unsafe fn create_or_open(dir_fd: wasi::Fd, name: &str, flags: wasi::Oflags) -> wasi::Fd {
|
||||
let file_fd = wasi::path_open(dir_fd, 0, name, flags, 0, 0, 0)
|
||||
let file_fd = wasi::path_open(dir_fd, 0, name, flags, TEST_RIGHTS, TEST_RIGHTS, 0)
|
||||
.unwrap_or_else(|_| panic!("opening '{}'", name));
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
@@ -14,7 +21,7 @@ unsafe fn create_or_open(dir_fd: wasi::Fd, name: &str, flags: wasi::Oflags) -> w
|
||||
}
|
||||
|
||||
unsafe fn open_link(dir_fd: wasi::Fd, name: &str) -> wasi::Fd {
|
||||
let file_fd = wasi::path_open(dir_fd, 0, name, 0, 0, 0, 0)
|
||||
let file_fd = wasi::path_open(dir_fd, 0, name, 0, TEST_RIGHTS, TEST_RIGHTS, 0)
|
||||
.unwrap_or_else(|_| panic!("opening a link '{}'", name));
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
|
||||
Reference in New Issue
Block a user