Deleted Added
full compact
acl_support.c (75404) acl_support.c (75928)
1/*-
2 * Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libc/posix1e/acl_support.c 75404 2001-04-11 02:19:01Z jedgar $
26 * $FreeBSD: head/lib/libc/posix1e/acl_support.c 75928 2001-04-24 22:45:41Z jedgar $
27 */
28/*
29 * Support functionality for the POSIX.1e ACL interface
30 * These calls are intended only to be called within the library.
31 */
32
33#include <sys/types.h>
34#include "namespace.h"

--- 56 unchanged lines hidden (view full) ---

91/*
92 * _posix1e_acl_sort -- sort ACL entries in POSIX.1e-formatted ACLs
93 * Give the opportunity to fail, althouh we don't currently have a way
94 * to fail.
95 */
96int
97_posix1e_acl_sort(acl_t acl)
98{
27 */
28/*
29 * Support functionality for the POSIX.1e ACL interface
30 * These calls are intended only to be called within the library.
31 */
32
33#include <sys/types.h>
34#include "namespace.h"

--- 56 unchanged lines hidden (view full) ---

91/*
92 * _posix1e_acl_sort -- sort ACL entries in POSIX.1e-formatted ACLs
93 * Give the opportunity to fail, althouh we don't currently have a way
94 * to fail.
95 */
96int
97_posix1e_acl_sort(acl_t acl)
98{
99 struct acl *acl_int;
99
100
100 qsort(&acl->acl_entry[0], acl->acl_cnt, sizeof(struct acl_entry),
101 (compare) _posix1e_acl_entry_compare);
101 acl_int = &acl->ats_acl;
102
102
103 qsort(&acl_int->acl_entry[0], acl_int->acl_cnt,
104 sizeof(struct acl_entry), (compare) _posix1e_acl_entry_compare);
105
103 return (0);
104}
105
106/*
107 * acl_posix1e -- in what situations should we acl_sort before submission?
108 * We apply posix1e ACL semantics for any ACL of type ACL_TYPE_ACCESS or
109 * ACL_TYPE_DEFAULT
110 */

--- 14 unchanged lines hidden (view full) ---

125 * the real checks on calls to get/setacl.
126 *
127 * See the comments in kernel for explanation -- just briefly, it assumes
128 * an already sorted ACL, and checks based on that assumption. The
129 * POSIX.1e interface, acl_valid(), will perform the sort before calling
130 * this. Returns 0 on success, EINVAL on failure.
131 */
132int
106 return (0);
107}
108
109/*
110 * acl_posix1e -- in what situations should we acl_sort before submission?
111 * We apply posix1e ACL semantics for any ACL of type ACL_TYPE_ACCESS or
112 * ACL_TYPE_DEFAULT
113 */

--- 14 unchanged lines hidden (view full) ---

128 * the real checks on calls to get/setacl.
129 *
130 * See the comments in kernel for explanation -- just briefly, it assumes
131 * an already sorted ACL, and checks based on that assumption. The
132 * POSIX.1e interface, acl_valid(), will perform the sort before calling
133 * this. Returns 0 on success, EINVAL on failure.
134 */
135int
133_posix1e_acl_check(struct acl *acl)
136_posix1e_acl_check(acl_t acl)
134{
137{
138 struct acl *acl_int;
135 struct acl_entry *entry; /* current entry */
136 uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
137 int stage = ACL_USER_OBJ;
138 int i = 0;
139 int count_user_obj=0, count_user=0, count_group_obj=0,
140 count_group=0, count_mask=0, count_other=0;
141
139 struct acl_entry *entry; /* current entry */
140 uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
141 int stage = ACL_USER_OBJ;
142 int i = 0;
143 int count_user_obj=0, count_user=0, count_group_obj=0,
144 count_group=0, count_mask=0, count_other=0;
145
146 acl_int = &acl->ats_acl;
147
142 /* printf("_posix1e_acl_check: checking acl with %d entries\n",
143 acl->acl_cnt); */
148 /* printf("_posix1e_acl_check: checking acl with %d entries\n",
149 acl->acl_cnt); */
144 while (i < acl->acl_cnt) {
145 entry = &acl->acl_entry[i];
150 while (i < acl_int->acl_cnt) {
151 entry = &acl_int->acl_entry[i];
146
147 if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
148 return (EINVAL);
149
150 switch(entry->ae_tag) {
151 case ACL_USER_OBJ:
152 /* printf("_posix1e_acl_check: %d: ACL_USER_OBJ\n",
153 i); */

--- 249 unchanged lines hidden (view full) ---

403}
404
405/*
406 * Add an ACL entry without doing much checking, et al
407 */
408int
409_posix1e_acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
410{
152
153 if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
154 return (EINVAL);
155
156 switch(entry->ae_tag) {
157 case ACL_USER_OBJ:
158 /* printf("_posix1e_acl_check: %d: ACL_USER_OBJ\n",
159 i); */

--- 249 unchanged lines hidden (view full) ---

409}
410
411/*
412 * Add an ACL entry without doing much checking, et al
413 */
414int
415_posix1e_acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
416{
417 struct acl *acl_int;
411 struct acl_entry *e;
412
418 struct acl_entry *e;
419
413 if (acl->acl_cnt >= ACL_MAX_ENTRIES) {
420 acl_int = &acl->ats_acl;
421
422 if (acl_int->acl_cnt >= ACL_MAX_ENTRIES) {
414 errno = ENOMEM;
415 return (-1);
416 }
417
423 errno = ENOMEM;
424 return (-1);
425 }
426
418 e = &(acl->acl_entry[acl->acl_cnt]);
427 e = &(acl_int->acl_entry[acl_int->acl_cnt]);
419 e->ae_perm = perm;
420 e->ae_tag = tag;
421 e->ae_id = id;
428 e->ae_perm = perm;
429 e->ae_tag = tag;
430 e->ae_id = id;
422 acl->acl_cnt++;
431 acl_int->acl_cnt++;
423
424 return (0);
425}
432
433 return (0);
434}