Deleted Added
full compact
acl_set.c (74191) acl_set.c (74667)
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_set.c 74191 2001-03-13 02:31:32Z rwatson $
26 * $FreeBSD: head/lib/libc/posix1e/acl_set.c 74667 2001-03-22 22:31:01Z jedgar $
27 */
28/*
29 * acl_set_file -- set a file/directory ACL by name
30 */
31
32#include <sys/types.h>
33#include <sys/acl.h>
27 */
28/*
29 * acl_set_file -- set a file/directory ACL by name
30 */
31
32#include <sys/types.h>
33#include <sys/acl.h>
34
34#include <errno.h>
35#include <errno.h>
36#include <stdlib.h>
37#include <string.h>
35
36#include "acl_support.h"
37
38/*
39 * For POSIX.1e-semantic ACLs, do a presort so the kernel doesn't have to
40 * (the POSIX.1e semantic code will reject unsorted ACL submission). If it's
41 * not a semantic that the library knows about, just submit it flat and
42 * assume the caller knows what they're up to.

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

81 if (error) {
82 errno = error;
83 return (-1);
84 }
85 }
86
87 return (__acl_set_fd(fd, type, acl));
88}
38
39#include "acl_support.h"
40
41/*
42 * For POSIX.1e-semantic ACLs, do a presort so the kernel doesn't have to
43 * (the POSIX.1e semantic code will reject unsorted ACL submission). If it's
44 * not a semantic that the library knows about, just submit it flat and
45 * assume the caller knows what they're up to.

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

84 if (error) {
85 errno = error;
86 return (-1);
87 }
88 }
89
90 return (__acl_set_fd(fd, type, acl));
91}
92
93/*
94 * acl_set_permset() sets the permissions of ACL entry entry_d
95 * with the permissions in permset_d
96 */
97int
98acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d)
99{
100
101 if (!entry_d) {
102 errno = EINVAL;
103 return -1;
104 }
105
106 entry_d->ae_perm = *permset_d;
107
108 return 0;
109}
110
111/*
112 * acl_set_qualifier() sets the qualifier (ae_id) of the tag for
113 * ACL entry entry_d to the value referred to by tag_qualifier_p
114 */
115int
116acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p)
117{
118 if (!entry_d || !tag_qualifier_p) {
119 errno = EINVAL;
120 return -1;
121 }
122
123 switch(entry_d->ae_tag) {
124 case ACL_USER:
125 case ACL_GROUP:
126 entry_d->ae_id = (uid_t)tag_qualifier_p;
127 break;
128 default:
129 errno = EINVAL;
130 return -1;
131 }
132
133 return 0;
134}
135
136/*
137 * acl_set_tag_type() sets the tag type for ACL entry entry_d to the
138 * value of tag_type
139 */
140int
141acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type)
142{
143
144 if (!entry_d) {
145 errno = EINVAL;
146 return -1;
147 }
148
149 switch(tag_type) {
150 case ACL_USER_OBJ:
151 case ACL_USER:
152 case ACL_GROUP_OBJ:
153 case ACL_GROUP:
154 case ACL_MASK:
155 case ACL_OTHER:
156 entry_d->ae_tag = tag_type;
157 return 0;
158 }
159
160 errno = EINVAL;
161 return -1;
162}