Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/uu/chroot/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think the "unable to enter..." string should be passed

#[error("cannot chroot to {dir}: {err}", dir = .0.quote(), err = .1)]

the first arg is the path (so, root here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I'll fix that. Sorry for the delay, I've been on vacation!

})?
.as_bytes_with_nul()
.as_ptr()
.cast::<libc::c_char>(),
Expand All @@ -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 {
Expand Down
Loading