Reputation: 1078
I need to code a jailed command executor and it needs to execute linux command, I've tried copying /bin to my new root, but system() (e.g. system("ls")) still doesn't work. I've read about copying libraries, however there are any other ways to execute linux command that doesn't involve copying stuff ?
Moreover (and maybe more important), there is a way for a jailed process that's not root to execute linux command ?
Thanks, any help is appreciated
Upvotes: 0
Views: 835
Reputation: 239191
Either the binaries you copy in to your chroot environment must be statically linked, or you need to copy in the necessary shared libraries as well (/lib
/ /usr/lib
).
Non-root processes can execute in a chroot environment just as root processes can, but only root processes can call chroot()
so you will need to have a root process set up the chroot environment and then switch to the unprivileged user id.
Upvotes: 1