mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-28 15:34:22 +00:00
signing: insert tracing events to command invocation paths
This might help debug command failure.
This commit is contained in:
parent
fa7864edeb
commit
c8023dbd8b
2 changed files with 8 additions and 0 deletions
|
@ -67,9 +67,11 @@ fn parse_gpg_verify_output(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_sign_command(command: &mut Command, input: &[u8]) -> Result<Vec<u8>, GpgError> {
|
fn run_sign_command(command: &mut Command, input: &[u8]) -> Result<Vec<u8>, GpgError> {
|
||||||
|
tracing::info!(?command, "running GPG signing command");
|
||||||
let process = command.stderr(Stdio::piped()).spawn()?;
|
let process = command.stderr(Stdio::piped()).spawn()?;
|
||||||
let write_result = process.stdin.as_ref().unwrap().write_all(input);
|
let write_result = process.stdin.as_ref().unwrap().write_all(input);
|
||||||
let output = process.wait_with_output()?;
|
let output = process.wait_with_output()?;
|
||||||
|
tracing::info!(?command, ?output.status, "GPG signing command exited");
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
write_result?;
|
write_result?;
|
||||||
Ok(output.stdout)
|
Ok(output.stdout)
|
||||||
|
@ -82,9 +84,11 @@ fn run_sign_command(command: &mut Command, input: &[u8]) -> Result<Vec<u8>, GpgE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_verify_command(command: &mut Command, input: &[u8]) -> Result<Vec<u8>, GpgError> {
|
fn run_verify_command(command: &mut Command, input: &[u8]) -> Result<Vec<u8>, GpgError> {
|
||||||
|
tracing::info!(?command, "running GPG signing command");
|
||||||
let process = command.stderr(Stdio::null()).spawn()?;
|
let process = command.stderr(Stdio::null()).spawn()?;
|
||||||
let write_result = process.stdin.as_ref().unwrap().write_all(input);
|
let write_result = process.stdin.as_ref().unwrap().write_all(input);
|
||||||
let output = process.wait_with_output()?;
|
let output = process.wait_with_output()?;
|
||||||
|
tracing::info!(?command, ?output.status, "GPG signing command exited");
|
||||||
match write_result {
|
match write_result {
|
||||||
Ok(()) => Ok(output.stdout),
|
Ok(()) => Ok(output.stdout),
|
||||||
// If the signature format is invalid, gpg will terminate early. Writing
|
// If the signature format is invalid, gpg will terminate early. Writing
|
||||||
|
|
|
@ -59,9 +59,11 @@ fn parse_utf8_string(data: Vec<u8>) -> SshResult<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_command(command: &mut Command, stdin: &[u8]) -> SshResult<Vec<u8>> {
|
fn run_command(command: &mut Command, stdin: &[u8]) -> SshResult<Vec<u8>> {
|
||||||
|
tracing::info!(?command, "running SSH signing command");
|
||||||
let process = command.spawn()?;
|
let process = command.spawn()?;
|
||||||
let write_result = process.stdin.as_ref().unwrap().write_all(stdin);
|
let write_result = process.stdin.as_ref().unwrap().write_all(stdin);
|
||||||
let output = process.wait_with_output()?;
|
let output = process.wait_with_output()?;
|
||||||
|
tracing::info!(?command, ?output.status, "SSH signing command exited");
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
write_result?;
|
write_result?;
|
||||||
Ok(output.stdout)
|
Ok(output.stdout)
|
||||||
|
@ -150,8 +152,10 @@ impl SshBackend {
|
||||||
// will return a non-0 exit code if no principals are found.
|
// will return a non-0 exit code if no principals are found.
|
||||||
//
|
//
|
||||||
// In this case we don't want to error out, just return None.
|
// In this case we don't want to error out, just return None.
|
||||||
|
tracing::info!(?command, "running SSH signing command");
|
||||||
let process = command.spawn()?;
|
let process = command.spawn()?;
|
||||||
let output = process.wait_with_output()?;
|
let output = process.wait_with_output()?;
|
||||||
|
tracing::info!(?command, ?output.status, "SSH signing command exited");
|
||||||
|
|
||||||
let principal = parse_utf8_string(output.stdout)?
|
let principal = parse_utf8_string(output.stdout)?
|
||||||
.split('\n')
|
.split('\n')
|
||||||
|
|
Loading…
Reference in a new issue