diff options
Diffstat (limited to 'lib/libc/posix1e/acl_entry.c')
-rw-r--r-- | lib/libc/posix1e/acl_entry.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/lib/libc/posix1e/acl_entry.c b/lib/libc/posix1e/acl_entry.c index cfb5e80..337340d 100644 --- a/lib/libc/posix1e/acl_entry.c +++ b/lib/libc/posix1e/acl_entry.c @@ -34,32 +34,64 @@ #include <errno.h> #include <stdlib.h> +/* + * acl_create_entry() (23.4.7): create a new ACL entry in the ACL pointed + * to by acl_p. + */ int acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p) { - acl_t acl; + struct acl *acl_int; - if (!acl_p || !*acl_p || ((*acl_p)->acl_cnt >= ACL_MAX_ENTRIES) || - ((*acl_p)->acl_cnt < 0)) { + if (!acl_p) { errno = EINVAL; return -1; } - acl = *acl_p; + acl_int = &(*acl_p)->ats_acl; + + if ((acl_int->acl_cnt >= ACL_MAX_ENTRIES) || (acl_int->acl_cnt < 0)) { + errno = EINVAL; + return -1; + } - *entry_p = &acl->acl_entry[acl->acl_cnt++]; + *entry_p = &acl_int->acl_entry[acl_int->acl_cnt++]; (**entry_p).ae_tag = ACL_UNDEFINED_TAG; (**entry_p).ae_id = ACL_UNDEFINED_ID; (**entry_p).ae_perm = ACL_PERM_NONE; + (*acl_p)->ats_cur_entry = 0; + return 0; } +/* + * acl_get_entry() (23.4.14): returns an ACL entry from an ACL + * indicated by entry_id. + */ int acl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p) { + struct acl *acl_int; + + if (!acl) { + errno = EINVAL; + return -1; + } + acl_int = &acl->ats_acl; + + switch(entry_id) { + case ACL_FIRST_ENTRY: + acl->ats_cur_entry = 0; + /* PASSTHROUGH */ + case ACL_NEXT_ENTRY: + if (acl->ats_cur_entry >= acl->ats_acl.acl_cnt) + return 0; + *entry_p = &acl_int->acl_entry[acl->ats_cur_entry++]; + return 1; + } - errno = ENOSYS; + errno = EINVAL; return -1; } |