Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardcoded sandbox experiment #1178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ rattler_shell = { version = "0.22.5", default-features = false, features = ["sys
rattler_solve = { version = "1.2.0", default-features = false, features = ["resolvo", "serde"] }
rattler_virtual_packages = { version = "1.1.8", default-features = false }
rattler_package_streaming = { version = "0.22.11", default-features = false }
rattler_sandbox = { path = "../rattler/crates/rattler_sandbox", features = ["tokio"] }
lazy_static = "1.5.0"

[dev-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use tempfile::tempdir;

#[tokio::main]
async fn main() -> miette::Result<()> {
rattler_sandbox::init_sandbox();

let app = App::parse();
let log_handler = if !app.is_tui() {
Some(
Expand Down
28 changes: 27 additions & 1 deletion src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,33 @@ async fn run_process_with_replacements(
cwd: &Path,
replacements: &HashMap<String, String>,
) -> Result<std::process::Output, std::io::Error> {
let mut command = tokio::process::Command::new(args[0]);
let temp_folder = std::env::var("TMPDIR").ok();

let mut sandbox_exceptions = vec![
rattler_sandbox::Exception::Read("/".to_string()),
rattler_sandbox::Exception::ExecuteAndRead("/bin/".to_string()),
rattler_sandbox::Exception::ExecuteAndRead("/usr/bin/".to_string()),
rattler_sandbox::Exception::ExecuteAndRead("/Users/wolfv/.pixi/".to_string()),
rattler_sandbox::Exception::ExecuteAndRead(
cwd.parent().unwrap().to_string_lossy().to_string(),
),
rattler_sandbox::Exception::ReadAndWrite(
cwd.parent().unwrap().to_string_lossy().to_string(),
),
// conda compiler activation writes to this tmp folder
rattler_sandbox::Exception::ReadAndWrite("/tmp".to_string()),
// configure command for curl seems to want to write to this temp folder
rattler_sandbox::Exception::ReadAndWrite("/var/tmp".to_string()),
];

if let Some(temp_folder) = temp_folder {
// the is the temp folder from TMPDIR
sandbox_exceptions.push(rattler_sandbox::Exception::ReadAndWrite(
temp_folder.to_string(),
))
}

let mut command = rattler_sandbox::tokio::sandboxed_command(args[0], &sandbox_exceptions);
command
.current_dir(cwd)
.args(&args[1..])
Expand Down
Loading