summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-04-25 21:29:38 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-06-20 08:08:31 -0300
commit717f315031630e9bdeeab7e39c4ad481e34ff3bc (patch)
tree9408efc6b08bdbb459ee8a0bead738670885b182
parent01d2e843d4ccb25cf17b4a984348a34b336df877 (diff)
downloadmullvadvpn-717f315031630e9bdeeab7e39c4ad481e34ff3bc.tar.xz
mullvadvpn-717f315031630e9bdeeab7e39c4ad481e34ff3bc.zip
Allow RPC client without RPC file security check
-rw-r--r--mullvad-ipc-client/src/lib.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/mullvad-ipc-client/src/lib.rs b/mullvad-ipc-client/src/lib.rs
index 6c1ade7fb1..686a7f1634 100644
--- a/mullvad-ipc-client/src/lib.rs
+++ b/mullvad-ipc-client/src/lib.rs
@@ -77,7 +77,18 @@ pub struct DaemonRpcClient {
impl DaemonRpcClient {
pub fn new() -> Result<Self> {
- let (address, credentials) = Self::read_rpc_file()?;
+ let (address, credentials) = Self::read_rpc_file(true)?;
+
+ Self::with_address_and_credentials(address, credentials)
+ }
+
+ pub fn without_rpc_file_security_check() -> Result<Self> {
+ let (address, credentials) = Self::read_rpc_file(false)?;
+
+ Self::with_address_and_credentials(address, credentials)
+ }
+
+ fn with_address_and_credentials(address: String, credentials: String) -> Result<Self> {
let rpc_client =
WsIpcClient::connect(&address).chain_err(|| ErrorKind::StartRpcClient(address))?;
let mut instance = DaemonRpcClient { rpc_client };
@@ -89,12 +100,14 @@ impl DaemonRpcClient {
Ok(instance)
}
- fn read_rpc_file() -> Result<(String, String)> {
+ fn read_rpc_file(verify_security: bool) -> Result<(String, String)> {
let file_path = mullvad_paths::get_rpc_address_path()?;
let rpc_file =
File::open(&file_path).chain_err(|| ErrorKind::ReadRpcFileError(file_path.clone()))?;
- ensure_written_by_admin(&file_path)?;
+ if verify_security {
+ ensure_written_by_admin(&file_path)?;
+ }
let reader = BufReader::new(rpc_file);
let mut lines = reader.lines();