From 9d9f2c99456dd348ecf15024fb291e2d5fa4679c Mon Sep 17 00:00:00 2001 From: Jovie LaRue <44442031+jovielarue@users.noreply.github.com> Date: Mon, 5 May 2025 18:14:30 -0600 Subject: [PATCH] chroot: remove unwrap calls --- src/uu/chroot/src/chroot.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 3f7c0886b5f..9724631878e 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -439,7 +439,9 @@ 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("Unable to enter root directory".to_string(), e.into()) + })? .as_bytes_with_nul() .as_ptr() .cast::(), @@ -448,7 +450,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 {