summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2023-01-15Try enabling LocalPeerPid for iosArmin Ronacher
2023-01-14Added changelog entry and test for LocalPeerPidArmin Ronacher
2023-01-10Added `mq_timedreceive` to `::nix::mqueue`.David Collard
2023-01-08feat: I/O safety `ftruncate`Jonathan
2022-12-14Merge #1944bors[bot]
1944: Rework vsock test r=asomers a=stefano-garzarella We mainly provide VsockAddr, so let's try to test well that VsockAddr mapping to libc::sockaddr_vm is correct. Let's remove all interactions with the socket, since vsock may or may not be available in the environment. Testing socket(), bind(), listen(), connect(), etc. caused unexpected failures, and it's out of scope of this crate. So let's simplify the vsock test focussing on VsockAddr. This should work also on graviton, so let's try to re-enable it. Fixes #1934 Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Co-authored-by: Stefano Garzarella <sgarzare@redhat.com>
2022-12-14Rework vsock testStefano Garzarella
We mainly provide VsockAddr, so let's try to test well that VsockAddr mapping to libc::sockaddr_vm is correct. Let's remove all interactions with the socket, since vsock may or may not be available in the environment. Testing socket(), bind(), listen(), connect(), etc. caused unexpected failures, and it's out of scope of this crate. So let's simplify the vsock test focussing on VsockAddr. This should work also on graviton, so let's try to re-enable it. Fixes #1934 Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2022-12-13Merge #1940bors[bot]
1940: feat: I/O safety for 'sys/select' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/select`. Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-12-12feat: I/O safety for 'sys/select'Steve Lau
2022-12-11feat: I/O safety for 'sys/poll'Steve Lau
2022-12-09Merge #1913 #1926 #1927 #1931 #1933bors[bot]
1913: feat: I/O safety for 'sys/inotify' r=asomers a=SteveLauC #### What this PR does: 1. Changes the `fd` field of `struct Inotify` from `RawFd` to `OwnedFd` 2. Changes the interfaces of functions in the `impl Inotify {}` > The type of `self` changes from `Self` to `&mut Self`. From: ```rust pub fn add_watch<P: ?Sized + NixPath>( self, path: &P, mask: AddWatchFlags, ) -> Result<WatchDescriptor> pub fn rm_watch(self, wd: WatchDescriptor) -> Result<()> pub fn read_events(self) -> Result<Vec<InotifyEvent>> ``` To: ```rust pub fn add_watch<P: ?Sized + NixPath>( &mut self, path: &P, mask: AddWatchFlags, ) -> Result<WatchDescriptor> pub fn rm_watch(&mut self, wd: WatchDescriptor) -> Result<()> pub fn read_events(&mut self) -> Result<Vec<InotifyEvent>> ``` In the previous implementation, these functions can take `self` by value as `struct Inotify` [was `Copy`](https://docs.rs/nix/latest/nix/sys/inotify/struct.Inotify.html#impl-Copy-for-Inotify). With the changes in `1` applied, `struct Inotify` is no longer `Copy`, so we have to take `self` by reference. ------- Blocks until the merge of #1863 as this PR needs `read(2)` to be I/O-safe. 1926: feat: I/O safety for 'sys/sendfile' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/sendfile`. 1927: feat: I/O safety for 'sys/statvfs' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/statvfs`. 1931: feat: I/O safety for 'sys/uid' & 'sched' r=asomers a=SteveLauC #### What this PR does: Adds I/O safety for modules: 1. `sys/uio` 2. `sched` 1933: feat: I/O safety for 'sys/timerfd' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/timerfd`. Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-12-09feat: I/O safety for 'sys/sendfile'Steve Lau
2022-12-09feat: I/O safety for 'sys/uid' & 'sched'Steve Lau
2022-12-09fixSteve Lau
2022-12-09refactor: take AsFd by valueSteve Lau
2022-12-08feat: I/O safety for 'sys/termios' & 'pty'Steve Lau
2022-12-06Merge #1916bors[bot]
1916: Use I/O safety in sys::mman r=rtzoeller a=asomers Co-authored-by: Alan Somers <asomers@gmail.com>
2022-12-06Merge #1882bors[bot]
1882: Epoll type r=asomers a=JonathanWoollett-Light Epoll can be most safely used as a type. This implement a type `Epoll` which supports this. Co-authored-by: Jonathan <jonathanwoollettlight@gmail.com>
2022-12-06feat: I/O safety for 'sys/statfs'Steve Lau
2022-12-05Use I/O safety in sys::mmanAlan Somers
2022-12-04EpollJonathan
2022-12-04Fix clippy lintsAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-12-03Nuke deprecated net APIsAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-28Fix UB in the SO_TYPE sockoptAlan Somers
When reading a value into an enum from getsockopt, we must validate it. Failing to do so can lead to UB for example with SOCK_PACKET on Linux. Perform the validation in GetSockOpt::get. Currently SockType is the only type that requires validation. Fixes #1819
2022-11-25Merge #1865bors[bot]
1865: Add IpMtu sockopt r=asomers a=ShadowJonathan Resolves https://github.com/nix-rust/nix/issues/1864 Co-authored-by: Jonathan de Jong <jonathandejong02@gmail.com>
2022-11-25Clippy cleanup with the latest nightly.Alan Somers
2022-11-23add IpMtu sockoptJonathan de Jong
2022-11-21Merge #1857bors[bot]
1857: Add better support for unnamed unix socket addrs r=asomers a=stevenengler This adds the following 2 functions/methods: `UnixAddr::new_unnamed` and `UnixAddr::is_unnamed`. Closes #1585 unix(7) on Linux: > unnamed: A stream socket that has not been bound to a pathname using bind(2) has no name. Likewise, the two sockets created by socketpair(2) are unnamed. When the address of an unnamed socket is returned, its length is `sizeof(sa_family_t)`, and `sun_path` should not be inspected. **Edit:** This currently isn't working on BSD, but I see why. Will fix it shortly. Co-authored-by: Steven Engler <opara@cs.georgetown.edu>
2022-11-21fixup! Added better support for unnamed unix socket addrsSteven Engler
Removed test assertion
2022-11-21fixup! Added better support for unnamed unix socket addrsSteven Engler
Make Linux-only
2022-11-21Added better support for unnamed unix socket addrsSteven Engler
2022-11-20mmap non-zero lengthJonathan
2022-11-20Merge #1853bors[bot]
1853: Adds IP_TOS, IPV6_TCLASS and SO_PRIORITY sockopt wrappers for Linux r=asomers a=mzachar Added socket option wrappers for DiffServ related parameters on Linux Co-authored-by: mzachar <mzachar@users.noreply.github.com>
2022-11-20mmap addrJonathan
2022-11-20Adds IP_TOS, IPV6_TCLASS and SO_PRIORITY sockopt wrappersmzachar
2022-11-06Run a round of clippy to fix CIAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-10-14reimplement recvmsg/sendmmsgMichael Baikov
New implementation performs no allocations after all the necessary structures are created, removes potentially unsound code that was used by the old version (see below) and adds a bit more documentation about bugs in how timeout is actually handled ``` let timeout = if let Some(mut t) = timeout { t.as_mut() as *mut libc::timespec } else { ptr::null_mut() }; ```
2022-10-13add eaccess on FreeBSD, DragonFly and Linux (musl and glibc)Steve Lau
2022-10-08Fix clippy warnings on nightlyRyan Zoeller
Clippy is now smarter about detecting unnecessary casts and useless conversions, which means we need to be more explicit about when the conversions are needed for a subset of platforms. Required changes found by repeatedly running the following command against a list of the supported platforms. `xargs -t -I {} sh -c "cargo clippy -Zbuild-std --target {} --all-targets -- -D warnings || exit 255"` I removed the casts it complained about, and then restored them with an `#[allow]` if a later target needed the cast.
2022-09-27Add a `sched_getcpu` wrapperJonas Schievink
2022-09-11Clippy cleanupAlan Somers
2022-08-25Add sched_getaffinity and sched_setaffinity on FreeBSDRyan Zoeller
2022-08-14Fix a new clippy lintAlan Somers
2022-08-12Merge #1776bors[bot]
1776: Add support for the IP_SENDSRCADDR control message r=rtzoeller a=matttpt This control message is available on FreeBSD, NetBSD, and OpenBSD. When used with `sendmsg`, it sets the IPv4 source address. This adds support through a new `ControlMessage::Ipv4SendSrcAddr` variant that complements `ControlMessageOwned::Ipv4RecvDstAddr`. A few notes: * `IP_SENDSRCADDR` is actually just an alias for `IP_RECVDSTADDR` (though the code doesn't depend on this). * On NetBSD, `IP_PKTINFO` can be used to accomplish the same thing and is already supported by nix. On FreeBSD and OpenBSD, though, `IP_SENDSRCADDR` is the only method I'm aware of. * The accompanying test binds a UDP socket to all local interfaces (0.0.0.0). If this is not acceptable, please let me know; however, FreeBSD requires this to use `IP_SENDSRCADDR`. I'll add a change-log entry once I see the PR number. Thanks! Co-authored-by: Matthew Ingwersen <matttpt@gmail.com>
2022-08-12Merge branch 'nix-rust:master' into remove-deprecated-itemsSteveLau
2022-08-12Folloup for !1778, remove some of the less helpful error msgsMichael Baikov
2022-08-09format codeSteveLauC
2022-08-09remove deprecated itemsSteveLauC
2022-08-05add faccessatZhang Miaolei
2022-08-05Add support for the IP_SENDSRCADDR control messageMatthew Ingwersen
This control message (actually just an alias for IP_RECVDSTADDR) sets the IPv4 source address when used with sendmsg. It is available on FreeBSD, NetBSD, OpenBSD, and DragonFlyBSD.
2022-08-04fix clippy assertions_on_result_statesMichael Baikov
https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states