summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--talpid-core/src/tunnel/mod.rs30
2 files changed, 24 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b87fef1b65..ec662526c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
position.
- Redact all 16 digit numbers from problem report logs. Extra safety against accidentally sending
account numbers.
+- Fix OpenVPN plugin search directory to be the installation directory.
## [2018.1] - 2018-03-01
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index 747115564e..086275f981 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -5,6 +5,7 @@ use openvpn_plugin::types::OpenVpnPluginEvent;
use process::openvpn::OpenVpnCommand;
use std::collections::HashMap;
+use std::env;
use std::ffi::{OsStr, OsString};
use std::fs;
use std::io::{self, Write};
@@ -145,11 +146,8 @@ impl TunnelMonitor {
}
};
- let monitor = openvpn::OpenVpnMonitor::new(
- cmd,
- on_openvpn_event,
- Self::get_plugin_path(resource_dir)?,
- ).chain_err(|| ErrorKind::TunnelMonitoringError)?;
+ let monitor = openvpn::OpenVpnMonitor::new(cmd, on_openvpn_event, Self::get_plugin_path()?)
+ .chain_err(|| ErrorKind::TunnelMonitoringError)?;
Ok(TunnelMonitor {
monitor,
_user_pass_file: user_pass_file,
@@ -191,9 +189,11 @@ impl TunnelMonitor {
}
}
- fn get_plugin_path(resource_dir: &Path) -> Result<PathBuf> {
+ fn get_plugin_path() -> Result<PathBuf> {
let library = Self::get_library_name().chain_err(|| ErrorKind::PluginNotFound)?;
- let path = resource_dir.join(library);
+ let mut path = Self::get_executable_dir();
+
+ path.push(library);
if path.exists() {
debug!("Using OpenVPN plugin at {}", path.to_string_lossy());
@@ -203,6 +203,22 @@ impl TunnelMonitor {
}
}
+ fn get_executable_dir() -> PathBuf {
+ match env::current_exe() {
+ Ok(mut path) => {
+ path.pop();
+ path
+ }
+ Err(e) => {
+ error!(
+ "Failed finding the install directory. Using working directory: {}",
+ e
+ );
+ PathBuf::from(".")
+ }
+ }
+ }
+
fn get_library_name() -> Result<&'static str> {
if cfg!(target_os = "macos") {
Ok("libtalpid_openvpn_plugin.dylib")