summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-12-03Nuke deprecated net APIsAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-12-03Merge #1902bors[bot]
1902: Enable ucontext module on aarch64-unknown-linux-gnu r=asomers a=rtzoeller Untested, but I saw https://github.com/rust-lang/libc/commit/fd32da6e7dfa2afcae86e176904244cf45a90c06 and figured we should uptake it. Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-12-02Nuke IoVecAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-12-02Enable ucontext module on aarch64-unknown-linux-gnuRyan Zoeller
2022-11-29Add routing socket typeEmils
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-29Merge #1788bors[bot]
1788: Workaround XNU bug in getifaddrs netmasks r=asomers a=roblabla Fixes #1709 Co-authored-by: roblabla <unfiltered@roblab.la> Co-authored-by: Alan Somers <asomers@gmail.com>
2022-11-29PollFd utility functionsJonathan
2022-11-28Update use of libc::timespec to prepare for future libc versionWesley Wiser
In a future release of the `libc` crate, `libc::timespec` will contain private padding fields on `*-linux-musl` targets and so the struct will no longer be able to be created using the literal initialization syntax. Update places where `libc::timespec` is created to first zero initialize the value and then update the `tv_sec` and `tv_nsec` fields manually. Many of these places are in `const fn`s so a helper function `zero_init_timespec()` is introduced to help with this as `std::mem::MaybeUninit::zeroed()` is not a `const` function. Some matches on `libc::timespec` are also updated to include a trailing `..` pattern which works when `libc::timespec` has additional, private fields as well as when it does not (like for `x86_64-unknown-linux-gnu`).
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 #1848bors[bot]
1848: SockProtocol::Raw = libc::IPPROTO_RAW for raw sockets r=asomers a=StackOverflowExcept1on Hey, I wanna to make call like `socket(af_type, SOCK_RAW, IPPROTO_RAW)` but currently there is no way to do it with rust https://github.com/rickettm/SendIP/blob/aad12a001157489ab9053c8665e09aec24a2ff6d/sendip.c#L143 Update: Feel free to add `#[cfg]` attribute if I made mistakes that might cause errors on some platforms Co-authored-by: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com>
2022-11-21Use the new UnixAddr::new_unnamed in the unit testsAlan Somers
Use it in the from_sockaddr_un_abstract_unnamed test. That test and this method were introduced by PRs #1871 and #1857, which crossed each other.
2022-11-21Added `SockProtocol::Raw = libc::IPPROTO_RAW` for raw socketsStackOverflowExcept1on
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-21Merge #1871bors[bot]
1871: Fix using SockaddrStorage to store Unix domain addresses on Linux r=rtzoeller a=asomers Since it has variable length, the user of a sockaddr_un must keep track of its true length. On the BSDs, this is handled by the builtin sun_len field. But on Linux-like operating systems it isn't. Fix this bug by explicitly tracking it for SockaddrStorage just like we already do for UnixAddr. Fixes #1866 Co-authored-by: Alan Somers <asomers@gmail.com>
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-20Merge #1870bors[bot]
1870: mmap addr r=asomers a=JonathanWoollett-Light Uses `Some<size_t>` instead of `*mut c_void` for the `addr` passed to [`sys::mman::mmap`](https://docs.rs/nix/latest/nix/sys/mman/fn.mmap.html). In this instance we are not usefully passing a pointer, it will never be dereferenced. We are passing a location which represents where to attach the shared memory to. In this case `size_t` better represents an address and not a pointer, and `Option<size_t>` better represents an optional argument than `NULLPTR`. In C since there is no optional type this is a pointer as this allows it be null which is an alias here for `None`. Co-authored-by: Jonathan <jonathanwoollettlight@gmail.com>
2022-11-20mmap addrJonathan
2022-11-20Workaround XNU bug in getifaddrs netmasksroblabla
2022-11-20Adds IP_TOS, IPV6_TCLASS and SO_PRIORITY sockopt wrappersmzachar
2022-11-19Merge #1872bors[bot]
1872: Misc internal optimizations r=rtzoeller a=asomers * Make ipv4addr_to_libc const * Use mem::transmute in ipv4addr_to_libc and ipv6addr_to_libc Fixes #1687 Fixes #1688 Co-authored-by: Alan Somers <asomers@gmail.com>
2022-11-19Misc internal optimizationsAlan Somers
* Make ipv4addr_to_libc const * Use mem::transmute in ipv4addr_to_libc and ipv6addr_to_libc Fixes #1687 Fixes #1688
2022-11-19Fix using SockaddrStorage to store Unix domain addresses on LinuxAlan Somers
Since it has variable length, the user of a sockaddr_un must keep track of its true length. On the BSDs, this is handled by the builtin sun_len field. But on Linux-like operating systems it isn't. Fix this bug by explicitly tracking it for SockaddrStorage just like we already do for UnixAddr. Fixes #1866
2022-11-19Mode flag documentationJonathan
2022-11-11Nuke deprecated Errno flagsAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-06Reformat everythingAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-10-23Add a Statfs::flags methodAlan Somers
It returns the mount flags on the BSDs. On Linux, it returns a slightly different set of flags.
2022-10-23Define `MntFlags` and `unmount` on all of the BSDs.Alan Somers
2022-10-23On Linux-like operating systems, use statfs64 instead of statfs.Alan Somers
And fstatfs64 instead of fstatfs.
2022-10-23Suppress deprecation warnings from the latest libcAlan Somers
https://github.com/rust-lang/libc/pull/2963
2022-10-14include docsMichael Baikov
2022-10-14disable a flaky test on aarch64Michael Baikov
See https://github.com/nix-rust/nix/pull/1744 for more details
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-14pack_mhdr_to_receive: pass iovec ptr and capacity separatelyMichael Baikov
We'll be using that to reinitialize buffers later
2022-10-14pack_mhdr_to_receive: pass pointer and capacity directlyMichael Baikov
This is already an unsafe function, dealing with pointers directly does not make it much more unsafe but simplifies lifetimes later on and similar to a previous commit allows to alocate a single buffer to store all the control messages
2022-10-14socket: stop setting vector length inside read_mhdrMichael Baikov
CMSG_FIRSTHDR/CMSG_NEXTHDR operate in terms of pointers contained inside msghdr structure, vector capacity doesn't matter for them. This would change external behavior of recvmsg/recvmmsg in a sense that buffer passed to store controll messages won't have it's length updated but intended way to receive control messages is with cmsgs iterator on `RecvMsg` which would still work. This change is required to allow using a single vector to store control messages from multiple packets
2022-10-13add XFS_SUPER_NUMBER to nix::sys::statfsMrCroxx
2022-10-13Merge #1842bors[bot]
1842: add eaccess on freebsd, dragonfly and linux r=rtzoeller a=SteveLauC #### man pages * [FreeBSD](https://www.freebsd.org/cgi/man.cgi?query=eaccess&sektion=2&n=1) * [DragonFly](https://man.dragonflybsd.org/?command=access&section=2) * [Linux](https://man7.org/linux/man-pages/man3/euidaccess.3.html) #### difference between `eaccess` and `access/faccessat` IMHO, `eaccess` uses effective identifiers to perform the permission check while `access/faccessat` use real IDs. Fixes #1373 Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-10-12fix '<newline>' being interpreted as htmlRyan Zoeller
2022-10-13add eaccess on FreeBSD, DragonFly and Linux (musl and glibc)Steve Lau
2022-10-11Remove unnecessary verb from doc comment of `dup`Yusuke Tanaka
2022-10-10add faccessat on illumosSteve Lau
2022-10-08Merge #1833bors[bot]
1833: add syncfs on linux r=rtzoeller a=SteveLauC Fixes #1818 Change has not been added to `CHANGELOG.md`, will add it when #1831 is merged, or there will be a merge conflict Co-authored-by: Steve Lau <stevelauc@outlook.com>
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-10-08add syncfs on linuxSteve Lau