Skip to content

chroot: don't panic on --skip-chdir with a non-resolving NEWROOT - #12732

Merged
cakebaker merged 1 commit into
uutils:mainfrom
leeewee:chroot-fix-skip-chdir-canonicalize
Jun 11, 2026
Merged

chroot: don't panic on --skip-chdir with a non-resolving NEWROOT#12732
cakebaker merged 1 commit into
uutils:mainfrom
leeewee:chroot-fix-skip-chdir-canonicalize

Conversation

@leeewee

@leeewee leeewee commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #12731

chroot --skip-chdir NEWROOT aborted with a Result::unwrap() panic when NEWROOT did not resolve: the permitted-only-if check canonicalized NEWROOT and unwrapped the result, but canonicalize returns Err when the path (or a component) doesn't exist or isn't readable.

Map the Err to a non-match (.ok().as_deref().and_then(|p| p.to_str())) so a non-resolving NEWROOT takes the existing "only permitted if NEWROOT is old '/'" usage error (exit 125) like GNU, instead of crashing. The check runs during argument validation before any chroot syscall. Adds a regression test.

`chroot --skip-chdir NEWROOT` aborted with a Result::unwrap panic when NEWROOT
did not resolve: the permitted-only-if check canonicalized NEWROOT and
unwrapped the result, but `canonicalize` returns Err when the path (or a
component) doesn't exist or isn't readable.

Map the Err to a non-match (`.ok().as_deref().and_then(|p| p.to_str())`) so a
non-resolving NEWROOT takes the existing "only permitted if NEWROOT is old '/'"
usage error (exit 125) like GNU, instead of crashing. This happens during
argument validation before any chroot syscall. Adds a regression test.
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Congrats! The gnu test tests/expand/bounded-memory is now passing!

@cakebaker
cakebaker merged commit 81d7eb1 into uutils:main Jun 11, 2026
174 of 175 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chroot panics (unwrap Err) on --skip-chdir with a non-existent NEWROOT

2 participants