acl_get.c (75928) | acl_get.c (91034) |
---|---|
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_get.c 75928 2001-04-24 22:45:41Z jedgar $ | 26 * $FreeBSD: head/lib/libc/posix1e/acl_get.c 91034 2002-02-21 23:17:19Z jedgar $ |
27 */ 28/* 29 * acl_get_file - syscall wrapper for retrieving ACL by filename 30 * acl_get_fd - syscall wrapper for retrieving access ACL by fd 31 * acl_get_fd_np - syscall wrapper for retrieving ACL by fd (non-POSIX) 32 * acl_get_perm_np() checks if a permission is in the specified 33 * permset (non-POSIX) 34 * acl_get_permset() returns the permission set in the ACL entry --- 12 unchanged lines hidden (view full) --- 47 48acl_t 49acl_get_file(const char *path_p, acl_type_t type) 50{ 51 acl_t aclp; 52 int error; 53 54 aclp = acl_init(ACL_MAX_ENTRIES); | 27 */ 28/* 29 * acl_get_file - syscall wrapper for retrieving ACL by filename 30 * acl_get_fd - syscall wrapper for retrieving access ACL by fd 31 * acl_get_fd_np - syscall wrapper for retrieving ACL by fd (non-POSIX) 32 * acl_get_perm_np() checks if a permission is in the specified 33 * permset (non-POSIX) 34 * acl_get_permset() returns the permission set in the ACL entry --- 12 unchanged lines hidden (view full) --- 47 48acl_t 49acl_get_file(const char *path_p, acl_type_t type) 50{ 51 acl_t aclp; 52 int error; 53 54 aclp = acl_init(ACL_MAX_ENTRIES); |
55 if (!aclp) { | 55 if (aclp == NULL) |
56 return (NULL); | 56 return (NULL); |
57 } | |
58 59 error = __acl_get_file(path_p, type, &aclp->ats_acl); 60 if (error) { 61 acl_free(aclp); 62 return (NULL); 63 } 64 65 return (aclp); 66} 67 68acl_t 69acl_get_fd(int fd) 70{ 71 acl_t aclp; 72 int error; 73 74 aclp = acl_init(ACL_MAX_ENTRIES); | 57 58 error = __acl_get_file(path_p, type, &aclp->ats_acl); 59 if (error) { 60 acl_free(aclp); 61 return (NULL); 62 } 63 64 return (aclp); 65} 66 67acl_t 68acl_get_fd(int fd) 69{ 70 acl_t aclp; 71 int error; 72 73 aclp = acl_init(ACL_MAX_ENTRIES); |
75 if (!aclp) { | 74 if (aclp == NULL) |
76 return (NULL); | 75 return (NULL); |
77 } | |
78 79 error = ___acl_get_fd(fd, ACL_TYPE_ACCESS, &aclp->ats_acl); 80 if (error) { 81 acl_free(aclp); 82 return (NULL); 83 } 84 85 return (aclp); 86} 87 88acl_t 89acl_get_fd_np(int fd, acl_type_t type) 90{ 91 acl_t aclp; 92 int error; 93 94 aclp = acl_init(ACL_MAX_ENTRIES); | 76 77 error = ___acl_get_fd(fd, ACL_TYPE_ACCESS, &aclp->ats_acl); 78 if (error) { 79 acl_free(aclp); 80 return (NULL); 81 } 82 83 return (aclp); 84} 85 86acl_t 87acl_get_fd_np(int fd, acl_type_t type) 88{ 89 acl_t aclp; 90 int error; 91 92 aclp = acl_init(ACL_MAX_ENTRIES); |
95 if (!aclp) { | 93 if (aclp == NULL) |
96 return (NULL); | 94 return (NULL); |
97 } | |
98 99 error = ___acl_get_fd(fd, type, &aclp->ats_acl); 100 if (error) { 101 acl_free(aclp); 102 return (NULL); 103 } 104 105 return (aclp); 106} 107 108int 109acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm) 110{ 111 | 95 96 error = ___acl_get_fd(fd, type, &aclp->ats_acl); 97 if (error) { 98 acl_free(aclp); 99 return (NULL); 100 } 101 102 return (aclp); 103} 104 105int 106acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm) 107{ 108 |
112 if (!permset_d) { | 109 if (permset_d == NULL) { |
113 errno = EINVAL; | 110 errno = EINVAL; |
114 return -1; | 111 return (-1); |
115 } 116 117 switch(perm) { 118 case ACL_READ: 119 case ACL_WRITE: 120 case ACL_EXECUTE: 121 if (*permset_d & perm) | 112 } 113 114 switch(perm) { 115 case ACL_READ: 116 case ACL_WRITE: 117 case ACL_EXECUTE: 118 if (*permset_d & perm) |
122 return 1; | 119 return (1); |
123 break; 124 default: 125 errno = EINVAL; | 120 break; 121 default: 122 errno = EINVAL; |
126 return -1; | 123 return (-1); |
127 } 128 | 124 } 125 |
129 return 0; | 126 return (0); |
130} 131 132/* 133 * acl_get_permset() (23.4.17): return via permset_p a descriptor to 134 * the permission set in the ACL entry entry_d. 135 */ 136int 137acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p) 138{ 139 | 127} 128 129/* 130 * acl_get_permset() (23.4.17): return via permset_p a descriptor to 131 * the permission set in the ACL entry entry_d. 132 */ 133int 134acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p) 135{ 136 |
140 if (!entry_d || !permset_p) { | 137 if (entry_d == NULL || permset_p == NULL) { |
141 errno = EINVAL; | 138 errno = EINVAL; |
142 return -1; | 139 return (-1); |
143 } 144 145 *permset_p = &entry_d->ae_perm; 146 | 140 } 141 142 *permset_p = &entry_d->ae_perm; 143 |
147 return 0; | 144 return (0); |
148} 149 150/* 151 * acl_get_qualifier() (23.4.18): retrieve the qualifier of the tag 152 * for the ACL entry entry_d. 153 */ 154void * 155acl_get_qualifier(acl_entry_t entry_d) 156{ 157 uid_t *retval; 158 | 145} 146 147/* 148 * acl_get_qualifier() (23.4.18): retrieve the qualifier of the tag 149 * for the ACL entry entry_d. 150 */ 151void * 152acl_get_qualifier(acl_entry_t entry_d) 153{ 154 uid_t *retval; 155 |
159 if (!entry_d) { | 156 if (entry_d == NULL) { |
160 errno = EINVAL; | 157 errno = EINVAL; |
161 return NULL; | 158 return (NULL); |
162 } 163 164 switch(entry_d->ae_tag) { 165 case ACL_USER: 166 case ACL_GROUP: 167 retval = malloc(sizeof(uid_t)); | 159 } 160 161 switch(entry_d->ae_tag) { 162 case ACL_USER: 163 case ACL_GROUP: 164 retval = malloc(sizeof(uid_t)); |
168 if (!retval) 169 return NULL; | 165 if (retval == NULL) 166 return (NULL); |
170 *retval = entry_d->ae_id; | 167 *retval = entry_d->ae_id; |
171 return retval; | 168 return (retval); |
172 } 173 174 errno = EINVAL; | 169 } 170 171 errno = EINVAL; |
175 return NULL; | 172 return (NULL); |
176} 177 178/* 179 * acl_get_tag_type() (23.4.19): return the tag type for the ACL 180 * entry entry_p. 181 */ 182int 183acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p) 184{ 185 | 173} 174 175/* 176 * acl_get_tag_type() (23.4.19): return the tag type for the ACL 177 * entry entry_p. 178 */ 179int 180acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p) 181{ 182 |
186 if (!entry_d || !tag_type_p) { | 183 if (entry_d == NULL || tag_type_p == NULL) { |
187 errno = EINVAL; | 184 errno = EINVAL; |
188 return -1; | 185 return (-1); |
189 } 190 191 *tag_type_p = entry_d->ae_tag; 192 | 186 } 187 188 *tag_type_p = entry_d->ae_tag; 189 |
193 return 0; | 190 return (0); |
194} | 191} |