summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-07-17 16:18:32 +0200
committerErik Larkö <erik@mullvad.net>2017-07-20 11:50:06 +0200
commit1015d9f42e2a5e690141c27fc3ea30c72b8bbbfb (patch)
tree3a81e78ffdc1b28c51a5c1e4ffd05e9dbbb70627
parente0b25ea79254932aa1bdfb58544ec3ecf5eaa083 (diff)
downloadmullvadvpn-1015d9f42e2a5e690141c27fc3ea30c72b8bbbfb.tar.xz
mullvadvpn-1015d9f42e2a5e690141c27fc3ea30c72b8bbbfb.zip
Search for bundled OpenVPN binaries close to the executable
-rw-r--r--talpid-core/src/tunnel/mod.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index 3835e26632..407c774d35 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -2,6 +2,7 @@ use mktemp;
use net;
use openvpn_plugin::types::OpenVpnPluginEvent;
use process::openvpn::OpenVpnCommand;
+use std::ffi::{OsStr, OsString};
use std::fs;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
@@ -84,7 +85,9 @@ impl TunnelMonitor {
}
fn create_openvpn_cmd(remote: net::Endpoint, user_pass_file: &Path) -> OpenVpnCommand {
- let mut cmd = OpenVpnCommand::new("openvpn");
+ let openvpn_binary = Self::find_path_to_openvpn_binary();
+
+ let mut cmd = OpenVpnCommand::new(openvpn_binary);
if let Some(config) = get_config_path() {
cmd.config(config);
}
@@ -92,6 +95,25 @@ impl TunnelMonitor {
cmd
}
+ fn find_path_to_openvpn_binary() -> OsString {
+ match ::std::env::current_exe() {
+ Ok(mut path) => {
+ path.pop();
+
+ path.push("openvpn-binaries");
+
+ let openvpn_binary = path.join("openvpn");
+ if openvpn_binary.exists() {
+ return openvpn_binary.into_os_string();
+ }
+ }
+ Err(e) => warn!("Failed finding the directory of the executable, {}", e),
+ }
+
+ debug!("Did not find a bundled version of OpenVPN, will rely on the PATH instead");
+ OsStr::new("openvpn").to_os_string()
+ }
+
fn create_user_pass_file(account_token: &str) -> io::Result<mktemp::Temp> {
let path = mktemp::Temp::new_file()?;
debug!(