]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
We can always assert that the uid is the same for all entries.
authorTim Kientzle <kientzle@gmail.com>
Mon, 3 Aug 2009 03:15:27 +0000 (23:15 -0400)
committerTim Kientzle <kientzle@gmail.com>
Mon, 3 Aug 2009 03:15:27 +0000 (23:15 -0400)
On POSIX, we can assert that the stored uid matches the current user.

SVN-Revision: 1333

cpio/test/test_option_c.c

index bdccd4a38328924c11df94d4f2d5a3803a740fc2..4905483675ec16fa4787d17f196c8b11702bed21 100644 (file)
@@ -55,6 +55,7 @@ DEFINE_TEST(test_option_c)
 {
        FILE *filelist;
        int r;
+       int uid = -1;
        int dev, ino, gid;
        time_t t, now;
        char *p, *e;
@@ -62,6 +63,10 @@ DEFINE_TEST(test_option_c)
 
        assertUmask(0);
 
+#if !defined(_WIN32)
+       uid = getuid();
+#endif
+
        /*
         * Create an assortment of files.
         * TODO: Extend this to cover more filetypes.
@@ -116,7 +121,9 @@ DEFINE_TEST(test_option_c)
 #else
        assertEqualMem(e + 18, "100644", 6); /* Mode */
 #endif
-       assertEqualInt(from_octal(e + 24, 6), getuid()); /* uid */
+       if (uid < 0)
+               uid = from_octal(e + 24, 6);
+       assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
        assert(is_octal(e + 30, 6)); /* gid */
        gid = from_octal(e + 30, 6);
        assertEqualMem(e + 36, "000001", 6); /* nlink */
@@ -142,7 +149,7 @@ DEFINE_TEST(test_option_c)
         * others bits do not work. */ 
        assertEqualMem(e + 18, "120777", 6); /* Mode */
 #endif
-       assertEqualInt(from_octal(e + 24, 6), getuid()); /* uid */
+       assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
        assertEqualInt(gid, from_octal(e + 30, 6)); /* gid */
        assertEqualMem(e + 36, "000001", 6); /* nlink */
        failure("file entries should have rdev == 0 (dev was 0%o)",
@@ -185,7 +192,7 @@ DEFINE_TEST(test_option_c)
        if (memcmp(e + 18, "042775", 6) != 0)
                assertEqualMem(e + 18, "040775", 6); /* Mode */
 #endif
-       assertEqualInt(from_octal(e + 24, 6), getuid()); /* uid */
+       assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
        /* Gid should be same as first entry. */
        assert(is_octal(e + 30, 6)); /* gid */
        assertEqualInt(gid, from_octal(e + 30, 6));