summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-02-21 17:25:22 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-02-21 17:29:38 +0100
commitd70e9361619cdeccb728eec8f9470498f8ebb84a (patch)
treecdaaef331b3db51800658571cc3b8409f438ac5f /net
parent795e1ee2a97b64029fa10e666211928e6adc8ca0 (diff)
net: New connect function overriding the IPC policy.
- Provide a function Descriptor::connect_with_policy that allows one to override the configured IPC policy. - Can be used to enforce the handling of secret key material in an external server.
Diffstat (limited to 'net')
-rw-r--r--net/src/ipc.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/net/src/ipc.rs b/net/src/ipc.rs
index 56363ddc..ba962b70 100644
--- a/net/src/ipc.rs
+++ b/net/src/ipc.rs
@@ -110,8 +110,19 @@ impl Descriptor {
&self.ctx
}
- /// Connect to a descriptor, starting the server if necessary.
- pub fn connect(&self, handle: &tokio_core::reactor::Handle) -> io::Result<RpcSystem<Side>> {
+ /// Connects to a descriptor, starting the server if necessary.
+ pub fn connect(&self, handle: &tokio_core::reactor::Handle)
+ -> io::Result<RpcSystem<Side>> {
+ self.connect_with_policy(handle, *self.ctx.ipc_policy())
+ }
+
+ /// Connects to a descriptor, starting the server if necessary.
+ ///
+ /// This function does not use the contexts IPC policy, but uses
+ /// the given one.
+ pub fn connect_with_policy(&self, handle: &tokio_core::reactor::Handle,
+ policy: core::IPCPolicy)
+ -> io::Result<RpcSystem<Side>> {
let do_connect =
move |cookie: Cookie, mut s: TcpStream| -> io::Result<RpcSystem<Side>> {
cookie.send(&mut s)?;
@@ -163,7 +174,7 @@ impl Descriptor {
let cookie = Cookie::new()?;
for external in [true, false].iter() {
// Implement the IPC pocicy.
- if *self.ctx.ipc_policy() == core::IPCPolicy::Internal && *external {
+ if policy == core::IPCPolicy::Internal && *external {
// Do not try to fork.
continue;
}
@@ -171,7 +182,7 @@ impl Descriptor {
let addr = match self.start(*external) {
Ok(a) => a,
Err(e) => if *external {
- if *self.ctx.ipc_policy() == core::IPCPolicy::External {
+ if policy == core::IPCPolicy::External {
// Fail!
return Err(e);
}