Paris
Paris

Reputation: 6771

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?

Upvotes: 4

Views: 993

Answers (2)

Perry
Perry

Reputation: 4495

That might work, but the purpose of having a chroot is generally to prevent attackers from being able to execute arbitrary shell commands. Once you have put /bin/sh into a chroot jail you've eliminated any purpose to having the chroot jail in the first place.

Upvotes: 0

Nemo
Nemo

Reputation: 71555

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.

Upvotes: 6

Related Questions