Skip to content

Commit

Permalink
Merge #227
Browse files Browse the repository at this point in the history
227: UsercallExtension::bind_stream() should return a Future r=parthsane a=mzohreva



Co-authored-by: Mohsen Zohrevandi <mohsen.zohrevandi@fortanix.com>
  • Loading branch information
bors[bot] and mzohreva committed Apr 9, 2020
2 parents 6dfd886 + 1bc06ae commit e763ba6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion enclave-runner/src/usercalls/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use fortanix_sgx_abi::*;

use super::abi::{UsercallResult, Usercalls};
use super::{EnclaveAbort, IOHandlerInput};
use crate::futures::FutureExt;
use futures::FutureExt;
use futures::future::Future;

pub(super) struct Handler<'ioinput, 'tcs>(pub &'ioinput mut IOHandlerInput<'tcs>);
Expand Down
17 changes: 9 additions & 8 deletions enclave-runner/src/usercalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ async fn trap_attached_debugger(tcs: usize) {
/// Provides a mechanism for the enclave code to interface with an external service via a modified runner.
///
/// An implementation of `UsercallExtension` can be registered while [building](../struct.EnclaveBuilder.html#method.usercall_extension) the enclave.

pub trait UsercallExtension: 'static + Send + Sync + std::fmt::Debug {
/// Override the connection target for connect calls by the enclave. The runner should determine the service that the enclave is trying to connect to by looking at addr.
/// If `connect_stream` returns None, the default implementation of [`connect_stream`](../../fortanix_sgx_abi/struct.Usercalls.html#method.connect_stream) is used.
Expand Down Expand Up @@ -1073,12 +1072,14 @@ pub trait UsercallExtension: 'static + Send + Sync + std::fmt::Debug {
///
/// The enclave must not make any security decisions based on the local address received.
#[allow(unused)]
fn bind_stream(
&self,
addr: &str,
local_addr: Option<&mut String>,
) -> IoResult<Option<Box<dyn AsyncListener>>> {
Ok(None)
fn bind_stream<'future>(
&'future self,
addr: &'future str,
local_addr: Option<&'future mut String>,
) -> std::pin::Pin<Box<dyn Future<Output = IoResult<Option<Box<dyn AsyncListener>>>> + 'future>> {
async {
Ok(None)
}.boxed_local()
}
}

Expand Down Expand Up @@ -1159,7 +1160,7 @@ impl<'tcs> IOHandlerInput<'tcs> {
if let Some(stream_ext) = self
.enclave
.usercall_ext
.bind_stream(addr, local_addr_str.as_mut())?
.bind_stream(addr, local_addr_str.as_mut()).await?
{
if let Some(local_addr) = local_addr {
local_addr.set(local_addr_str.unwrap().into_bytes());
Expand Down

0 comments on commit e763ba6

Please sign in to comment.