From 0f632f2fbab49b16705fc2a80cc3b02a6d6d1b47 Mon Sep 17 00:00:00 2001 From: "jovie :)" <44442031+jovielarue@users.noreply.github.com> Date: Wed, 28 May 2025 01:29:19 -0600 Subject: [PATCH] chroot: remove unwrap calls (#7890) --- src/uu/chroot/src/chroot.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 3f7c0886b..15c7bac4d 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -439,7 +439,7 @@ fn enter_chroot(root: &Path, skip_chdir: bool) -> UResult<()> { let err = unsafe { chroot( CString::new(root.as_os_str().as_bytes().to_vec()) - .unwrap() + .map_err(|e| ChrootError::CannotEnter("root".to_string(), e.into()))? .as_bytes_with_nul() .as_ptr() .cast::(), @@ -448,7 +448,7 @@ fn enter_chroot(root: &Path, skip_chdir: bool) -> UResult<()> { if err == 0 { if !skip_chdir { - std::env::set_current_dir("/").unwrap(); + std::env::set_current_dir("/")?; } Ok(()) } else {