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 1/3] 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 { From bbc682ded646a6ecd25be4fd2ae71f60225da208 Mon Sep 17 00:00:00 2001 From: Jovie LaRue <44442031+jovielarue@users.noreply.github.com> Date: Sat, 24 May 2025 17:51:00 -0600 Subject: [PATCH 2/3] chroot: fix error string --- src/uu/chroot/src/chroot.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 9724631878e..fa78d396e95 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -442,6 +442,7 @@ fn enter_chroot(root: &Path, skip_chdir: bool) -> UResult<()> { .map_err(|e| { ChrootError::CannotEnter("Unable to enter root directory".to_string(), e.into()) })? + .map_err(|e| ChrootError::CannotEnter("root".to_string(), e.into()))? .as_bytes_with_nul() .as_ptr() .cast::(), From b8cabb94aeafdf47851ed9586b9b70b82ee592eb Mon Sep 17 00:00:00 2001 From: Jovie LaRue <44442031+jovielarue@users.noreply.github.com> Date: Sat, 24 May 2025 17:53:41 -0600 Subject: [PATCH 3/3] Fix: git issue --- src/uu/chroot/src/chroot.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index fa78d396e95..15c7bac4d8d 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -439,9 +439,6 @@ fn enter_chroot(root: &Path, skip_chdir: bool) -> UResult<()> { let err = unsafe { chroot( CString::new(root.as_os_str().as_bytes().to_vec()) - .map_err(|e| { - ChrootError::CannotEnter("Unable to enter root directory".to_string(), e.into()) - })? .map_err(|e| ChrootError::CannotEnter("root".to_string(), e.into()))? .as_bytes_with_nul() .as_ptr()