mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-19 16:10:53 +00:00
complete decompress and list commands
This commit is contained in:
parent
a6b3e96df5
commit
bf22fdaf50
@ -319,7 +319,7 @@ fn execute_decompression(
|
|||||||
) -> crate::Result<ControlFlow<(), usize>> {
|
) -> crate::Result<ControlFlow<(), usize>> {
|
||||||
|
|
||||||
// init landlock sandbox to restrict file system write access to output_dir
|
// init landlock sandbox to restrict file system write access to output_dir
|
||||||
landlock::init_sandbox(output_dir);
|
landlock::init_sandbox(Some(output_dir));
|
||||||
|
|
||||||
if is_smart_unpack {
|
if is_smart_unpack {
|
||||||
return smart_unpack(unpack_fn, output_dir, output_file_path, question_policy);
|
return smart_unpack(unpack_fn, output_dir, output_file_path, question_policy);
|
||||||
|
@ -27,7 +27,7 @@ pub fn list_archive_contents(
|
|||||||
|
|
||||||
// Initialize landlock sandbox with empty write path
|
// Initialize landlock sandbox with empty write path
|
||||||
// This allows only read access to the filesystem
|
// This allows only read access to the filesystem
|
||||||
//landlock::init_sandbox(None);
|
landlock::init_sandbox(None);
|
||||||
|
|
||||||
let reader = fs::File::open(archive_path)?;
|
let reader = fs::File::open(archive_path)?;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ fn restrict_paths(hierarchies: &[&str]) -> Result<RestrictionStatus, MyRestrictE
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn init_sandbox(allowed_dir: &Path) {
|
pub fn init_sandbox(allowed_dir: Option<&Path>) {
|
||||||
|
|
||||||
if std::env::var("CI").is_ok() {
|
if std::env::var("CI").is_ok() {
|
||||||
return;
|
return;
|
||||||
@ -85,21 +85,27 @@ pub fn init_sandbox(allowed_dir: &Path) {
|
|||||||
|
|
||||||
|
|
||||||
if is_landlock_supported() {
|
if is_landlock_supported() {
|
||||||
|
let status = if let Some(allowed_dir) = allowed_dir {
|
||||||
|
let path_str = allowed_dir.to_str().expect("Cannot convert path");
|
||||||
|
restrict_paths(&[path_str])
|
||||||
|
} else {
|
||||||
|
restrict_paths(&[])
|
||||||
|
};
|
||||||
|
|
||||||
let path_str = allowed_dir.to_str().expect("Cannot convert path");
|
match status {
|
||||||
|
Ok(_status) => {
|
||||||
match restrict_paths(&[path_str]) {
|
|
||||||
Ok(status) => {
|
|
||||||
//check
|
//check
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(_e) => {
|
||||||
//log warning
|
//log warning
|
||||||
std::process::exit(EXIT_FAILURE);
|
std::process::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// warn!("Landlock is NOT supported on this platform or kernel (<5.19).");
|
// warn!("Landlock is NOT supported on this platform or kernel (<5.19).");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user