mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-18 23:50:35 +00:00
improve code structure
This commit is contained in:
parent
133f46a2c8
commit
a4ff65f44c
@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use fs_err as fs;
|
||||
use crate::utils::landlock;
|
||||
//use crate::utils::landlock;
|
||||
|
||||
#[cfg(not(feature = "bzip3"))]
|
||||
use crate::archive;
|
||||
@ -19,7 +19,7 @@ use crate::{
|
||||
utils::{
|
||||
self,
|
||||
io::lock_and_flush_output_stdio,
|
||||
is_path_stdin,
|
||||
is_path_stdin, landlock,
|
||||
logger::{info, info_accessible},
|
||||
nice_directory_display, user_wants_to_continue,
|
||||
},
|
||||
@ -324,14 +324,11 @@ fn execute_decompression(
|
||||
is_smart_unpack: bool,
|
||||
disable_sandbox: bool,
|
||||
) -> crate::Result<ControlFlow<(), usize>> {
|
||||
|
||||
// init landlock sandbox to restrict file system write access to output_dir
|
||||
// The output directory iseither specified with the -d option or the current working directory is used
|
||||
// TODO: restrict acess to the current working directory to allow only creating new files
|
||||
|
||||
// TODO: move to unpack and smart_unpack to cover the differetn dirctories used for
|
||||
// decompression
|
||||
|
||||
//if !input_is_stdin && options.remove {
|
||||
//permit write access to input_file_path
|
||||
//} else {
|
||||
@ -339,7 +336,6 @@ fn execute_decompression(
|
||||
|
||||
landlock::init_sandbox(&[output_dir], disable_sandbox);
|
||||
|
||||
|
||||
if is_smart_unpack {
|
||||
return smart_unpack(unpack_fn, output_dir, output_file_path, question_policy);
|
||||
}
|
||||
|
@ -4,14 +4,14 @@ use std::{
|
||||
};
|
||||
|
||||
use fs_err as fs;
|
||||
use crate::utils::landlock;
|
||||
//use crate::utils::landlock;
|
||||
|
||||
use crate::{
|
||||
archive,
|
||||
commands::warn_user_about_loading_zip_in_memory,
|
||||
extension::CompressionFormat::{self, *},
|
||||
list::{self, FileInArchive, ListOptions},
|
||||
utils::{io::lock_and_flush_output_stdio, user_wants_to_continue},
|
||||
utils::{io::lock_and_flush_output_stdio, user_wants_to_continue, landlock},
|
||||
QuestionAction, QuestionPolicy, BUFFER_CAPACITY,
|
||||
};
|
||||
|
||||
@ -25,7 +25,6 @@ pub fn list_archive_contents(
|
||||
password: Option<&[u8]>,
|
||||
disable_sandbox: bool,
|
||||
) -> crate::Result<()> {
|
||||
|
||||
//rar uses a temporary file which needs to be defined early to be permitted in landlock
|
||||
let mut temp_file = tempfile::NamedTempFile::new()?;
|
||||
|
||||
|
@ -261,9 +261,7 @@ pub fn run(
|
||||
.map(|str| <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")),
|
||||
args.disable_sandbox,
|
||||
)?;
|
||||
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,6 @@ use self::{
|
||||
},
|
||||
};
|
||||
|
||||
//use utils::landlock::*;
|
||||
|
||||
|
||||
// Used in BufReader and BufWriter to perform less syscalls
|
||||
const BUFFER_CAPACITY: usize = 1024 * 32;
|
||||
|
||||
@ -64,7 +61,6 @@ fn run() -> Result<()> {
|
||||
// Since either the specified output directory is created if it did not exist, or the .ouch-tmp
|
||||
// directory is created in the current working directory, the parent directory of the target
|
||||
// directory requires LANDLOCK_ACCESS_FS_MAKE_DIR
|
||||
|
||||
// expects either the .tmp-ouch-XXXXXX path or the specified output directory (-d option)
|
||||
//utils::landlock::init_sandbox(&working_dir);
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
// Landlock support and generic Landlock sandbox implementation.
|
||||
// https://landlock.io/rust-landlock/landlock/struct.Ruleset.html
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use landlock::{
|
||||
Access, AccessFs, PathBeneath, PathFd, PathFdError, RestrictionStatus, Ruleset,
|
||||
RulesetAttr, RulesetCreatedAttr, RulesetError, ABI,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
/// The status code returned from `ouch` on error
|
||||
pub const EXIT_FAILURE: i32 = libc::EXIT_FAILURE;
|
||||
|
||||
|
@ -8,9 +8,9 @@ mod file_visibility;
|
||||
mod formatting;
|
||||
mod fs;
|
||||
pub mod io;
|
||||
pub mod landlock;
|
||||
pub mod logger;
|
||||
mod question;
|
||||
pub mod landlock;
|
||||
|
||||
pub use self::{
|
||||
file_visibility::FileVisibilityPolicy,
|
||||
|
Loading…
x
Reference in New Issue
Block a user