Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 Alternate data streams don't work with Command in Rust 1.58.0 #93772

Closed
roblabla opened this issue Feb 8, 2022 · 3 comments
Closed

Win32 Alternate data streams don't work with Command in Rust 1.58.0 #93772

roblabla opened this issue Feb 8, 2022 · 3 comments

Comments

@roblabla
Copy link
Contributor

roblabla commented Feb 8, 2022

Since Rust 1.58, code using Command to spawn new processes that live in an alternate data stream on Windows fails to work. Alternate Data Streams are files that have a :suffix, such as filename.exe:alt.

Code

This is the code that fails:

std::fs::File::create("test.txt").unwrap();
std::fs::copy(r"C:\Windows\System32\find.exe", "test.txt:lolexe").unwrap();

let _cmd = Command::new("test.txt:lolexe")
    .status()
    .unwrap();

I expected to see this happen: The command spawns properly and executes the find.exe code

Instead, this happened: The unwrap fails with

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: NotFound, message: "program not found" }', altdatastreamprog/src/lib.rs:514:14

Version it worked on

It most recently worked on: Rust 1.57.x

Version with regression

rust 1.58.0

I believe the commit that broke it is d9a1f9a

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

@roblabla roblabla added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Feb 8, 2022
@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Feb 8, 2022
@Urgau
Copy link
Member

Urgau commented Feb 8, 2022

I believe this is now the excepted behavior: Windows: Resolve process::Command program without using the current directory
I don't thing this has anything to do with Alternate Data Streams, but just the fact that the process is no longer resolved using the current working directory.

You could check if it works by making the executable explicitly relative by appending .\ to your executable like this .\test.txt:lolexe.

cc @ChrisDenton

@ChrisDenton
Copy link
Member

ChrisDenton commented Feb 8, 2022

Indeed. The release announcement for 1.58 gives the motivation for why the current directory is no longer used. In short, it was considered a security risk.

@roblabla
Copy link
Contributor Author

roblabla commented Feb 8, 2022

Ah, you're correct. Using .\ works. Thanks for the help!

@roblabla roblabla closed this as completed Feb 8, 2022
@apiraino apiraino removed regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. C-bug Category: This is a bug. labels Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants