Merge pull request #3 from fnr1r/main
fix(genshin): make sure dirs exist bef. sandboxing
This commit is contained in:
commit
cf78f39156
1 changed files with 43 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
|
use std::fs::metadata;
|
||||||
|
|
||||||
mod mounts;
|
mod mounts;
|
||||||
|
|
||||||
|
@ -141,15 +142,53 @@ impl Sandbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.isolate_home {
|
if self.isolate_home {
|
||||||
|
match metadata("/home") {
|
||||||
|
Ok(meta) => {
|
||||||
|
if meta.is_dir() {
|
||||||
command.push_str(" --tmpfs /home");
|
command.push_str(" --tmpfs /home");
|
||||||
|
} else {
|
||||||
|
tracing::info!("/var/home is not a directory.")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => tracing::info!("/home does not exist.")
|
||||||
|
}
|
||||||
|
match metadata("/var/home") {
|
||||||
|
Ok(meta) => {
|
||||||
|
if meta.is_dir() {
|
||||||
command.push_str(" --tmpfs /var/home");
|
command.push_str(" --tmpfs /var/home");
|
||||||
|
} else {
|
||||||
|
tracing::info!("/var/home is not a directory.")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => tracing::info!("/var/home does not exist.")
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(user) = std::env::var("USER") {
|
if let Ok(user) = std::env::var("USER") {
|
||||||
command += &format!(" --tmpfs '/var/home/{}'", user.trim());
|
let dir = format!("/var/home/{}", user.trim());
|
||||||
|
match metadata(&dir) {
|
||||||
|
Ok(meta) => {
|
||||||
|
if meta.is_dir() {
|
||||||
|
command += &format!(" --tmpfs '{}'", dir);
|
||||||
|
} else {
|
||||||
|
tracing::info!("{} is not a directory.", dir)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => tracing::info!("{} does not exist.", dir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(home) = std::env::var("HOME") {
|
if let Ok(home) = std::env::var("HOME") {
|
||||||
command += &format!(" --tmpfs '{}'", home.trim());
|
let dir = home.trim();
|
||||||
|
match metadata(dir) {
|
||||||
|
Ok(meta) => {
|
||||||
|
if meta.is_dir() {
|
||||||
|
command += &format!(" --tmpfs '{}'", dir);
|
||||||
|
} else {
|
||||||
|
tracing::info!("{} is not a directory.", dir)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => tracing::info!("{} does not exist.", dir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue