- if (path_acl == (acl_t)NULL) {
- perror("assign_default_acl (acl_dup)");
- return ACL_ERROR; /* Nothing to clean up in this case. */
+ size_t src_size_guess = fgetxattr(src_fd, src_name, NULL, 0);
+ if (src_size_guess == XATTR_ERROR) {
+ if (errno == ENODATA) {
+ /* A missing ACL isn't really an error. ENOATTR and ENODATA are
+ synonyms, but using ENODATA here lets us avoid another
+ "include" directive. */
+ return ACL_FAILURE;
+ }
+ perror("acl_copy_xattr (fgetxattr size guess)");
+ return ACL_ERROR;
+ }
+ char* src_acl_p = alloca(src_size_guess);
+ /* The actual size may be smaller than our guess? I don't know. */
+ size_t src_size = fgetxattr(src_fd, src_name, src_acl_p, (int)src_size_guess);
+ if (src_size == XATTR_ERROR) {
+ if (errno == ENODATA) {
+ /* A missing ACL isn't an error. */
+ return ACL_FAILURE;
+ }
+ perror("acl_copy_xattr (fgetxattr)");
+ return ACL_ERROR;