acl_to_text.c (56055) | acl_to_text.c (56625) |
---|---|
1/*- 2 * Copyright (c) 1999 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 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_to_text.c 56055 2000-01-15 19:44:27Z rwatson $ | 26 * $FreeBSD: head/lib/libc/posix1e/acl_to_text.c 56625 2000-01-26 04:19:38Z rwatson $ |
27 */ 28/* 29 * acl_to_text - return a text string with a text representation of the acl 30 * in it. 31 */ 32 33#include <sys/types.h> 34#include <sys/acl.h> 35#include <sys/errno.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> 39#include <utmp.h> 40 41#include "acl_support.h" 42 | 27 */ 28/* 29 * acl_to_text - return a text string with a text representation of the acl 30 * in it. 31 */ 32 33#include <sys/types.h> 34#include <sys/acl.h> 35#include <sys/errno.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> 39#include <utmp.h> 40 41#include "acl_support.h" 42 |
43 | |
44/* 45 * acl_to_text - generate a text form of an acl 46 * spec says nothing about output ordering, so leave in acl order 47 * | 43/* 44 * acl_to_text - generate a text form of an acl 45 * spec says nothing about output ordering, so leave in acl order 46 * |
48 * For the time-being, reject the printing of ACLs that aren't an 49 * understood semantic. Later on, we might want to try and have a 50 * generic printing mechanism... | 47 * This function will not produce nice results if it is called with 48 * a non-POSIX.1e semantics ACL. |
51 */ 52char * 53acl_to_text(acl_t acl, ssize_t *len_p) 54{ 55 char *buf, *tmpbuf; 56 char name_buf[UT_NAMESIZE+1]; 57 char perm_buf[ACL_STRING_PERM_MAXSIZE+1], 58 effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1]; 59 int i, error, len; 60 uid_t ae_id; 61 acl_tag_t ae_tag; 62 acl_perm_t ae_perm, effective_perm, mask_perm; 63 | 49 */ 50char * 51acl_to_text(acl_t acl, ssize_t *len_p) 52{ 53 char *buf, *tmpbuf; 54 char name_buf[UT_NAMESIZE+1]; 55 char perm_buf[ACL_STRING_PERM_MAXSIZE+1], 56 effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1]; 57 int i, error, len; 58 uid_t ae_id; 59 acl_tag_t ae_tag; 60 acl_perm_t ae_perm, effective_perm, mask_perm; 61 |
64 if (!acl_posix1e(acl)) { 65 errno = EINVAL; 66 return (0); 67 } 68 | |
69 buf = strdup(""); 70 71 mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */ 72 for (i = 0; i < acl->acl_cnt; i++) 73 if (acl->acl_entry[i].ae_tag == ACL_MASK) 74 mask_perm = acl->acl_entry[i].ae_perm; 75 76 for (i = 0; i < acl->acl_cnt; i++) { --- 156 unchanged lines hidden (view full) --- 233 } 234 return (buf); 235 236error_label: 237 /* jump to here sets errno already, we just clean up */ 238 if (buf) free(buf); 239 return (0); 240} | 62 buf = strdup(""); 63 64 mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */ 65 for (i = 0; i < acl->acl_cnt; i++) 66 if (acl->acl_entry[i].ae_tag == ACL_MASK) 67 mask_perm = acl->acl_entry[i].ae_perm; 68 69 for (i = 0; i < acl->acl_cnt; i++) { --- 156 unchanged lines hidden (view full) --- 226 } 227 return (buf); 228 229error_label: 230 /* jump to here sets errno already, we just clean up */ 231 if (buf) free(buf); 232 return (0); 233} |
241 242 243 244 | |