Skip to main content

write_in_dir

Function write_in_dir 

Source
pub fn write_in_dir(
    dir: &Path,
    name: &str,
    bytes: &[u8],
) -> Result<(), PathSecurityError>
Expand description

Write bytes to a file named name inside the directory dir, using a capability-scoped cap_std::fs::Dir handle (see skills/rust-path-security.md).

name must be a single relative file name; cap-std rejects any .., absolute path, or symlink that would escape dir at the syscall layer, so a crafted report file name cannot redirect the write outside dir. This is the one place ambient authority crosses into the program for writes.

ยงErrors

Returns PathSecurityError::Io if dir cannot be opened or the file cannot be created/written.