1780: Implement faccessat r=asomers a=nateavers
This is a re-post of #1134, which seems to have been abandoned. Includes the changes requested in [this comment](https://github.com/nix-rust/nix/pull/1134#issuecomment-541346612).
Co-authored-by: Zhang Miaolei <zmlcc@outlook.com>
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.
1779: Upgrade libc to 0.2.127 r=asomers a=rtzoeller
This is the last version of libc which will support Rust 1.46, per https://github.com/rust-lang/libc/pull/2845.
I think we should ship nix 0.25.0 against this version of libc (at some point, not necessarily now), as it will allow us to maintain an MSRV of 1.46, and subsequently upgrade to a later libc immediately after releasing 0.25.0.
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
1774: Fix typo guarding memfd export on android. r=asomers a=detly
Extremely minor but crucial typo on import guard from #1773. `@flxo`
Co-authored-by: Jason Heeris <jason.heeris@gmail.com>
1768: Add ETH_P_ALL protocol number to SockProtocol r=asomers a=valdaarhun
Hi. I am working on a networking project that uses [packet sockets](https://man7.org/linux/man-pages/man7/packet.7.html) and noticed that ETH_P_ALL is not there in the `SockProtocol` enum. I thought it would be nice to have it here alongside IPPROTO_TCP and IPPROTO_UDP instead of having to separately import it from the libc crate.
Co-authored-by: valdaarhun <icegambit91@gmail.com>
1770: Fix SockaddrLike::from_raw with unaligned inputs r=rtzoeller a=asomers
The major users of this function are functions like gethostname, which
will always properly align their buffers. But out-of-crate consumers
could manually construct an unaligned buffer. Handle that correctly.
Enable Clippy's cast_ptr_alignment lint. It's disabled by default as it
reports many false positives, but it would've caught this problem.
Reported-by: Miri
Fixes: 1769
Co-authored-by: Alan Somers <asomers@gmail.com>
The major users of this function are functions like gethostname, which
will always properly align their buffers. But out-of-crate consumers
could manually construct an unaligned buffer. Handle that correctly.
Enable Clippy's cast_ptr_alignment lint. It's disabled by default as it
reports many false positives, but it would've caught this problem.
Reported-by: Miri
Fixes: 1769
1764: Fix description of fchownat r=asomers a=valdaarhun
Based on the man page for `fchownat` and `lchown`, I have got the impression that with `FchownatFlags::NoFollowSymlink`, fchownat and lchown are identical. I couldn't find any documentation on `lchmod`.
Co-authored-by: valdaarhun <icegambit91@gmail.com>
1741: SigSet: A new unsafe helper method to create a SigSet from a sigset_t r=rtzoeller a=germag
Currently, the only way to create a `SigSet` from a `sigset_t` object
is by using pointer casts, like:
```
unsafe {
let sigset = *(&sigset as *const libc::sigset_t as *const SigSet)
};
```
This is un-ergonomic for library creators with interfaces to C.
So, let's add a new unsafe method that creates a `SigSet` from a
`libc::sigset_t` object.
We can't implement `From` since converting from `libc::sigset_t` to
`SigSet` is unsafe, because objects of type `libc::sigset_t` must be
initialized by calling either `sigemptyset(3)` or `sigfillset(3)`
before being used. In other case, the results are undefined.
We can't implement `TryFrom` either, because there is no way to check
if an object of type `libc::sigset_t` is initialized.
Signed-off-by: German Maglione <gmaglione@redhat.com>
Co-authored-by: German Maglione <gmaglione@redhat.com>
1763: Fix a buffer overflow in sys::socket::recvfrom r=posborne a=asomers
IPv4 and stream sockets are unaffected, but for datagram sockets of
other address types libc::recvfrom might overwrite part of the stack.
Fixes#1762
Co-authored-by: Alan Somers <asomers@gmail.com>
1761: Add non-standard Linux `SysconfVar` variants r=asomers a=stevenengler
Closes#1240.
You can find these options near the end of https://man7.org/linux/man-pages/man3/sysconf.3.html.
I can see that the libc crate defines these for Linux and Android, but I'm not sure if they're defined for any others as well.
Co-authored-by: Steven Engler <opara@cs.georgetown.edu>
This commit adds the `repr(transparent)` attribute to the `SigSet`
struct, to make sure that its representation is exactly like the
`sigset_t` struct from C, in all cases.
Signed-off-by: German Maglione <gmaglione@redhat.com>
Currently, the only way to create a `SigSet` from a `sigset_t` object
is by using pointer casts, like:
```
unsafe {
let sigset = *(&sigset as *const libc::sigset_t as *const SigSet)
};
```
This is un-ergonomic for library creators with interfaces to C.
So, let's add a new unsafe method that creates a `SigSet` from a
`libc::sigset_t` object.
We can't implement `From` since converting from `libc::sigset_t` to
`SigSet` is unsafe, because objects of type `libc::sigset_t` must be
initialized by calling either `sigemptyset(3)` or `sigfillset(3)`
before being used. In other case, the results are undefined.
We can't implement `TryFrom` either, because there is no way to check
if an object of type `libc::sigset_t` is initialized.
Signed-off-by: German Maglione <gmaglione@redhat.com>
1759: More docs for dir and mqueue r=rtzoeller a=asomers
Add doc comments for the `dir` and `mqueue` modules. Also, delete dead code in `mqueue`
1760: Add const constructors for TimeSpec and TimeVal r=rtzoeller a=asomers
These are basically the same as From<libc::timespec> and
From<libc::timeval>, but they're const and require less typing.
Co-authored-by: Alan Somers <asomers@gmail.com>
1752: Add missing DontRoute SockOpt r=asomers a=leoleoasd
I'm not sure, but according to [unix standard](https://pubs.opengroup.org/onlinepubs/7908799/xns/setsockopt.html), SO_DONTROUTE should appear in all unix systems.
Does this need a test?
Co-authored-by: Leo Lu <luyuxuanleo@gmail.com>
1745: Change gethostname to use a buffer of MaybeUninit values r=asomers a=nathaniel-daniel
Changing `gethostname` to accept a buffer of `MaybeUninit` bytes allows the user to avoid needlessly initializing a buffer. This is a breaking API change.
Co-authored-by: Nathaniel Daniel <nathaniel.daniel12@gmail.com>
1693: Document aliases for functions like getuid() r=asomers a=rtzoeller
Add the autocfg crate as a build dependency, and introduce `has_doc_alias` as a conditional compilation symbol.
Closes#1673.
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>