1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

o Update copyright dates.

o Rename internal library functions so that they are prefixed with
  _posix1e or _POSIX1E, removing them from the application namespace (and
  potential conflict with other ACL functions elsewhere in the system).

Obtained from:	TrustedBSD Project
This commit is contained in:
Robert Watson 2001-03-13 02:31:32 +00:00
parent 438821dfc9
commit 2de14c39b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74191
20 changed files with 214 additions and 196 deletions

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_delete_def_file -- remove a default acl from a file

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_free -- free ACL objects from user memory

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999, 2000 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -173,7 +173,7 @@ acl_from_text(const char *buf_p)
goto error_label;
}
error = acl_string_to_perm(permission, &p);
error = _posix1e_acl_string_to_perm(permission, &p);
if (error == -1) {
errno = EINVAL;
goto error_label;
@ -193,7 +193,8 @@ acl_from_text(const char *buf_p)
case ACL_USER:
case ACL_GROUP:
error = acl_name_to_id(t, qualifier, &id);
error = _posix1e_acl_name_to_id(t, qualifier,
&id);
if (error == -1)
goto error_label;
break;
@ -203,7 +204,7 @@ acl_from_text(const char *buf_p)
goto error_label;
}
error = acl_add_entry(acl, t, id, p);
error = _posix1e_acl_add_entry(acl, t, id, p);
if (error == -1)
goto error_label;
}

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_get_file - syscall wrapper for retrieving ACL by filename

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_init -- return a fresh acl structure

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_set_file -- set a file/directory ACL by name
@ -46,8 +46,8 @@ acl_set_file(const char *path_p, acl_type_t type, acl_t acl)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);
@ -62,7 +62,7 @@ acl_set_fd(int fd, acl_t acl)
{
int error;
error = acl_sort(acl);
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return(-1);
@ -76,8 +76,8 @@ acl_set_fd_np(int fd, acl_t acl, acl_type_t type)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* Support functionality for the POSIX.1e ACL interface
@ -46,15 +46,15 @@
#define ACL_STRING_PERM_NONE '-'
/*
* acl_entry_compare -- compare two acl_entry structures to determine the
* order they should appear in. Used by acl_sort to sort ACL entries into
* the kernel-desired order -- i.e., the order useful for evaluation and
* O(n) validity checking. Beter to have an O(nlogn) sort in userland and
* an O(n) in kernel than to have both in kernel.
* _posix1e_acl_entry_compare -- compare two acl_entry structures to
* determine the order they should appear in. Used by _posix1e_acl_sort to
* sort ACL entries into the kernel-desired order -- i.e., the order useful
* for evaluation and O(n) validity checking. Beter to have an O(nlogn) sort
* in userland and an O(n) in kernel than to have both in kernel.
*/
typedef int (*compare)(const void *, const void *);
static int
acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
_posix1e_acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
{
/*
* First, sort between tags -- conveniently defined in the correct
@ -87,16 +87,16 @@ acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
}
/*
* acl_sort -- sort ACL entries.
* _posix1e_acl_sort -- sort ACL entries in POSIX.1e-formatted ACLs
* Give the opportunity to fail, althouh we don't currently have a way
* to fail.
*/
int
acl_sort(acl_t acl)
_posix1e_acl_sort(acl_t acl)
{
qsort(&acl->acl_entry[0], acl->acl_cnt, sizeof(struct acl_entry),
(compare) acl_entry_compare);
(compare) _posix1e_acl_entry_compare);
return (0);
}
@ -107,18 +107,18 @@ acl_sort(acl_t acl)
* ACL_TYPE_DEFAULT
*/
int
acl_posix1e(acl_t acl, acl_type_t type)
_posix1e_acl(acl_t acl, acl_type_t type)
{
return ((type == ACL_TYPE_ACCESS) || (type == ACL_TYPE_DEFAULT));
}
/*
* acl_check -- given an ACL, check its validity. This is mirrored from
* code in sys/kern/kern_acl.c, and if changes are made in one, they should
* be made in the other also. This copy of acl_check is made available
* in userland for the benefit of processes wanting to check ACLs for
* validity before submitting them to the kernel, or for performing
* _posix1e_acl_check -- given an ACL, check its validity. This is mirrored
* from code in sys/kern/kern_acl.c, and if changes are made in one, they
* should be made in the other also. This copy of acl_check is made
* available * in userland for the benefit of processes wanting to check ACLs
* for validity before submitting them to the kernel, or for performing
* in userland file system checking. Needless to say, the kernel makes
* the real checks on calls to get/setacl.
*
@ -128,7 +128,7 @@ acl_posix1e(acl_t acl, acl_type_t type)
* this. Returns 0 on success, EINVAL on failure.
*/
int
acl_check(struct acl *acl)
_posix1e_acl_check(struct acl *acl)
{
struct acl_entry *entry; /* current entry */
uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
@ -137,9 +137,9 @@ acl_check(struct acl *acl)
int count_user_obj=0, count_user=0, count_group_obj=0,
count_group=0, count_mask=0, count_other=0;
/* printf("acl_check: checking acl with %d entries\n", acl->acl_cnt); */
/* printf("_posix1e_acl_check: checking acl with %d entries\n",
acl->acl_cnt); */
while (i < acl->acl_cnt) {
entry = &acl->acl_entry[i];
if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
@ -147,7 +147,8 @@ acl_check(struct acl *acl)
switch(entry->ae_tag) {
case ACL_USER_OBJ:
/* printf("acl_check: %d: ACL_USER_OBJ\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_USER_OBJ\n",
i); */
if (stage > ACL_USER_OBJ)
return (EINVAL);
stage = ACL_USER;
@ -156,7 +157,7 @@ acl_check(struct acl *acl)
break;
case ACL_USER:
/* printf("acl_check: %d: ACL_USER\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_USER\n", i); */
if (stage > ACL_USER)
return (EINVAL);
stage = ACL_USER;
@ -169,7 +170,8 @@ acl_check(struct acl *acl)
break;
case ACL_GROUP_OBJ:
/* printf("acl_check: %d: ACL_GROUP_OBJ\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_GROUP_OBJ\n",
i); */
if (stage > ACL_GROUP_OBJ)
return (EINVAL);
stage = ACL_GROUP;
@ -178,7 +180,7 @@ acl_check(struct acl *acl)
break;
case ACL_GROUP:
/* printf("acl_check: %d: ACL_GROUP\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_GROUP\n", i); */
if (stage > ACL_GROUP)
return (EINVAL);
stage = ACL_GROUP;
@ -191,7 +193,7 @@ acl_check(struct acl *acl)
break;
case ACL_MASK:
/* printf("acl_check: %d: ACL_MASK\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_MASK\n", i); */
if (stage > ACL_MASK)
return (EINVAL);
stage = ACL_MASK;
@ -199,7 +201,7 @@ acl_check(struct acl *acl)
break;
case ACL_OTHER:
/* printf("acl_check: %d: ACL_OTHER\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_OTHER\n", i); */
if (stage > ACL_OTHER)
return (EINVAL);
stage = ACL_OTHER;
@ -207,7 +209,7 @@ acl_check(struct acl *acl)
break;
default:
/* printf("acl_check: %d: INVALID\n", i); */
/* printf("_posix1e_acl_check: %d: INVALID\n", i); */
return (EINVAL);
}
i++;
@ -236,7 +238,7 @@ acl_check(struct acl *acl)
* MAY HAVE SIDE-EFFECTS
*/
int
acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
_posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
{
struct group *g;
struct passwd *p;
@ -285,7 +287,7 @@ acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
* instead of a username. What is correct behavior here? Check chown.
*/
int
acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
_posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
{
struct group *g;
struct passwd *p;
@ -332,10 +334,10 @@ acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
* in a string describing the permissions.
*/
int
acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
_posix1e_acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
{
if (buf_len < ACL_STRING_PERM_MAXSIZE + 1) {
if (buf_len < _POSIX1E_ACL_STRING_PERM_MAXSIZE + 1) {
errno = ENOMEM;
return (-1);
}
@ -369,7 +371,7 @@ acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
* given a string, return a permission describing it
*/
int
acl_string_to_perm(char *string, acl_perm_t *perm)
_posix1e_acl_string_to_perm(char *string, acl_perm_t *perm)
{
acl_perm_t myperm = ACL_PERM_NONE;
char *ch;
@ -402,7 +404,7 @@ acl_string_to_perm(char *string, acl_perm_t *perm)
* Add an ACL entry without doing much checking, et al
*/
int
acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
_posix1e_acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
{
struct acl_entry *e;

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* Support functionality for the POSIX.1e ACL interface
@ -32,15 +32,18 @@
#ifndef _ACL_SUPPORT_H
#define _ACL_SUPPORT_H
#define ACL_STRING_PERM_MAXSIZE 3 /* read, write, exec */
#define _POSIX1E_ACL_STRING_PERM_MAXSIZE 3 /* read, write, exec */
int acl_check(struct acl *acl);
int acl_sort(acl_t acl);
int acl_posix1e(acl_t acl, acl_type_t type);
int acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf);
int acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
int acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf);
int acl_string_to_perm(char *string, acl_perm_t *perm);
int acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm);
int _posix1e_acl_check(struct acl *acl);
int _posix1e_acl_sort(acl_t acl);
int _posix1e_acl(acl_t acl, acl_type_t type);
int _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len,
char *buf);
int _posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
int _posix1e_acl_perm_to_string(acl_perm_t perm, ssize_t buf_len,
char *buf);
int _posix1e_acl_string_to_perm(char *string, acl_perm_t *perm);
int _posix1e_acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id,
acl_perm_t perm);
#endif

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 20001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_to_text - return a text string with a text representation of the acl
@ -52,8 +52,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
{
char *buf, *tmpbuf;
char name_buf[UT_NAMESIZE+1];
char perm_buf[ACL_STRING_PERM_MAXSIZE+1],
effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1];
char perm_buf[_POSIX1E_ACL_STRING_PERM_MAXSIZE+1],
effective_perm_buf[_POSIX1E_ACL_STRING_PERM_MAXSIZE+1];
int i, error, len;
uid_t ae_id;
acl_tag_t ae_tag;
@ -75,8 +75,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
switch(ae_tag) {
case ACL_USER_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%suser::%s\n", buf,
@ -88,20 +88,21 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_USER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, UT_NAMESIZE+1,
name_buf);
error = _posix1e_acl_id_to_name(ae_tag, ae_id,
UT_NAMESIZE+1, name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
error = _posix1e_acl_perm_to_string(
effective_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
@ -120,15 +121,16 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_GROUP_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
error = _posix1e_acl_perm_to_string(
effective_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
@ -146,20 +148,21 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_GROUP:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, UT_NAMESIZE+1,
name_buf);
error = _posix1e_acl_id_to_name(ae_tag, ae_id,
UT_NAMESIZE+1, name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
error = _posix1e_acl_perm_to_string(
effective_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
@ -177,8 +180,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_MASK:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
@ -191,8 +194,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_OTHER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 20001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_valid -- POSIX.1e ACL check routine
@ -40,7 +40,7 @@
* and errno set to EINVAL.
*
* Implemented by calling the acl_check routine in acl_support, which
* requires ordering. We call acl_support's acl_sort to make this
* requires ordering. We call acl_support's _posix1e_acl_sort to make this
* true. POSIX.1e allows acl_valid() to reorder the ACL as it sees fit.
*
* This call is deprecated, as it doesn't ask whether the ACL is valid
@ -52,8 +52,8 @@ acl_valid(acl_t acl)
{
int error;
acl_sort(acl);
error = acl_check(acl);
_posix1e_acl_sort(acl);
error = _posix1e_acl_check(acl);
if (error) {
errno = error;
return (-1);
@ -68,8 +68,8 @@ acl_valid_file_np(const char *pathp, acl_type_t type, acl_t acl)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);
@ -85,8 +85,8 @@ acl_valid_fd_np(int fd, acl_type_t type, acl_t acl)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_delete_def_file -- remove a default acl from a file

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_free -- free ACL objects from user memory

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999, 2000 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -173,7 +173,7 @@ acl_from_text(const char *buf_p)
goto error_label;
}
error = acl_string_to_perm(permission, &p);
error = _posix1e_acl_string_to_perm(permission, &p);
if (error == -1) {
errno = EINVAL;
goto error_label;
@ -193,7 +193,8 @@ acl_from_text(const char *buf_p)
case ACL_USER:
case ACL_GROUP:
error = acl_name_to_id(t, qualifier, &id);
error = _posix1e_acl_name_to_id(t, qualifier,
&id);
if (error == -1)
goto error_label;
break;
@ -203,7 +204,7 @@ acl_from_text(const char *buf_p)
goto error_label;
}
error = acl_add_entry(acl, t, id, p);
error = _posix1e_acl_add_entry(acl, t, id, p);
if (error == -1)
goto error_label;
}

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_get_file - syscall wrapper for retrieving ACL by filename

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_init -- return a fresh acl structure

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_set_file -- set a file/directory ACL by name
@ -46,8 +46,8 @@ acl_set_file(const char *path_p, acl_type_t type, acl_t acl)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);
@ -62,7 +62,7 @@ acl_set_fd(int fd, acl_t acl)
{
int error;
error = acl_sort(acl);
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return(-1);
@ -76,8 +76,8 @@ acl_set_fd_np(int fd, acl_t acl, acl_type_t type)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* Support functionality for the POSIX.1e ACL interface
@ -46,15 +46,15 @@
#define ACL_STRING_PERM_NONE '-'
/*
* acl_entry_compare -- compare two acl_entry structures to determine the
* order they should appear in. Used by acl_sort to sort ACL entries into
* the kernel-desired order -- i.e., the order useful for evaluation and
* O(n) validity checking. Beter to have an O(nlogn) sort in userland and
* an O(n) in kernel than to have both in kernel.
* _posix1e_acl_entry_compare -- compare two acl_entry structures to
* determine the order they should appear in. Used by _posix1e_acl_sort to
* sort ACL entries into the kernel-desired order -- i.e., the order useful
* for evaluation and O(n) validity checking. Beter to have an O(nlogn) sort
* in userland and an O(n) in kernel than to have both in kernel.
*/
typedef int (*compare)(const void *, const void *);
static int
acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
_posix1e_acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
{
/*
* First, sort between tags -- conveniently defined in the correct
@ -87,16 +87,16 @@ acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
}
/*
* acl_sort -- sort ACL entries.
* _posix1e_acl_sort -- sort ACL entries in POSIX.1e-formatted ACLs
* Give the opportunity to fail, althouh we don't currently have a way
* to fail.
*/
int
acl_sort(acl_t acl)
_posix1e_acl_sort(acl_t acl)
{
qsort(&acl->acl_entry[0], acl->acl_cnt, sizeof(struct acl_entry),
(compare) acl_entry_compare);
(compare) _posix1e_acl_entry_compare);
return (0);
}
@ -107,18 +107,18 @@ acl_sort(acl_t acl)
* ACL_TYPE_DEFAULT
*/
int
acl_posix1e(acl_t acl, acl_type_t type)
_posix1e_acl(acl_t acl, acl_type_t type)
{
return ((type == ACL_TYPE_ACCESS) || (type == ACL_TYPE_DEFAULT));
}
/*
* acl_check -- given an ACL, check its validity. This is mirrored from
* code in sys/kern/kern_acl.c, and if changes are made in one, they should
* be made in the other also. This copy of acl_check is made available
* in userland for the benefit of processes wanting to check ACLs for
* validity before submitting them to the kernel, or for performing
* _posix1e_acl_check -- given an ACL, check its validity. This is mirrored
* from code in sys/kern/kern_acl.c, and if changes are made in one, they
* should be made in the other also. This copy of acl_check is made
* available * in userland for the benefit of processes wanting to check ACLs
* for validity before submitting them to the kernel, or for performing
* in userland file system checking. Needless to say, the kernel makes
* the real checks on calls to get/setacl.
*
@ -128,7 +128,7 @@ acl_posix1e(acl_t acl, acl_type_t type)
* this. Returns 0 on success, EINVAL on failure.
*/
int
acl_check(struct acl *acl)
_posix1e_acl_check(struct acl *acl)
{
struct acl_entry *entry; /* current entry */
uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
@ -137,9 +137,9 @@ acl_check(struct acl *acl)
int count_user_obj=0, count_user=0, count_group_obj=0,
count_group=0, count_mask=0, count_other=0;
/* printf("acl_check: checking acl with %d entries\n", acl->acl_cnt); */
/* printf("_posix1e_acl_check: checking acl with %d entries\n",
acl->acl_cnt); */
while (i < acl->acl_cnt) {
entry = &acl->acl_entry[i];
if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
@ -147,7 +147,8 @@ acl_check(struct acl *acl)
switch(entry->ae_tag) {
case ACL_USER_OBJ:
/* printf("acl_check: %d: ACL_USER_OBJ\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_USER_OBJ\n",
i); */
if (stage > ACL_USER_OBJ)
return (EINVAL);
stage = ACL_USER;
@ -156,7 +157,7 @@ acl_check(struct acl *acl)
break;
case ACL_USER:
/* printf("acl_check: %d: ACL_USER\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_USER\n", i); */
if (stage > ACL_USER)
return (EINVAL);
stage = ACL_USER;
@ -169,7 +170,8 @@ acl_check(struct acl *acl)
break;
case ACL_GROUP_OBJ:
/* printf("acl_check: %d: ACL_GROUP_OBJ\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_GROUP_OBJ\n",
i); */
if (stage > ACL_GROUP_OBJ)
return (EINVAL);
stage = ACL_GROUP;
@ -178,7 +180,7 @@ acl_check(struct acl *acl)
break;
case ACL_GROUP:
/* printf("acl_check: %d: ACL_GROUP\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_GROUP\n", i); */
if (stage > ACL_GROUP)
return (EINVAL);
stage = ACL_GROUP;
@ -191,7 +193,7 @@ acl_check(struct acl *acl)
break;
case ACL_MASK:
/* printf("acl_check: %d: ACL_MASK\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_MASK\n", i); */
if (stage > ACL_MASK)
return (EINVAL);
stage = ACL_MASK;
@ -199,7 +201,7 @@ acl_check(struct acl *acl)
break;
case ACL_OTHER:
/* printf("acl_check: %d: ACL_OTHER\n", i); */
/* printf("_posix1e_acl_check: %d: ACL_OTHER\n", i); */
if (stage > ACL_OTHER)
return (EINVAL);
stage = ACL_OTHER;
@ -207,7 +209,7 @@ acl_check(struct acl *acl)
break;
default:
/* printf("acl_check: %d: INVALID\n", i); */
/* printf("_posix1e_acl_check: %d: INVALID\n", i); */
return (EINVAL);
}
i++;
@ -236,7 +238,7 @@ acl_check(struct acl *acl)
* MAY HAVE SIDE-EFFECTS
*/
int
acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
_posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
{
struct group *g;
struct passwd *p;
@ -285,7 +287,7 @@ acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
* instead of a username. What is correct behavior here? Check chown.
*/
int
acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
_posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
{
struct group *g;
struct passwd *p;
@ -332,10 +334,10 @@ acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
* in a string describing the permissions.
*/
int
acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
_posix1e_acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
{
if (buf_len < ACL_STRING_PERM_MAXSIZE + 1) {
if (buf_len < _POSIX1E_ACL_STRING_PERM_MAXSIZE + 1) {
errno = ENOMEM;
return (-1);
}
@ -369,7 +371,7 @@ acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
* given a string, return a permission describing it
*/
int
acl_string_to_perm(char *string, acl_perm_t *perm)
_posix1e_acl_string_to_perm(char *string, acl_perm_t *perm)
{
acl_perm_t myperm = ACL_PERM_NONE;
char *ch;
@ -402,7 +404,7 @@ acl_string_to_perm(char *string, acl_perm_t *perm)
* Add an ACL entry without doing much checking, et al
*/
int
acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
_posix1e_acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
{
struct acl_entry *e;

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* Support functionality for the POSIX.1e ACL interface
@ -32,15 +32,18 @@
#ifndef _ACL_SUPPORT_H
#define _ACL_SUPPORT_H
#define ACL_STRING_PERM_MAXSIZE 3 /* read, write, exec */
#define _POSIX1E_ACL_STRING_PERM_MAXSIZE 3 /* read, write, exec */
int acl_check(struct acl *acl);
int acl_sort(acl_t acl);
int acl_posix1e(acl_t acl, acl_type_t type);
int acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf);
int acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
int acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf);
int acl_string_to_perm(char *string, acl_perm_t *perm);
int acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm);
int _posix1e_acl_check(struct acl *acl);
int _posix1e_acl_sort(acl_t acl);
int _posix1e_acl(acl_t acl, acl_type_t type);
int _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len,
char *buf);
int _posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
int _posix1e_acl_perm_to_string(acl_perm_t perm, ssize_t buf_len,
char *buf);
int _posix1e_acl_string_to_perm(char *string, acl_perm_t *perm);
int _posix1e_acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id,
acl_perm_t perm);
#endif

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 20001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_to_text - return a text string with a text representation of the acl
@ -52,8 +52,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
{
char *buf, *tmpbuf;
char name_buf[UT_NAMESIZE+1];
char perm_buf[ACL_STRING_PERM_MAXSIZE+1],
effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1];
char perm_buf[_POSIX1E_ACL_STRING_PERM_MAXSIZE+1],
effective_perm_buf[_POSIX1E_ACL_STRING_PERM_MAXSIZE+1];
int i, error, len;
uid_t ae_id;
acl_tag_t ae_tag;
@ -75,8 +75,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
switch(ae_tag) {
case ACL_USER_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%suser::%s\n", buf,
@ -88,20 +88,21 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_USER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, UT_NAMESIZE+1,
name_buf);
error = _posix1e_acl_id_to_name(ae_tag, ae_id,
UT_NAMESIZE+1, name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
error = _posix1e_acl_perm_to_string(
effective_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
@ -120,15 +121,16 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_GROUP_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
error = _posix1e_acl_perm_to_string(
effective_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
@ -146,20 +148,21 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_GROUP:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, UT_NAMESIZE+1,
name_buf);
error = _posix1e_acl_id_to_name(ae_tag, ae_id,
UT_NAMESIZE+1, name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
error = _posix1e_acl_perm_to_string(
effective_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
@ -177,8 +180,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_MASK:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
@ -191,8 +194,8 @@ acl_to_text(acl_t acl, ssize_t *len_p)
break;
case ACL_OTHER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
error = _posix1e_acl_perm_to_string(ae_perm,
_POSIX1E_ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 1999 Robert N. M. Watson
* Copyright (c) 1999, 2000, 20001 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
/*
* acl_valid -- POSIX.1e ACL check routine
@ -40,7 +40,7 @@
* and errno set to EINVAL.
*
* Implemented by calling the acl_check routine in acl_support, which
* requires ordering. We call acl_support's acl_sort to make this
* requires ordering. We call acl_support's _posix1e_acl_sort to make this
* true. POSIX.1e allows acl_valid() to reorder the ACL as it sees fit.
*
* This call is deprecated, as it doesn't ask whether the ACL is valid
@ -52,8 +52,8 @@ acl_valid(acl_t acl)
{
int error;
acl_sort(acl);
error = acl_check(acl);
_posix1e_acl_sort(acl);
error = _posix1e_acl_check(acl);
if (error) {
errno = error;
return (-1);
@ -68,8 +68,8 @@ acl_valid_file_np(const char *pathp, acl_type_t type, acl_t acl)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);
@ -85,8 +85,8 @@ acl_valid_fd_np(int fd, acl_type_t type, acl_t acl)
{
int error;
if (acl_posix1e(acl, type)) {
error = acl_sort(acl);
if (_posix1e_acl(acl, type)) {
error = _posix1e_acl_sort(acl);
if (error) {
errno = error;
return (-1);