-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split isolation.rs into files
This is a form of preparation for the introduction of additional security-related measures, which may be best to implement in separate files.
- Loading branch information
Showing
5 changed files
with
25 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod filemap; | ||
pub mod tempdir; |
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,19 @@ | ||
use std::{fs::Permissions, os::unix::fs::PermissionsExt}; | ||
|
||
use tempfile::{Builder, TempDir}; | ||
use uuid::Uuid; | ||
/// Creates a temporary directory. | ||
pub fn create_temp_dir() -> TempDir { | ||
let dir = Builder::new() | ||
.permissions(Permissions::from_mode(0o700)) | ||
.prefix("uhyve-") | ||
.suffix(&Uuid::new_v4().to_string()) | ||
.tempdir() | ||
.ok() | ||
.unwrap_or_else(|| panic!("The temporary directory could not be created.")); | ||
|
||
let dir_permissions = dir.path().metadata().unwrap().permissions(); | ||
assert!(!dir_permissions.readonly()); | ||
|
||
dir | ||
} |
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