Skip to content

Commit

Permalink
feat: display keyring stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
samypr100 committed Jun 16, 2024
1 parent 5752817 commit 9dd5e24
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/uv-auth/src/keyring.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::process::Stdio;
use tokio::process::Command;
use tracing::{instrument, trace, warn};
use url::Url;
Expand Down Expand Up @@ -83,15 +84,24 @@ impl KeyringProvider {

#[instrument(skip(self))]
async fn fetch_subprocess(&self, service_name: &str, username: &str) -> Option<String> {
let output = Command::new("keyring")
// https://github.com/pypa/pip/blob/24.0/src/pip/_internal/network/auth.py#L136-L141
let child = Command::new("keyring")
.arg("get")
.arg(service_name)
.arg(username)
.output()
.await
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::inherit())
.spawn()
.inspect_err(|err| warn!("Failure running `keyring` command: {err}"))
.ok()?;

let output = child
.wait_with_output()
.await
.inspect_err(|err| warn!("Failed to wait for `keyring` output: {err}"))
.ok()?;

if output.status.success() {
// On success, parse the newline terminated password
String::from_utf8(output.stdout)
Expand Down

0 comments on commit 9dd5e24

Please sign in to comment.