]>
git.saurik.com Git - apple/libc.git/blob - posix1e/acl_file.c
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 /* XXX temporary implementation using __acl__ file */
26 #include <sys/appleapiopts.h>
27 #include <sys/types.h>
39 static acl_t
acl_get_file1(const char *path
, acl_type_t acl_type
, int follow
);
42 acl_delete_fd_np(int filedes
, acl_type_t type
)
49 acl_delete_file_np(const char *path
, acl_type_t type
)
56 acl_delete_link_np(const char *path
, acl_type_t type
)
65 return(acl_get_fd_np(fd
, ACL_TYPE_EXTENDED
));
69 acl_get_fd_np(int fd
, acl_type_t type
)
75 if (type
!= ACL_TYPE_EXTENDED
) {
79 if ((fsec
= filesec_init()) == NULL
)
83 if (fstatx_np(fd
, &sb
, fsec
) == 0)
84 filesec_get_property(fsec
, FILESEC_ACL
, &acl
);
90 acl_get_file1(const char *path
, acl_type_t acl_type
, int follow
)
96 if (acl_type
!= ACL_TYPE_EXTENDED
) {
100 if ((fsec
= filesec_init()) == NULL
)
104 if ((follow
? statx_np(path
, &sb
, fsec
) : lstatx_np(path
, &sb
, fsec
)) == 0)
105 filesec_get_property(fsec
, FILESEC_ACL
, &acl
);
111 acl_get_file(const char *path
, acl_type_t type
)
113 return(acl_get_file1(path
, type
, 1 /* follow */));
117 acl_get_link_np(const char *path
, acl_type_t type
)
119 return(acl_get_file1(path
, type
, 0 /* no follow */));
123 acl_set_fd_np(int fd
, acl_t acl
, acl_type_t type
)
128 if ((fsec
= filesec_init()) == NULL
)
130 if ((filesec_set_property(fsec
, FILESEC_ACL
, &acl
)) != 0) {
134 error
= fchmodx_np(fd
, fsec
);
136 return((error
== 0) ? 0 : -1);
140 acl_set_fd(int fd
, acl_t acl
)
142 return(acl_set_fd_np(fd
, acl
, ACL_TYPE_EXTENDED
));
146 acl_set_file(const char *path
, acl_type_t acl_type
, acl_t acl
)
151 if ((fsec
= filesec_init()) == NULL
)
153 if (filesec_set_property(fsec
, FILESEC_ACL
, &acl
) != 0) {
157 error
= chmodx_np(path
, fsec
);
159 return((error
== 0) ? 0 : -1);
163 acl_set_link_np(const char *path
, acl_type_t acl_type
, acl_t acl
)
167 if(lstat(path
, &s
) < 0)
169 if(S_ISLNK(s
.st_mode
)) {
173 return(acl_set_file(path
, acl_type
, acl
));
177 * Not applicable; not supported.
180 acl_delete_def_file(__unused
const char *path
)