acl_get.c (75492) | acl_get.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_get.c 75492 2001-04-13 19:37:04Z jedgar $ | 26 * $FreeBSD: head/lib/libc/posix1e/acl_get.c 75928 2001-04-24 22:45:41Z 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 --- 8 unchanged lines hidden (view full) --- 43 44#include <errno.h> 45#include <stdlib.h> 46#include <string.h> 47 48acl_t 49acl_get_file(const char *path_p, acl_type_t type) 50{ | 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 --- 8 unchanged lines hidden (view full) --- 43 44#include <errno.h> 45#include <stdlib.h> 46#include <string.h> 47 48acl_t 49acl_get_file(const char *path_p, acl_type_t type) 50{ |
51 struct acl *aclp; | 51 acl_t aclp; |
52 int error; 53 54 aclp = acl_init(ACL_MAX_ENTRIES); 55 if (!aclp) { 56 return (NULL); 57 } 58 | 52 int error; 53 54 aclp = acl_init(ACL_MAX_ENTRIES); 55 if (!aclp) { 56 return (NULL); 57 } 58 |
59 error = __acl_get_file(path_p, type, aclp); | 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{ | 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 struct acl *aclp; | 71 acl_t aclp; |
72 int error; 73 74 aclp = acl_init(ACL_MAX_ENTRIES); 75 if (!aclp) { 76 return (NULL); 77 } 78 | 72 int error; 73 74 aclp = acl_init(ACL_MAX_ENTRIES); 75 if (!aclp) { 76 return (NULL); 77 } 78 |
79 error = ___acl_get_fd(fd, ACL_TYPE_ACCESS, aclp); | 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{ | 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 struct acl *aclp; | 91 acl_t aclp; |
92 int error; 93 94 aclp = acl_init(ACL_MAX_ENTRIES); 95 if (!aclp) { 96 return (NULL); 97 } 98 | 92 int error; 93 94 aclp = acl_init(ACL_MAX_ENTRIES); 95 if (!aclp) { 96 return (NULL); 97 } 98 |
99 error = ___acl_get_fd(fd, type, aclp); | 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 | 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 |
112 if (!permset_d) { 113 errno = EINVAL; 114 return -1; 115 } 116 |
|
112 switch(perm) { 113 case ACL_READ: 114 case ACL_WRITE: 115 case ACL_EXECUTE: 116 if (*permset_d & perm) 117 return 1; 118 break; 119 default: 120 errno = EINVAL; 121 return -1; 122 } 123 124 return 0; 125} 126 | 117 switch(perm) { 118 case ACL_READ: 119 case ACL_WRITE: 120 case ACL_EXECUTE: 121 if (*permset_d & perm) 122 return 1; 123 break; 124 default: 125 errno = EINVAL; 126 return -1; 127 } 128 129 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 */ |
|
127int 128acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p) 129{ 130 131 if (!entry_d || !permset_p) { 132 errno = EINVAL; 133 return -1; 134 } 135 136 *permset_p = &entry_d->ae_perm; 137 138 return 0; 139} 140 | 136int 137acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p) 138{ 139 140 if (!entry_d || !permset_p) { 141 errno = EINVAL; 142 return -1; 143 } 144 145 *permset_p = &entry_d->ae_perm; 146 147 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 */ |
|
141void * 142acl_get_qualifier(acl_entry_t entry_d) 143{ 144 uid_t *retval; 145 146 if (!entry_d) { 147 errno = EINVAL; 148 return NULL; 149 } 150 151 switch(entry_d->ae_tag) { 152 case ACL_USER: 153 case ACL_GROUP: 154 retval = malloc(sizeof(uid_t)); | 154void * 155acl_get_qualifier(acl_entry_t entry_d) 156{ 157 uid_t *retval; 158 159 if (!entry_d) { 160 errno = EINVAL; 161 return NULL; 162 } 163 164 switch(entry_d->ae_tag) { 165 case ACL_USER: 166 case ACL_GROUP: 167 retval = malloc(sizeof(uid_t)); |
155 if (retval) { 156 *retval = entry_d->ae_id; 157 return retval; 158 } | 168 if (!retval) 169 return NULL; 170 *retval = entry_d->ae_id; 171 return retval; |
159 } 160 161 errno = EINVAL; 162 return NULL; 163} 164 | 172 } 173 174 errno = EINVAL; 175 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 */ |
|
165int 166acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p) 167{ 168 169 if (!entry_d || !tag_type_p) { 170 errno = EINVAL; 171 return -1; 172 } 173 174 *tag_type_p = entry_d->ae_tag; 175 176 return 0; 177} | 182int 183acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p) 184{ 185 186 if (!entry_d || !tag_type_p) { 187 errno = EINVAL; 188 return -1; 189 } 190 191 *tag_type_p = entry_d->ae_tag; 192 193 return 0; 194} |