diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-01-01 22:28:04 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-01-01 22:28:04 +0000 |
commit | 02ff80aa514f0bbb5712a71b96f5593ada26bb80 (patch) | |
tree | 0719828e5aab493661568e13eaa8b2aa062e27da /lib/libarchive/test/test_write_disk_perms.c | |
parent | f89bbe213dfe121e5c9af00662285358ab07dc81 (diff) | |
download | FreeBSD-src-02ff80aa514f0bbb5712a71b96f5593ada26bb80.zip FreeBSD-src-02ff80aa514f0bbb5712a71b96f5593ada26bb80.tar.gz |
Extensive improvements to the libarchive_test test program that
exercises and verifies the libarchive APIs:
* Improved error reporting; hexdumps are now provided for
many file/memory content differences.
* Overall status more clearly counts "tests" and "assertions"
* Reference files can now be stored on disk instead of having
to be compiled into the test program itself. A couple of
tests have been converted to this more natural structure.
* Several memory leaks corrected so that leaks within libarchive
itself can be more easily detected and diagnosed.
* New test: GNU tar compatibility
* New test: Zip compatibility
* New test: Zero-byte writes to a compressed archive entry
* New test: archive_entry_strmode() format verification
* New test: mtree reader
* New test: write/read of large (2G - 1TB) entries to tar archives
(thanks to recent performance work, this test only requires a few seconds)
* New test: detailed format verification of cpio odc and newc writers
* Many minor additions/improvements to existing tests as well.
Diffstat (limited to 'lib/libarchive/test/test_write_disk_perms.c')
-rw-r--r-- | lib/libarchive/test/test_write_disk_perms.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/libarchive/test/test_write_disk_perms.c b/lib/libarchive/test/test_write_disk_perms.c index accd754..2a5d5fd 100644 --- a/lib/libarchive/test/test_write_disk_perms.c +++ b/lib/libarchive/test/test_write_disk_perms.c @@ -244,16 +244,18 @@ DEFINE_TEST(test_write_disk_perms) failure("Opportunistic SUID failure shouldn't return error."); assertEqualInt(0, archive_write_finish_entry(a)); - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_bad_suid2"); - archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742); - archive_entry_set_uid(ae, getuid() + 1); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER); - assertA(0 == archive_write_header(a, ae)); - /* Owner change should fail here. */ - failure("Non-opportunistic SUID failure should return error."); - assertEqualInt(ARCHIVE_WARN, archive_write_finish_entry(a)); + if (getuid() != 0) { + assert(archive_entry_clear(ae) != NULL); + archive_entry_copy_pathname(ae, "file_bad_suid2"); + archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742); + archive_entry_set_uid(ae, getuid() + 1); + archive_write_disk_set_options(a, + ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER); + assertA(0 == archive_write_header(a, ae)); + /* Owner change should fail here. */ + failure("Non-opportunistic SUID failure should return error."); + assertEqualInt(ARCHIVE_WARN, archive_write_finish_entry(a)); + } /* Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit */ assert(archive_entry_clear(ae) != NULL); @@ -403,10 +405,13 @@ DEFINE_TEST(test_write_disk_perms) failure("file_bad_suid: st.st_mode=%o", st.st_mode); assert((st.st_mode & 07777) == (0742)); - /* SUID bit should NOT have been set here. */ - assert(0 == stat("file_bad_suid2", &st)); - failure("file_bad_suid2: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0742)); + /* Some things don't fail if you're root, so suppress this. */ + if (getuid() != 0) { + /* SUID bit should NOT have been set here. */ + assert(0 == stat("file_bad_suid2", &st)); + failure("file_bad_suid2: st.st_mode=%o", st.st_mode); + assert((st.st_mode & 07777) == (0742)); + } /* SGID should be set here. */ assert(0 == stat("file_perm_sgid", &st)); |