]> gitweb.michael.orlitzky.com - apply-default-acl.git/blobdiff - src/apply-default-acl.c
Eliminate pointless newline in the signature of acl_set_entry().
[apply-default-acl.git] / src / apply-default-acl.c
index 993b1f7649e14c50300174da1f5d87fcb534d20a..1eb49c44fd88b9d403c2bc0b4c8cce28e1e6ce87 100644 (file)
 
 
 
-/**
- * @brief Get the mode bits from the given file descriptor.
- *
- * @param fd
- *   The file descriptor (which may reference a directory) whose
- *   mode we want.
- *
- * @return A mode_t (st_mode) structure containing the mode bits.
- *   See sys/stat.h for details.
- */
-mode_t get_mode(int fd) {
-  if (fd <= 0) {
-    errno = ENOENT;
-    return ACL_ERROR;
-  }
-
-  struct stat s;
-  int result = fstat(fd, &s);
-
-  if (result == 0) {
-    return s.st_mode;
-  }
-  else {
-    /* errno will be set already by lstat() */
-    return result;
-  }
-}
-
-
 
 /**
  * @brief Determine if the given file descriptor might refer to an
@@ -220,8 +191,7 @@ bool is_directory(int fd) {
  *   returned. Otherwise, @c ACL_SUCCESS.
  *
  */
-int acl_set_entry(acl_t* aclp,
-                 acl_entry_t entry) {
+int acl_set_entry(acl_t* aclp, acl_entry_t entry) {
 
   acl_tag_t entry_tag;
   if (acl_get_tag_type(entry, &entry_tag) == ACL_ERROR) {
@@ -482,8 +452,13 @@ int any_can_execute_or_dir(int fd) {
   int result = ACL_FAILURE;
 
   if (acl_is_minimal(acl)) {
-    mode_t mode = get_mode(fd);
-    if (mode & (S_IXUSR | S_IXOTH | S_IXGRP)) {
+    struct stat s;
+    if (fstat(fd, &s) == -1) {
+      perror("any_can_execute_or_dir (fstat)");
+      result = ACL_ERROR;
+      goto cleanup;
+    }
+    if (s.st_mode & (S_IXUSR | S_IXOTH | S_IXGRP)) {
       result = ACL_SUCCESS;
       goto cleanup;
     }