TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PRoot: User-space implementation of chroot, mount –bind, and binfmt_misc

132 pointsby nateb20226 months ago

14 comments

CaliforniaKarl6 months ago
Here&#x27;s an example of how we&#x27;ve used this.<p>RStudio Server[0] 1.3 and older hard-coded a number of paths, such as the path for storing temporary files: Instead of looking for the TMPDIR environment variable (as specified by POSIX[1]), R Studio Server would always use &#x2F;tmp. That is extremely annoying, because we set TMPDIR to a path on fast local storage (SATA or NVMe SSDs) that the job scheduler cleans up at the end of the compute job.<p>We do have a last-resort mechanism using pam_namespace[2], such that a user going to `&#x2F;tmp` actually takes them to `&#x2F;namespace&#x2F;tmp&#x2F;${username}`, but that is per-user, not per-job. If a user has two R Studio jobs, and those two jobs landed on the same host, there would be trouble.<p>So, we used PRoot to wrap R Studio, with &#x2F;tmp bind-mounted to a directory under TMPDIR.<p>[0]: <a href="https:&#x2F;&#x2F;www.rstudio.com&#x2F;products&#x2F;rstudio&#x2F;download-server&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.rstudio.com&#x2F;products&#x2F;rstudio&#x2F;download-server&#x2F;</a><p>[1]: <a href="https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;basedefs&#x2F;V1_chap08.html" rel="nofollow">https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;basedefs&#x2F;V1...</a><p>[2]: <a href="https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;8&#x2F;pam_namespace" rel="nofollow">https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;8&#x2F;pam_namespace</a>
评论 #42264301 未加载
评论 #42267639 未加载
albertzeyer6 months ago
A similar tool for this user-space bind-mount is <a href="https:&#x2F;&#x2F;github.com&#x2F;fritzw&#x2F;ld-preload-open">https:&#x2F;&#x2F;github.com&#x2F;fritzw&#x2F;ld-preload-open</a>, which relies on LD_PRELOAD to overwrite common libc functions. Thus this is less reliable as the presented tool which uses ptrace, but it still works reasonably well (I run e.g. PyCharm with it).
评论 #42264118 未加载
评论 #42264535 未加载
rekado6 months ago
`guix pack` can create bundles that use a static proot to make them relocatable:<p><a href="https:&#x2F;&#x2F;hpc.guix.info&#x2F;blog&#x2F;2017&#x2F;10&#x2F;using-guix-without-being-root&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hpc.guix.info&#x2F;blog&#x2F;2017&#x2F;10&#x2F;using-guix-without-being-...</a><p>It also supports other more performant ways, but in some situations proot is the best choice.
评论 #42269445 未加载
hks06 months ago
Termux has now a nice wrapper (manager?) for proot [1]. I once wanted to submit a wrapper but got an angry response as the first comment to my PR and it was closed. Guess enough people did that until they decided maybe it&#x27;s not a bad idea after all.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;termux&#x2F;proot-distro">https:&#x2F;&#x2F;github.com&#x2F;termux&#x2F;proot-distro</a>
评论 #42265926 未加载
评论 #42263251 未加载
Voklen6 months ago
Can anyone explain why chroot requires root privileges in the first place? Because from my understanding it seems like it should only restrict what you can do rather than grant any new abilities.
评论 #42264451 未加载
评论 #42264399 未加载
评论 #42265066 未加载
nine_k6 months ago
Ah! Finally I see a way to try nix (the package manager) on my existing installation without it requiring access to the root directory and other such stuff!
评论 #42263772 未加载
评论 #42262710 未加载
评论 #42269995 未加载
molticrystal6 months ago
Does this support using gdb to debug a program, because I vaguely remember years ago using a simulated root to install a linux distro on android to compile and test certain ideas while traveling and due to the nature of ptrace , they couldn&#x27;t be loaded into a debugger.
ggm6 months ago
Unless I am mistaken this cannot elide over the fundamental protections Android enforce which make it impossible to do cross-device symlinks to external SD cards in a non-rooted Android: the outer kernel blocks this, even though you can cd into the paths.<p>If (for example) you can overlay&#x2F;union mount and have a synthetic upper layer FS which manages things, I could use this.
评论 #42263261 未加载
randomtoast6 months ago
If I shell script something together that executes a process in a PRoot environment, would that be similar to Docker?
bieganski6 months ago
related url, for syscall intercepting made easy: <a href="https:&#x2F;&#x2F;github.com&#x2F;bieganski&#x2F;asstrace&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;bieganski&#x2F;asstrace&#x2F;</a><p>see `pathsubst` example.<p>unfortunately set of use cases for `ptrace`-based solution is limited, due to high performance overhead.
badmintonbaseba6 months ago
So this works by intercepting file-related syscalls. Does it intercept io_uring?
gbraad6 months ago
have been using proot on Android to start my container image[1] as an alternative OS on top of termux. it is not perfect, but at least you can have a Fedora userspace on an Android tablet. when you add termux:x11 or vnc you have a minimal desktop, and with vscode a dev environment.<p>1: <a href="https:&#x2F;&#x2F;github.com&#x2F;gbraad-devenv&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;gbraad-devenv&#x2F;</a>
aloisdg6 months ago
Great name in french
评论 #42265652 未加载
animesh10k6 months ago
this is epic stuff