Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

nix

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nix - cargo Package Compare versions

Comparing version
0.31.2
to
0.31.3
+1
-1
.cargo_vcs_info.json
{
"git": {
"sha1": "bf1d0e9707189422f546e398594fa1a51a772d9d"
"sha1": "b5933ca178802b558a667514f717a86b3a1cedcc"
},
"path_in_vcs": ""
}

@@ -168,5 +168,5 @@ # This file is automatically @generated by Cargo.

name = "libc"
version = "0.2.182"
version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"

@@ -211,3 +211,3 @@ [[package]]

name = "nix"
version = "0.31.2"
version = "0.31.3"
dependencies = [

@@ -214,0 +214,0 @@ "assert-impl",

@@ -16,4 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "nix"
version = "0.31.2"
authors = ["The nix-rust Project Developers"]
version = "0.31.3"
build = "build.rs"

@@ -126,3 +125,3 @@ include = [

[dependencies.libc]
version = "0.2.181"
version = "0.2.186"
features = ["extra_traits"]

@@ -129,0 +128,0 @@

# Rust bindings to *nix APIs
[![Cirrus Build Status](https://api.cirrus-ci.com/github/nix-rust/nix.svg)](https://cirrus-ci.com/github/nix-rust/nix)
[![crates.io](https://img.shields.io/crates/v/nix.svg)](https://crates.io/crates/nix)

@@ -5,0 +4,0 @@ [![docs.rs](https://img.shields.io/badge/docs.rs-nix-blue?style=flat-square&logo=docs.rs)](https://docs.rs/nix)

@@ -1148,2 +1148,3 @@ // vim: tw=80

// * i686-unknown-linux-musl
// * x86_64-unknown-linux-musl
// because it hangs on these targets. After further debugging, we think this is

@@ -1153,7 +1154,12 @@ // likely a bug of musl. Since we only test our bindings and do not intend to

// See this thread for the discussion of this issue:
// https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159
// 1. https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159
// 2. https://github.com/nix-rust/nix/issues/2788
#[cfg_attr(
all(
target_env = "musl",
any(target_arch = "aarch64", target_arch = "x86")
any(
target_arch = "aarch64",
target_arch = "x86",
target_arch = "x86_64"
)
),

@@ -1165,3 +1171,7 @@ doc = " ```no_run"

target_env = "musl",
any(target_arch = "aarch64", target_arch = "x86")
any(
target_arch = "aarch64",
target_arch = "x86",
target_arch = "x86_64"
)
)),

@@ -1168,0 +1178,0 @@ doc = " ```"

@@ -66,3 +66,3 @@ use crate::errno::Errno;

pub fn events(&self) -> EpollFlags {
EpollFlags::from_bits(self.event.events as c_int).unwrap()
EpollFlags::from_bits_retain(self.event.events as c_int)
}

@@ -69,0 +69,0 @@

@@ -17,4 +17,3 @@ //! Kernel event notification mechanism

/// A kernel event queue. Used to notify a process of various asynchronous
/// events.
/// An event for use with [`Kqueue::kevent`].
#[repr(C)]

@@ -26,2 +25,10 @@ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]

/// An event for use with [`Kqueue::kevent64`].
#[cfg(apple_targets)]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct KEvent64 {
kevent: libc::kevent64_s,
}
/// A kernel event queue.

@@ -94,2 +101,29 @@ ///

}
/// Like [`kevent`](Kqueue::kevent), but uses [`KEvent64`].
#[cfg(apple_targets)]
pub fn kevent64(
&self,
changelist: &[KEvent64],
eventlist: &mut [KEvent64],
flags: Kevent64Flags,
timeout_opt: Option<timespec>,
) -> Result<usize> {
let res = unsafe {
libc::kevent64(
self.0.as_raw_fd(),
changelist.as_ptr().cast(),
changelist.len() as c_int,
eventlist.as_mut_ptr().cast(),
eventlist.len() as c_int,
flags.bits(),
if let Some(ref timeout) = timeout_opt {
timeout as *const timespec
} else {
ptr::null()
},
)
};
Errno::result(res).map(|r| r as usize)
}
}

@@ -334,2 +368,13 @@

#[cfg(apple_targets)]
libc_bitflags! {
/// Flags for [`Kqueue::kevent64`].
pub struct Kevent64Flags: libc::c_uint {
/// Return immediately even if there are no events to return.
KEVENT_FLAG_IMMEDIATE;
/// Only return error events from the changelist.
KEVENT_FLAG_ERROR_EVENTS;
}
}
#[allow(missing_docs)]

@@ -389,3 +434,3 @@ #[deprecated(since = "0.27.0", note = "Use KEvent::new instead")]

pub fn flags(&self) -> EvFlags {
EvFlags::from_bits(self.kevent.flags).unwrap()
EvFlags::from_bits_retain(self.kevent.flags)
}

@@ -395,3 +440,3 @@

pub fn fflags(&self) -> FilterFlag {
FilterFlag::from_bits(self.kevent.fflags).unwrap()
FilterFlag::from_bits_retain(self.kevent.fflags)
}

@@ -410,2 +455,71 @@

#[cfg(apple_targets)]
const _: () = {
fn _assert_send<T: Send>() {}
fn _assert() {
_assert_send::<KEvent64>();
}
};
#[cfg(apple_targets)]
impl KEvent64 {
/// Construct a new `KEvent64`.
pub fn new(
ident: u64,
filter: EventFilter,
flags: EvFlags,
fflags: FilterFlag,
data: i64,
udata: u64,
ext: [u64; 2],
) -> KEvent64 {
KEvent64 {
kevent: libc::kevent64_s {
ident,
filter: filter as type_of_event_filter,
flags: flags.bits(),
fflags: fflags.bits(),
data,
udata,
ext,
},
}
}
/// Value used to identify this event.
pub fn ident(&self) -> u64 {
self.kevent.ident
}
/// Identifies the kernel filter used to process this event.
pub fn filter(&self) -> Result<EventFilter> {
self.kevent.filter.try_into()
}
/// Event flags.
pub fn flags(&self) -> EvFlags {
EvFlags::from_bits_retain(self.kevent.flags)
}
/// Filter-specific flags.
pub fn fflags(&self) -> FilterFlag {
FilterFlag::from_bits_retain(self.kevent.fflags)
}
/// Filter-specific data value.
pub fn data(&self) -> i64 {
self.kevent.data
}
/// Opaque user-defined value passed through the kernel unchanged.
pub fn udata(&self) -> u64 {
self.kevent.udata
}
/// Filter-specific extension data.
pub fn ext(&self) -> [u64; 2] {
self.kevent.ext
}
}
#[allow(missing_docs)]

@@ -412,0 +526,0 @@ #[deprecated(since = "0.27.0", note = "Use Kqueue::kevent instead")]

@@ -7,2 +7,3 @@ use cfg_if::cfg_if;

target_os = "fuchsia",
target_os = "cygwin",
target_env = "musl",

@@ -16,2 +17,3 @@ target_env = "ohos"

target_os = "fuchsia",
target_os = "cygwin",
target_env = "musl",

@@ -23,2 +25,3 @@ target_env = "ohos"

/// The datatype used for the 3rd argument
#[cfg(not(target_os = "cygwin"))]
#[doc(hidden)]

@@ -25,0 +28,0 @@ pub type ioctl_param_type = ::libc::c_ulong;

@@ -230,7 +230,17 @@ //! Provide helpers for making ioctl system calls.

#[cfg(any(linux_android, target_os = "fuchsia", target_os = "redox"))]
#[cfg(any(
linux_android,
target_os = "fuchsia",
target_os = "redox",
target_os = "cygwin"
))]
#[macro_use]
mod linux;
#[cfg(any(linux_android, target_os = "fuchsia", target_os = "redox"))]
#[cfg(any(
linux_android,
target_os = "fuchsia",
target_os = "redox",
target_os = "cygwin"
))]
pub use self::linux::*;

@@ -237,0 +247,0 @@

@@ -43,2 +43,3 @@ //! Mostly platform-specific functionality

target_os = "redox",
target_os = "cygwin",
))]

@@ -45,0 +46,0 @@ #[cfg(feature = "ioctl")]

@@ -429,6 +429,4 @@ //! Operating system signals.

cfg_if! {
if #[cfg(target_os = "redox")] {
if #[cfg(target_env = "uclibc")] {
type SaFlags_t = libc::c_ulong;
} else if #[cfg(target_env = "uclibc")] {
type SaFlags_t = libc::c_ulong;
} else {

@@ -448,21 +446,21 @@ type SaFlags_t = libc::c_int;

/// stops.
SA_NOCLDSTOP;
SA_NOCLDSTOP as SaFlags_t;
/// When catching a [`Signal::SIGCHLD`] signal, the system will not
/// create zombie processes when children of the calling process exit.
#[cfg(not(target_os = "hurd"))]
SA_NOCLDWAIT;
SA_NOCLDWAIT as SaFlags_t;
/// Further occurrences of the delivered signal are not masked during
/// the execution of the handler.
SA_NODEFER;
SA_NODEFER as SaFlags_t;
/// The system will deliver the signal to the process on a signal stack,
/// specified by each thread with sigaltstack(2).
SA_ONSTACK;
SA_ONSTACK as SaFlags_t;
/// The handler is reset back to the default at the moment the signal is
/// delivered.
SA_RESETHAND;
SA_RESETHAND as SaFlags_t;
/// Requests that certain system calls restart if interrupted by this
/// signal. See the man page for complete details.
SA_RESTART;
SA_RESTART as SaFlags_t;
/// This flag is controlled internally by Nix.
SA_SIGINFO;
SA_SIGINFO as SaFlags_t;
}

@@ -757,3 +755,33 @@ }

/// A signal handler.
/// A signal handler used with [`sigaction`] or [`signal`].
///
/// Signal handlers have very limited functionality. A signal handler must
/// only call async-signal-safe functions. A list of async-signal-safe
/// functions can be found in
/// [signal-safety(7)](https://man7.org/linux/man-pages/man7/signal-safety.7.html).
///
/// In particular, signal handlers should only set a flag using an atomic type
/// (such as [`std::sync::atomic::AtomicBool`]) and do nothing else. Any more
/// complex logic should be performed outside the signal handler.
///
/// # Examples
///
/// Catch `SIGINT` and record it with an atomic flag:
///
/// ```no_run
/// # use std::convert::TryFrom;
/// # use std::sync::atomic::{AtomicBool, Ordering};
/// # use nix::sys::signal::{self, Signal, SigHandler};
/// static SIGNALED: AtomicBool = AtomicBool::new(false);
///
/// extern "C" fn handle_sigint(signal: libc::c_int) {
/// let signal = Signal::try_from(signal).unwrap();
/// SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed);
/// }
///
/// fn main() {
/// let handler = SigHandler::Handler(handle_sigint);
/// unsafe { signal::signal(Signal::SIGINT, handler) }.unwrap();
/// }
/// ```
#[derive(Clone, Copy, Debug, Hash)]

@@ -773,3 +801,25 @@ pub enum SigHandler {

/// Action to take on receipt of a signal. Corresponds to `sigaction`.
/// Action to take on receipt of a signal.
///
/// `SigAction` wraps `libc::sigaction`, which defines the full signal
/// disposition: the handler, flags controlling delivery behavior, and the set
/// of signals to block while the handler runs. Construct one with
/// [`SigAction::new`] and install it with [`sigaction`].
///
/// # Examples
///
/// Install a handler for `SIGINT`:
///
/// ```no_run
/// # use nix::sys::signal::{self, SaFlags, SigAction, SigHandler, SigSet, Signal};
/// extern "C" fn handle_sigint(signal: libc::c_int) {
/// // handle signal
/// }
///
/// fn main() {
/// let handler = SigHandler::Handler(handle_sigint);
/// let action = SigAction::new(handler, SaFlags::empty(), SigSet::empty());
/// unsafe { signal::sigaction(Signal::SIGINT, &action) }.unwrap();
/// }
/// ```
#[repr(transparent)]

@@ -776,0 +826,0 @@ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]

@@ -63,3 +63,4 @@ //! Sleep, query system clocks, and set system clock

target_os = "freebsd",
target_os = "fuchsia"
target_os = "fuchsia",
target_os = "openbsd",
))]

@@ -101,2 +102,3 @@ /// Starts at zero when the kernel boots and increments monotonically in SI seconds while the

freebsdlike,
netbsdlike,
target_os = "emscripten",

@@ -157,2 +159,3 @@ target_os = "fuchsia",

freebsdlike,
netbsdlike,
target_os = "emscripten",

@@ -164,3 +167,3 @@ target_os = "fuchsia",

ClockId(libc::CLOCK_THREAD_CPUTIME_ID);
#[cfg(freebsdlike)]
#[cfg(any(freebsdlike, target_os = "openbsd"))]
/// Starts at zero when the kernel boots and increments monotonically in SI seconds while the

@@ -167,0 +170,0 @@ /// machine is running.

@@ -54,12 +54,2 @@ use cfg_if::cfg_if;

#[cfg(linux_android)]
#[macro_export]
macro_rules! skip_if_cirrus {
($reason:expr) => {
if std::env::var_os("CIRRUS_CI").is_some() {
skip!("{}", $reason);
}
};
}
#[cfg(target_os = "freebsd")]

@@ -66,0 +56,0 @@ #[macro_export]

@@ -131,3 +131,3 @@ use std::fs::{self, File};

"{:?} did not have execute permissions",
&test_path
test_path
);

@@ -134,0 +134,0 @@

use libc::intptr_t;
use nix::sys::event::{EvFlags, EventFilter, FilterFlag, KEvent};
#[cfg(apple_targets)]
use nix::sys::event::{KEvent64, Kevent64Flags, Kqueue};

@@ -28,3 +30,30 @@ #[test]

#[cfg(apple_targets)]
#[test]
fn test_struct_kevent64() {
use std::mem;
let actual = KEvent64::new(
0xdead_beef,
EventFilter::EVFILT_READ,
EvFlags::EV_ONESHOT | EvFlags::EV_ADD,
FilterFlag::NOTE_CHILD | FilterFlag::NOTE_EXIT,
0x1337,
12345,
[0xaa, 0xbb],
);
assert_eq!(0xdead_beef, actual.ident());
assert_eq!(EventFilter::EVFILT_READ, actual.filter().unwrap());
assert_eq!(libc::EV_ONESHOT | libc::EV_ADD, actual.flags().bits());
assert_eq!(libc::NOTE_CHILD | libc::NOTE_EXIT, actual.fflags().bits());
assert_eq!(0x1337, actual.data());
assert_eq!(12345, actual.udata());
assert_eq!([0xaa, 0xbb], actual.ext());
assert_eq!(
mem::size_of::<libc::kevent64_s>(),
mem::size_of::<KEvent64>()
);
}
#[test]
fn test_kevent_filter() {

@@ -43,1 +72,20 @@ let udata: intptr_t = 12345;

}
#[test]
#[cfg(apple_targets)]
fn kevent64_empty_lists_zero_timeout() {
let kq = Kqueue::new().expect("failed to create kqueue");
let changelist: [KEvent64; 0] = [];
let mut eventlist: [KEvent64; 0] = [];
let timeout = libc::timespec {
tv_sec: 0,
tv_nsec: 0,
};
let result = kq.kevent64(
&changelist,
&mut eventlist,
Kevent64Flags::empty(),
Some(timeout),
);
assert_eq!(result.expect("kevent64 should succeed"), 0);
}

@@ -250,3 +250,3 @@ #[cfg(not(target_os = "redox"))]

let dst = tempdir.path().join("b");
println!("a: {:?}, b: {:?}", &src, &dst);
println!("a: {:?}, b: {:?}", src, dst);
fs::symlink(src.as_path(), dst.as_path()).unwrap();

@@ -253,0 +253,0 @@ let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display