summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-08-14Raise the MSRV to 1.56.1 in anticipation of the next releaseAlan Somers
And fix some documentation lints warned about by the newer rustdoc.
2022-08-12Merge #1782bors[bot]
1782: feat #1733: add F_GET_SEALS and F_ADD_SEALS on FreeBSD r=rtzoeller a=SteveLauC Closes #1733 Co-authored-by: SteveLauC <stevelauc@outlook.com>
2022-08-12feat nix-rust#1733: add F_GET_SEALS and F_ADD_SEALS on FreeBSDSteveLauC
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 #1785bors[bot]
1785: Remove deprecated items r=asomers a=SteveLauC #### What this pr does 1. Convert `assert!(x == y)` to `assert_eq!(x, y)` 2. Convert `assert!(x != y)` to `assert_ne!(x, y)` 3. Add `.unwrap()` to unused `Result/Option` (in code comments) 4. Convert `std::ixx::MAX` to `ixx::MAX` 5. Convert `Box<Trait>` to `Box<dyn Trait>` Co-authored-by: SteveLauC <stevelauc@outlook.com> Co-authored-by: SteveLau <stevelauc@outlook.com>
2022-08-12fix CI errorSteveLauC
2022-08-12Merge branch 'nix-rust:master' into remove-deprecated-itemsSteveLau
2022-08-12Merge #1790bors[bot]
1790: minor terminology fix in User docs r=asomers a=oconnor663 Passwords are hashed, not encrypted. Co-authored-by: Jack O'Connor <oconnor663@gmail.com>
2022-08-11minor terminology fix in User docsJack O'Connor
Passwords are hashed, not encrypted.
2022-08-12Folloup for !1778, remove some of the less helpful error msgsMichael Baikov
2022-08-09remove deprecated itemsSteveLauC
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
2022-07-26Merge #1772bors[bot]
1772: Add support for RecvOrigDstAddr on Linux r=asomers a=brianmay Fixes #1767 Co-authored-by: Brian May <brian@linuxpenguins.xyz>
2022-07-26Fix typo guarding memfd export on android.Jason Heeris
2022-07-26Add support for RecvOrigDstAddr on LinuxBrian May
Fixes #1767
2022-07-25Add memfd for target_os = "android"Felix Obenhuber
Memory fds (`memfd`) are implemented and exported by Androids bionic. Export the `memfd` module if the target os is `android`. https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/mman.h;drc=23c7543b8e608ebcbb38b952761b54bb56065577;bpv=1;bpt=1;l=182
2022-07-24Add ETH_P_ALL protocol number to SockProtocolvaldaarhun
Add note to Changelog.md Make changes in comments Co-authored-by: Alan Somers <asomers@gmail.com> Add Android as target os for ETH_P_ALL
2022-07-23Fix SockaddrLike::from_raw with unaligned inputsAlan Somers
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
2022-07-16Fix description of fchownatvaldaarhun
2022-07-15Merge #1741bors[bot]
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>
2022-07-14Fix a buffer overflow in sys::socket::recvfromAlan Somers
IPv4 and stream sockets are unaffected, but for datagram sockets of other address types libc::recvfrom might overwrite part of the stack. Fixes #1762
2022-07-13Add chflagsmusikid
2022-07-13Added non-standard Linux `SysconfVar` variantsSteven Engler
2022-07-12SigSet: Add the `repr(transparent)` attributeGerman Maglione
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>
2022-07-12SigSet: A new unsafe helper method to create a SigSet from a sigset_tGerman Maglione
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>
2022-07-11Merge #1759 #1760bors[bot]
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>
2022-07-10Add const constructors for TimeSpec and TimeValAlan Somers
These are basically the same as From<libc::timespec> and From<libc::timeval>, but they're const and require less typing.
2022-07-11Add DontRoute SockOptLeo Lu
2022-07-10More docs for the dir moduleAlan Somers
2022-07-10More docs for mqueue.Alan Somers
Also, delete some dead code. It's always been dead.
2022-07-10Merge #1745bors[bot]
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>
2022-07-07Fix clippy on nightlyRyan Zoeller
2022-06-27Change gethostname to return an OsStringNathaniel Daniel
2022-06-27Change gethostname to use a buffer of MaybeUninit valuesNathaniel Daniel
2022-06-26Document aliases for functions like getuid()Ryan Zoeller
Add the autocfg crate as a build dependency, and introduce has_doc_alias as a conditional compilation symbol.
2022-06-24Merge #1748bors[bot]
1748: Add format test to CI r=rtzoeller a=costinsin To enforce uniformity for all PRs, the CI checks if the code is formatted right using `cargo fmt` tool. Results after implementing the format test in CicleCI, but before fixing the format errors: https://cirrus-ci.com/build/4684991404703744 Results after fixing the format errors: https://cirrus-ci.com/build/5423803479097344 Solves #770 Co-authored-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-24Fix all formating problems to pass CI formating testCostin-Robert Sin
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-21Merge #1747bors[bot]
1747: Add getrusage wrapper r=rtzoeller a=kov Includes an enum to specify what to get resource usage for, and a new struct that provides a more readable view into libc::rusage, including using TimeVal for user and system CPU time. Signed-off-by: Gustavo Noronha Silva <gustavo@noronha.dev.br> Co-authored-by: Gustavo Noronha Silva <gustavo@noronha.dev.br>
2022-06-20Add getrusage wrapperGustavo Noronha Silva
Includes an enum to specify what to get resource usage for, and a new struct that provides a more readable view into libc::rusage, including using TimeVal for user and system CPU time.
2022-06-19Minimise the use of the unsafe block inside pipe functionCostin-Robert Sin
Some of the operations inside the pipe function are safe and should not be included inside an unsafe block. Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-19Fix typo by adding a semicolonCostin-Robert Sin
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-09Merge #1739bors[bot]
1739: ppoll: make sigmask parameter optional r=rtzoeller a=stefano-garzarella ppoll(2) supports 'sigmask' as NULL. In that case no signal mask manipulation is performed. Let's make `sigmask` parameter of `nix::poll::ppoll` optional to allow that behaviour. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Co-authored-by: Stefano Garzarella <sgarzare@redhat.com>
2022-06-09ppoll: make sigmask parameter optionalStefano Garzarella
ppoll(2) supports 'sigmask' as NULL. In that case no signal mask manipulation is performed. Let's make `sigmask` parameter of `nix::poll::ppoll` optional to allow that behaviour. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2022-06-09Merge #1736bors[bot]
1736: Fix socket address family checks r=rtzoeller a=qwandor The `SockaddrLike::from_raw` implementations for `VsockAddr` and `SysControlAddr` were checking against the wrong address family constant. This PR makes them consistent with the values matched against in `SockaddrStorage::from_raw`. Co-authored-by: Andrew Walbran <qwandor@google.com>
2022-06-07Fix socket address family check for SysControlAddr::from_raw.Andrew Walbran
2022-06-07Fix socket address family check for VsockAddr::from_raw.Andrew Walbran