acl_get.c revision 71142
156055Srwatson/*- 256055Srwatson * Copyright (c) 1999 Robert N. M. Watson 356055Srwatson * All rights reserved. 456055Srwatson * 556055Srwatson * Redistribution and use in source and binary forms, with or without 656055Srwatson * modification, are permitted provided that the following conditions 756055Srwatson * are met: 856055Srwatson * 1. Redistributions of source code must retain the above copyright 956055Srwatson * notice, this list of conditions and the following disclaimer. 1056055Srwatson * 2. Redistributions in binary form must reproduce the above copyright 1156055Srwatson * notice, this list of conditions and the following disclaimer in the 1256055Srwatson * documentation and/or other materials provided with the distribution. 1356055Srwatson * 1456055Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1556055Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1656055Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1756055Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1856055Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1956055Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2056055Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2156055Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2256055Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2356055Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2456055Srwatson * SUCH DAMAGE. 2556055Srwatson * 2656055Srwatson * $FreeBSD: head/lib/libc/posix1e/acl_get.c 71142 2001-01-17 02:40:39Z rwatson $ 2756055Srwatson */ 2856055Srwatson/* 2956055Srwatson * acl_get_file - syscall wrapper for retrieving ACL by filename 3056625Srwatson * acl_get_fd - syscall wrapper for retrieving access ACL by fd 3156625Srwatson * acl_get_fd_np - syscall wrapper for retrieving ACL by fd (non-POSIX) 3256055Srwatson */ 3356055Srwatson 3456055Srwatson#include <sys/types.h> 3556055Srwatson#include <sys/acl.h> 3656055Srwatson#include <sys/errno.h> 3756055Srwatson#include <stdlib.h> 3856055Srwatson 3956055Srwatsonacl_t 4056055Srwatsonacl_get_file(const char *path_p, acl_type_t type) 4156055Srwatson{ 4256055Srwatson struct acl *aclp; 4356055Srwatson int error; 4456055Srwatson 4556274Srwatson aclp = acl_init(ACL_MAX_ENTRIES); 4656055Srwatson if (!aclp) { 4771142Srwatson return (NULL); 4856055Srwatson } 4956055Srwatson 5056274Srwatson error = __acl_get_file(path_p, type, aclp); 5156055Srwatson if (error) { 5256055Srwatson acl_free(aclp); 5371142Srwatson return (NULL); 5456055Srwatson } 5556055Srwatson 5656055Srwatson return (aclp); 5756055Srwatson} 5856055Srwatson 5956625Srwatsonacl_t 6056625Srwatsonacl_get_fd(int fd) 6156625Srwatson{ 6256625Srwatson struct acl *aclp; 6356625Srwatson int error; 6456055Srwatson 6556625Srwatson aclp = acl_init(ACL_MAX_ENTRIES); 6656625Srwatson if (!aclp) { 6771142Srwatson return (NULL); 6856625Srwatson } 6956625Srwatson 7056625Srwatson error = __acl_get_fd(fd, ACL_TYPE_ACCESS, aclp); 7156625Srwatson if (error) { 7256625Srwatson acl_free(aclp); 7371142Srwatson return (NULL); 7456625Srwatson } 7556625Srwatson 7656625Srwatson return (aclp); 7756625Srwatson} 7856625Srwatson 7956055Srwatsonacl_t 8056625Srwatsonacl_get_fd_np(int fd, acl_type_t type) 8156055Srwatson{ 8256055Srwatson struct acl *aclp; 8356055Srwatson int error; 8456055Srwatson 8556274Srwatson aclp = acl_init(ACL_MAX_ENTRIES); 8656055Srwatson if (!aclp) { 8771142Srwatson return (NULL); 8856055Srwatson } 8956055Srwatson 9056274Srwatson error = __acl_get_fd(fd, type, aclp); 9156055Srwatson if (error) { 9256055Srwatson acl_free(aclp); 9371142Srwatson return (NULL); 9456055Srwatson } 9556055Srwatson 9656055Srwatson return (aclp); 9756055Srwatson} 98