Yes, it is possible, but you have to make it accessible to the jail (typically, it means copying the desired program + all its libraries to the jail; symlinking wouldn't work, hardlinking is OK). Otherwise, it's no surprise that if you confine a program to part of the directory tree without /bin
, you can't access /bin/ls
.
Using execlp after jailing a process
Question
Basically I want to execute a shell command inside a jailed process. When I try the below code(both as a normal user & root user), it produced no output
if(!(pid=fork)){
chroot("./jail_folder");
chdir("/");
execl("/bin/ls","ls",NULL);
}
I tried the perror() function and it gave me a "No such file or directory" error. Is it possible to run a shell command in a jailed process? If so, how do we do that?
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow