From 264e6a4a4751058319e9c9e27492a48b6265b0f4 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Thu, 13 Jun 2024 12:51:08 +0200 Subject: [PATCH] fixup! Specify full rpc socket file path to daemon --- mullvad-jni/src/lib.rs | 21 ++++++++++----------- mullvad-paths/src/lib.rs | 3 ++- mullvad-paths/src/rpc_socket.rs | 6 ------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index 2af8d824f666..67e40ea5340e 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -65,13 +65,13 @@ pub extern "system" fn Java_net_mullvad_mullvadvpn_service_MullvadDaemon_initial env: JNIEnv<'_>, this: JObject<'_>, vpnService: JObject<'_>, - dataDirectory: JObject<'_>, + rpcSocketPath: JObject<'_>, filesDirectory: JObject<'_>, cacheDirectory: JObject<'_>, apiEndpoint: JObject<'_>, ) { let env = JnixEnv::from(env); - let data_dir = PathBuf::from(String::from_java(&env, dataDirectory)); + let rpc_socket = PathBuf::from(String::from_java(&env, rpcSocketPath)); let files_dir = PathBuf::from(String::from_java(&env, filesDirectory)); let cache_dir = PathBuf::from(String::from_java(&env, cacheDirectory)); @@ -99,7 +99,7 @@ pub extern "system" fn Java_net_mullvad_mullvadvpn_service_MullvadDaemon_initial &env, &this, &vpnService, - data_dir, + rpc_socket, files_dir, cache_dir, api_endpoint, @@ -227,7 +227,7 @@ fn initialize( env: &JnixEnv<'_>, this: &JObject<'_>, vpn_service: &JObject<'_>, - data_dir: PathBuf, + rpc_socket: PathBuf, files_dir: PathBuf, cache_dir: PathBuf, api_endpoint: Option, @@ -239,7 +239,7 @@ fn initialize( spawn_daemon( env, this, - data_dir, + rpc_socket, files_dir, cache_dir, api_endpoint, @@ -268,7 +268,7 @@ fn create_android_context( fn spawn_daemon( env: &JnixEnv<'_>, this: &JObject<'_>, - data_dir: PathBuf, + rpc_socket: PathBuf, files_dir: PathBuf, cache_dir: PathBuf, #[cfg_attr(not(feature = "api-override"), allow(unused_variables))] api_endpoint: Option< @@ -305,12 +305,11 @@ fn spawn_daemon( } } - let rpc_socket_path = mullvad_paths::get_rpc_socket_path(data_dir); - runtime.block_on(cleanup_old_rpc_socket(&rpc_socket_path)); + runtime.block_on(cleanup_old_rpc_socket(&rpc_socket)); - let event_listener = match runtime.block_on(async { - spawn_management_interface(command_channel.sender(), &rpc_socket_path) - }) { + let event_listener = match runtime + .block_on(async { spawn_management_interface(command_channel.sender(), &rpc_socket) }) + { Ok(event_listener) => event_listener, Err(error) => { let _ = tx.send(Err(error)); diff --git a/mullvad-paths/src/lib.rs b/mullvad-paths/src/lib.rs index afffee3037b0..6b3faa98840b 100644 --- a/mullvad-paths/src/lib.rs +++ b/mullvad-paths/src/lib.rs @@ -87,8 +87,9 @@ pub mod resources; #[cfg(not(target_os = "android"))] pub use crate::resources::{get_default_resource_dir, get_resource_dir}; +#[cfg(not(target_os = "android"))] mod rpc_socket; -#[cfg(target_os = "android")] +#[cfg(not(target_os = "android"))] pub use crate::rpc_socket::get_rpc_socket_path; #[cfg(not(target_os = "android"))] pub use crate::rpc_socket::{get_default_rpc_socket_path, get_rpc_socket_path}; diff --git a/mullvad-paths/src/rpc_socket.rs b/mullvad-paths/src/rpc_socket.rs index 9152b7ca7ffe..9e228cdf1546 100644 --- a/mullvad-paths/src/rpc_socket.rs +++ b/mullvad-paths/src/rpc_socket.rs @@ -8,12 +8,6 @@ pub fn get_rpc_socket_path() -> PathBuf { } } -/// Return the path to the RPC socket using `data_dir` as the base directory. -#[cfg(target_os = "android")] -pub fn get_rpc_socket_path(data_dir: PathBuf) -> PathBuf { - data_dir.join("rpc-socket") -} - #[cfg(any(target_os = "linux", target_os = "macos"))] pub fn get_default_rpc_socket_path() -> PathBuf { PathBuf::from("/var/run/mullvad-vpn")