# Test that one "failure" exit code overrides two "successes"
+# We need a default ACL on ${TESTDIR} because otherwise we do
+# nothing, successfully, on the symlink path.
TESTNUM=37
mkdir "${TESTDIR}/foo"
ln -s foo "${TESTDIR}/bar"
mkdir "${TESTDIR}/baz"
+setfacl --default --modify user:${USERS[0]}:rw "${TESTDIR}"
"${BIN}" "${TESTDIR}/foo" "${TESTDIR}/bar" "${TESTDIR}/baz"
ACTUAL="$?"
EXPECTED="1"
}
+/**
+ * @brief Determine if a file descriptor has a default ACL.
+ *
+ * @param fd
+ * The file descriptor whose default ACL is in question.
+ *
+ * @return
+ * - @c ACL_SUCCESS - If @c fd has a default ACL.
+ * - @c ACL_FAILURE - If @c fd does not have a default ACL.
+ * - @c ACL_ERROR - Unexpected library error.
+ */
+int has_default_acl_fd(int fd) {
+ if (fgetxattr(fd, XATTR_NAME_POSIX_ACL_DEFAULT, NULL, 0) == XATTR_ERROR) {
+ if (errno == ENODATA) {
+ return ACL_FAILURE;
+ }
+ perror("has_default_acl_fd (fgetxattr)");
+ return ACL_ERROR;
+ }
+
+ return ACL_SUCCESS;
+}
+
+
/**
* @brief Apply parent default ACL to a path.
*
}
}
+ /* Check to make sure the parent descriptor actually has a default
+ ACL. If it doesn't, then we can "succeed" immediately. */
+ if (has_default_acl_fd(parent_fd) == ACL_FAILURE) {
+ result = ACL_SUCCESS;
+ goto cleanup;
+ }
+
fd = safe_open(path, O_NOFOLLOW);
if (fd == OPEN_ERROR) {
if (errno == ELOOP || errno == ENOTDIR) {