+
Skip to content

Fix chroot trying to change into non-existent directory #7803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2025

Conversation

jplatte
Copy link
Contributor

@jplatte jplatte commented Apr 20, 2025

I tried to use the uutils chroot binary, it failed saying it can't switch to the new root. I found that the line I'm changing in this PR was the culprit, and commented it out. This made it work, however the new shell opened in the directory I had previously opened (I believe it was mapped inside the new root somewhere). Changing the set_current_dir call to target / (which is always the new root AFAIK, since this call runs after chroot) seems to do the right thing (it worked for me).

I did not look into how other implementations of chroot work, I only observed that this implementation was broken (initially the version AerynOS ships, then a self-built binary from the latest state of this repo, a little over two weeks ago), and played around with it until I had a fix that worked, and seemed reasonable, to me.

Copy link

GNU testsuite comparison:

GNU test failed: tests/misc/tee. tests/misc/tee is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

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

Looks good! Great PR description by the way!

@tertsdiepraam tertsdiepraam merged commit 993644c into uutils:main Apr 21, 2025
69 of 70 checks passed
@jplatte jplatte deleted the chroot branch April 21, 2025 11:58
@pixelb
Copy link

pixelb commented Apr 24, 2025

The GNU coreutils test suite would have caught this if run as root.
Given all the permission considerations in these utilities a run as the root user is very advisable

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.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载