Age | Commit message (Collapse) | Author |
|
1618: Refactor UnixAddr r=asomers a=asomers
* Within UnixAddr, replace the path_len variable (length of the sun_path
field) with sun_len (length of the whole structure). This is more
similar to how other sockaddr types work, and it's the same way that the
BSDs use the sun_len field.
Also, don't require that sun_path be nul-terminated. The OS doesn't
require it.
* On BSD-derived operating systems, struct sockaddr has a sa_len field
that holds the length of the structure. UnixAddr's path_len field is
redundant. Remove path_len on BSD-derived OSes, retaining it only for
Illumos and Linux-based OSes.
Co-authored-by: Alan Somers <asomers@gmail.com>
|
|
On BSD-derived operating systems, struct sockaddr has a sa_len field
that holds the length of the structure. UnixAddr's path_len field is
redundant. Remove path_len on BSD-derived OSes, retaining it only for
Illumos and Linux-based OSes.
Also, ensure that two UnixAddrs compare equal if they differ only by the
presence of a trailing NUL. On Linux, syscalls like getsockname add a
trailing NUL to the sockaddr they return, even if no NUL was present on
the sockaddr originally passed to the kernel via a syscall like bind,
and even though the docs explicitly say that any NUL passed to bind is
not considered to be part of the address. Work around this bug by
stripping it in UnixAddrKind::get(), so that at least two UnixAddrs will
compare identical even if they differ in the presence of a trailing NUL.
|
|
|
|
1547: feat: Add glibc::SOF_TIMESTAMPING_* support r=asomers a=pacak
Support for kernel and hardware receive timestamps
Co-authored-by: Michael Baikov <manpacket@gmail.com>
|
|
|
|
Within UnixAddr, replace the path_len variable (length of the sun_path
field) with sun_len (length of the whole structure). This is more
similar to how other sockaddr types work, and it's the same way that the
BSDs use the sun_len field.
Also, don't require that sun_path be nul-terminated. The OS doesn't
require it.
|
|
* All sockaddr newtypes should be repr(transparent)
* All sockaddr newtypes should be opaque, so the user can't do something
like change the sa_family field in a way that violates invariants.
This is a prerequisite for #1544.
|
|
Using features reduces build time and size for consumer crates. By
default all features are enabled.
|
|
They were properly marked as unsafe as originally written. However,
when the internal mem::zeroed() was replaced by mem::uninitialized(),
these traits actually became safe. Only Get::assume_init() is actually
unsafe. Fixes a warning with the latest Clippy.
|
|
This reverts commit ed43d2c65e65dd68c9cf2dcf06f5ec45a44aaccd.
As discussed in #1544 the API of this function needs to change. For
now, revert the PR that made it public, because it has not yet been
included in any release.
|
|
And this time, start running Clippy in CI
|
|
1496: Rework UnixAddr to fix soundness issues r=asomers a=coolreader18
Fixes #1494
I went with making `sun_path` always nul-terminated since that just seems to make things easier, since (at least according to linux man pages) `sockaddr_un`s returned by the kernel will always be nul-terminated.
Co-authored-by: Noa <33094578+coolreader18@users.noreply.github.com>
|
|
|
|
|
|
This macro is not exported outside of the crate, so there's no danger.
|
|
Test: `cargo test --test test test_ttl_opts`
|
|
|
|
Setting these options enables receiving errors, such as ICMP errors from
the network, via `recvmsg()` with `MSG_ERRQUEUE`.
Adds new `Ipv{4,6}RecvErr` variants to `ControlMessageOwned`. These
control messages are produced when `Ipv4RecvErr` or `Ipv6RecvErr`
options are enabled on a raw or datagram socket.
New tests for the functionality can be run with `cargo test --test test
test_recverr`.
This commit builds on an earlier draft of the functionality authored by
Matthew McPherrin <git@mcpherrin.ca>.
|
|
|
|
|
|
|
|
|
|
|
|
1447: Expose SockAddr::from_raw_sockaddr r=asomers a=coolreader18
I also noticed the `SockAddr/InetAddr::to_str` functions were entirely redundant - `ToString` exists for that, & has a blanket impl on `T: Display`.
Co-authored-by: Noah <33094578+coolreader18@users.noreply.github.com>
|
|
|
|
|
|
1486: Relax assertions in sockaddr_storage_to_addr to match the documentation. r=asomers a=khuey
Fixes #1479
1490: add libc::IP6T_SO_ORIGINAL_DST to socket opt r=asomers a=bearice
the original PR #1410 was stalled for a while
let's make it happen.
this should closes #1410 and #938
1493: Fix crates.io badge r=asomers a=atouchet
Co-authored-by: Kyle Huey <khuey@kylehuey.com>
Co-authored-by: Icemic <bingfeng.web@gmail.com>
Co-authored-by: Bearice Ren <bearice@icybear.net>
Co-authored-by: Alex Touchet <alextouchet@outlook.com>
|
|
Fixes #1479
|
|
Constify more functions, since we're raising the MSRV from 1.41.0 to
1.46.0.
Fixes #1477
|
|
|
|
On FreeBSD and its derivatives, this socket option gets the credentials
of the connected peer.
|
|
1473: sys/stat: add a safe wrapper for mknodat(2) r=asomers a=lucab
This introduces a new `mknodat` helper.
Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html
1474: Mark most C-derived enums as non_exhaustive r=asomers a=asomers
Since libc may add new variants at any time, Nix's consumers should not
use exhaustive match patterns.
Fixes #1182
1476: Constify many functions r=asomers a=asomers
Constify most functions that can be constified. The exceptions are
mostly accessors for structs that have no const constructor.
Co-authored-by: Luca BRUNO <luca.bruno@coreos.com>
Co-authored-by: Alan Somers <asomers@gmail.com>
|
|
Constify most functions that can be constified. The exceptions are
mostly accessors for structs that have no const constructor.
|
|
Since libc may add new variants at any time, Nix's consumers should not
use exhaustive match patterns.
Fixes #1182
|
|
|
|
This PR implements support of RXQ_OVFL flag and parsing ControlMessage
to get the packet drop counter of UDP socket.
|
|
Now that Nix's weird error types are eliminated, there's no reason not
to simply use Errno as the Error type.
|
|
For many of Nix's consumers it be convenient to easily convert a Nix
error into a std::io::Error. That's currently not possible because of
the InvalidPath, InvalidUtf8, and UnsupportedOperation types that have
no equivalent in std::io::Error.
However, very few of Nix's public APIs actually return those unusual
errors. So a more useful API would be for Nix's standard error type to
implement Into<std::io::Error>.
This commit makes Error a simple NewType around Errno. For most
functions it's a drop-in replacement. There are only three exceptions:
* clearenv now returns a bespoke error type. It was the only Nix
function whose error couldn't be cleanly mapped onto an Errno.
* sys::signal::signal now returns Error(Errno::ENOTSUP) instead of
Error::UnsupportedOperation when the user passes an incompatible
argument to `handler`.
* When a NixPath exceeds PATH_MAX, it will now return
Error(Errno::ENAMETOOLONG) instead of Error::InvalidPath.
In the latter two cases there is now some abiguity about whether the
error code was generated by Nix or by the OS. But I think the ambiguity
is worth it for the sake of being able to implement Into<io::Error>.
This commit also introduces Error::Sys() as a migration aid. Previously
that as an enum variant. Now it's a function, but it will work in many
of the same contexts as the original.
Fixes #1155
|
|
|
|
|
|
* Fix race conditions in the tests. Two tests were grabbing a mutex but
immediately dropping it. Thank you, Clippy.
* Remove vestigial Windows support. Remove some code added to support
Windows in 2015. Nix is no longer intended to ever run on Windows.
* Various other minor Clippy lints.
|
|
|
|
|
|
1402: Support TIMESTAMPNS r=asomers a=WiSaGaN
This adds support of linux TIMESTAMPNS.
The code is mostly copied paste from https://github.com/nix-rust/nix/pull/663
Co-authored-by: Lu, Wangshan <wisagan@gmail.com>
|
|
1414: Fix corrupted sendmmsg() call r=asomers a=eaufavor
Before this fix, the buffer that holds cmsgs may move due to the resize()
call. That causes msg_hdr pointing to invalid memory, which ends up
breaking the sendmmsg() call, resulting in EINVAL.
This change fixes it by avoiding re-allocating the buffers.
Co-authored-by: Yuchen Wu <yuchen@cloudflare.com>
|
|
|
|
Before this fix, the buffer that holds cmsgs may move due to the resize()
call. That causes msg_hdr pointing to invalid memory, which ends up
breaking the sendmmsg() call, resulting in EINVAL.
This change fixes it by avoiding re-allocating the buffers.
|
|
The homegrown macro was fine in 2016, but at some point it technically
became UB. The memoffset crate does the same thing, but avoids UB when
using rustc 1.51.0 or later.
Fixes #1415
|
|
|
|
Co-authored-by: Dominik Hassler <hadfl@omnios.org>
Co-authored-by: Joshua M. Clulow <josh@sysmgr.org>
|