How can I detect I am running in a chroot() environment without being UID 0? [duplicate]
Possible Duplicate:
Detecting a chroot jail from within
Detecting whether your process is executed in a chroot() environment on Linux is relatively easy: by comparing the device/inode of /proc/1/root and /. However, that requires access to stat() on /proc/1/root -- which is unfortunately privileged.
I am looking for a nice way to achieve the same thing, but witho开发者_如何学JAVAut requiring privileges for that. Anybody can help me? How can my unprivileged code detect whether its is being executed in a chroot() environment?
If you found one, you should report it as a bug. The whole point of chroot() is to let someone make a protected environment that doesn't give away that hint without privilege.
精彩评论