Chroot jailing isn't working...

it's executing ls command after chroot jailing at 'chroot/jail' dir.

I run this program as a root and place 'ls' at chroot/jail with execute permission

But it cotinously output like below.

---

exit with -1

---


my program is below.



#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char* argv[]){

if (chroot("chroot/jail") == -1) {
perror("error-1: ");
}

if (chdir("/") == -1) {
perror("error-2: ");
}

File *fd;
fd = fopen("/bin/ls","r");
fd.
fclose(fd);
int ret;
ret = execl("/bin/ls","ls",NULL);

printf("exit with %d\n",ret);
return 0;
}

Did you put ls in chroot/jail or chroot/jail/bin?

Topic archived. No new replies allowed.