about summary refs log tree commit diff
path: root/library/std/src/env.rs
AgeCommit message (Collapse)AuthorLines
2022-02-11Add missing platform-specific information on current_dir and set_current_dirGuillaume Gomez-0/+10
2021-12-09Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-seMatthias Krüger-12/+9
Update std::env::temp_dir to use GetTempPath2 on Windows when available. As a security measure, Windows 11 introduces a new temporary directory API, GetTempPath2. When the calling process is running as SYSTEM, a separate temporary directory will be returned inaccessible to non-SYSTEM processes. For non-SYSTEM processes the behavior will be the same as before. This can help mitigate against attacks such as this one: https://medium.com/csis-techblog/cve-2020-1088-yet-another-arbitrary-delete-eop-a00b97d8c3e2 Compatibility risk: Software which relies on temporary files to communicate between SYSTEM and non-SYSTEM processes may be affected by this change. In many cases, such patterns may be vulnerable to the very attacks the new API was introduced to harden against. I'm unclear on the Rust project's tolerance for such change-of-behavior in the standard library. If anything, this PR is meant to raise awareness of the issue and hopefully start the conversation. How tested: Taking the example code from the documentation and running it through psexec (from SysInternals) on Win10 and Win11. On Win10: C:\test>psexec -s C:\test\main.exe <...> Temporary directory: C:\WINDOWS\TEMP\ On Win11: C:\test>psexec -s C:\test\main.exe <...> Temporary directory: C:\Windows\SystemTemp\
2021-10-30Add #[must_use] to remaining std functions (A-N)John Kugelman-0/+8
2021-10-18Update std::env::temp_dir to use GetTempPath2 on Windows when available.Eugene Talagrand-12/+9
As a security measure, Windows 11 introduces a new temporary directory API, GetTempPath2. When the calling process is running as SYSTEM, a separate temporary directory will be returned inaccessible to non-SYSTEM processes. For non-SYSTEM processes the behavior will be the same as before.
2021-09-17library/std/env: Add 'm68k' to comment on ARCH constantJohn Paul Adrian Glaubitz-0/+1
2021-08-27Document `std::env::current_exe` rename behaviourChris Denton-0/+3
It might not be obvious that the "path of the current running executable" may (or may not) mean "at the time it was loaded".
2021-08-17Fix environment variable getter docsinquisitivecrystal-5/+14
2021-08-02Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-seYuki Okushi-17/+9
Change environment variable getters to error recoverably This PR changes the standard library environment variable getter functions to error recoverably (i.e. not panic) when given an invalid value. On some platforms, it is invalid for environment variable names to contain `'\0'` or `'='`, or for their values to contain `'\0'`. Currently, the standard library panics when manipulating environment variables with names or values that violate these invariants. However, this behavior doesn't make a lot of sense, at least in the case of getters. If the environment variable is missing, the standard library just returns an error value, rather than panicking. It doesn't make sense to treat the case where the variable is invalid any differently from that. See the [internals thread](https://internals.rust-lang.org/t/why-should-std-var-panic/14847) for discussion. Thus, this PR changes the functions to error recoverably in this case as well. If desired, I could change the functions that manipulate environment variables in other ways as well. I didn't do that here because it wasn't entirely clear what to change them to. Should they error silently or do something else? If someone tells me how to change them, I'm happy to implement the changes. This fixes #86082, an ICE that arises from the current behavior. It also adds a regression test to make sure the ICE does not occur again in the future. `@rustbot` label +T-libs r? `@joshtriplett`
2021-07-29Fix may not to appropriate might not or must notAli Malik-4/+4
2021-07-23Fix parameter names in std::env documentation.Érico Nogueira Rolim-4/+3
The function parameters were renamed, but the documentation wasn't.
2021-07-05Improve env var getter docsAris Merchant-8/+5
2021-07-05Make `getenv` return an Option instead of a ResultAris Merchant-1/+1
2021-07-05Change env var getters to error recoverablyAris Merchant-15/+10
Before this, `std`'s env var getter functions would panic on receiving certain invalid inputs. This commit makes them return a `None` or `Err` instead.
2021-06-23Use HTTPS links where possibleSmitty-2/+2
2021-05-10change k to key and v to v in std::env modshirshak55-10/+10
2021-05-05Rollup merge of #84709 - joshtriplett:doc-alias-chdir, r=dtolnayRalf Jung-0/+1
Add doc alias for `chdir` to `std::env::set_current_dir` Searching for `chdir` in the Rust documentation produces no useful results. I wrote some code recently that called `libc::chdir` and manually handled errors, because I didn't realize that the safe `std::env::set_current_dir` existed. I searched for `chdir` and `change_dir` and `change_directory` (the latter two based on the precedent of unabbreviating set by `create_dir`), and I also read through `std::fs` expecting to potentially find it there. Given that none of those led to `std::env::set_current_dir`, I think that provides sufficient justification to add this specific alias.
2021-04-29Add doc alias for `chdir` to `std::env::set_current_dir`Josh Triplett-0/+1
Searching for `chdir` in the Rust documentation produces no useful results.
2021-04-29Link between std::env::{var, var_os} and std::env::{vars, vars_os}r00ster91-2/+11
2021-04-27Make sentence in env::args_os' docs plain and simpler00ster-1/+1
2021-04-25Change wordingr00ster-2/+2
2021-04-25Unify the docs of std::env::{args_os, args} morer00ster-8/+16
2021-04-22Rollup merge of #84413 - CDirkx:args_inner_debug, r=m-ou-seDylan DPC-2/+2
Remove `sys::args::Args::inner_debug` and use `Debug` instead This removes the method `sys::args::Args::inner_debug` on all platforms and implements `Debug` for `Args` instead. I believe this creates a more natural API for the different platforms under `sys`: export a type `Args: Debug + Iterator + ...` vs. `Args: Iterator + ...` and with a method `inner_debug`.
2021-04-22Remove `sys::args::Args::inner_debug` and use `Debug` insteadChristiaan Dirkx-2/+2
2021-04-21Replace all `fmt.pad` with `debug_struct`Christiaan Dirkx-3/+3
2021-01-20Document security implications of std::env::temp_dirJosh Triplett-6/+9
Update the sample code to not create an insecure temporary file.
2020-09-04Improve docs for `std::env::args()`Camelid-6/+6
2020-08-31Rollup merge of #75945 - pickfire:patch-7, r=jyn514Tyler Mandry-26/+25
Use `env::func()`, not 'the function env::func' in docs for std::env Follow up of https://github.com/rust-lang/rust/pull/75629 r? @jyn514
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-109/+3
Also doing fmt inplace as requested.
2020-08-30Fix env doc vars_os broken linkIvan Tham-1/+1
2020-08-30Env use shorter intra-doc links in pathIvan Tham-26/+25
vars() rather than vars function Co-authored-by: Joshua Nelson <joshua@yottadb.com> Use [xxx()] rather than the [xxx] function Co-authored-by: Joshua Nelson <joshua@yottadb.com> Env text representation of function intra-doc link Suggested by @jyn514 Link join_paths in env doc for parity Change xxx to env::xxx for lib env doc Add link requsted by @jyn514 Fix doc build with same link Co-authored-by: Joshua Nelson <joshua@yottadb.com> Fix missing intra-doc link Fix added whitespace in doc Co-authored-by: Joshua Nelson <joshua@yottadb.com> Add brackets for `join_paths` Co-authored-by: Joshua Nelson <joshua@yottadb.com> Use unused link join_paths Removed same link for join_paths Co-authored-by: Joshua Nelson <joshua@yottadb.com> Remove unsed link join_paths
2020-08-17Remove unnecessary links in env.rsEllen-8/+0
2020-08-17Switch to intra-doc links for std/src/env.rsEllen-27/+14
2020-07-27mv std libs to library/mark-0/+1076