From 8c9a0b5548dfb7235f4b8bd97af9cb993c1dbb90 Mon Sep 17 00:00:00 2001 From: Nick Santana Date: Mon, 17 Oct 2022 14:06:05 -0700 Subject: [PATCH] Use separate types per path entry. Previously `mc-sgx-ql::PathInitializer::with_paths()` used the same generic type for all the pathlike parameters. This had the side effect that all four paths had to be the same type. Now each pathlike parameter has it's own type. --- dcap/ql/src/quote_enclave.rs | 38 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/dcap/ql/src/quote_enclave.rs b/dcap/ql/src/quote_enclave.rs index 21cdb0b7..e2fd4bec 100644 --- a/dcap/ql/src/quote_enclave.rs +++ b/dcap/ql/src/quote_enclave.rs @@ -48,7 +48,7 @@ impl PathInitializer { Self::with_paths( "/usr/lib/x86_64-linux-gnu/libsgx_qe3.signed.so.1", "/usr/lib/x86_64-linux-gnu/libsgx_pce.signed.so.1", - None, + None::<&Path>, "/usr/lib/x86_64-linux-gnu/libsgx_id_enclave.signed.so.1", ) } @@ -73,12 +73,18 @@ impl PathInitializer { /// * one of the paths does not point to a file /// * one of the paths is longer than 259 (bytes) /// * one of the paths contains a null (0) byte. - pub fn with_paths>( - quoting_enclave: P, - provisioning_certificate_enclave: P, - quote_provider_library: Option

, - id_enclave: P, - ) -> Result<()> { + pub fn with_paths( + quoting_enclave: P1, + provisioning_certificate_enclave: P2, + quote_provider_library: Option, + id_enclave: P4, + ) -> Result<()> + where + P1: AsRef, + P2: AsRef, + P3: AsRef, + P4: AsRef, + { let mut value = PATH_INITIALIZER.lock().expect("Mutex has been poisoned"); if value.is_none() { Self::set_paths( @@ -110,12 +116,18 @@ impl PathInitializer { } } - fn set_paths>( - quoting_enclave: P, - provisioning_certificate_enclave: P, - quote_provider_library: Option

, - id_enclave: P, - ) -> Result { + fn set_paths( + quoting_enclave: P1, + provisioning_certificate_enclave: P2, + quote_provider_library: Option, + id_enclave: P4, + ) -> Result + where + P1: AsRef, + P2: AsRef, + P3: AsRef, + P4: AsRef, + { Self::set_path(PathKind::QuotingEnclave, quoting_enclave)?; Self::set_path( PathKind::ProvisioningCertificateEnclave,