summaryrefslogtreecommitdiffstats
path: root/lib/libc/posix1e/acl_set.c
diff options
context:
space:
mode:
authorjedgar <jedgar@FreeBSD.org>2001-03-22 22:31:01 +0000
committerjedgar <jedgar@FreeBSD.org>2001-03-22 22:31:01 +0000
commita2c2ce60b3075656d05b60cdc57e87a284637374 (patch)
tree4ef0b68e84c3b26506377d62e3387915a6738e83 /lib/libc/posix1e/acl_set.c
parenteee9cab668b487432cc086947e228ad81ea24422 (diff)
downloadFreeBSD-src-a2c2ce60b3075656d05b60cdc57e87a284637374.zip
FreeBSD-src-a2c2ce60b3075656d05b60cdc57e87a284637374.tar.gz
Add the following ACL editing functions:
acl_add_perm, acl_clear_perms, acl_copy_entry, acl_create_entry, acl_delete_perm, acl_get_permset, acl_get_qualifier, acl_get_tag_type, acl_set_permset, acl_set_qualifier, acl_set_tag_type This brings us within 4 functions of a full ACL editing library. Reviewed by: rwatson
Diffstat (limited to 'lib/libc/posix1e/acl_set.c')
-rw-r--r--lib/libc/posix1e/acl_set.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/libc/posix1e/acl_set.c b/lib/libc/posix1e/acl_set.c
index e4bd9ed..58be508 100644
--- a/lib/libc/posix1e/acl_set.c
+++ b/lib/libc/posix1e/acl_set.c
@@ -31,7 +31,10 @@
#include <sys/types.h>
#include <sys/acl.h>
+
#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
#include "acl_support.h"
@@ -86,3 +89,74 @@ acl_set_fd_np(int fd, acl_t acl, acl_type_t type)
return (__acl_set_fd(fd, type, acl));
}
+
+/*
+ * acl_set_permset() sets the permissions of ACL entry entry_d
+ * with the permissions in permset_d
+ */
+int
+acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d)
+{
+
+ if (!entry_d) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ entry_d->ae_perm = *permset_d;
+
+ return 0;
+}
+
+/*
+ * acl_set_qualifier() sets the qualifier (ae_id) of the tag for
+ * ACL entry entry_d to the value referred to by tag_qualifier_p
+ */
+int
+acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p)
+{
+ if (!entry_d || !tag_qualifier_p) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ switch(entry_d->ae_tag) {
+ case ACL_USER:
+ case ACL_GROUP:
+ entry_d->ae_id = (uid_t)tag_qualifier_p;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * acl_set_tag_type() sets the tag type for ACL entry entry_d to the
+ * value of tag_type
+ */
+int
+acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type)
+{
+
+ if (!entry_d) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ switch(tag_type) {
+ case ACL_USER_OBJ:
+ case ACL_USER:
+ case ACL_GROUP_OBJ:
+ case ACL_GROUP:
+ case ACL_MASK:
+ case ACL_OTHER:
+ entry_d->ae_tag = tag_type;
+ return 0;
+ }
+
+ errno = EINVAL;
+ return -1;
+}
OpenPOWER on IntegriCloud