summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-07-13 11:12:08 +0200
committerErik Larkö <erik@mullvad.net>2017-07-14 13:10:43 +0200
commit08fe7ad5cffe138741e9e94b5c9187169d8b36f2 (patch)
treea9a12e43a1160ca35af4a5a0aee23a8fa2bce930
parentcd4e983ca55135dbd7a92b032d739c84148675c7 (diff)
downloadmullvadvpn-08fe7ad5cffe138741e9e94b5c9187169d8b36f2.tar.xz
mullvadvpn-08fe7ad5cffe138741e9e94b5c9187169d8b36f2.zip
Write the RPC server address to the tempdir instead of the working directory
-rw-r--r--mullvad_cli/src/rpc.rs12
-rw-r--r--mullvad_daemon/src/rpc_info.rs6
2 files changed, 9 insertions, 9 deletions
diff --git a/mullvad_cli/src/rpc.rs b/mullvad_cli/src/rpc.rs
index 73c0c64dc1..7397e822c4 100644
--- a/mullvad_cli/src/rpc.rs
+++ b/mullvad_cli/src/rpc.rs
@@ -25,12 +25,12 @@ pub fn call_internal<T, O>(method: &str, args: &T) -> Result<O>
}
fn read_rpc_address() -> Result<String> {
- for path in &["./.mullvad_rpc_address", "../.mullvad_rpc_address"] {
- debug!("Trying to read RPC address at {}", path);
- let mut address = String::new();
- if let Ok(_) = File::open(path).and_then(|mut file| file.read_to_string(&mut address)) {
- return Ok(address);
- }
+ let path = ::std::env::temp_dir().join(".mullvad_rpc_address");
+
+ debug!("Trying to read RPC address at {}", path.to_string_lossy());
+ let mut address = String::new();
+ if let Ok(_) = File::open(path).and_then(|mut file| file.read_to_string(&mut address)) {
+ return Ok(address);
}
bail!("Unable to read RPC address");
}
diff --git a/mullvad_daemon/src/rpc_info.rs b/mullvad_daemon/src/rpc_info.rs
index f1dae58506..25078ff899 100644
--- a/mullvad_daemon/src/rpc_info.rs
+++ b/mullvad_daemon/src/rpc_info.rs
@@ -17,12 +17,12 @@ error_chain! {
lazy_static! {
/// The path to the file where we write the RPC address
- static ref RPC_ADDRESS_FILE_PATH: &'static Path = Path::new("./.mullvad_rpc_address");
+ static ref RPC_ADDRESS_FILE_PATH: PathBuf = ::std::env::temp_dir().join(".mullvad_rpc_address");
}
/// Writes down the RPC address to some API to a file.
pub fn write(rpc_address: &str) -> Result<()> {
- open_file(*RPC_ADDRESS_FILE_PATH)
+ open_file(RPC_ADDRESS_FILE_PATH.as_path())
.and_then(|mut file| file.write_all(rpc_address.as_bytes()))
.chain_err(|| ErrorKind::WriteFailed(RPC_ADDRESS_FILE_PATH.to_owned()))?;
@@ -34,7 +34,7 @@ pub fn write(rpc_address: &str) -> Result<()> {
}
pub fn remove() -> Result<()> {
- fs::remove_file(*RPC_ADDRESS_FILE_PATH)
+ fs::remove_file(RPC_ADDRESS_FILE_PATH.as_path())
.chain_err(|| ErrorKind::RemoveFailed(RPC_ADDRESS_FILE_PATH.to_owned()))
}