mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-25932] Shorten socket paths (#17093)
* feat: shorten socket paths * fix: No such file or directory error * feat: remove tmp folder from path * fix: No such file or directory autofill error
This commit is contained in:
@@ -35,7 +35,7 @@ fn internal_ipc_codec<T: AsyncRead + AsyncWrite>(inner: T) -> Framed<T, LengthDe
|
||||
pub fn path(name: &str) -> std::path::PathBuf {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
// Use a unique IPC pipe //./pipe/xxxxxxxxxxxxxxxxx.app.bitwarden per user.
|
||||
// Use a unique IPC pipe //./pipe/xxxxxxxxxxxxxxxxx.s.bw per user (s for socket).
|
||||
// Hashing prevents problems with reserved characters and file length limitations.
|
||||
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
|
||||
use sha2::Digest;
|
||||
@@ -43,7 +43,7 @@ pub fn path(name: &str) -> std::path::PathBuf {
|
||||
let hash = sha2::Sha256::digest(home.as_os_str().as_encoded_bytes());
|
||||
let hash_b64 = URL_SAFE_NO_PAD.encode(hash.as_slice());
|
||||
|
||||
format!(r"\\.\pipe\{hash_b64}.app.{name}").into()
|
||||
format!(r"\\.\pipe\{hash_b64}.s.{name}").into()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -65,11 +65,11 @@ pub fn path(name: &str) -> std::path::PathBuf {
|
||||
home.pop();
|
||||
}
|
||||
|
||||
let tmp = home.join("Library/Group Containers/LTZ2PFU5D6.com.bitwarden.desktop/tmp");
|
||||
let tmp = home.join("Library/Group Containers/LTZ2PFU5D6.com.bitwarden.desktop");
|
||||
|
||||
// The tmp directory might not exist, so create it
|
||||
let _ = std::fs::create_dir_all(&tmp);
|
||||
return tmp.join(format!("app.{name}"));
|
||||
return tmp.join(format!("s.{name}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,6 @@ pub fn path(name: &str) -> std::path::PathBuf {
|
||||
|
||||
// The cache directory might not exist, so create it
|
||||
let _ = std::fs::create_dir_all(&path_dir);
|
||||
path_dir.join(format!("app.{name}"))
|
||||
path_dir.join(format!("s.{name}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ impl MacOSProviderClient {
|
||||
response_callbacks_queue: Arc::new(Mutex::new(HashMap::new())),
|
||||
};
|
||||
|
||||
let path = desktop_core::ipc::path("autofill");
|
||||
let path = desktop_core::ipc::path("af");
|
||||
|
||||
let queue = client.response_callbacks_queue.clone();
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ async fn main() {
|
||||
#[cfg(target_os = "windows")]
|
||||
let should_foreground = windows::allow_foreground();
|
||||
|
||||
let sock_path = desktop_core::ipc::path("bitwarden");
|
||||
let sock_path = desktop_core::ipc::path("bw");
|
||||
|
||||
let log_path = {
|
||||
let mut path = sock_path.clone();
|
||||
|
||||
@@ -78,7 +78,7 @@ export class NativeMessagingMain {
|
||||
this.ipcServer.stop();
|
||||
}
|
||||
|
||||
this.ipcServer = await ipc.IpcServer.listen("bitwarden", (error, msg) => {
|
||||
this.ipcServer = await ipc.IpcServer.listen("bw", (error, msg) => {
|
||||
switch (msg.kind) {
|
||||
case ipc.IpcMessageType.Connected: {
|
||||
this.connected.push(msg.clientId);
|
||||
|
||||
@@ -35,7 +35,7 @@ export class NativeAutofillMain {
|
||||
);
|
||||
|
||||
this.ipcServer = await autofill.IpcServer.listen(
|
||||
"autofill",
|
||||
"af",
|
||||
// RegistrationCallback
|
||||
(error, clientId, sequenceNumber, request) => {
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user