Reputation: 99
I'm working on a webserver in UNIX environment with C language. Currently, I have done jailing the process but now I cannot use syslog and logging to a file option and that's basically due to the changed root path.
New root path for the program is it's directory. I could not escape from it to real root "/" in order to use these functions and go back to jail root path again.
Are there any other alternatives or solutions to this?
Upvotes: 0
Views: 1633
Reputation: 36431
If both env are on the same file system, you can use hard links so that under the chroot'ed env you see files "outside". It may not be so easy to configure everything to work, but it is possible. Change your viewpoint: don't try to escape from chroot, try to include things into.
Upvotes: 0
Reputation: 2514
The whole point of using chroot()
is to make the real root inaccessible, so easy formula: If you can break it, you don't need it.
So, you should make syslog accessible from within your chroot environment instead. How? Just openlog()
prior to chroot()
. After that, you can syslog()
even though you wouldn't be able to openlog()
it anymore.
Upvotes: 4
Reputation: 1093
If your root is the working directory, don't use chroot, and remove the '/' at the beggining of all the relative path you use, or add '.' before this '/'. Use chroot only if you want to fully work as if it was your system root.
Upvotes: 0