Sha256: 53a0e16f954f95426efe990ff3206a431c6c4c680cd64f6460f13e8c2537be69

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

use crate::fs::{AccessType, FollowSymlinks};
use rustix::fs::{Access, AtFlags};
use std::path::Path;
use std::{fs, io};

/// *Unsandboxed* function similar to `access`, but which does not perform
/// sandboxing.
pub(crate) fn access_unchecked(
    start: &fs::File,
    path: &Path,
    type_: AccessType,
    follow: FollowSymlinks,
) -> io::Result<()> {
    let mut access_type = Access::empty();
    match type_ {
        AccessType::Exists => access_type |= Access::EXISTS,
        AccessType::Access(modes) => {
            if modes.readable {
                access_type |= Access::READ_OK;
            }
            if modes.writable {
                access_type |= Access::WRITE_OK;
            }
            if modes.executable {
                access_type |= Access::EXEC_OK;
            }
        }
    }

    let atflags = match follow {
        FollowSymlinks::Yes => AtFlags::empty(),
        FollowSymlinks::No => AtFlags::SYMLINK_NOFOLLOW,
    };

    rustix::fs::accessat(start, path, access_type, atflags)?;

    Ok(())
}

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
wasmtime-28.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/rustix/fs/access_unchecked.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/rustix/fs/access_unchecked.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/rustix/fs/access_unchecked.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/fs/access_unchecked.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/fs/access_unchecked.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/fs/access_unchecked.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/fs/access_unchecked.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/fs/access_unchecked.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/fs/access_unchecked.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/fs/access_unchecked.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/fs/access_unchecked.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/rustix/fs/access_unchecked.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/fs/access_unchecked.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/fs/access_unchecked.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/fs/access_unchecked.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/fs/access_unchecked.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/fs/access_unchecked.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/fs/access_unchecked.rs