#undef NDEBUG
[util-vserver.git] / util-vserver / tests / escaperoot.c
index 4a64433..3b1925f 100644 (file)
@@ -51,8 +51,9 @@ static void test1()
        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));
@@ -66,10 +67,12 @@ static void test1()
 */
 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){
@@ -78,8 +81,9 @@ static void test2()
                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));