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

Ignore lockdown errors for invalid paths #65

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- (macOS) Modifying exceptions for paths affected by existing exceptions
- (Linux) Symlink/Canonical path's exceptions overriding each other
- (Linux) PID namespace support
- (Linux) Sandbox lockdown failing when deleting file after adding exception

## [v0.5.0] - 2023-10-13

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ harness = false
[target.'cfg(target_os = "linux")'.dependencies]
seccompiler = "0.3.0"
libc = "0.2.132"
log = "0.4.20"

[dev-dependencies]
clap = { version = "3.2.17", features = ["derive"] }
Expand Down
22 changes: 22 additions & 0 deletions integration/delete_before_lockdown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

use birdcage::{Birdcage, Exception, Sandbox};
use tempfile::NamedTempFile;

use crate::TestSetup;

pub fn setup() -> TestSetup {
// Create temporary file.
let tempfile = NamedTempFile::new().unwrap();

// Setup sandbox exceptions.
let mut sandbox = Birdcage::new();
sandbox.add_exception(Exception::Read(tempfile.path().into())).unwrap();

drop(tempfile);
cd-work marked this conversation as resolved.
Show resolved Hide resolved

TestSetup { sandbox, data: String::new() }
}

pub fn validate(_data: String) {
// We just want to test sandbox creation worked.
}
1 change: 1 addition & 0 deletions integration/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_mods! {
mod canonicalize;
#[cfg(target_os = "linux")]
mod consistent_id_mappings;
mod delete_before_lockdown;
mod env;
mod exec;
mod exec_symlinked_dir;
Expand Down
5 changes: 4 additions & 1 deletion src/linux/namespaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ pub(crate) fn setup_mount_namespace(exceptions: PathExceptions) -> io::Result<()
let dst_c = CString::new(dst.as_os_str().as_bytes()).unwrap();

// Create mount target.
copy_tree(&path, &new_root)?;
if let Err(err) = copy_tree(&path, &new_root) {
log::error!("skipping birdcage exception {path:?}: {err}");
continue;
}

// Bind path with full permissions.
bind_mount(&src_c, &dst_c)?;
Expand Down
Loading