From c86a532bb3c052c423a1e7ffddaa253c73e7267d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 8 Aug 2012 19:47:32 -0400 Subject: [PATCH] Add some non-working junk. --- src/aclq.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/src/aclq.c b/src/aclq.c index 495196d..4f9ad72 100644 --- a/src/aclq.c +++ b/src/aclq.c @@ -8,6 +8,7 @@ #include #include + bool has_default_acl(const char* path) { /* Return true if the given path has a default ACL, false otherwise. */ @@ -55,7 +56,7 @@ bool has_default_tag_acl(const char* path, acl_tag_t tag_type) { int tag_result = acl_get_tag_type(entry, &tag); if (tag_result == -1) { - perror("has_default_tag_acl"); + perror("has_default_tag_acl - acl_get_tag_type"); return false; } else { @@ -87,12 +88,13 @@ bool has_default_other_obj_acl(const char* path) { int get_default_tag_permset(const char* path, acl_tag_t tag_type, acl_permset_t* output_perms) { - /* Return true if the given path has a default ACL for the supplied - tag, false otherwise. */ + /* Returns 0 if successful or -1 on error in accordance with + acl_get_permset. */ acl_t defacl = acl_get_file(path, ACL_TYPE_DEFAULT); if (defacl == (acl_t)NULL) { /* Follow the acl_foo convention of -1 == error. */ + errno = EINVAL; return -1; } @@ -116,8 +118,9 @@ int get_default_tag_permset(const char* path, result = acl_get_entry(defacl, ACL_NEXT_ENTRY, &entry); } - - return false; + + errno = EINVAL; + return -1; } int get_default_user_obj_permset(const char* path, @@ -136,6 +139,42 @@ int get_default_other_obj_permset(const char* path, } + +bool has_default_tag_perm(const char* path, acl_perm_t, perm) { + acl_permset_t permset; + int ps_result = get_default_tag_permset(path, tag, &permset); + + if (ps_result == -1) { + perror("has_default_tag_perm - get_default_tag_permset"); + return false; + } + + int p_result = acl_get_perm(permset, perm); + if (p_result == 1) { + return true; + } + else if (p_result == 0) { + return false; + } + else { + /* p_result == -1 */ + perror("has_default_tag_perm - get_default_tag_permset"); + return false; + } +} + +bool has_default_user_obj_read(const char* path) { + return has_default_tag_perm(ACL_USER_OBJ, ACL_READ); +} + +bool has_default_user_obj_write(const char* path) { + return has_default_tag_perm(ACL_USER_OBJ, ACL_WRITE); +} + +bool has_default_user_obj_execute(const char* path) { + return has_default_tag_perm(ACL_USER_OBJ, ACL_EXECUTE); +} + int main(int argc, char* argv[]) { const char* target = argv[1]; printf("Target: %s\n", target); -- 2.43.2