X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/224c70764cab4e0e39a26aaf3ad3016552f62f55..c92a3ae8556c6113025cea583e06396c2824ed41:/posix1e/acl_file.c?ds=sidebyside diff --git a/posix1e/acl_file.c b/posix1e/acl_file.c index 7948bc1..6b62d13 100644 --- a/posix1e/acl_file.c +++ b/posix1e/acl_file.c @@ -37,8 +37,8 @@ #include "aclvar.h" static acl_t acl_get_file1(const char *path, acl_type_t acl_type, int follow); -static int acl_set_file1(const char *path, acl_type_t acl_type, acl_t acl, int follow); +int acl_delete_fd_np(int filedes, acl_type_t type); int acl_delete_fd_np(int filedes, acl_type_t type) { @@ -46,6 +46,7 @@ acl_delete_fd_np(int filedes, acl_type_t type) return(-1); } +int acl_delete_file_np(const char *path, acl_type_t type); int acl_delete_file_np(const char *path, acl_type_t type) { @@ -53,6 +54,7 @@ acl_delete_file_np(const char *path, acl_type_t type) return(-1); } +int acl_delete_link_np(const char *path, acl_type_t type); int acl_delete_link_np(const char *path, acl_type_t type) { @@ -143,17 +145,12 @@ acl_set_fd(int fd, acl_t acl) return(acl_set_fd_np(fd, acl, ACL_TYPE_EXTENDED)); } -static int -acl_set_file1(const char *path, acl_type_t acl_type, acl_t acl, int follow) +int +acl_set_file(const char *path, acl_type_t acl_type, acl_t acl) { filesec_t fsec; int error; - if (follow == 0) { /* XXX this requires some thought - can links have ACLs? */ - errno = ENOTSUP; - return(-1); - } - if ((fsec = filesec_init()) == NULL) return(-1); if (filesec_set_property(fsec, FILESEC_ACL, &acl) != 0) { @@ -165,16 +162,18 @@ acl_set_file1(const char *path, acl_type_t acl_type, acl_t acl, int follow) return((error == 0) ? 0 : -1); } -int -acl_set_file(const char *path, acl_type_t acl_type, acl_t acl) -{ - return(acl_set_file1(path, acl_type, acl, 1)); -} - int acl_set_link_np(const char *path, acl_type_t acl_type, acl_t acl) { - return(acl_set_file1(path, acl_type, acl, 0)); + struct stat s; + + if(lstat(path, &s) < 0) + return(-1); + if(S_ISLNK(s.st_mode)) { + errno = ENOTSUP; + return(-1); + } + return(acl_set_file(path, acl_type, acl)); } /*