You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I ran into the following issue on Windows 10. Could be related to #49 but I'm not sure. With the main.rs below
fnmain(){
rpassword::read_password().unwrap();}
running echo "asd" | cargo run results in thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 6, kind: Other, message: "The handle is invalid." }'.
but I'm not sure if there are any other implications to doing so. If this sounds acceptable, I can make a PR for it. Alternatively it could check that the handle is of type FILE_TYPE_CHAR (related SO answer https://stackoverflow.com/a/3453272) but I felt like making a special case for pipe would be less likely to cause any other issues.
For additional context, I originally bumped into this issue when trying to test a CLI app that asks for a password using rpassword, which tried to run the CLI with Command::new(cli).stdin(Stdio::piped()).spawn() and write into the stdin handle. Also, I don't really know anything about the Windows API so it's possible I've misunderstood or overlooked something. Thanks for your work on rpassword!
The text was updated successfully, but these errors were encountered:
Hey @Heliozoa ! Thanks for reporting this and proposing a PR ! 🙏 👍
@equalsraf Since you wrote the GetConsoleMode part, would you by any chance be able to review @Heliozoa 's proposal ? Ideally, you'd both agree on a fix, make a PR and I'd then merge.
I agree with his proposal. Checking the handle type for FILE_TYPE_PIPE has the least potential for disruption even if later we change our minds on this. Any other option requires some research on how FILE_TYPE_CHAR or other types behave. But since this function targets stdin specifically i dont think that is required.
Hi!
I ran into the following issue on Windows 10. Could be related to #49 but I'm not sure. With the
main.rs
belowrunning
echo "asd" | cargo run
results inthread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 6, kind: Other, message: "The handle is invalid." }'
.The cause is the
GetConsoleMode
call atrpassword/src/lib.rs
Lines 184 to 188 in 096c352
A simple solution could be to wrap the console mode calls in something like
but I'm not sure if there are any other implications to doing so. If this sounds acceptable, I can make a PR for it. Alternatively it could check that the handle is of type
FILE_TYPE_CHAR
(related SO answer https://stackoverflow.com/a/3453272) but I felt like making a special case for pipe would be less likely to cause any other issues.For additional context, I originally bumped into this issue when trying to test a CLI app that asks for a password using rpassword, which tried to run the CLI with
Command::new(cli).stdin(Stdio::piped()).spawn()
and write into the stdin handle. Also, I don't really know anything about the Windows API so it's possible I've misunderstood or overlooked something. Thanks for your work on rpassword!The text was updated successfully, but these errors were encountered: