aboutsummaryrefslogtreecommitdiffstats
path: root/libarchive/test/test_write_disk_perms.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2018-01-24 11:01:12 +0000
committerMartin Matuska <mm@FreeBSD.org>2018-01-24 11:01:12 +0000
commita2160dbed3dca5a43147e805b79b35f55d150188 (patch)
tree03a9bb1ae2bda0343ac2c16865db6b563969a0e9 /libarchive/test/test_write_disk_perms.c
parent188b0da4f28dc7b295a2a13d917120fc11ee7a0d (diff)
downloadsrc-a2160dbed3dca5a43147e805b79b35f55d150188.tar.gz
src-a2160dbed3dca5a43147e805b79b35f55d150188.zip
Update libarchive to git 2d9156bb3ad92c43c1e81546f4a2c21549ba248f
Relevant vendor changes: PR #893: delete dead ppmd7 alloc callbacks PR #904: Fix archive freeing bug in bsdcat PR #961: Fix ZIP format names PR #962: Don't modify attributes for existing directories when ARCHIVE_EXTRACT_NO_OVERWRITE is set PR #964: Fix -Werror=implicit-fallthrough= for GCC 7 PR #970: zip: Allow backslash as path separator
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=328323
Diffstat (limited to 'libarchive/test/test_write_disk_perms.c')
-rw-r--r--libarchive/test/test_write_disk_perms.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libarchive/test/test_write_disk_perms.c b/libarchive/test/test_write_disk_perms.c
index 4b68e52b4ee5..8205d6abc59a 100644
--- a/libarchive/test/test_write_disk_perms.c
+++ b/libarchive/test/test_write_disk_perms.c
@@ -131,6 +131,8 @@ DEFINE_TEST(test_write_disk_perms)
struct archive *a;
struct archive_entry *ae;
struct stat st;
+ uid_t original_uid;
+ uid_t try_to_change_uid;
assertUmask(UMASK);
@@ -201,6 +203,37 @@ DEFINE_TEST(test_write_disk_perms)
failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode);
assertEqualInt(st.st_mode & 0777, 0744);
+ /* For dir, the owner should get left when not overwritting. */
+ assertMakeDir("dir_owner", 0744);
+
+ if (getuid() == 0) {
+ original_uid = getuid() + 1;
+ try_to_change_uid = getuid();
+ assertEqualInt(0, chown("dir_owner", original_uid, getgid()));
+ } else {
+ original_uid = getuid();
+ try_to_change_uid = getuid() + 1;
+ }
+
+ /* Check original owner. */
+ assertEqualInt(0, stat("dir_owner", &st));
+ failure("dir_owner: st.st_uid=%d", st.st_uid);
+ assertEqualInt(st.st_uid, original_uid);
+ /* Shouldn't try to edit the owner when no overwrite option is set. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "dir_owner");
+ archive_entry_set_mode(ae, S_IFDIR | 0744);
+ archive_entry_set_uid(ae, try_to_change_uid);
+ archive_write_disk_set_options(a,
+ ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_NO_OVERWRITE);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_finish_entry(a));
+ /* Make sure they're unchanged. */
+ assertEqualInt(0, stat("dir_owner", &st));
+ failure("dir_owner: st.st_uid=%d", st.st_uid);
+ assertEqualInt(st.st_uid, original_uid);
+
/* Write a regular file with SUID bit, but don't use _EXTRACT_PERM. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "file_no_suid");