summaryrefslogtreecommitdiffstats
path: root/lib/libc/posix1e/acl_entry.c
diff options
context:
space:
mode:
authorjedgar <jedgar@FreeBSD.org>2001-04-24 22:45:41 +0000
committerjedgar <jedgar@FreeBSD.org>2001-04-24 22:45:41 +0000
commit2da23531d99e45f34811fd6982a681112de0e182 (patch)
tree0b8830fcccafadf6607f3658e96733124ef8617d /lib/libc/posix1e/acl_entry.c
parentecbf3eacd9a17a3a9b238e2fa65b2d33d85e8d1f (diff)
downloadFreeBSD-src-2da23531d99e45f34811fd6982a681112de0e182.zip
FreeBSD-src-2da23531d99e45f34811fd6982a681112de0e182.tar.gz
o Separate acl_t into internal and external representations as
required by POSIX.1e. This maintains the current 'struct acl' in the kernel while providing the generic external acl_t interface required to complete the ACL editing library. o Add the acl_get_entry() function. o Convert the existing ACL utilities, getfacl and setfacl, to fully make use of the ACL editing library. Obtained from: TrustedBSD Project
Diffstat (limited to 'lib/libc/posix1e/acl_entry.c')
-rw-r--r--lib/libc/posix1e/acl_entry.c44
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;
}
OpenPOWER on IntegriCloud