* @param fd
* The file descriptor to check.
*
+ * @param sp
+ * A pointer to a stat structure for @c fd.
+ *
* @return
* - @c ACL_SUCCESS - Someone has effective execute permissions on @c fd.
* - @c ACL_FAILURE - Nobody can execute @c fd.
* - @c ACL_ERROR - Unexpected library error.
*/
-int any_can_execute(int fd) {
+int any_can_execute(int fd, const struct stat* sp) {
acl_t acl = acl_get_fd(fd);
if (acl == (acl_t)NULL) {
int result = ACL_FAILURE;
if (acl_is_minimal(acl)) {
- struct stat s;
- if (fstat(fd, &s) == -1) {
- perror("any_can_execute (fstat)");
- result = ACL_ERROR;
- goto cleanup;
- }
- if (s.st_mode & (S_IXUSR | S_IXOTH | S_IXGRP)) {
+ if (sp->st_mode & (S_IXUSR | S_IXOTH | S_IXGRP)) {
result = ACL_SUCCESS;
goto cleanup;
}
if (!no_exec_mask) {
/* Never mask the execute bit on directories. */
- int ace_result = any_can_execute(fd) || S_ISDIR(sp->st_mode);
+ int ace_result = any_can_execute(fd,sp) || S_ISDIR(sp->st_mode);
if (ace_result == ACL_ERROR) {
perror("apply_default_acl (any_can_execute)");