]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Multiple bugfixes for setup_acls() 777/head
authorMartin Matuska <martin@matuska.org>
Mon, 15 Aug 2016 21:54:37 +0000 (23:54 +0200)
committerMartin Matuska <martin@matuska.org>
Sun, 4 Sep 2016 21:58:05 +0000 (23:58 +0200)
CMakeLists.txt
libarchive/archive_read_disk_entry_from_file.c
libarchive/config_freebsd.h

index f5917fbae06d8214f089b50bf7c413ddf5ff4052..1f2466ec60cc2fccbf722748758b5e5c64143ae8 100644 (file)
@@ -1600,6 +1600,7 @@ IF(ENABLE_ACL)
   # test for specific permissions in a permset.)  Linux uses the obvious
   # name, FreeBSD adds _np to mark it as "non-Posix extension."
   # Test for both as a double-check that we really have POSIX-style ACL support.
+  CHECK_FUNCTION_EXISTS(acl_get_fd_np HAVE_ACL_GET_FD_NP)
   CHECK_FUNCTION_EXISTS(acl_get_perm HAVE_ACL_GET_PERM)
   CHECK_FUNCTION_EXISTS(acl_get_perm_np HAVE_ACL_GET_PERM_NP)
   CHECK_FUNCTION_EXISTS(acl_get_link HAVE_ACL_GET_LINK)
index 18963ce11bf54459fa43f9b60c92d16b374a7840..5efee046378c9d45526bd58bf5b990df7c53e2e7 100644 (file)
@@ -419,12 +419,32 @@ setup_acls(struct archive_read_disk *a,
        if (accpath == NULL)
                accpath = archive_entry_pathname(entry);
 
+       if (*fd < 0 && a->tree != NULL) {
+               if (a->follow_symlinks ||
+                   archive_entry_filetype(entry) != AE_IFLNK)
+                       *fd = a->open_on_current_dir(a->tree,
+                           accpath, O_RDONLY | O_NONBLOCK);
+               if (*fd < 0) {
+                       if (a->tree_enter_working_dir(a->tree) != 0) {
+                               archive_set_error(&a->archive, errno,
+                                   "Couldn't access %s", accpath);
+                               return (ARCHIVE_FAILED);
+                       }
+               }
+       }
+
        archive_entry_acl_clear(entry);
 
+       acl = NULL;
+
 #ifdef ACL_TYPE_NFS4
        /* Try NFS4 ACL first. */
        if (*fd >= 0)
+#if HAVE_ACL_GET_FD_NP
+               acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
+#else
                acl = acl_get_fd(*fd);
+#endif
 #if HAVE_ACL_GET_LINK_NP
        else if (!a->follow_symlinks)
                acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
@@ -437,12 +457,19 @@ setup_acls(struct archive_read_disk *a,
 #endif
        else
                acl = acl_get_file(accpath, ACL_TYPE_NFS4);
+
 #if HAVE_ACL_IS_TRIVIAL_NP
-       /* Ignore "trivial" ACLs that just mirror the file mode. */
-       acl_is_trivial_np(acl, &r);
-       if (r) {
-               acl_free(acl);
-               acl = NULL;
+       if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+               /* Ignore "trivial" ACLs that just mirror the file mode. */
+               if (r) {
+                       acl_free(acl);
+                       acl = NULL;
+                       /*
+                        * Simultaneous NFSv4 and POSIX.1e ACLs for the same
+                        * entry are not allowed, so we should return here
+                        */
+                       return (ARCHIVE_OK);
+               }
        }
 #endif
        if (acl != NULL) {
@@ -450,7 +477,7 @@ setup_acls(struct archive_read_disk *a,
                acl_free(acl);
                return (ARCHIVE_OK);
        }
-#endif
+#endif /* ACL_TYPE_NFS4 */
 
        /* Retrieve access ACL from file. */
        if (*fd >= 0)
@@ -467,10 +494,22 @@ setup_acls(struct archive_read_disk *a,
 #endif
        else
                acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+
+#if HAVE_ACL_IS_TRIVIAL_NP
+       /* Ignore "trivial" ACLs that just mirror the file mode. */
+       if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+               if (r) {
+                       acl_free(acl);
+                       acl = NULL;
+               }
+       }
+#endif
+
        if (acl != NULL) {
                translate_acl(a, entry, acl,
                    ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
                acl_free(acl);
+               acl = NULL;
        }
 
        /* Only directories can have default ACLs. */
index 2073431635e9ed39f4291f9150953ce693e4ede7..d3ce373cef0bdd40897cd1334e57e4bf5681d7cd 100644 (file)
@@ -28,6 +28,7 @@
 /* FreeBSD 5.0 and later have ACL and extattr support. */
 #if __FreeBSD__ > 4
 #define        HAVE_ACL_CREATE_ENTRY 1
+#define        HAVE_ACL_GET_FD_NP 1
 #define        HAVE_ACL_GET_LINK_NP 1
 #define        HAVE_ACL_GET_PERM_NP 1
 #define        HAVE_ACL_INIT 1