exp: cross #3
This commit is contained in:
@@ -78,12 +78,20 @@ impl ContextDriver for UnshareDriver {
|
||||
))
|
||||
}
|
||||
|
||||
fn list_files(&self, _path: &Path) -> io::Result<Vec<PathBuf>> {
|
||||
// TODO: Implement chroot file listing logic
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Unsupported,
|
||||
"list_files not yet implemented for chroot",
|
||||
))
|
||||
fn list_files(&self, path: &Path) -> io::Result<Vec<PathBuf>> {
|
||||
let host_path = Path::new(&self.path).join(path.to_string_lossy().trim_start_matches('/'));
|
||||
let host_entries = self.parent().list_files(&host_path)?;
|
||||
|
||||
let mut entries = Vec::new();
|
||||
let prefix = Path::new(&self.path);
|
||||
for entry in host_entries {
|
||||
if let Ok(rel_path) = entry.strip_prefix(prefix) {
|
||||
entries.push(Path::new("/").join(rel_path));
|
||||
} else {
|
||||
entries.push(entry);
|
||||
}
|
||||
}
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
fn run(
|
||||
@@ -164,7 +172,10 @@ impl UnshareDriver {
|
||||
let mut cmd = self.parent().command("sudo");
|
||||
cmd.args(env.iter().map(|(k, v)| format!("{k}={v}")));
|
||||
|
||||
cmd.arg("unshare").arg("-R").arg(&self.path);
|
||||
cmd.arg("unshare")
|
||||
.arg("--mount-proc")
|
||||
.arg("-R")
|
||||
.arg(&self.path);
|
||||
|
||||
if let Some(dir) = cwd {
|
||||
cmd.arg("-w").arg(dir);
|
||||
|
||||
Reference in New Issue
Block a user