Skip to content

Commit 910ddc8

Browse files
committed
env: Force a separate Firefox profile
Otherwise Firefox launched in the guest will concurrently access the host profile, corrupting it. We can make it not do that by implementing locks, which would fix the corruption but would still break the browser in the guest. So let's explicitly set a muvm-private Firefox profile. Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent b40bf03 commit 910ddc8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/muvm/src/env.rs

+21
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@ pub fn prepare_env_vars(env: Vec<(String, Option<String>)>) -> Result<HashMap<St
9090
env_map.insert("GTK_IM_MODULE".to_owned(), "xim".to_owned());
9191
env_map.insert("QT_IM_MODULE".to_owned(), "xim".to_owned());
9292

93+
// Force a separate Firefox profile, since Firefox in muvm cannot see
94+
// the lock from outside the VM and will concurrently launch on the same
95+
// profile, corrupting it. This makes Firefox safely work in the VM
96+
// (for browser launches).
97+
if let Ok(home) = env::var("HOME") {
98+
let mut path = PathBuf::new();
99+
path.push(home);
100+
path.push(".mozilla");
101+
path.push("firefox");
102+
if path.exists() {
103+
path.push("muvm-profile");
104+
if !path.exists() {
105+
std::fs::create_dir(&path)?;
106+
}
107+
env_map.insert(
108+
"XRE_PROFILE_PATH".to_owned(),
109+
path.to_str().unwrap().to_owned(),
110+
);
111+
}
112+
}
113+
93114
for (key, value) in env {
94115
let value = value.map_or_else(
95116
|| env::var(&key).with_context(|| format!("Failed to get `{key}` env var")),

0 commit comments

Comments
 (0)