diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-03-08 07:20:01 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-03-08 07:20:01 -0300 |
| commit | 2e13fd124402fdca056f36db2a7560f66552a585 (patch) | |
| tree | fa3decb84046affcb07e130890e372ea16c79e87 | |
| parent | 5b0118e589b5b1fb60fd9f3ba8c132bd483db975 (diff) | |
| parent | f42ab666e075c7668657afe4bb80d4cbc1297f93 (diff) | |
| download | mullvadvpn-2e13fd124402fdca056f36db2a7560f66552a585.tar.xz mullvadvpn-2e13fd124402fdca056f36db2a7560f66552a585.zip | |
Merge branch 'fix-openvpn-plugin-path'
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 30 |
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") |
