Skip to content

Commit

Permalink
Update documentation on SystemIO::allow_file_*
Browse files Browse the repository at this point in the history
Warn that fds may be reused
  • Loading branch information
boustrophedon committed Feb 27, 2022
1 parent dc0b13b commit 1551da6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/builtins/systemio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,13 @@ impl SystemIO {
self
}

/// Allow reading a given open File. Note that with just this, you will not be able to close
/// the file under this context. In most cases that shouldn't really matter since presumably
/// you've opened it in a context that has open (and therefore close) capabilities.
/// Allow reading a given open [File]. Note that with just this function, you will not be able
/// to close the file under this context.
///
/// # Security considerations
///
/// If another file or socket is opened after the file provided to this function is closed,
/// it's possible that the fd will be reused and therefore may be read from.
#[must_use]
pub fn allow_file_read(mut self, file: &File) -> SystemIO {
let fd = file.as_raw_fd();
Expand All @@ -205,9 +209,13 @@ impl SystemIO {
self
}

/// Allow writing to a given open File. Note that with just this, you will not be able to close
/// the file under this context. In most cases that shouldn't really matter since presumably
/// you've opened it in a context that has open (and therefore close) capabilities.
/// Allow writing to a given open [File]. Note that with just this, you will not be able to
/// close the file under this context.
///
/// # Security considerations
///
/// If another file or socket is opened after the file provided to this function is closed,
/// it's possible that the fd will be reused and therefore may be written to.
#[must_use]
pub fn allow_file_write(mut self, file: &File) -> SystemIO {
let fd = file.as_raw_fd();
Expand Down

0 comments on commit 1551da6

Please sign in to comment.