]> git.saurik.com Git - apple/libc.git/blob - posix1e/acl.c
Libc-1082.50.1.tar.gz
[apple/libc.git] / posix1e / acl.c
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #include <sys/appleapiopts.h>
25 #include <sys/types.h>
26 #include <sys/acl.h>
27 #include <errno.h>
28 #include <fcntl.h>
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include "aclvar.h"
33
34 acl_t
35 acl_dup(acl_t acl)
36 {
37 struct _acl *ap;
38
39 if (!_ACL_VALID_ACL(acl)) {
40 errno = EINVAL;
41 return(NULL);
42 }
43
44 if ((ap = malloc(sizeof(*ap))) != NULL)
45 bcopy(acl, ap, sizeof(*ap));
46 return(ap);
47 }
48
49 int
50 acl_free(void *obj)
51 {
52 /*
53 * Without tracking the addresses of text buffers and qualifiers,
54 * we can't validate the obj argument here at all.
55 */
56 if(obj != _FILESEC_REMOVE_ACL)
57 free(obj);
58 return(0);
59 }
60
61 acl_t
62 acl_init(int count)
63 {
64 struct _acl *ap;
65
66 /* validate count */
67 if (count < 0) {
68 errno = EINVAL;
69 return(NULL);
70 }
71 if (count > ACL_MAX_ENTRIES) {
72 errno = ENOMEM;
73 return(NULL);
74 }
75
76 if ((ap = malloc(sizeof (*ap))) != NULL) {
77 bzero(ap, sizeof(*ap));
78 ap->a_magic = _ACL_ACL_MAGIC;
79 ap->a_last_get = -1;
80 }
81 return(ap);
82 }
83
84 int
85 acl_valid(acl_t acl)
86 {
87 _ACL_VALIDATE_ACL(acl);
88
89 /* XXX */
90 return(0);
91 }
92
93 int
94 acl_valid_fd_np(int fd, acl_type_t type, acl_t acl)
95 {
96 errno = ENOTSUP; /* XXX */
97 return(-1);
98 }
99
100 int
101 acl_valid_file_np(const char *path, acl_type_t type, acl_t acl)
102 {
103 errno = ENOTSUP; /* XXX */
104 return(-1);
105 }
106
107 int
108 acl_valid_link(const char *path, acl_type_t type, acl_t acl)
109 {
110 errno = ENOTSUP; /* XXX */
111 return(-1);
112 }
113
114 /*
115 * Not applicable; not supportedl
116 */
117 int
118 acl_calc_mask(__unused acl_t *acl_p)
119 {
120 errno = ENOTSUP;
121 return(-1);
122 }