Im having problems on my ubuntu system writing a small program which start a chroot'ed apache server. The following is my code
Code:
int main() {
pid_t apache_pid;
if ((apache_pid = fork()) == 0 )
{ chroot("/var/webjail/");
execl("/usr/local/apache/bin/apachectl", "apachectl", "-k", "start", NULL);
}
waitpid(apache_pid,NULL,0);
return 0;
}
It always seems to fail whilst creating a chroot. I put some debugging in there and chroot always returns null. I run the process as root and I have tried chrooting to other directories, of which all fail. I have changed the permissions to 777 on these directories so permissions would not be a problem (not that it should be as root anyway).
Any ideas?
Cheers
Ray