Skip to content

Commit

Permalink
Do not adjust rights on Stdio
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Konka committed Apr 20, 2020
1 parent a4fd811 commit c3628b0
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions crates/wasi-common/src/sys/unix/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ impl StdioExt for Stdio {
}

fn get_rights(file: &File) -> io::Result<HandleRights> {
use yanix::fcntl;
use yanix::file::{isatty, OFlag};
use yanix::file::isatty;
let (base, inheriting) = {
if unsafe { isatty(file.as_raw_fd())? } {
(types::Rights::tty_base(), types::Rights::tty_base())
Expand All @@ -54,13 +53,5 @@ fn get_rights(file: &File) -> io::Result<HandleRights> {
)
}
};
let mut rights = HandleRights::new(base, inheriting);
let flags = unsafe { fcntl::get_status_flags(file.as_raw_fd())? };
let accmode = flags & OFlag::ACCMODE;
if accmode == OFlag::RDONLY {
rights.base &= !types::Rights::FD_WRITE;
} else if accmode == OFlag::WRONLY {
rights.base &= !types::Rights::FD_READ;
}
Ok(rights)
Ok(HandleRights::new(base, inheriting))
}

0 comments on commit c3628b0

Please sign in to comment.