Search code examples
csystemcalllibrarieschroot

C : system() call inside chroot


I have a program written in C, which runs chrooted, inside a jail, that makes some system calls e.g system ( "ls" ). The problem is that the program does not execute the system calls when I run it inside the jail. I have included all the necessary libraries of the executable ( found them with ldd bash command ), along with the bash executable ( /bin/bash ), and it's libraries ( also found with ldd ). It seems that something is missing. Does anyone have an idea about that?


Solution

  • By definition, system runs "/bin/sh -c <command>".

    Copy /bin/sh to your chroot jail (or link it to /bin/bash) and you should be good to go.