complete disable-sandbox option

This commit is contained in:
valoq 2025-07-12 17:25:25 +02:00
parent 7f0d1e72ec
commit 78b993c500
No known key found for this signature in database
GPG Key ID: 19F09A0FB865CBD8
3 changed files with 11 additions and 3 deletions

View File

@ -51,7 +51,7 @@ pub struct CliArgs {
/// Disable the sandbox feature /// Disable the sandbox feature
#[arg(long, global = true)] #[arg(long, global = true)]
pub no_sandbox: bool, pub disable_sandbox: bool,
// Ouch and claps subcommands // Ouch and claps subcommands
#[command(subcommand)] #[command(subcommand)]

View File

@ -40,6 +40,7 @@ pub struct DecompressOptions<'a> {
pub quiet: bool, pub quiet: bool,
pub password: Option<&'a [u8]>, pub password: Option<&'a [u8]>,
pub remove: bool, pub remove: bool,
pub disable_sandbox: bool,
} }
/// Decompress a file /// Decompress a file
@ -80,6 +81,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
options.question_policy, options.question_policy,
options.is_output_dir_provided, options.is_output_dir_provided,
options.is_smart_unpack, options.is_smart_unpack,
options.disable_sandbox,
)? { )? {
files files
} else { } else {
@ -169,6 +171,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
options.question_policy, options.question_policy,
options.is_output_dir_provided, options.is_output_dir_provided,
options.is_smart_unpack, options.is_smart_unpack,
options.disable_sandbox,
)? { )? {
files files
} else { } else {
@ -204,6 +207,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
options.question_policy, options.question_policy,
options.is_output_dir_provided, options.is_output_dir_provided,
options.is_smart_unpack, options.is_smart_unpack,
options.disable_sandbox,
)? { )? {
files files
} else { } else {
@ -237,6 +241,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
options.question_policy, options.question_policy,
options.is_output_dir_provided, options.is_output_dir_provided,
options.is_smart_unpack, options.is_smart_unpack,
options.disable_sandbox,
)? { )? {
files files
} else { } else {
@ -280,6 +285,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
options.question_policy, options.question_policy,
options.is_output_dir_provided, options.is_output_dir_provided,
options.is_smart_unpack, options.is_smart_unpack,
options.disable_sandbox,
)? { )? {
files files
} else { } else {
@ -316,6 +322,7 @@ fn execute_decompression(
question_policy: QuestionPolicy, question_policy: QuestionPolicy,
is_output_dir_provided: bool, is_output_dir_provided: bool,
is_smart_unpack: bool, is_smart_unpack: bool,
disable_sandbox: bool,
) -> 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
@ -330,7 +337,7 @@ fn execute_decompression(
//} else { //} else {
//} //}
//landlock::init_sandbox(&[output_dir]); landlock::init_sandbox(&[output_dir], disable_sandbox);
if is_smart_unpack { if is_smart_unpack {

View File

@ -216,6 +216,7 @@ pub fn run(
<[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed") <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")
}), }),
remove, remove,
disable_sandbox: args.disable_sandbox,
}) })
}) })
} }
@ -257,7 +258,7 @@ pub fn run(
args.password args.password
.as_deref() .as_deref()
.map(|str| <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")), .map(|str| <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")),
args.no_sandbox, args.disable_sandbox,
)?; )?;
} }