summaryrefslogtreecommitdiff
path: root/src/unistd.rs
AgeCommit message (Collapse)Author
2020-04-06unistd: avoid infinite loop caused by reserve_double_buffer_sizeSteven Danna
Functions such as Group::from_anything use reserve_double_buffer_size in a loop, expecting it to return ERANGE if the passed limit is reached. However, the returned vector is passed as pointer to a libc function that writes data into memory and doesn't update the length of the Vec. Because of this, the previous code would never return ERANGE and the calling loops would never exit if they hit a case where the required buffer was larger than the maximum buffer. This fixes the problem by checking the capacity rather than the length. Signed-off-by: Steven Danna <steve@chef.io>
2020-03-03Derive `Ord`, `PartialOrd` for `Pid`Joe Ranweiler
2020-02-29add setfsuid and setfsgid implementation for filesystem checksMarco Conte
2020-01-12Add CLK_TCK to SysconfVarCaleb Bassi
http://man7.org/linux/man-pages/man3/sysconf.3.html says that the corresponding variable is obsolete, but I think that just means the constant defined in limits.h is obsolete. Checking the value using sysconf is still valid.
2019-11-03Implment linkatJohnnie Birch
This adds the linkat function which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/linkat.html and widely implmented on Unix-Family platforms. Add back trailing whitespace removed on previous force push
2019-10-30Add `Users` and `Group` related functionsOtavio Salvador
This was a collaborative work between Johannes Schilling <dario@deaktualisierung.org>, Fredrick Brennan <copypaste@kittens.ph> and myself. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2019-10-21fix documentation typo for effective gidScott Schroeder
2019-09-30refactored test casesZhang Miaolei
ignore mkfifoat in OSX and andriod
2019-09-30add mkfifoatZhang Miaolei
2019-09-28Merge #1121 #1130bors[bot]
1121: Fix #1093 r=asomers a=tathanhdinh Hello, This PR fixes the problem discovered in #1093. Thanks for any comment. 1130: unistd: getgrouplist: Rework code to use `reserve_double_buffer_size` r=asomers a=otavio The buffer resize logic can be simplified reusing the `reserve_double_buffer_size` method. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Co-authored-by: Ta Thanh Dinh <tathanhdinh@gmail.com> Co-authored-by: Otavio Salvador <otavio@ossystems.com.br>
2019-09-25unistd: getgrouplist: Rework code to use `reserve_double_buffer_size`Otavio Salvador
The buffer resize logic can be simplified reusing the `reserve_double_buffer_size` method. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2019-09-25unistd: getgroups: Resize buffer up to NGROUPS_MAXOtavio Salvador
Use `reserve_double_buffer_size` up to NGROUPS_MAX as limit. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2019-09-25unistd: getgroups: Rework variable namesOtavio Salvador
We are preparing the use of `reserve_double_buffer_size` but for this, some logic need to be reworked so we are doing some rename preparing for the next patch which adds its use. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2019-09-23fix #1093Ta Thanh Dinh
2019-09-21unistd: getcwd: Double the buffer when need, up to PATH_MAX as limitOtavio Salvador
We now have a `reserve_double_buffer_size` method which reserves the double of buffer, up to a limit, allowing it to be reused on other methods in future. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2019-09-03Replace most instances of mem::uninitialized with mem::MaybeUninitAlan Somers
Only two instances remain: * For the deprecated sys::socket::CmsgSpace::new. We should probably just remove that method. * For sys::termios::Termios::default_uninit. This will require some more thought. Fixes #1096
2019-08-29Clippy cleanupAlan Somers
2019-07-14Implement unlinkatJohnnie Birch
This adds the unlinkat function, which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html and widely implmented on Unix-family platforms. Implement unlinkat - Update comments to unlink at and breakup tests Changes made based on comments from pull request #1058 Implement unlinkat - Update should_panic for more precise check Updae should_panic attribute for more precise check. Also remove some dead code and note the pull request ID. Implement unlinkat - Update error handling to use unwrap_err The previous patch failed testing on two targets that returned EPERM as the Sys error instead of EISDIR. This patch changes from using the should_panic attribute to using the unwrap_err and matching against the result. Implement Unlinkat - Passing tests should not print anything. Fix. Implement unlinkat - Update location of commit comment in the CHANGELOG Implement unlinkat - Remove newline
2019-04-21Remove duplicate use statements on macOS.Tom Pusateri
2019-04-20Add a access(2) wrapperjr
2019-04-11Add unistd::{seteuid,setegid}Julio Merino
This is for the benefit of those platforms that do not provide setresuid nor setresgid, like macOS.
2019-03-03Fix the build on OSX with libc 0.2.49Alan Somers
Several symbols are now marked as deprecated on OSX. Fix the build by marking these symbols' Nix wrappers as deprecated, too.
2019-01-15Fix build and tests issues on OpenBSD 6.4+Andrei-Marius Radu
1) lutimes doesn't exist on OpenBSD so it needs to be under conditional compilation. The only "reference" that I could find related to this is the discussion here: https://github.com/rust-lang/libc/pull/790 . 2) fexecve doesn't exist on OpenBSD so add conditional compilation for it in unistd and in related tests. The only "reference" that I could find is a mention that fexecve is not implemented on OpenBSD in the manual pages for signal(3) and sigaction(2): Official repository (search for "fexecve"): https://cvsweb.openbsd.org/src/lib/libc/sys/sigaction.2?rev=1.75&content-type=text/x-cvsweb-markup Github mirror: https://github.com/openbsd/src/blob/master/lib/libc/sys/sigaction.2#L619 3) AIO doesn't work on OpenBSD so put test_aio_drop under conditional compilation. 4) Add relevant changelog entries. P.S. On OpenBSD remains the issue of test_scm_rights which builds correctly but fails at runtime.
2018-12-12Implement symlinkatoblique
2018-12-08Replace try! with ?Alan Somers
try! is not available in Rust 2018
2018-11-28Prefer `map(drop)` to `map(|_| ())`Alan Somers
I previously advocated for the latter syntax on stylistic grounds. But it generates less efficient code, because it creates a new lambda function for each usage. The optimizer does not combine them. This change saves about 6KB of code.
2018-11-19Add execvpe support, conditional on platformF1rst-Unicorn
2018-11-02Add sync (fix #959)Roey Darwish Dror
2018-10-21Add acct(2) wrapper APIJosh Abraham
This patch adds a wrapper for the acct(2) syscall, with two functions for enabling and disabling process accounting.
2018-10-19Add a fchownat(2) wrapperJulio Merino
2018-10-17Add a truncate(2) wrapperJulio Merino
This also adds a test for truncate (obviously) but, while doing so, also adds a test for the already-existing ftruncate.
2018-10-09Fix #945 - documentation fixJosh Abraham
Correct references to user ids to group ids.
2018-09-01deps: update tempfile to 3Igor Gnatenko
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2018-07-27Fix *decoding* of cmsgs and add `ScmCredentials`.Jonas Schievink
2018-02-06Merge #851bors[bot]
851: Added `getsid` in `::nix::unistd` r=asomers a=ggriffiniii Resolves Issue #850
2018-02-03Merge #830bors[bot]
830: Add alarm r=asomers a=Thomasdezeeuw Fixed #828.
2018-02-02Add alarm moduleThomas de Zeeuw
This module has two functions; set: set an alarm, and cancel: cancels a previously set alarm.
2018-01-29Added `getsid` in `::nix::unistd`Glenn Griffin
2018-01-28Require Debug impls for all typesBryant Mairs
2018-01-28Implement Copy/Clone for all types missing itBryant Mairs
2018-01-28Disallow unnecessary import bracesBryant Mairs
2018-01-28Deny unused qualificationsBryant Mairs
2018-01-11Remove return value from `pause`Thomas de Zeeuw
`pause` will always return `-1` as a result and sets `errno` to `EINTR`, which indicates that a signal was caught by the process. Since this is the point of `pause` return an error here makes little sense. Closes #827.
2017-12-20Use backticks around types/functions in docsBryant Mairs
2017-12-20Remove unnecessary lifetime annotationsBryant Mairs
2017-12-19Merge #799bors[bot]
799: Fix nix on Dragonfly r=Susurrus a=mneumann This commit replaces pull request https://github.com/nix-rust/nix/pull/684. It fixes building `nix` on DragonFly. All tests pass. This requires most recent libc to build: https://github.com/rust-lang/libc/pull/851.
2017-12-19Fix support for DragonFlyMichael Neumann
* DragonFly does not have a O_DSYNC flag * Fix type_of_cmsg_data on DragonFly * No fexecve() on DragonFly * Do not run aio test cases on DragonFly * Keep target lists in alphabetical order * Unscrable #[cfg] directives and use cfg_if! macro instead * Fix errno on DragonFly Below follows an explanation why we have to use a C extension to get errno working on DragonFly: DragonFly uses a thread-local errno variable, but #[thread_local] is feature-gated and not available in stable Rust as of this writing (Rust 1.21.0). We have to use a C extension (src/errno_dragonfly.c) to access it. Tracking issue for `thread_local` stabilization: https://github.com/rust-lang/rust/issues/29594 Once this becomes stable, we can remove build.rs, src/errno_dragonfly.c, remove the build-dependency from Cargo.toml, and use: extern { #[thread_local] static errno: c_int; } Now all targets will use the build.rs script, but only on DragonFly this will do something. Also, there are no additional dependencies for targets other than DragonFly (no gcc dep).
2017-12-11Merge #806bors[bot]
806: Cleanup all doc warnings r=asomers a=Susurrus With the impending switch to Pulldown as the default doc generator, warnings have been enabled for incompatible syntax. This fixes all of said warnings.
2017-12-10Cleanup doc warningsBryant Mairs
With the impending switch to Pulldown as the default doc generator, warnings have been enabled for incompatible syntax. This fixes all of said warnings.
2017-12-10Fix doctest that weren't run with the old doctest parserBryant Mairs
The switch to Pulldown for the Markdown parser for Rustdoc has revealed that there were a large number of doctests that weren't being run. These tests failed to compile before, but will also fail to run because they attach to arbitrary user and group IDs, which likely don't exist on the system. These are therefore marked as `no_run`.