Skip to content

Commit

Permalink
fixup! Specify full rpc socket file path to daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Jun 13, 2024
1 parent f7cd913 commit 264e6a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
21 changes: 10 additions & 11 deletions mullvad-jni/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<mullvad_api::ApiEndpoint>,
Expand All @@ -239,7 +239,7 @@ fn initialize(
spawn_daemon(
env,
this,
data_dir,
rpc_socket,
files_dir,
cache_dir,
api_endpoint,
Expand Down Expand Up @@ -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<
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion mullvad-paths/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 0 additions & 6 deletions mullvad-paths/src/rpc_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 264e6a4

Please sign in to comment.