summaryrefslogtreecommitdiff
path: root/src/unistd.rs
AgeCommit message (Collapse)Author
2022-09-25fix crash on Android platformwdsgyj
2022-09-11Handle unacceptable name gracefully in {User,Group}::from_nameWATANABE Yuki
Calling `unwrap` on the result of `CString::new` may cause the current thread to panic, which is a bit surprising undocumented behavior. It would be more reasonable to treat the erroneous name as a non-existing user or group.
2022-08-20Remove MSRV-related workaround for doc aliasesRyan Zoeller
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-11minor terminology fix in User docsJack O'Connor
Passwords are hashed, not encrypted.
2022-08-09format codeSteveLauC
2022-08-09remove deprecated itemsSteveLauC
2022-08-05add faccessatZhang Miaolei
2022-07-16Fix description of fchownatvaldaarhun
2022-07-13Add chflagsmusikid
2022-07-13Added non-standard Linux `SysconfVar` variantsSteven Engler
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-24Fix all formating problems to pass CI formating testCostin-Robert Sin
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
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-05-30Merge #1727bors[bot]
1727: Add From<uid_t> and From<gid_t> r=rtzoeller a=vkkoskie Conversions to/from primitive uid_t and gid_t to newtype Uid and Gid types are valid and infallible, but are only implemented in one direction. This provides the counterparts in the other direction. These conversions are identical in behavior to the from_raw methods. However, using the more idiomatic From trait enables easier interoperability with other crates (e.g., deserialization with serde) Co-authored-by: Keith Koskie <vkkoskie@gmail.com>
2022-05-30Add infallible conversion from uid_t and gid_tKeith Koskie
Implements the following traits: * From<uid_t> for Uid * From<gid_t> for Gid
2022-05-29Clippy cleanup for latest nightlyAlan Somers
2022-05-14add haiku supportAl Hoang
* enabled as much functionality and defines that match updated libc definitions for haiku
2022-04-09Use singular number for all feature namesAlan Somers
features => feature users => user Neither of these features have yet been included in a release, so it's ok to rename them.
2022-03-19[skip ci] spellcheck a comment for sethostnameAlan Somers
2022-01-10Add getresuid/gid and setresuid/gid on BSDsRyan Zoeller
2021-12-26Fix typosRyan Zoeller
2021-12-22Add fdatasync for missing platformsRyan Zoeller
2021-12-21DragonFly 6.0 added fexecve(2)Ryan Zoeller
2021-12-20feature-gate most Nix functionsVincent Dagonneau
Using features reduces build time and size for consumer crates. By default all features are enabled.
2021-11-17Fix documentation formating for pipe2rusty-snake
2021-09-28Fix memory unsafety in unistd::getgrouplistvitalyd
Fixes #1541
2021-09-19Clippy cleanupAlan Somers
And this time, start running Clippy in CI
2021-09-12Prevent buffer over-read in getgroups()Jan Verbeek
2021-08-25Fix build for DragonFlyBSDRyan Zoeller
2021-07-29Merge #1473 #1474 #1476bors[bot]
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>
2021-07-24unistd: Add conversion from User to libc::passwdorvij
Add From<User> for libc::passwd trait implementation to convert a User into a libc::passwd Implementation consumes the User struct, giving ownership over the internal members to the libc::passwd struct Add the User::gecos field to 64-bit Android builds, since it is supported by libc::passwd for those builds
2021-07-24Mark most C-derived enums as non_exhaustiveAlan Somers
Since libc may add new variants at any time, Nix's consumers should not use exhaustive match patterns. Fixes #1182
2021-07-09Fix fork test and enable doc testJim Newsome
Replaces `println!` with raw `libc::write`. `println!` isn't guaranteed to be async-signal-safe, and almost certainly *isn't* due to internal buffering and locking. Adds a call to `libc::_exit` in the child arm, so that it doesn't fall through and start executing the parent code. Adds a call to `waitpid` in the parent arm, to clean up the child process. Removes the `no_run` directive, so that it's run in the doc tests.
2021-07-07Collapse Error into ErrnoAlan Somers
Now that Nix's weird error types are eliminated, there's no reason not to simply use Errno as the Error type.
2021-07-07Overhaul Nix's error typesAlan Somers
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
2021-06-12Hopefully fix unreliability in unistd::alarm's doc testAlan Somers
2021-05-31Add getresuid() and getresgid() to unistdJeryl Vaz
2021-05-30misc Clippy cleanupAlan Somers
* 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.
2021-05-13Use https instead of httpRyan Zoeller
2021-05-01Merge pull request #1431 from asomers/alarm_doc_test2Alan Somers
Hopefully improve unistd::alarm::set's doc test's reliability
2021-05-01Hopefully improve unistd::alarm::set's doc test's reliabilityAlan Somers
2021-04-26constify from_raw and as_raw for Uid, Gid and PidWolfgang Bumiller
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-25unistd: Increase maximum passwd/group buffer to 1MBGeoffrey Thomas
We have one UNIX group that contains most of our users whose size is about 20 kB, so `Group::from_name` is failing with ERANGE. The discussion on PR #864 suggests that 1 MB is a reasonable maximum - it follows what FreeBSD's libc does. (glibc appears to have no maximum on the _r function and will just double the buffer until malloc fails, but that's not particularly Rusty.)
2021-03-21illumos and Solaris supportJason King
Co-authored-by: Dominik Hassler <hadfl@omnios.org> Co-authored-by: Joshua M. Clulow <josh@sysmgr.org>