From 72f27f2fbf620439935bd961ba2350d6d10654b6 Mon Sep 17 00:00:00 2001 From: Aneesh Kumar K.V Date: Fri, 13 Nov 2009 22:48:41 +0530 Subject: [PATCH 1/5] richacl: Rename the tools as richacl-tools. Rename the acl as richacl along with kernel changes. Linux kernel already have an exported nfsv4 acl interface via nfsv4 client. So having another nfs4acl-tools will create confusion. Signed-off-by: Aneesh Kumar K.V --- Makefile | 20 +- include/{nfs4acl-internal.h => richacl-internal.h} | 18 +- include/{nfs4acl.h => richacl.h} | 84 +++--- include/{nfs4acl_xattr.h => richacl_xattr.h} | 12 +- lib/{nfs4acl.c => richacl.c} | 322 ++++++++++---------- lib/{nfs4acl_compat.c => richacl_compat.c} | 270 ++++++++-------- src/{nfs4acl.c => richacl.c} | 134 ++++---- 7 files changed, 430 insertions(+), 430 deletions(-) rename include/{nfs4acl-internal.h => richacl-internal.h} (62%) rename include/{nfs4acl.h => richacl.h} (57%) rename include/{nfs4acl_xattr.h => richacl_xattr.h} (66%) rename lib/{nfs4acl.c => richacl.c} (74%) rename lib/{nfs4acl_compat.c => richacl_compat.c} (69%) rename src/{nfs4acl.c => richacl.c} (74%) diff --git a/Makefile b/Makefile index 84a5711..6eb8a67 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -NAME := nfs4acl +NAME := richacl VERSION := 0.9 -INCLUDE_SOURCES := include/nfs4acl.h include/nfs4acl_xattr.h include/nfs4acl-internal.h include/string_buffer.h -SRC_SOURCES := src/nfs4acl.c -LIB_SOURCES := lib/nfs4acl.c lib/nfs4acl_compat.c lib/string_buffer.c +INCLUDE_SOURCES := include/richacl.h include/richacl_xattr.h include/richacl-internal.h include/string_buffer.h +SRC_SOURCES := src/richacl.c +LIB_SOURCES := lib/richacl.c lib/richacl_compat.c lib/string_buffer.c TESTS := test/run $(wildcard test/*.test) SOURCES := Makefile $(INCLUDE_SOURCES) $(SRC_SOURCES) $(LIB_SOURCES) @@ -11,12 +11,12 @@ CPPFLAGS := -Iinclude CFLAGS := -g -Wall -DVERSION=\"$(VERSION)\" LDFLAGS := -g -all: src/nfs4acl +all: src/richacl -src/nfs4acl : src/nfs4acl.o lib/libnfs4acl.a +src/richacl : src/richacl.o lib/librichacl.a $(CC) $(LDFLAGS) -o $@ $+ -lib/libnfs4acl.a : lib/nfs4acl.o lib/string_buffer.o lib/nfs4acl_compat.o +lib/librichacl.a : lib/richacl.o lib/string_buffer.o lib/richacl_compat.o $(RM) -f $@ $(AR) r $@ $+ @@ -32,9 +32,9 @@ install: all $(INSTALL) -d -m 755 $(DESTDIR)$(includedir)/$(NAME) for file in $(INCLUDE_SOURCES) ; do $(INSTALL) -m 644 $$file $(DESTDIR)$(includedir)/$(NAME) ; done $(INSTALL) -d -m 755 $(DESTDIR)$(libdir) - $(INSTALL) -m 644 lib/libnfs4acl.a $(DESTDIR)$(libdir) + $(INSTALL) -m 644 lib/librichacl.a $(DESTDIR)$(libdir) $(INSTALL) -d -m 755 $(DESTDIR)$(sbindir) - $(INSTALL) -m 755 src/nfs4acl $(DESTDIR)$(sbindir) + $(INSTALL) -m 755 src/richacl $(DESTDIR)$(sbindir) $(INSTALL) -d -m 755 $(DESTDIR)$(pkgdatadir)/test for file in $(TESTS) ; do $(INSTALL) -m 644 $$file $(DESTDIR)$(pkgdatadir)/test ; done chmod 755 $(DESTDIR)$(pkgdatadir)/test/run @@ -46,4 +46,4 @@ dist: rm -f $(NAME)-$(VERSION) clean: - rm -f src/nfs4acl.o lib/libnfs4acl.a lib/nfs4acl.o lib/string_buffer.o lib/nfs4acl_compat.o + rm -f src/richacl src/richacl.o lib/librichacl.a lib/richacl.o lib/string_buffer.o lib/richacl_compat.o diff --git a/include/nfs4acl-internal.h b/include/richacl-internal.h similarity index 62% rename from include/nfs4acl-internal.h rename to include/richacl-internal.h index 3838d00..0727724 100644 --- a/include/nfs4acl-internal.h +++ b/include/richacl-internal.h @@ -1,5 +1,5 @@ -#ifndef __NFS4ACL_INTERNAL_H -#define __NFS4ACL_INTERNAL_H +#ifndef __RICHACL_INTERNAL_H +#define __RICHACL_INTERNAL_H /* * The ACE4_READ_ATTRIBUTES and ACE4_READ_ACL flags are always granted @@ -14,7 +14,7 @@ #define ACE4_SPECIAL_WHO 0x4000 /* internal to the library */ static inline void -nfs4ace_clear_inheritance_flags(struct nfs4ace *ace) +richace_clear_inheritance_flags(struct richace *ace) { ace->e_flags &= ~(ACE4_FILE_INHERIT_ACE | ACE4_DIRECTORY_INHERIT_ACE | @@ -22,19 +22,19 @@ nfs4ace_clear_inheritance_flags(struct nfs4ace *ace) ACE4_INHERIT_ONLY_ACE); } -static inline int nfs4ace_is_inheritable(const struct nfs4ace *ace) +static inline int richace_is_inheritable(const struct richace *ace) { return ace->e_flags & (ACE4_FILE_INHERIT_ACE | ACE4_DIRECTORY_INHERIT_ACE); } -static inline int nfs4ace_is_inherit_only(const struct nfs4ace *ace) +static inline int richace_is_inherit_only(const struct richace *ace) { return ace->e_flags & ACE4_INHERIT_ONLY_ACE; } -extern const char *nfs4ace_owner_who; -extern const char *nfs4ace_group_who; -extern const char *nfs4ace_everyone_who; +extern const char *richace_owner_who; +extern const char *richace_group_who; +extern const char *richace_everyone_who; -#endif /* __NFS4ACL_INTERNAL_H */ +#endif /* __RICHACL_INTERNAL_H */ diff --git a/include/nfs4acl.h b/include/richacl.h similarity index 57% rename from include/nfs4acl.h rename to include/richacl.h index ab8fd9e..bb708fa 100644 --- a/include/nfs4acl.h +++ b/include/richacl.h @@ -1,5 +1,5 @@ -#ifndef __NFS4ACL_H -#define __NFS4ACL_H +#ifndef __RICHACL_H +#define __RICHACL_H #include #include @@ -71,7 +71,7 @@ ACE4_WRITE_OWNER | \ ACE4_SYNCHRONIZE ) -struct nfs4ace { +struct richace { unsigned short e_type; unsigned short e_flags; unsigned int e_mask; @@ -81,75 +81,75 @@ struct nfs4ace { } u; }; -struct nfs4acl { +struct richacl { unsigned char a_flags; unsigned short a_count; unsigned int a_owner_mask; unsigned int a_group_mask; unsigned int a_other_mask; - struct nfs4ace a_entries[0]; + struct richace a_entries[0]; }; -#define nfs4acl_for_each_entry(_ace, _acl) \ +#define richacl_for_each_entry(_ace, _acl) \ for ((_ace) = (_acl)->a_entries; \ (_ace) != (_acl)->a_entries + (_acl)->a_count; \ (_ace)++) -#define nfs4acl_for_each_entry_reverse(_ace, _acl) \ +#define richacl_for_each_entry_reverse(_ace, _acl) \ for ((_ace) = (_acl)->a_entries + (_acl)->a_count - 1; \ (_ace) != (_acl)->a_entries - 1; \ (_ace)--) -/* nfs4acl_to_text flags */ -#define NFS4ACL_TEXT_LONG 1 -#define NFS4ACL_TEXT_FILE_CONTEXT 2 -#define NFS4ACL_TEXT_DIRECTORY_CONTEXT 4 -#define NFS4ACL_TEXT_SHOW_MASKS 8 -#define NFS4ACL_TEXT_SIMPLIFY 16 +/* richacl_to_text flags */ +#define RICHACL_TEXT_LONG 1 +#define RICHACL_TEXT_FILE_CONTEXT 2 +#define RICHACL_TEXT_DIRECTORY_CONTEXT 4 +#define RICHACL_TEXT_SHOW_MASKS 8 +#define RICHACL_TEXT_SIMPLIFY 16 -/* nfs4acl_from_text flags */ -#define NFS4ACL_TEXT_OWNER_MASK 1 -#define NFS4ACL_TEXT_GROUP_MASK 2 -#define NFS4ACL_TEXT_OTHER_MASK 4 -#define NFS4ACL_TEXT_FLAGS 8 +/* richacl_from_text flags */ +#define RICHACL_TEXT_OWNER_MASK 1 +#define RICHACL_TEXT_GROUP_MASK 2 +#define RICHACL_TEXT_OTHER_MASK 4 +#define RICHACL_TEXT_FLAGS 8 -extern int nfs4ace_is_owner(const struct nfs4ace *); -extern int nfs4ace_is_group(const struct nfs4ace *); -extern int nfs4ace_is_everyone(const struct nfs4ace *); +extern int richace_is_owner(const struct richace *); +extern int richace_is_group(const struct richace *); +extern int richace_is_everyone(const struct richace *); -static inline int nfs4ace_is_allow(const struct nfs4ace *ace) +static inline int richace_is_allow(const struct richace *ace) { return ace->e_type == ACE4_ACCESS_ALLOWED_ACE_TYPE; } -static inline int nfs4ace_is_deny(const struct nfs4ace *ace) +static inline int richace_is_deny(const struct richace *ace) { return ace->e_type == ACE4_ACCESS_DENIED_ACE_TYPE; } -extern const char *nfs4ace_get_who(const struct nfs4ace *); +extern const char *richace_get_who(const struct richace *); -extern int nfs4ace_set_who(struct nfs4ace *, const char *); -extern void nfs4ace_set_uid(struct nfs4ace *, uid_t); -extern void nfs4ace_set_gid(struct nfs4ace *, gid_t); -extern int nfs4ace_is_same_identifier(const struct nfs4ace *, const struct nfs4ace *); -extern void nfs4ace_copy(struct nfs4ace *, const struct nfs4ace *); +extern int richace_set_who(struct richace *, const char *); +extern void richace_set_uid(struct richace *, uid_t); +extern void richace_set_gid(struct richace *, gid_t); +extern int richace_is_same_identifier(const struct richace *, const struct richace *); +extern void richace_copy(struct richace *, const struct richace *); -extern struct nfs4acl *nfs4acl_get_file(const char *); -extern struct nfs4acl *nfs4acl_get_fd(int); -extern int nfs4acl_set_file(const char *, const struct nfs4acl *); -extern int nfs4acl_set_fd(int, const struct nfs4acl *); +extern struct richacl *richacl_get_file(const char *); +extern struct richacl *richacl_get_fd(int); +extern int richacl_set_file(const char *, const struct richacl *); +extern int richacl_set_fd(int, const struct richacl *); -extern char *nfs4acl_to_text(const struct nfs4acl *, int); -extern struct nfs4acl *nfs4acl_from_text(const char *, int *, +extern char *richacl_to_text(const struct richacl *, int); +extern struct richacl *richacl_from_text(const char *, int *, void (*)(const char *, ...)); -extern struct nfs4acl *nfs4acl_alloc(size_t); -extern struct nfs4acl *nfs4acl_clone(struct nfs4acl *); -extern void nfs4acl_free(struct nfs4acl *); +extern struct richacl *richacl_alloc(size_t); +extern struct richacl *richacl_clone(struct richacl *); +extern void richacl_free(struct richacl *); -extern int nfs4acl_apply_masks(struct nfs4acl **); -extern void nfs4acl_compute_max_masks(struct nfs4acl *); -extern struct nfs4acl *nfs4acl_from_mode(mode_t); +extern int richacl_apply_masks(struct richacl **); +extern void richacl_compute_max_masks(struct richacl *); +extern struct richacl *richacl_from_mode(mode_t); -#endif /* __NFS4ACL_H */ +#endif /* __RICHACL_H */ diff --git a/include/nfs4acl_xattr.h b/include/richacl_xattr.h similarity index 66% rename from include/nfs4acl_xattr.h rename to include/richacl_xattr.h index ff89ff7..517dd3f 100644 --- a/include/nfs4acl_xattr.h +++ b/include/richacl_xattr.h @@ -1,10 +1,10 @@ -#ifndef __NFS4ACL_XATTR_H -#define __NFS4ACL_XATTR_H +#ifndef __RICHACL_XATTR_H +#define __RICHACL_XATTR_H #include #include -struct nfs4ace_xattr { +struct richace_xattr { uint16_t e_type; uint16_t e_flags; uint32_t e_mask; @@ -12,7 +12,7 @@ struct nfs4ace_xattr { char e_who[0]; }; -struct nfs4acl_xattr { +struct richacl_xattr { unsigned char a_version; unsigned char a_flags; uint16_t a_count; @@ -21,8 +21,8 @@ struct nfs4acl_xattr { uint32_t a_other_mask; }; -#define SYSTEM_NFS4ACL "system.nfs4acl" +#define SYSTEM_RICHACL "system.richacl" #define ACL4_XATTR_VERSION 0 #define ACL4_XATTR_MAX_COUNT 1024 -#endif /* __NFS4ACL_XATTR_H */ +#endif /* __RICHACL_XATTR_H */ diff --git a/lib/nfs4acl.c b/lib/richacl.c similarity index 74% rename from lib/nfs4acl.c rename to lib/richacl.c index 8b75a40..f8bbe92 100644 --- a/lib/nfs4acl.c +++ b/lib/richacl.c @@ -9,16 +9,16 @@ #include #include #include "string_buffer.h" -#include "nfs4acl.h" -#include "nfs4acl_xattr.h" -#include "nfs4acl-internal.h" +#include "richacl.h" +#include "richacl_xattr.h" +#include "richacl-internal.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ALIGN(x,a) (((x)+(a)-1)&~((a)-1)) -const char *nfs4ace_owner_who = "OWNER@"; -const char *nfs4ace_group_who = "GROUP@"; -const char *nfs4ace_everyone_who = "EVERYONE@"; +const char *richace_owner_who = "OWNER@"; +const char *richace_group_who = "GROUP@"; +const char *richace_everyone_who = "EVERYONE@"; /* * The POSIX permissions are supersets of the following mask flags. @@ -70,12 +70,12 @@ static struct { #undef FLAGS_BIT #define MASK_BIT(c, name, str) \ - { ACE4_ ## name, c, str, NFS4ACL_TEXT_FILE_CONTEXT | \ - NFS4ACL_TEXT_DIRECTORY_CONTEXT } + { ACE4_ ## name, c, str, RICHACL_TEXT_FILE_CONTEXT | \ + RICHACL_TEXT_DIRECTORY_CONTEXT } #define FILE_MASK_BIT(c, name, str) \ - { ACE4_ ## name, c, str, NFS4ACL_TEXT_FILE_CONTEXT } + { ACE4_ ## name, c, str, RICHACL_TEXT_FILE_CONTEXT } #define DIRECTORY_MASK_BIT(c, name, str) \ - { ACE4_ ## name, c, str, NFS4ACL_TEXT_DIRECTORY_CONTEXT } + { ACE4_ ## name, c, str, RICHACL_TEXT_DIRECTORY_CONTEXT } struct { uint32_t e_mask; @@ -107,14 +107,14 @@ struct { #undef FILE_MASK_BIT #undef DIRECTORY_MASK_BIT -const char *nfs4ace_get_who(const struct nfs4ace *ace) +const char *richace_get_who(const struct richace *ace) { if (!(ace->e_flags & ACE4_SPECIAL_WHO)) return NULL; return ace->u.e_who; } -int nfs4ace_is_same_identifier(const struct nfs4ace *a, const struct nfs4ace *b) +int richace_is_same_identifier(const struct richace *a, const struct richace *b) { #define WHO_FLAGS (ACE4_SPECIAL_WHO | ACE4_IDENTIFIER_GROUP) if ((a->e_flags & WHO_FLAGS) != (b->e_flags & WHO_FLAGS)) @@ -126,28 +126,28 @@ int nfs4ace_is_same_identifier(const struct nfs4ace *a, const struct nfs4ace *b) #undef WHO_FLAGS } -int nfs4ace_is_owner(const struct nfs4ace *ace) +int richace_is_owner(const struct richace *ace) { return (ace->e_flags & ACE4_SPECIAL_WHO) && - ace->u.e_who == nfs4ace_owner_who; + ace->u.e_who == richace_owner_who; } -int nfs4ace_is_group(const struct nfs4ace *ace) +int richace_is_group(const struct richace *ace) { return (ace->e_flags & ACE4_SPECIAL_WHO) && - ace->u.e_who == nfs4ace_group_who; + ace->u.e_who == richace_group_who; } -int nfs4ace_is_everyone(const struct nfs4ace *ace) +int richace_is_everyone(const struct richace *ace) { return (ace->e_flags & ACE4_SPECIAL_WHO) && - ace->u.e_who == nfs4ace_everyone_who; + ace->u.e_who == richace_everyone_who; } -struct nfs4acl *nfs4acl_alloc(size_t count) +struct richacl *richacl_alloc(size_t count) { - size_t size = sizeof(struct nfs4acl) + count * sizeof(struct nfs4ace); - struct nfs4acl *acl = malloc(size); + size_t size = sizeof(struct richacl) + count * sizeof(struct richace); + struct richacl *acl = malloc(size); if (acl) { memset(acl, 0, size); @@ -156,45 +156,45 @@ struct nfs4acl *nfs4acl_alloc(size_t count) return acl; } -struct nfs4acl *nfs4acl_clone(struct nfs4acl *acl) +struct richacl *richacl_clone(struct richacl *acl) { size_t size; - struct nfs4acl *acl2; + struct richacl *acl2; if (!acl) return NULL; - size = sizeof(struct nfs4acl) + acl->a_count * sizeof(struct nfs4ace); + size = sizeof(struct richacl) + acl->a_count * sizeof(struct richace); acl2 = malloc(size); if (acl2) memcpy(acl2, acl, size); return acl2; } -void nfs4acl_free(struct nfs4acl *acl) +void richacl_free(struct richacl *acl) { free(acl); } /** - * nfs4acl_allowed_to_who - mask flags allowed to a specific who value + * richacl_allowed_to_who - mask flags allowed to a specific who value * * Computes the mask values allowed to a specific who value, taking * EVERYONE@ entries into account. */ -static unsigned int nfs4acl_allowed_to_who(struct nfs4acl *acl, - struct nfs4ace *who) +static unsigned int richacl_allowed_to_who(struct richacl *acl, + struct richace *who) { - struct nfs4ace *ace; + struct richace *ace; unsigned int allowed = 0; - nfs4acl_for_each_entry_reverse(ace, acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry_reverse(ace, acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_same_identifier(ace, who) || - nfs4ace_is_everyone(ace)) { - if (nfs4ace_is_allow(ace)) + if (richace_is_same_identifier(ace, who) || + richace_is_everyone(ace)) { + if (richace_is_allow(ace)) allowed |= ace->e_mask; - else if (nfs4ace_is_deny(ace)) + else if (richace_is_deny(ace)) allowed &= ~ace->e_mask; } } @@ -202,49 +202,49 @@ static unsigned int nfs4acl_allowed_to_who(struct nfs4acl *acl, } /** - * nfs4acl_compute_max_masks - compute upper bound masks + * richacl_compute_max_masks - compute upper bound masks * * Computes upper bound owner, group, and other masks so that none of * the mask flags allowed by the acl are disabled (for any choice of the * file owner or group membership). */ -void nfs4acl_compute_max_masks(struct nfs4acl *acl) +void richacl_compute_max_masks(struct richacl *acl) { - struct nfs4ace *ace; + struct richace *ace; acl->a_owner_mask = 0; acl->a_group_mask = 0; acl->a_other_mask = 0; - nfs4acl_for_each_entry_reverse(ace, acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry_reverse(ace, acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_owner(ace)) { - if (nfs4ace_is_allow(ace)) + if (richace_is_owner(ace)) { + if (richace_is_allow(ace)) acl->a_owner_mask |= ace->e_mask; - else if (nfs4ace_is_deny(ace)) + else if (richace_is_deny(ace)) acl->a_owner_mask &= ~ace->e_mask; - } else if (nfs4ace_is_everyone(ace)) { - if (nfs4ace_is_allow(ace)) { - struct nfs4ace who = { + } else if (richace_is_everyone(ace)) { + if (richace_is_allow(ace)) { + struct richace who = { .e_flags = ACE4_SPECIAL_WHO, - .u.e_who = nfs4ace_group_who, + .u.e_who = richace_group_who, }; acl->a_other_mask |= ace->e_mask; acl->a_group_mask |= - nfs4acl_allowed_to_who(acl, &who); + richacl_allowed_to_who(acl, &who); acl->a_owner_mask |= ace->e_mask; - } else if (nfs4ace_is_deny(ace)) { + } else if (richace_is_deny(ace)) { acl->a_other_mask &= ~ace->e_mask; acl->a_group_mask &= ~ace->e_mask; acl->a_owner_mask &= ~ace->e_mask; } } else { - if (nfs4ace_is_allow(ace)) { + if (richace_is_allow(ace)) { unsigned int mask = - nfs4acl_allowed_to_who(acl, ace); + richacl_allowed_to_who(acl, ace); acl->a_group_mask |= mask; acl->a_owner_mask |= mask; @@ -253,15 +253,15 @@ void nfs4acl_compute_max_masks(struct nfs4acl *acl) } } -static struct nfs4acl *nfs4acl_from_xattr(const void *value, size_t size) +static struct richacl *richacl_from_xattr(const void *value, size_t size) { - const struct nfs4acl_xattr *xattr_acl = value; - const struct nfs4ace_xattr *xattr_ace = (void *)(xattr_acl + 1); - struct nfs4acl *acl = NULL; - struct nfs4ace *ace; + const struct richacl_xattr *xattr_acl = value; + const struct richace_xattr *xattr_ace = (void *)(xattr_acl + 1); + struct richacl *acl = NULL; + struct richace *ace; int count; - if (size < sizeof(struct nfs4acl_xattr) || + if (size < sizeof(struct richacl_xattr) || xattr_acl->a_version != ACL4_XATTR_VERSION) goto fail_einval; @@ -269,7 +269,7 @@ static struct nfs4acl *nfs4acl_from_xattr(const void *value, size_t size) if (count > ACL4_XATTR_MAX_COUNT) goto fail_einval; - acl = nfs4acl_alloc(count); + acl = richacl_alloc(count); if (!acl) return NULL; @@ -278,7 +278,7 @@ static struct nfs4acl *nfs4acl_from_xattr(const void *value, size_t size) acl->a_group_mask = ntohl(xattr_acl->a_group_mask); acl->a_other_mask = ntohl(xattr_acl->a_other_mask); - nfs4acl_for_each_entry(ace, acl) { + richacl_for_each_entry(ace, acl) { const char *who = (void *)(xattr_ace + 1), *end; ssize_t used = (void *)who - value; @@ -296,7 +296,7 @@ static struct nfs4acl *nfs4acl_from_xattr(const void *value, size_t size) if (who == end) { if (ace->u.e_id == -1) goto fail_einval; /* uid/gid needed */ - } else if (nfs4ace_set_who(ace, who)) + } else if (richace_set_who(ace, who)) goto fail_einval; xattr_ace = (void *)who + ALIGN(end - who + 1, 4); @@ -305,29 +305,29 @@ static struct nfs4acl *nfs4acl_from_xattr(const void *value, size_t size) return acl; fail_einval: - nfs4acl_free(acl); + richacl_free(acl); errno = EINVAL; return NULL; } -static size_t nfs4acl_xattr_size(const struct nfs4acl *acl) +static size_t richacl_xattr_size(const struct richacl *acl) { - size_t size = sizeof(struct nfs4acl_xattr); - const struct nfs4ace *ace; + size_t size = sizeof(struct richacl_xattr); + const struct richace *ace; - nfs4acl_for_each_entry(ace, acl) { - size += sizeof(struct nfs4ace_xattr) + - (nfs4ace_get_who(ace) ? + richacl_for_each_entry(ace, acl) { + size += sizeof(struct richace_xattr) + + (richace_get_who(ace) ? ALIGN(strlen(ace->u.e_who) + 1, 4) : 4); } return size; } -static void nfs4acl_to_xattr(const struct nfs4acl *acl, void *buffer) +static void richacl_to_xattr(const struct richacl *acl, void *buffer) { - struct nfs4acl_xattr *xattr_acl = buffer; - struct nfs4ace_xattr *xattr_ace; - const struct nfs4ace *ace; + struct richacl_xattr *xattr_acl = buffer; + struct richace_xattr *xattr_ace; + const struct richace *ace; xattr_acl->a_version = ACL4_XATTR_VERSION; xattr_acl->a_flags = acl->a_flags; @@ -338,11 +338,11 @@ static void nfs4acl_to_xattr(const struct nfs4acl *acl, void *buffer) xattr_acl->a_other_mask = htonl(acl->a_other_mask); xattr_ace = (void *)(xattr_acl + 1); - nfs4acl_for_each_entry(ace, acl) { + richacl_for_each_entry(ace, acl) { xattr_ace->e_type = htons(ace->e_type); xattr_ace->e_flags = htons(ace->e_flags & ACE4_VALID_FLAGS); xattr_ace->e_mask = htonl(ace->e_mask); - if (nfs4ace_get_who(ace)) { + if (richace_get_who(ace)) { int sz = ALIGN(strlen(ace->u.e_who) + 1, 4); xattr_ace->e_id = htonl(-1); @@ -357,60 +357,60 @@ static void nfs4acl_to_xattr(const struct nfs4acl *acl, void *buffer) } } -struct nfs4acl *nfs4acl_get_file(const char *path) +struct richacl *richacl_get_file(const char *path) { void *value; ssize_t retval; - struct nfs4acl *acl; + struct richacl *acl; - retval = getxattr(path, SYSTEM_NFS4ACL, NULL, 0); + retval = getxattr(path, SYSTEM_RICHACL, NULL, 0); if (retval <= 0) return NULL; value = alloca(retval); if (!value) return NULL; - retval = getxattr(path, SYSTEM_NFS4ACL, value, retval); - acl = nfs4acl_from_xattr(value, retval); + retval = getxattr(path, SYSTEM_RICHACL, value, retval); + acl = richacl_from_xattr(value, retval); return acl; } -struct nfs4acl *nfs4acl_get_fd(int fd) +struct richacl *richacl_get_fd(int fd) { void *value; ssize_t retval; - struct nfs4acl *acl; + struct richacl *acl; - retval = fgetxattr(fd, SYSTEM_NFS4ACL, NULL, 0); + retval = fgetxattr(fd, SYSTEM_RICHACL, NULL, 0); if (retval <= 0) return NULL; value = alloca(retval); if (!value) return NULL; - retval = fgetxattr(fd, SYSTEM_NFS4ACL, value, retval); - acl = nfs4acl_from_xattr(value, retval); + retval = fgetxattr(fd, SYSTEM_RICHACL, value, retval); + acl = richacl_from_xattr(value, retval); return acl; } -int nfs4acl_set_file(const char *path, const struct nfs4acl *acl) +int richacl_set_file(const char *path, const struct richacl *acl) { - size_t size = nfs4acl_xattr_size(acl); + size_t size = richacl_xattr_size(acl); void *value = alloca(size); - nfs4acl_to_xattr(acl, value); - return setxattr(path, SYSTEM_NFS4ACL, value, size, 0); + richacl_to_xattr(acl, value); + return setxattr(path, SYSTEM_RICHACL, value, size, 0); } -int nfs4acl_set_fd(int fd, const struct nfs4acl *acl) +int richacl_set_fd(int fd, const struct richacl *acl) { - size_t size = nfs4acl_xattr_size(acl); + size_t size = richacl_xattr_size(acl); void *value = alloca(size); - nfs4acl_to_xattr(acl, value); - return fsetxattr(fd, SYSTEM_NFS4ACL, value, size, 0); + richacl_to_xattr(acl, value); + return fsetxattr(fd, SYSTEM_RICHACL, value, size, 0); } static void write_acl_flags(struct string_buffer *buffer, unsigned char flags, int fmt) @@ -425,7 +425,7 @@ static void write_acl_flags(struct string_buffer *buffer, unsigned char flags, i continue; flags &= ~acl_flag_bits[i].a_flag; - if (fmt & NFS4ACL_TEXT_LONG) { + if (fmt & RICHACL_TEXT_LONG) { if (cont) buffer_sprintf(buffer, "/"); buffer_sprintf(buffer, "%s", acl_flag_bits[i].a_name); @@ -466,7 +466,7 @@ static void write_ace_flags(struct string_buffer *buffer, uint16_t flags, int fm continue; flags &= ~ace_flag_bits[i].e_flag; - if (fmt & NFS4ACL_TEXT_LONG) { + if (fmt & RICHACL_TEXT_LONG) { if (cont) buffer_sprintf(buffer, "/"); buffer_sprintf(buffer, "%s", ace_flag_bits[i].e_name); @@ -492,40 +492,40 @@ static void write_mask(struct string_buffer *buffer, uint32_t mask, int fmt) * does not distinguish between the two, so make sure that we won't * repeat the same mask letters. */ - if (!(fmt & (NFS4ACL_TEXT_FILE_CONTEXT | - NFS4ACL_TEXT_DIRECTORY_CONTEXT))) - fmt |= NFS4ACL_TEXT_FILE_CONTEXT | - NFS4ACL_TEXT_DIRECTORY_CONTEXT; - if (!(fmt & NFS4ACL_TEXT_LONG) && - (fmt & NFS4ACL_TEXT_FILE_CONTEXT)) - fmt &= ~NFS4ACL_TEXT_DIRECTORY_CONTEXT; + if (!(fmt & (RICHACL_TEXT_FILE_CONTEXT | + RICHACL_TEXT_DIRECTORY_CONTEXT))) + fmt |= RICHACL_TEXT_FILE_CONTEXT | + RICHACL_TEXT_DIRECTORY_CONTEXT; + if (!(fmt & RICHACL_TEXT_LONG) && + (fmt & RICHACL_TEXT_FILE_CONTEXT)) + fmt &= ~RICHACL_TEXT_DIRECTORY_CONTEXT; - nondir_mask = (fmt & NFS4ACL_TEXT_FILE_CONTEXT) ? mask : 0; - dir_mask = (fmt & NFS4ACL_TEXT_DIRECTORY_CONTEXT) ? mask : 0; + nondir_mask = (fmt & RICHACL_TEXT_FILE_CONTEXT) ? mask : 0; + dir_mask = (fmt & RICHACL_TEXT_DIRECTORY_CONTEXT) ? mask : 0; for (i = 0; i < ARRAY_SIZE(mask_bits); i++) { int found = 0; if ((nondir_mask & mask_bits[i].e_mask) == mask_bits[i].e_mask && - (mask_bits[i].e_context & NFS4ACL_TEXT_FILE_CONTEXT)) { + (mask_bits[i].e_context & RICHACL_TEXT_FILE_CONTEXT)) { nondir_mask &= ~mask_bits[i].e_mask; found = 1; } if ((dir_mask & mask_bits[i].e_mask) == mask_bits[i].e_mask && - (mask_bits[i].e_context & NFS4ACL_TEXT_DIRECTORY_CONTEXT)) { + (mask_bits[i].e_context & RICHACL_TEXT_DIRECTORY_CONTEXT)) { dir_mask &= ~mask_bits[i].e_mask; found = 1; } if (found) { - if (fmt & NFS4ACL_TEXT_SIMPLIFY) { + if (fmt & RICHACL_TEXT_SIMPLIFY) { /* Hide permissions that are always allowed. */ if (mask_bits[i].e_mask == (mask_bits[i].e_mask & ACE4_POSIX_ALWAYS_ALLOWED)) continue; } - if (fmt & NFS4ACL_TEXT_LONG) { + if (fmt & RICHACL_TEXT_LONG) { if (stuff_written) buffer_sprintf(buffer, "/"); buffer_sprintf(buffer, "%s", @@ -544,7 +544,7 @@ static void write_mask(struct string_buffer *buffer, uint32_t mask, int fmt) } static void write_identifier(struct string_buffer *buffer, - const struct nfs4ace *ace) + const struct richace *ace) { /* FIXME: switch to getpwuid_r() and getgrgid_r() here. */ @@ -574,10 +574,10 @@ static void write_identifier(struct string_buffer *buffer, } } -char *nfs4acl_to_text(const struct nfs4acl *acl, int fmt) +char *richacl_to_text(const struct richacl *acl, int fmt) { struct string_buffer *buffer; - const struct nfs4ace *ace; + const struct richace *ace; int fmt2; buffer = alloc_string_buffer(128); @@ -585,24 +585,24 @@ char *nfs4acl_to_text(const struct nfs4acl *acl, int fmt) return NULL; write_acl_flags(buffer, acl->a_flags, fmt); - if (fmt & NFS4ACL_TEXT_SHOW_MASKS) { + if (fmt & RICHACL_TEXT_SHOW_MASKS) { unsigned int allowed = 0; fmt2 = fmt; - nfs4acl_for_each_entry(ace, acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry(ace, acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_allow(ace)) + if (richace_is_allow(ace)) allowed |= ace->e_mask; if (ace->e_flags & ACE4_FILE_INHERIT_ACE) - fmt2 |= NFS4ACL_TEXT_FILE_CONTEXT; + fmt2 |= RICHACL_TEXT_FILE_CONTEXT; if (ace->e_flags & ACE4_DIRECTORY_INHERIT_ACE) - fmt2 |= NFS4ACL_TEXT_DIRECTORY_CONTEXT; + fmt2 |= RICHACL_TEXT_DIRECTORY_CONTEXT; } - if (!(fmt & NFS4ACL_TEXT_SIMPLIFY)) + if (!(fmt & RICHACL_TEXT_SIMPLIFY)) allowed = ~0; buffer_sprintf(buffer, "owner:"); @@ -616,18 +616,18 @@ char *nfs4acl_to_text(const struct nfs4acl *acl, int fmt) buffer_sprintf(buffer, "::mask\n"); } - nfs4acl_for_each_entry(ace, acl) { + richacl_for_each_entry(ace, acl) { write_identifier(buffer, ace); buffer_sprintf(buffer, ":"); fmt2 = fmt; if (ace->e_flags & ACE4_INHERIT_ONLY_ACE) - fmt2 &= ~(NFS4ACL_TEXT_FILE_CONTEXT | - NFS4ACL_TEXT_DIRECTORY_CONTEXT); + fmt2 &= ~(RICHACL_TEXT_FILE_CONTEXT | + RICHACL_TEXT_DIRECTORY_CONTEXT); if (ace->e_flags & ACE4_FILE_INHERIT_ACE) - fmt2 |= NFS4ACL_TEXT_FILE_CONTEXT; + fmt2 |= RICHACL_TEXT_FILE_CONTEXT; if (ace->e_flags & ACE4_DIRECTORY_INHERIT_ACE) - fmt2 |= NFS4ACL_TEXT_DIRECTORY_CONTEXT; + fmt2 |= RICHACL_TEXT_DIRECTORY_CONTEXT; write_mask(buffer, ace->e_mask, fmt2); buffer_sprintf(buffer, ":"); @@ -648,7 +648,7 @@ char *nfs4acl_to_text(const struct nfs4acl *acl, int fmt) return NULL; } -static int acl_flags_from_text(const char *str, struct nfs4acl *acl, +static int acl_flags_from_text(const char *str, struct richacl *acl, void (*error)(const char *, ...)) { char *dup, *end; @@ -705,7 +705,7 @@ static int acl_flags_from_text(const char *str, struct nfs4acl *acl, return 0; } -static int identifier_from_text(const char *str, struct nfs4ace *ace, +static int identifier_from_text(const char *str, struct richace *ace, void (*error)(const char *, ...)) { char *c; @@ -726,7 +726,7 @@ static int identifier_from_text(const char *str, struct nfs4ace *ace, for (c = dup; *c; c++) *c = toupper(*c); - if (nfs4ace_set_who(ace, dup)) { + if (richace_set_who(ace, dup)) { error("Special user `%s' not supported\n", str); goto fail; } @@ -760,7 +760,7 @@ fail: return -1; } -static int type_from_text(const char *str, struct nfs4ace *ace, +static int type_from_text(const char *str, struct richace *ace, void (*error)(const char *, ...)) { char *c; @@ -784,7 +784,7 @@ static int type_from_text(const char *str, struct nfs4ace *ace, return -1; } -static int ace_flags_from_text(const char *str, struct nfs4ace *ace, +static int ace_flags_from_text(const char *str, struct richace *ace, void (*error)(const char *, ...)) { char *dup, *end; @@ -898,21 +898,21 @@ static int mask_from_text(const char *str, unsigned int *mask, return 0; } -struct nfs4acl *nfs4acl_from_text(const char *str, int *pflags, +struct richacl *richacl_from_text(const char *str, int *pflags, void (*error)(const char *, ...)) { char *who_str = NULL, *mask_str = NULL, *flags_str = NULL, *type_str = NULL; - struct nfs4acl *acl; + struct richacl *acl; int flags = 0; - acl = nfs4acl_alloc(0); + acl = richacl_alloc(0); if (!acl) return NULL; while (*str) { - struct nfs4acl *acl2; - struct nfs4ace *ace; + struct richacl *acl2; + struct richace *ace; unsigned int mask; const char *entry, *c; @@ -941,7 +941,7 @@ struct nfs4acl *nfs4acl_from_text(const char *str, int *pflags, if (*c != ':') { if (acl_flags_from_text(mask_str, acl, error)) goto fail_einval; - flags |= NFS4ACL_TEXT_FLAGS; + flags |= RICHACL_TEXT_FLAGS; str = c; goto free_mask_str; } else { @@ -980,27 +980,27 @@ struct nfs4acl *nfs4acl_from_text(const char *str, int *pflags, if (!strcasecmp(type_str, "MASK")) { if (!strcasecmp(who_str, "OWNER")) { acl->a_owner_mask = mask; - flags |= NFS4ACL_TEXT_OWNER_MASK; + flags |= RICHACL_TEXT_OWNER_MASK; } else if (!strcasecmp(who_str, "GROUP")) { acl->a_group_mask = mask; - flags |= NFS4ACL_TEXT_GROUP_MASK; + flags |= RICHACL_TEXT_GROUP_MASK; } else if (!strcasecmp(who_str, "OTHER")) { acl->a_other_mask = mask; - flags |= NFS4ACL_TEXT_OTHER_MASK; + flags |= RICHACL_TEXT_OTHER_MASK; } else { error("Invalid file mask `%s'\n", who_str); goto fail_einval; } } else { - size_t size = sizeof(struct nfs4acl) + (acl->a_count - + 1) * sizeof(struct nfs4ace); + size_t size = sizeof(struct richacl) + (acl->a_count + + 1) * sizeof(struct richace); acl2 = realloc(acl, size); if (!acl2) goto fail; acl = acl2; memset(acl->a_entries + acl->a_count, 0, - sizeof(struct nfs4ace)); + sizeof(struct richace)); acl->a_count++; ace = acl->a_entries + acl->a_count - 1; @@ -1043,18 +1043,18 @@ fail: free(flags_str); free(mask_str); free(who_str); - nfs4acl_free(acl); + richacl_free(acl); return NULL; } -int nfs4ace_set_who(struct nfs4ace *ace, const char *who) +int richace_set_who(struct richace *ace, const char *who) { - if (!strcmp(who, nfs4ace_owner_who)) - who = nfs4ace_owner_who; - else if (!strcmp(who, nfs4ace_group_who)) - who = nfs4ace_group_who; - else if (!strcmp(who, nfs4ace_everyone_who)) - who = nfs4ace_everyone_who; + if (!strcmp(who, richace_owner_who)) + who = richace_owner_who; + else if (!strcmp(who, richace_group_who)) + who = richace_group_who; + else if (!strcmp(who, richace_everyone_who)) + who = richace_everyone_who; else return -1; @@ -1062,31 +1062,31 @@ int nfs4ace_set_who(struct nfs4ace *ace, const char *who) ace->e_flags |= ACE4_SPECIAL_WHO; /* * Also clear the ACE4_IDENTIFIER_GROUP flag for ACEs with a special - * who value: nfs4ace_is_same_identifier() relies on that. + * who value: richace_is_same_identifier() relies on that. */ ace->e_flags &= ~ACE4_IDENTIFIER_GROUP; return 0; } -void nfs4ace_set_uid(struct nfs4ace *ace, uid_t uid) +void richace_set_uid(struct richace *ace, uid_t uid) { ace->u.e_id = uid; ace->e_flags &= ~(ACE4_SPECIAL_WHO | ACE4_IDENTIFIER_GROUP); } -void nfs4ace_set_gid(struct nfs4ace *ace, gid_t gid) +void richace_set_gid(struct richace *ace, gid_t gid) { ace->u.e_id = gid; ace->e_flags |= ACE4_IDENTIFIER_GROUP; ace->e_flags &= ~ACE4_SPECIAL_WHO; } -void nfs4ace_copy(struct nfs4ace *dst, const struct nfs4ace *src) +void richace_copy(struct richace *dst, const struct richace *src) { - memcpy(dst, src, sizeof(struct nfs4ace)); + memcpy(dst, src, sizeof(struct richace)); } -static unsigned int nfs4acl_mode_to_mask(mode_t mode) +static unsigned int richacl_mode_to_mask(mode_t mode) { unsigned int mask = ACE4_POSIX_ALWAYS_ALLOWED; @@ -1100,26 +1100,26 @@ static unsigned int nfs4acl_mode_to_mask(mode_t mode) return mask; } -struct nfs4acl *nfs4acl_from_mode(mode_t mode) +struct richacl *richacl_from_mode(mode_t mode) { - struct nfs4acl *acl; - struct nfs4ace *ace; + struct richacl *acl; + struct richace *ace; - acl = nfs4acl_alloc(1); + acl = richacl_alloc(1); if (!acl) return NULL; ace = acl->a_entries; - acl->a_owner_mask = nfs4acl_mode_to_mask(mode >> 6); - acl->a_group_mask = nfs4acl_mode_to_mask(mode >> 3); - acl->a_other_mask = nfs4acl_mode_to_mask(mode); + acl->a_owner_mask = richacl_mode_to_mask(mode >> 6); + acl->a_group_mask = richacl_mode_to_mask(mode >> 3); + acl->a_other_mask = richacl_mode_to_mask(mode); ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE; ace->e_flags = ACE4_SPECIAL_WHO; ace->e_mask = ACE4_VALID_MASK; - ace->u.e_who = nfs4ace_everyone_who; + ace->u.e_who = richace_everyone_who; - if (nfs4acl_apply_masks(&acl)) { + if (richacl_apply_masks(&acl)) { free(acl); acl = NULL; } diff --git a/lib/nfs4acl_compat.c b/lib/richacl_compat.c similarity index 69% rename from lib/nfs4acl_compat.c rename to lib/richacl_compat.c index a7837ae..1890ae1 100644 --- a/lib/nfs4acl_compat.c +++ b/lib/richacl_compat.c @@ -13,11 +13,11 @@ */ #include -#include "nfs4acl.h" -#include "nfs4acl-internal.h" +#include "richacl.h" +#include "richacl-internal.h" /** - * struct nfs4acl_alloc - remember how many entries are actually allocated + * struct richacl_alloc - remember how many entries are actually allocated * @acl: acl with a_count <= @count * @count: the actual number of entries allocated in @acl * @@ -25,13 +25,13 @@ * not have to reallocate when we remove existing entries followed by * adding new entries. */ -struct nfs4acl_alloc { - struct nfs4acl *acl; +struct richacl_alloc { + struct richacl *acl; unsigned int count; }; /** - * nfs4acl_delete_entry - delete an entry in an acl + * richacl_delete_entry - delete an entry in an acl * @x: acl and number of allocated entries * @ace: an entry in @x->acl * @@ -42,7 +42,7 @@ struct nfs4acl_alloc { * an acl. */ static void -nfs4acl_delete_entry(struct nfs4acl_alloc *x, struct nfs4ace **ace) +richacl_delete_entry(struct richacl_alloc *x, struct richace **ace) { void *end = x->acl->a_entries + x->acl->a_count; @@ -52,7 +52,7 @@ nfs4acl_delete_entry(struct nfs4acl_alloc *x, struct nfs4ace **ace) } /** - * nfs4acl_insert_entry - insert an entry in an acl + * richacl_insert_entry - insert an entry in an acl * @x: acl and number of allocated entries * @ace: entry before which the new entry shall be inserted * @@ -60,14 +60,14 @@ nfs4acl_delete_entry(struct nfs4acl_alloc *x, struct nfs4ace **ace) * it. This may require reallocating @x->acl. */ static int -nfs4acl_insert_entry(struct nfs4acl_alloc *x, struct nfs4ace **ace) +richacl_insert_entry(struct richacl_alloc *x, struct richace **ace) { int n = *ace - x->acl->a_entries; if (x->count == x->acl->a_count) { - size_t size = sizeof(struct nfs4acl) + - (x->count + 1) * sizeof(struct nfs4ace); - struct nfs4acl *acl2; + size_t size = sizeof(struct richacl) + + (x->count + 1) * sizeof(struct richace); + struct richacl *acl2; acl2 = realloc(x->acl, size); if (!acl2) @@ -76,14 +76,14 @@ nfs4acl_insert_entry(struct nfs4acl_alloc *x, struct nfs4ace **ace) x->acl = acl2; *ace = acl2->a_entries + n; } - memmove(*ace + 1, *ace, sizeof(struct nfs4ace) * (x->acl->a_count - n)); - memset(*ace, 0, sizeof(struct nfs4ace)); + memmove(*ace + 1, *ace, sizeof(struct richace) * (x->acl->a_count - n)); + memset(*ace, 0, sizeof(struct richace)); x->acl->a_count++; return 0; } /** - * nfs4ace_change_mask - change the mask in @ace to @mask + * richace_change_mask - change the mask in @ace to @mask * @x: acl and number of allocated entries * @ace: entry to modify * @mask: new mask for @ace @@ -100,32 +100,32 @@ nfs4acl_insert_entry(struct nfs4acl_alloc *x, struct nfs4ace **ace) * modifying masks while forward iterating over an acl. */ static int -nfs4ace_change_mask(struct nfs4acl_alloc *x, struct nfs4ace **ace, +richace_change_mask(struct richacl_alloc *x, struct richace **ace, unsigned int mask) { if (mask && (*ace)->e_mask == mask) return 0; if (mask & ~ACE4_POSIX_ALWAYS_ALLOWED) { - if (nfs4ace_is_inheritable(*ace)) { - if (nfs4acl_insert_entry(x, ace)) + if (richace_is_inheritable(*ace)) { + if (richacl_insert_entry(x, ace)) return -1; - memcpy(*ace, *ace + 1, sizeof(struct nfs4ace)); + memcpy(*ace, *ace + 1, sizeof(struct richace)); (*ace)->e_flags |= ACE4_INHERIT_ONLY_ACE; (*ace)++; - nfs4ace_clear_inheritance_flags(*ace); + richace_clear_inheritance_flags(*ace); } (*ace)->e_mask = mask; } else { - if (nfs4ace_is_inheritable(*ace)) + if (richace_is_inheritable(*ace)) (*ace)->e_flags |= ACE4_INHERIT_ONLY_ACE; else - nfs4acl_delete_entry(x, ace); + richacl_delete_entry(x, ace); } return 0; } /** - * nfs4acl_move_everyone_aces_down - move everyone@ acl entries to the end + * richacl_move_everyone_aces_down - move everyone@ acl entries to the end * @x: acl and number of allocated entries * * Move all everyone acl entries to the bottom of the acl so that only a @@ -137,57 +137,57 @@ nfs4ace_change_mask(struct nfs4acl_alloc *x, struct nfs4ace **ace, * grants, but we need it to simplify successive transformations. */ static int -nfs4acl_move_everyone_aces_down(struct nfs4acl_alloc *x) +richacl_move_everyone_aces_down(struct richacl_alloc *x) { - struct nfs4ace *ace; + struct richace *ace; unsigned int allowed = 0, denied = 0; - nfs4acl_for_each_entry(ace, x->acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry(ace, x->acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_everyone(ace)) { - if (nfs4ace_is_allow(ace)) + if (richace_is_everyone(ace)) { + if (richace_is_allow(ace)) allowed |= (ace->e_mask & ~denied); - else if (nfs4ace_is_deny(ace)) + else if (richace_is_deny(ace)) denied |= (ace->e_mask & ~allowed); else continue; - if (nfs4ace_change_mask(x, &ace, 0)) + if (richace_change_mask(x, &ace, 0)) return -1; } else { - if (nfs4ace_is_allow(ace)) { - if (nfs4ace_change_mask(x, &ace, allowed | + if (richace_is_allow(ace)) { + if (richace_change_mask(x, &ace, allowed | (ace->e_mask & ~denied))) return -1; - } else if (nfs4ace_is_deny(ace)) { - if (nfs4ace_change_mask(x, &ace, denied | + } else if (richace_is_deny(ace)) { + if (richace_change_mask(x, &ace, denied | (ace->e_mask & ~allowed))) return -1; } } } if (allowed & ~ACE4_POSIX_ALWAYS_ALLOWED) { - struct nfs4ace *last_ace = ace - 1; + struct richace *last_ace = ace - 1; - if (nfs4ace_is_everyone(last_ace) && - nfs4ace_is_allow(last_ace) && - nfs4ace_is_inherit_only(last_ace) && + if (richace_is_everyone(last_ace) && + richace_is_allow(last_ace) && + richace_is_inherit_only(last_ace) && last_ace->e_mask == allowed) last_ace->e_flags &= ~ACE4_INHERIT_ONLY_ACE; else { - if (nfs4acl_insert_entry(x, &ace)) + if (richacl_insert_entry(x, &ace)) return -1; ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE; ace->e_flags = ACE4_SPECIAL_WHO; ace->e_mask = allowed; - ace->u.e_who = nfs4ace_everyone_who; + ace->u.e_who = richace_everyone_who; } } return 0; } /** - * __nfs4acl_propagate_everyone - propagate everyone@ mask flags up for @who + * __richacl_propagate_everyone - propagate everyone@ mask flags up for @who * @x: acl and number of allocated entries * @who: identifier to propagate mask flags for * @allow: mask flags to propagate up @@ -204,25 +204,25 @@ nfs4acl_move_everyone_aces_down(struct nfs4acl_alloc *x) * with mask flags that overlap the flags we care about. */ static int -__nfs4acl_propagate_everyone(struct nfs4acl_alloc *x, struct nfs4ace *who, +__richacl_propagate_everyone(struct richacl_alloc *x, struct richace *who, unsigned int allow) { - struct nfs4ace *allow_last = NULL, *ace; + struct richace *allow_last = NULL, *ace; /* Remove the mask flags from allow that are already determined for this who value, and figure out if there is an ALLOW entry for this who value that is "reachable" from the trailing EVERYONE@ ALLOW ACE. */ - nfs4acl_for_each_entry(ace, x->acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry(ace, x->acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_allow(ace)) { - if (nfs4ace_is_same_identifier(ace, who)) { + if (richace_is_allow(ace)) { + if (richace_is_same_identifier(ace, who)) { allow &= ~ace->e_mask; allow_last = ace; } - } else if (nfs4ace_is_deny(ace)) { - if (nfs4ace_is_same_identifier(ace, who)) + } else if (richace_is_deny(ace)) { + if (richace_is_same_identifier(ace, who)) allow &= ~ace->e_mask; if (allow & ace->e_mask) allow_last = NULL; @@ -231,18 +231,18 @@ __nfs4acl_propagate_everyone(struct nfs4acl_alloc *x, struct nfs4ace *who, if (allow) { if (allow_last) - return nfs4ace_change_mask(x, &allow_last, + return richace_change_mask(x, &allow_last, allow_last->e_mask | allow); else { - struct nfs4ace who_copy; + struct richace who_copy; ace = x->acl->a_entries + x->acl->a_count - 1; - memcpy(&who_copy, who, sizeof(struct nfs4ace)); - if (nfs4acl_insert_entry(x, &ace)) + memcpy(&who_copy, who, sizeof(struct richace)); + if (richacl_insert_entry(x, &ace)) return -1; - memcpy(ace, &who_copy, sizeof(struct nfs4ace)); + memcpy(ace, &who_copy, sizeof(struct richace)); ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE; - nfs4ace_clear_inheritance_flags(ace); + richace_clear_inheritance_flags(ace); ace->e_mask = allow; } } @@ -250,7 +250,7 @@ __nfs4acl_propagate_everyone(struct nfs4acl_alloc *x, struct nfs4ace *who, } /** - * nfs4acl_propagate_everyone - propagate everyone@ mask flags up the acl + * richacl_propagate_everyone - propagate everyone@ mask flags up the acl * @x: acl and number of allocated entries * * Make sure for owner@, group@, and all other users, groups, and @@ -305,11 +305,11 @@ __nfs4acl_propagate_everyone(struct nfs4acl_alloc *x, struct nfs4ace *who, * who value, no matter how many entries each who value has already. */ static int -nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) +richacl_propagate_everyone(struct richacl_alloc *x) { int write_through = x->acl->a_flags & ACL4_WRITE_THROUGH; - struct nfs4ace who = { .e_flags = ACE4_SPECIAL_WHO }; - struct nfs4ace *ace; + struct richace who = { .e_flags = ACE4_SPECIAL_WHO }; + struct richace *ace; unsigned int owner_allow, group_allow; if (!((x->acl->a_owner_mask | x->acl->a_group_mask) & @@ -318,7 +318,7 @@ nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) if (!x->acl->a_count) return 0; ace = x->acl->a_entries + x->acl->a_count - 1; - if (nfs4ace_is_inherit_only(ace) || !nfs4ace_is_everyone(ace)) + if (richace_is_inherit_only(ace) || !richace_is_everyone(ace)) return 0; if (!(ace->e_mask & ~x->acl->a_other_mask)) { /* None of the allowed permissions will get masked. */ @@ -330,8 +330,8 @@ nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) /* Propagate everyone@ permissions through to owner@. */ if (owner_allow && !write_through && (x->acl->a_owner_mask & ~x->acl->a_other_mask)) { - who.u.e_who = nfs4ace_owner_who; - if (__nfs4acl_propagate_everyone(x, &who, owner_allow)) + who.u.e_who = richace_owner_who; + if (__richacl_propagate_everyone(x, &who, owner_allow)) return -1; } @@ -340,8 +340,8 @@ nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) if (!write_through) { /* Propagate everyone@ permissions through to group@. */ - who.u.e_who = nfs4ace_group_who; - if (__nfs4acl_propagate_everyone(x, &who, group_allow)) + who.u.e_who = richace_group_who; + if (__richacl_propagate_everyone(x, &who, group_allow)) return -1; } @@ -350,14 +350,14 @@ nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) for (n = x->acl->a_count - 2; n != -1; n--) { ace = x->acl->a_entries + n; - if (nfs4ace_is_inherit_only(ace) || - nfs4ace_is_owner(ace) || - nfs4ace_is_group(ace)) + if (richace_is_inherit_only(ace) || + richace_is_owner(ace) || + richace_is_group(ace)) continue; - if (nfs4ace_is_allow(ace) || nfs4ace_is_deny(ace)) { + if (richace_is_allow(ace) || richace_is_deny(ace)) { /* Any inserted entry will end up below the current entry. */ - if (__nfs4acl_propagate_everyone(x, ace, group_allow)) + if (__richacl_propagate_everyone(x, ace, group_allow)) return -1; } } @@ -366,7 +366,7 @@ nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) } /** - * __nfs4acl_apply_masks - apply the masks to the acl entries + * __richacl_apply_masks - apply the masks to the acl entries * @x: acl and number of allocated entries * * Apply the owner file mask to owner@ entries, the intersection of the @@ -374,43 +374,43 @@ nfs4acl_propagate_everyone(struct nfs4acl_alloc *x) * mask to all other entries. */ static int -__nfs4acl_apply_masks(struct nfs4acl_alloc *x) +__richacl_apply_masks(struct richacl_alloc *x) { - struct nfs4ace *ace; + struct richace *ace; - nfs4acl_for_each_entry(ace, x->acl) { + richacl_for_each_entry(ace, x->acl) { unsigned int mask; - if (nfs4ace_is_inherit_only(ace) || !nfs4ace_is_allow(ace)) + if (richace_is_inherit_only(ace) || !richace_is_allow(ace)) continue; - if (nfs4ace_is_owner(ace)) + if (richace_is_owner(ace)) mask = x->acl->a_owner_mask; - else if (nfs4ace_is_everyone(ace)) + else if (richace_is_everyone(ace)) mask = x->acl->a_other_mask; else mask = x->acl->a_group_mask; - if (nfs4ace_change_mask(x, &ace, ace->e_mask & mask)) + if (richace_change_mask(x, &ace, ace->e_mask & mask)) return -1; } return 0; } /** - * nfs4acl_max_allowed - maximum mask flags that anybody is allowed + * richacl_max_allowed - maximum mask flags that anybody is allowed */ static unsigned int -nfs4acl_max_allowed(struct nfs4acl *acl) +richacl_max_allowed(struct richacl *acl) { - struct nfs4ace *ace; + struct richace *ace; unsigned int allowed = 0; - nfs4acl_for_each_entry_reverse(ace, acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry_reverse(ace, acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_allow(ace)) + if (richace_is_allow(ace)) allowed |= ace->e_mask; - else if (nfs4ace_is_deny(ace)) { - if (nfs4ace_is_everyone(ace)) + else if (richace_is_deny(ace)) { + if (richace_is_everyone(ace)) allowed &= ~ace->e_mask; } } @@ -418,7 +418,7 @@ nfs4acl_max_allowed(struct nfs4acl *acl) } /** - * nfs4acl_isolate_owner_class - limit the owner class to the owner file mask + * richacl_isolate_owner_class - limit the owner class to the owner file mask * @x: acl and number of allocated entries * * Make sure the owner class (owner@) is granted no more than the owner @@ -426,45 +426,45 @@ nfs4acl_max_allowed(struct nfs4acl *acl) * denying owner@ all permissions beyond that. */ static int -nfs4acl_isolate_owner_class(struct nfs4acl_alloc *x) +richacl_isolate_owner_class(struct richacl_alloc *x) { - struct nfs4ace *ace; + struct richace *ace; unsigned int allowed = 0; - allowed = nfs4acl_max_allowed(x->acl); + allowed = richacl_max_allowed(x->acl); if (allowed & ~x->acl->a_owner_mask) { /* Figure out if we can update an existig OWNER@ DENY entry. */ - nfs4acl_for_each_entry(ace, x->acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry(ace, x->acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_deny(ace)) { - if (nfs4ace_is_owner(ace)) + if (richace_is_deny(ace)) { + if (richace_is_owner(ace)) break; - } else if (nfs4ace_is_allow(ace)) { + } else if (richace_is_allow(ace)) { ace = x->acl->a_entries + x->acl->a_count; break; } } if (ace != x->acl->a_entries + x->acl->a_count) { - if (nfs4ace_change_mask(x, &ace, ace->e_mask | + if (richace_change_mask(x, &ace, ace->e_mask | (allowed & ~x->acl->a_owner_mask))) return -1; } else { /* Insert an owner@ deny entry at the front. */ ace = x->acl->a_entries; - if (nfs4acl_insert_entry(x, &ace)) + if (richacl_insert_entry(x, &ace)) return -1; ace->e_type = ACE4_ACCESS_DENIED_ACE_TYPE; ace->e_flags = ACE4_SPECIAL_WHO; ace->e_mask = allowed & ~x->acl->a_owner_mask; - ace->u.e_who = nfs4ace_owner_who; + ace->u.e_who = richace_owner_who; } } return 0; } /** - * __nfs4acl_isolate_who - isolate entry from EVERYONE@ ALLOW entry + * __richacl_isolate_who - isolate entry from EVERYONE@ ALLOW entry * @x: acl and number of allocated entries * @who: identifier to isolate * @deny: mask flags this identifier should not be allowed @@ -475,20 +475,20 @@ nfs4acl_isolate_owner_class(struct nfs4acl_alloc *x) * entry, or inserting such an entry. */ static int -__nfs4acl_isolate_who(struct nfs4acl_alloc *x, struct nfs4ace *who, +__richacl_isolate_who(struct richacl_alloc *x, struct richace *who, unsigned int deny) { - struct nfs4ace *ace; + struct richace *ace; unsigned int allowed = 0, n; /* Compute the mask flags granted to this who value. */ - nfs4acl_for_each_entry_reverse(ace, x->acl) { - if (nfs4ace_is_inherit_only(ace)) + richacl_for_each_entry_reverse(ace, x->acl) { + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_same_identifier(ace, who)) { - if (nfs4ace_is_allow(ace)) + if (richace_is_same_identifier(ace, who)) { + if (richace_is_allow(ace)) allowed |= ace->e_mask; - else if (nfs4ace_is_deny(ace)) + else if (richace_is_deny(ace)) allowed &= ~ace->e_mask; deny &= ~ace->e_mask; } @@ -501,39 +501,39 @@ __nfs4acl_isolate_who(struct nfs4acl_alloc *x, struct nfs4ace *who, will not hit EVERYONE@ entries in the loop. */ for (n = x->acl->a_count - 2; n != -1; n--) { ace = x->acl->a_entries + n; - if (nfs4ace_is_inherit_only(ace)) + if (richace_is_inherit_only(ace)) continue; - if (nfs4ace_is_deny(ace)) { - if (nfs4ace_is_same_identifier(ace, who)) + if (richace_is_deny(ace)) { + if (richace_is_same_identifier(ace, who)) break; - } else if (nfs4ace_is_allow(ace) && + } else if (richace_is_allow(ace) && (ace->e_mask & deny)) { n = -1; break; } } if (n != -1) { - if (nfs4ace_change_mask(x, &ace, ace->e_mask | deny)) + if (richace_change_mask(x, &ace, ace->e_mask | deny)) return -1; } else { /* Insert a eny entry before the trailing EVERYONE@ DENY entry. */ - struct nfs4ace who_copy; + struct richace who_copy; ace = x->acl->a_entries + x->acl->a_count - 1; - memcpy(&who_copy, who, sizeof(struct nfs4ace)); - if (nfs4acl_insert_entry(x, &ace)) + memcpy(&who_copy, who, sizeof(struct richace)); + if (richacl_insert_entry(x, &ace)) return -1; - memcpy(ace, &who_copy, sizeof(struct nfs4ace)); + memcpy(ace, &who_copy, sizeof(struct richace)); ace->e_type = ACE4_ACCESS_DENIED_ACE_TYPE; - nfs4ace_clear_inheritance_flags(ace); + richace_clear_inheritance_flags(ace); ace->e_mask = deny; } return 0; } /** - * nfs4acl_isolate_group_class - limit the group class to the group file mask + * richacl_isolate_group_class - limit the group class to the group file mask * @x: acl and number of allocated entries * * Make sure the group class (all entries except owner@ and everyone@) is @@ -541,26 +541,26 @@ __nfs4acl_isolate_who(struct nfs4acl_alloc *x, struct nfs4ace *who, * class entries where necessary. */ static int -nfs4acl_isolate_group_class(struct nfs4acl_alloc *x) +richacl_isolate_group_class(struct richacl_alloc *x) { - struct nfs4ace who = { + struct richace who = { .e_flags = ACE4_SPECIAL_WHO, - .u.e_who = nfs4ace_group_who, + .u.e_who = richace_group_who, }; - struct nfs4ace *ace; + struct richace *ace; unsigned int deny; if (!x->acl->a_count) return 0; ace = x->acl->a_entries + x->acl->a_count - 1; - if (nfs4ace_is_inherit_only(ace) || !nfs4ace_is_everyone(ace)) + if (richace_is_inherit_only(ace) || !richace_is_everyone(ace)) return 0; deny = ace->e_mask & ~x->acl->a_group_mask; if (deny) { unsigned int n; - if (__nfs4acl_isolate_who(x, &who, deny)) + if (__richacl_isolate_who(x, &who, deny)) return -1; /* Start from the entry before the trailing EVERYONE@ ALLOW @@ -568,11 +568,11 @@ nfs4acl_isolate_group_class(struct nfs4acl_alloc *x) for (n = x->acl->a_count - 2; n != -1; n--) { ace = x->acl->a_entries + n; - if (nfs4ace_is_inherit_only(ace) || - nfs4ace_is_owner(ace) || - nfs4ace_is_group(ace)) + if (richace_is_inherit_only(ace) || + richace_is_owner(ace) || + richace_is_group(ace)) continue; - if (__nfs4acl_isolate_who(x, ace, deny)) + if (__richacl_isolate_who(x, ace, deny)) return -1; } } @@ -580,7 +580,7 @@ nfs4acl_isolate_group_class(struct nfs4acl_alloc *x) } /** - * nfs4acl_apply_masks - apply the masks to the acl + * richacl_apply_masks - apply the masks to the acl * * Apply the masks so that the acl allows no more flags than the * intersection between the flags that the original acl allows and the @@ -590,19 +590,19 @@ nfs4acl_isolate_group_class(struct nfs4acl_alloc *x) * ACL4_XATTR_MAX_COUNT, so a read-modify-write cycle would fail. */ int -nfs4acl_apply_masks(struct nfs4acl **acl) +richacl_apply_masks(struct richacl **acl) { - struct nfs4acl_alloc x = { + struct richacl_alloc x = { .acl = *acl, .count = (*acl)->a_count, }; int retval = 0; - if (nfs4acl_move_everyone_aces_down(&x) || - nfs4acl_propagate_everyone(&x) || - __nfs4acl_apply_masks(&x) || - nfs4acl_isolate_owner_class(&x) || - nfs4acl_isolate_group_class(&x)) + if (richacl_move_everyone_aces_down(&x) || + richacl_propagate_everyone(&x) || + __richacl_apply_masks(&x) || + richacl_isolate_owner_class(&x) || + richacl_isolate_group_class(&x)) retval = -1; *acl = x.acl; diff --git a/src/nfs4acl.c b/src/richacl.c similarity index 74% rename from src/nfs4acl.c rename to src/richacl.c index 7e0ab58..ab447ef 100644 --- a/src/nfs4acl.c +++ b/src/richacl.c @@ -13,7 +13,7 @@ */ /* - * FIXME: Make ls show a `+' for nfs4acls (in coreutils). + * FIXME: Make ls show a `+' for richacls (in coreutils). */ #define _GNU_SOURCE @@ -28,7 +28,7 @@ #include #include -#include "nfs4acl.h" +#include "richacl.h" #include "string_buffer.h" static const char *progname; @@ -42,17 +42,17 @@ void printf_stderr(const char *fmt, ...) va_end(ap); } -int modify_nfs4acl(struct nfs4acl **acl2, struct nfs4acl *acl, int acl_has) +int modify_richacl(struct richacl **acl2, struct richacl *acl, int acl_has) { - struct nfs4ace *ace2, *ace; + struct richace *ace2, *ace; - nfs4acl_for_each_entry(ace, acl) { - struct nfs4acl *acl3; - struct nfs4ace *ace3; + richacl_for_each_entry(ace, acl) { + struct richacl *acl3; + struct richace *ace3; - nfs4acl_for_each_entry(ace2, *acl2) { + richacl_for_each_entry(ace2, *acl2) { if (ace2->e_type == ace->e_type && - nfs4ace_is_same_identifier(ace, ace2)) { + richace_is_same_identifier(ace, ace2)) { ace2->e_mask = ace->e_mask; ace2->e_flags = ace->e_flags; break; @@ -61,66 +61,66 @@ int modify_nfs4acl(struct nfs4acl **acl2, struct nfs4acl *acl, int acl_has) if (ace2 != (*acl2)->a_entries + (*acl2)->a_count) continue; - acl3 = nfs4acl_alloc((*acl2)->a_count + 1); + acl3 = richacl_alloc((*acl2)->a_count + 1); if (!acl3) return -1; ace3 = acl3->a_entries; - if (nfs4ace_is_deny(ace)) { - nfs4acl_for_each_entry(ace2, *acl2) { - if (!nfs4ace_is_deny(ace2)) + if (richace_is_deny(ace)) { + richacl_for_each_entry(ace2, *acl2) { + if (!richace_is_deny(ace2)) break; - nfs4ace_copy(ace3++, ace2); + richace_copy(ace3++, ace2); } - nfs4ace_copy(ace3++, ace); + richace_copy(ace3++, ace); while (ace2 != (*acl2)->a_entries + (*acl2)->a_count) - nfs4ace_copy(ace3++, ace2++); + richace_copy(ace3++, ace2++); } else { - nfs4acl_for_each_entry(ace2, *acl2) - nfs4ace_copy(ace3++, ace2); - nfs4ace_copy(ace3++, ace); + richacl_for_each_entry(ace2, *acl2) + richace_copy(ace3++, ace2); + richace_copy(ace3++, ace); } - nfs4acl_free(*acl2); + richacl_free(*acl2); *acl2 = acl3; } - if (acl_has & NFS4ACL_TEXT_FLAGS) + if (acl_has & RICHACL_TEXT_FLAGS) (*acl2)->a_flags = acl->a_flags; - if (!((acl_has & NFS4ACL_TEXT_OWNER_MASK) && - (acl_has & NFS4ACL_TEXT_GROUP_MASK) && - (acl_has & NFS4ACL_TEXT_OTHER_MASK))) - nfs4acl_compute_max_masks(*acl2); - if (acl_has & NFS4ACL_TEXT_OWNER_MASK) + if (!((acl_has & RICHACL_TEXT_OWNER_MASK) && + (acl_has & RICHACL_TEXT_GROUP_MASK) && + (acl_has & RICHACL_TEXT_OTHER_MASK))) + richacl_compute_max_masks(*acl2); + if (acl_has & RICHACL_TEXT_OWNER_MASK) (*acl2)->a_owner_mask = acl->a_owner_mask; - if (acl_has & NFS4ACL_TEXT_GROUP_MASK) + if (acl_has & RICHACL_TEXT_GROUP_MASK) (*acl2)->a_group_mask = acl->a_group_mask; - if (acl_has & NFS4ACL_TEXT_OTHER_MASK) + if (acl_has & RICHACL_TEXT_OTHER_MASK) (*acl2)->a_other_mask = acl->a_other_mask; return 0; } -static struct nfs4acl *get_nfs4acl(const char *file, mode_t mode) +static struct richacl *get_richacl(const char *file, mode_t mode) { - struct nfs4acl *acl; + struct richacl *acl; - acl = nfs4acl_get_file(file); + acl = richacl_get_file(file); if (!acl && (errno == ENODATA || errno == ENOTSUP || errno == ENOSYS)) { - acl = nfs4acl_from_mode(mode); + acl = richacl_from_mode(mode); } return acl; } -static int print_nfs4acl(const char *file, struct nfs4acl **acl, int fmt) +static int print_richacl(const char *file, struct richacl **acl, int fmt) { char *text; - if (!(fmt & NFS4ACL_TEXT_SHOW_MASKS)) { - if (nfs4acl_apply_masks(acl)) + if (!(fmt & RICHACL_TEXT_SHOW_MASKS)) { + if (richacl_apply_masks(acl)) goto fail; } - text = nfs4acl_to_text(*acl, fmt); + text = richacl_to_text(*acl, fmt); if (!text) goto fail; printf("%s:\n", file); @@ -135,9 +135,9 @@ fail: int format_for_mode(mode_t mode) { if (S_ISDIR(mode)) - return NFS4ACL_TEXT_DIRECTORY_CONTEXT; + return RICHACL_TEXT_DIRECTORY_CONTEXT; else - return NFS4ACL_TEXT_FILE_CONTEXT; + return RICHACL_TEXT_FILE_CONTEXT; } static struct option long_options[] = { @@ -217,11 +217,11 @@ int main(int argc, char *argv[]) int opt_get = 0, opt_remove = 0, opt_dry_run = 0; int opt_modify = 0, opt_set = 0; char *acl_text = NULL, *acl_file = NULL; - int format = NFS4ACL_TEXT_SIMPLIFY; + int format = RICHACL_TEXT_SIMPLIFY; int status = 0; int c; - struct nfs4acl *acl = NULL; + struct richacl *acl = NULL; int acl_has; progname = argv[0]; @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) break; case 'l': - format |= NFS4ACL_TEXT_LONG; + format |= RICHACL_TEXT_LONG; break; case 'v': @@ -268,8 +268,8 @@ int main(int argc, char *argv[]) break; case 1: /* --raw */ - format |= NFS4ACL_TEXT_SHOW_MASKS; - format &= ~NFS4ACL_TEXT_SIMPLIFY; + format |= RICHACL_TEXT_SHOW_MASKS; + format &= ~RICHACL_TEXT_SIMPLIFY; break; case 2: /* --dry-run */ @@ -287,7 +287,7 @@ int main(int argc, char *argv[]) synopsis(argc == 1); if (acl_text) { - acl = nfs4acl_from_text(acl_text, &acl_has, printf_stderr); + acl = richacl_from_text(acl_text, &acl_has, printf_stderr); if (!acl) return 1; } @@ -322,35 +322,35 @@ int main(int argc, char *argv[]) return 1; } - acl = nfs4acl_from_text(buffer->buffer, &acl_has, printf_stderr); + acl = richacl_from_text(buffer->buffer, &acl_has, printf_stderr); if (!acl) return 1; free_string_buffer(buffer); } /* Compute all masks which haven't been set explicitly. */ - if (opt_set && acl && !((acl_has & NFS4ACL_TEXT_OWNER_MASK) && - (acl_has & NFS4ACL_TEXT_GROUP_MASK) && - (acl_has & NFS4ACL_TEXT_OTHER_MASK))) { + if (opt_set && acl && !((acl_has & RICHACL_TEXT_OWNER_MASK) && + (acl_has & RICHACL_TEXT_GROUP_MASK) && + (acl_has & RICHACL_TEXT_OTHER_MASK))) { unsigned int owner_mask = acl->a_owner_mask; unsigned int group_mask = acl->a_group_mask; unsigned int other_mask = acl->a_other_mask; - nfs4acl_compute_max_masks(acl); - if (acl_has & NFS4ACL_TEXT_OWNER_MASK) + richacl_compute_max_masks(acl); + if (acl_has & RICHACL_TEXT_OWNER_MASK) acl->a_owner_mask = owner_mask; - if (acl_has & NFS4ACL_TEXT_GROUP_MASK) + if (acl_has & RICHACL_TEXT_GROUP_MASK) acl->a_group_mask = group_mask; - if (acl_has & NFS4ACL_TEXT_OTHER_MASK) + if (acl_has & RICHACL_TEXT_OTHER_MASK) acl->a_other_mask = other_mask; } if (opt_dry_run && opt_set) { const char *file = ""; - if (print_nfs4acl(file, &acl, format | - NFS4ACL_TEXT_FILE_CONTEXT | - NFS4ACL_TEXT_DIRECTORY_CONTEXT)) { + if (print_richacl(file, &acl, format | + RICHACL_TEXT_FILE_CONTEXT | + RICHACL_TEXT_DIRECTORY_CONTEXT)) { perror(file); return 1; } @@ -359,31 +359,31 @@ int main(int argc, char *argv[]) for (; optind < argc; optind++) { const char *file = argv[optind]; - struct nfs4acl *acl2 = NULL; + struct richacl *acl2 = NULL; if (opt_set) { - if (nfs4acl_set_file(file, acl)) + if (richacl_set_file(file, acl)) goto fail; } else if (opt_modify) { struct stat st; if (stat(file, &st)) goto fail; - acl2 = get_nfs4acl(file, st.st_mode); + acl2 = get_richacl(file, st.st_mode); if (!acl2) goto fail; - if (modify_nfs4acl(&acl2, acl, acl_has)) + if (modify_richacl(&acl2, acl, acl_has)) goto fail; if (opt_dry_run) { - if (print_nfs4acl(file, &acl2, format | + if (print_richacl(file, &acl2, format | format_for_mode(st.st_mode))) goto fail; } else { - if (nfs4acl_set_file(file, acl2)) + if (richacl_set_file(file, acl2)) goto fail; } } else if (opt_remove) { - if (removexattr(file, "system.nfs4acl")) { + if (removexattr(file, "system.richacl")) { if (errno != ENODATA) goto fail; } @@ -392,22 +392,22 @@ int main(int argc, char *argv[]) if (stat(file, &st)) goto fail; - acl2 = get_nfs4acl(file, st.st_mode); + acl2 = get_richacl(file, st.st_mode); if (!acl2) goto fail; - if (print_nfs4acl(file, &acl2, format | + if (print_richacl(file, &acl2, format | format_for_mode(st.st_mode))) goto fail; } - nfs4acl_free(acl2); + richacl_free(acl2); continue; fail: - nfs4acl_free(acl2); + richacl_free(acl2); perror(file); status = 1; } - nfs4acl_free(acl); + richacl_free(acl); return status; } -- 1.6.5.2.74.g610f9