if (chroot ("dummy_dir")==-1){
fprintf (stderr,"Can't chroot into dummy_dir (%s)\n",strerror(errno));
}else{
+ int i;
// Try to chdir into the real root
- for (int i=0; i<1000; i++) chdir("..");
+ for (i=0; i<1000; i++) chdir("..");
print_pwd();
if (execl ("/bin/sh","/bin/sh",NULL)==-1){
fprintf (stderr,"execl /bin/sh failed (%s)\n",strerror(errno));
*/
static void test2()
{
+ int fd;
+
printf ("test2\n");
print_pwd();
mkdir ("dummy_dir",0755);
- int fd = open (".",O_RDONLY);
+ fd = open (".",O_RDONLY);
if (fd == -1){
fprintf (stderr,"Can't open current directory (%s)\n",strerror(errno));
}else if (chroot ("dummy_dir")==-1){
fprintf (stderr,"Can't fchdir to the current directory (%s)\n"
,strerror(errno));
}else{
+ int i;
// Try to chdir into the real root
- for (int i=0; i<1000; i++) chdir("..");
+ for (i=0; i<1000; i++) chdir("..");
print_pwd();
if (execl ("/bin/sh","/bin/sh",NULL)==-1){
fprintf (stderr,"execl /bin/sh failed (%s)\n",strerror(errno));