X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fapply-default-acl.c;h=1d590303462fc601685cfdb2aeb22f6135c6947a;hb=2bc2d104386912d39aa78c6fceb5694014257a7e;hp=29ca5faa9ddde14aa8e0344b1870c2d713705770;hpb=6ac6902a55f6fd0427373db4d6dd5eedb6e330df;p=apply-default-acl.git diff --git a/src/apply-default-acl.c b/src/apply-default-acl.c index 29ca5fa..1d59030 100644 --- a/src/apply-default-acl.c +++ b/src/apply-default-acl.c @@ -92,29 +92,6 @@ bool is_path_directory(const char* path) { } -/** - * @brief Determine whether or not the given file descriptor is for - * a directory. - * - * @param fd - * The file descriptor whose directoryness is in question. - * - * @return true if @c fd describes a directory, and false otherwise. - */ -bool is_directory(int fd) { - if (fd <= 0) { - return false; - } - - struct stat s; - if (fstat(fd, &s) == 0) { - return S_ISDIR(s.st_mode); - } - else { - return false; - } -} - /** @@ -487,7 +464,8 @@ int any_can_execute(int fd) { int assign_default_acl(const char* path, acl_t acl) { if (path == NULL) { - errno = ENOENT; + errno = EINVAL; + perror("assign_default_acl (args)"); return ACL_ERROR; } @@ -641,7 +619,7 @@ int apply_default_acl(const char* path, bool no_exec_mask) { if (!no_exec_mask) { /* Never mask the execute bit on directories. */ - int ace_result = any_can_execute(fd) || is_directory(fd); + int ace_result = any_can_execute(fd) || S_ISDIR(s.st_mode); if (ace_result == ACL_ERROR) { perror("apply_default_acl (any_can_execute)");