Coder Social home page Coder Social logo

palaver's Introduction

palaver

Crates.io MIT / Apache 2.0 licensed Build Status

Docs

Cross-platform polyfills.

This library attempts to provide reliable polyfills for functionality that isn't implemented on all platforms.

palaver = "Platform Abstraction Layer" + pa·lav·er n. prolonged and tedious fuss.

Functionality

ThreadingDescriptionLinuxmacOSWindowsFreeBSDNetBSDiOSAndroid
gettid()Get thread ID
count()Number of threads in current process
FilesDescriptionLinuxmacOSWindowsFreeBSDNetBSDiOSAndroid
seal_fd()Make a file descriptor read-only
dup_fd()Duplicate a file descriptor
copy_fd()Copy a file descriptor to a specific offset
move_fd()Move a file descriptor to a specific offset
move_fds()Move file descriptors to specific offsets
fd_dir()Get a path to the file descriptor directory
fd_path()Get a path to a file descriptor
FdIterIterate all open file descriptors
memfd_create()Create an anonymous file
fexecve()Execute program specified via file descriptor
copy()Copy by looping io::copy
copy_sendfile()Copy using sendfile
copy_splice()Copy using splice
pipe()Create a pipe
SocketDescriptionLinuxmacOSWindowsFreeBSDNetBSDiOSAndroid
socket()Create a socket
accept()Accept a connection on a socket
is_connected()Get whether a pending connection is connected
unreceived()Get number of bytes readable
unsent()Get number of bytes that have yet to be acknowledged
EnvDescriptionLinuxmacOSWindowsFreeBSDNetBSDiOSAndroid
exe()Opens the current running executable
exe_path()Get a path to the current running executable
args()Get command line arguments
vars()Get environment variables
ProcessDescriptionLinuxmacOSWindowsFreeBSDNetBSDiOSAndroid
count()Count the processes visible to the current process
count_threads()Count the threads visible to the current process
fork()Fork a process, using process descriptors where available
ValgrindDescriptionLinuxmacOSWindowsFreeBSDNetBSDiOSAndroid
is()Check if running under Valgrind
start_fd()Get Valgrind's file descriptor range

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

palaver's People

Contributors

alecmocatta avatar mergify[bot] avatar dependabot-preview[bot] avatar valpackett avatar dalance avatar dependabot-support avatar

Stargazers

IchHabeKeineNamen avatar Olivier Eblé avatar Nicolas Marshall avatar José Luis Cruz avatar Vitaliy Yermolenko avatar lucky avatar  avatar GAURAV avatar Thibs avatar  avatar Andrejs Agejevs avatar Thomas Hurst avatar Odin avatar  avatar

Watchers

 avatar

palaver's Issues

Prefer getrandom/getentropy to /dev/urandom

e.g. in

palaver/src/file.rs

Lines 293 to 298 in 60f5e88

let rand = nix::fcntl::open(
"/dev/urandom",
OFlag::O_RDONLY,
nix::sys::stat::Mode::empty(),
)
.expect("Couldn't open /dev/urandom");

currently the /dev/ based RNG is used, which can be problematic with various kinds of sandboxing. This crate looks like the best cross-platform API to get randomness without depending on the filesystem.

Add closefrom

Noticed this example in the documentation:

/// // Close all file descriptors except std{in,out,err}.
/// # #[cfg(unix)]
/// for fd in FdIter::new().unwrap() {
///     if fd > 2 {
///         nix::unistd::close(fd).unwrap();
///     }
/// }

the closefrom libc function for doing exactly this (via an efficient syscall/fcntl/whatever) has been a thing since Solaris 9, FreeBSD 8.0, DragonFly 1.2, OpenBSD 3.5, and NetBSD whatever-but-also-ages-ago. Would make sense to have a wrapper that uses it and falls back to the above code.

Android buid fails on MacOS

When I run cargo ndk -t arm64-v8a build --release

On MacOS it does not build.

With latest HEAD, I get:

   Compiling as-slice v0.1.5
error[E0433]: failed to resolve: could not find `linux` in `os`
  --> /Users/domenukk/.cargo/registry/src/github.com-1ecc6299db9ec823/procfs-0.8.1/src/process/mod.rs:62:14
   |
62 | use std::os::linux::fs::MetadataExt;
   |              ^^^^^ could not find `linux` in `os`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
error: could not compile `procfs`

With v0.2.8, I get:

   Compiling palaver v0.2.8 (/Users/domenukk/tmp/palaver)
error[E0432]: unresolved import `nix::sys::memfd`
   --> src/file.rs:185:8
    |
185 |             use nix::sys::memfd;
    |                 ^^^^^^^^^^^^^^^ no `memfd` in `sys`

error[E0425]: cannot find function `shm_open` in module `mman`
   --> src/file.rs:213:9
    |
213 |         mman::shm_open(
    |               ^^^^^^^^ not found in `mman`

error[E0425]: cannot find function `shm_unlink` in module `mman`
   --> src/file.rs:226:10
    |
226 |             mman::shm_unlink(name).unwrap();
    |                   ^^^^^^^^^^ not found in `mman`

warning: ignoring -C extra-filename flag due to -o flag

error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `palaver`

To learn more, run the command again with --verbose.

Both seem to somehow assume I'm building Android on Linux (I guess?), which is not the case.

Broken CI, Update deps

It looks like CI is not running correctly anymore and therefore the dependabot PR's are not passing. Would you be interested in a PR changing to GH ci?

Support for stable rust?

Hi,

Are there any plans for this crate to support stable rust? Right now, valgrind_request, which is a dep, uses nightly only features.

FdIter not guaranteed to work properly on FreeBSD

fdescfs, which would populate /dev/fd/ with stuff other than 0/1/2, is an optional mount on FreeBSD, so the current FdIter which goes over fd_dir is not guaranteed to work properly.

There is work on fdwalk but that hasn't landed yet. So I guess there should be a safe fallback that iterates over all the descriptors. Plus #33 for the common closefrom case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.