]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Some privileged users can write to non-writable directories,
authorTim Kientzle <kientzle@gmail.com>
Sat, 4 Apr 2009 20:29:11 +0000 (16:29 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sat, 4 Apr 2009 20:29:11 +0000 (16:29 -0400)
so this test needs to be skipped in that situation.

SVN-Revision: 913

libarchive/test/test_write_disk_failures.c

index d72a2ad73dff59ec22021e20e4bde72c2595ddd9..c0e1f8fb9de2153838282a76eac1a74cc28a3ebb 100644 (file)
@@ -39,6 +39,7 @@ DEFINE_TEST(test_write_disk_failures)
 #else
        struct archive_entry *ae;
        struct archive *a;
+       int fd;
 
        /* Force the umask to something predictable. */
        umask(UMASK);
@@ -46,6 +47,15 @@ DEFINE_TEST(test_write_disk_failures)
        /* A directory that we can't write to. */
        assertEqualInt(0, mkdir("dir", 0555));
 
+       /* Can we? */
+       fd = open("dir/testfile", O_WRONLY | O_CREAT);
+       if (fd >= 0) {
+         /* Apparently, we can, so the test below won't work. */
+         close(fd);
+         skipping("Can't test writing to non-writable directory");
+         return;
+       }
+
        /* Try to extract a regular file into the directory above. */
        assert((ae = archive_entry_new()) != NULL);
        archive_entry_copy_pathname(ae, "dir/file");