fix(tee-key-preexec): add context to file write operations

- Add context to `std::fs::write` calls to improve error tracing.
- Ensures better debugging by attaching filenames to potential errors.

Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
Harald Hoyer 2025-03-19 10:37:37 +01:00
parent 9114c47b90
commit e27b5da856
Signed by: harald
GPG key ID: F519A1143B3FBE32

View file

@ -58,17 +58,17 @@ fn main_with_error() -> Result<()> {
.extend()?;
// save quote to file
std::fs::write(TEE_QUOTE_FILE, quote)?;
std::fs::write(TEE_QUOTE_FILE, quote).context(TEE_QUOTE_FILE)?;
teepot::quote::TEEType::TDX.to_string()
}
Ok((tee_type, quote)) => {
// save quote to file
std::fs::write(TEE_QUOTE_FILE, quote)?;
std::fs::write(TEE_QUOTE_FILE, quote).context(TEE_QUOTE_FILE)?;
tee_type.to_string()
}
Err(e) => {
error!("Failed to get quote: {}", e);
std::fs::write(TEE_QUOTE_FILE, [])?;
std::fs::write(TEE_QUOTE_FILE, []).context(TEE_QUOTE_FILE)?;
"none".to_string()
}
};