-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix readonly/noexec exceptions in Linux sandbox
This fixes an issue where every path added as exception on Linux would allow for full write/exec privileges.
- Loading branch information
Showing
5 changed files
with
114 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::fs; | ||
|
||
use birdcage::{Birdcage, Exception, Sandbox}; | ||
use tempfile::NamedTempFile; | ||
|
||
fn main() { | ||
const FILE_CONTENT: &str = "expected content"; | ||
|
||
// Setup the test file. | ||
let file = NamedTempFile::new().unwrap(); | ||
fs::write(&file, FILE_CONTENT.as_bytes()).unwrap(); | ||
|
||
// Activate our sandbox. | ||
let mut birdcage = Birdcage::new(); | ||
birdcage.add_exception(Exception::Read(file.path().into())).unwrap(); | ||
birdcage.lock().unwrap(); | ||
|
||
// Reading from the file is allowed. | ||
let content = fs::read_to_string(&file).unwrap(); | ||
assert_eq!(content, FILE_CONTENT); | ||
|
||
// Writing to the file is prohibited. | ||
let result = fs::write(&file, FILE_CONTENT.as_bytes()); | ||
assert!(result.is_err()); | ||
} |