How can I detect I am running in a chroot() environment without being UID 0?

2k views Asked by At

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 without requiring privileges for that. Anybody can help me? How can my unprivileged code detect whether its is being executed in a chroot() environment?

1

There are 1 answers

3
Charlie Martin On

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.