rust/library/std/src
Matthias Krüger 856eefece9
Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se
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-12-09 05:08:31 +01:00
..
backtrace Add Frames iterator for Backtrace 2021-01-23 11:56:33 -06:00
collections Use IntoIterator for array impl everywhere. 2021-12-04 19:40:33 +01:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 Implement IEEE 754-2019 minimun and maximum functions for f32/f64 2021-11-20 10:14:03 +01:00
f64 Remove fNN::lerp - consensus unlikely 2021-10-25 22:44:41 -05:00
ffi Emphasise that an OsStr[ing] is not necessarily a platform string 2021-12-02 21:02:56 +00:00
fs Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se 2021-11-19 13:06:35 +09:00
io Document how last_os_error should be used 2021-12-02 17:53:57 +00:00
lazy Upgrade wasm32 image to Ubuntu 20.04 2021-02-06 13:05:56 +01:00
net use matches!() macro in more places 2021-11-06 16:13:14 +01:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Auto merge of #91284 - t6:freebsd-riscv64, r=Amanieu 2021-12-06 03:51:05 +00:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path add benchmarks and tests for Hash and Eq impls on Path 2021-11-09 20:54:00 +01:00
prelude Implement concat_bytes! 2021-12-06 21:05:13 -05:00
process fix test in std::process on android 2021-11-23 13:57:22 +08:00
sync Add #[must_use] to remaining std functions (O-Z) 2021-10-30 23:37:32 -04:00
sys Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se 2021-12-09 05:08:31 +01:00
sys_common libcore: assume the input of next_code_point and next_code_point_reverse is UTF-8-like 2021-11-21 17:05:55 +01:00
thread Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se 2021-12-05 00:38:00 +01:00
time Add #[must_use] to remaining std functions (O-Z) 2021-10-30 23:37:32 -04:00
alloc.rs Rename rterr to rtprintpanic 2021-05-19 15:52:09 +02:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs Add #[must_use] to remaining std functions (A-N) 2021-10-30 23:44:02 -04:00
env.rs Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se 2021-12-09 05:08:31 +01:00
error.rs Stabilize try_reserve 2021-10-04 10:29:46 +01:00
f32.rs Remove fNN::lerp - consensus unlikely 2021-10-25 22:44:41 -05:00
f64.rs Remove fNN::lerp - consensus unlikely 2021-10-25 22:44:41 -05:00
fs.rs Stabilize File::options() 2021-11-09 10:22:28 -08:00
keyword_docs.rs Simplify for loop desugar 2021-11-21 08:15:21 -06:00
lazy.rs Add #[must_use] to core and std constructors 2021-10-10 02:44:26 -04:00
lib.rs Implement concat_bytes! 2021-12-06 21:05:13 -05:00
macros.rs bump bootstrap compiler to 1.55 2021-08-01 11:19:24 -04:00
num.rs Add Saturating type (based on Wrapping type) 2021-08-10 19:27:01 +02:00
panic.rs Deduplicate panic_fmt 2021-10-19 15:02:21 +01:00
panicking.rs Add #[must_use] to remaining std functions (O-Z) 2021-10-30 23:37:32 -04:00
path.rs Document file path case sensitivity 2021-12-02 19:48:10 +00:00
primitive_docs.rs Update docs. 2021-12-04 19:40:33 +01:00
process.rs Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc 2021-11-16 09:14:15 +09:00
rt.rs Rollup merge of #89068 - bjorn3:restructure_rt2, r=joshtriplett 2021-10-31 13:20:04 +01:00
time.rs Add #[must_use] to remaining std functions (O-Z) 2021-10-30 23:37:32 -04:00