114721edaSChris D. Faulhaber /* 214721edaSChris D. Faulhaber * Copyright (c) 2001 Chris D. Faulhaber 314721edaSChris D. Faulhaber * All rights reserved. 414721edaSChris D. Faulhaber * 514721edaSChris D. Faulhaber * Redistribution and use in source and binary forms, with or without 614721edaSChris D. Faulhaber * modification, are permitted provided that the following conditions 714721edaSChris D. Faulhaber * are met: 814721edaSChris D. Faulhaber * 1. Redistributions of source code must retain the above copyright 914721edaSChris D. Faulhaber * notice, this list of conditions and the following disclaimer. 1014721edaSChris D. Faulhaber * 2. Redistributions in binary form must reproduce the above copyright 1114721edaSChris D. Faulhaber * notice, this list of conditions and the following disclaimer in the 1214721edaSChris D. Faulhaber * documentation and/or other materials provided with the distribution. 1314721edaSChris D. Faulhaber * 1414721edaSChris D. Faulhaber * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1514721edaSChris D. Faulhaber * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1614721edaSChris D. Faulhaber * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1714721edaSChris D. Faulhaber * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1814721edaSChris D. Faulhaber * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1914721edaSChris D. Faulhaber * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2014721edaSChris D. Faulhaber * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2114721edaSChris D. Faulhaber * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2214721edaSChris D. Faulhaber * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2314721edaSChris D. Faulhaber * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2414721edaSChris D. Faulhaber * SUCH DAMAGE. 2514721edaSChris D. Faulhaber * 2614721edaSChris D. Faulhaber * $FreeBSD$ 2714721edaSChris D. Faulhaber */ 2814721edaSChris D. Faulhaber 2914721edaSChris D. Faulhaber /* acl_delete_entry() - delete an ACL entry from an ACL */ 3014721edaSChris D. Faulhaber 3114721edaSChris D. Faulhaber #include <sys/types.h> 3214721edaSChris D. Faulhaber #include <sys/acl.h> 3314721edaSChris D. Faulhaber #include <errno.h> 3414721edaSChris D. Faulhaber #include <string.h> 3514721edaSChris D. Faulhaber 3614721edaSChris D. Faulhaber int 3714721edaSChris D. Faulhaber acl_delete_entry(acl_t acl, acl_entry_t entry_d) 3814721edaSChris D. Faulhaber { 3914721edaSChris D. Faulhaber int i; 4014721edaSChris D. Faulhaber 4114721edaSChris D. Faulhaber if (!acl || !entry_d || (acl->acl_cnt < 1) || 4214721edaSChris D. Faulhaber (acl->acl_cnt > ACL_MAX_ENTRIES)) { 4314721edaSChris D. Faulhaber errno = EINVAL; 4414721edaSChris D. Faulhaber return -1; 4514721edaSChris D. Faulhaber } 4614721edaSChris D. Faulhaber for (i = 0; i < acl->acl_cnt; i++) { 4714721edaSChris D. Faulhaber /* if this is our entry... */ 4814721edaSChris D. Faulhaber if ((acl->acl_entry[i].ae_tag == entry_d->ae_tag) && 4914721edaSChris D. Faulhaber (acl->acl_entry[i].ae_id == entry_d->ae_id)) { 5014721edaSChris D. Faulhaber /* ...shift the remaining entries... */ 5114721edaSChris D. Faulhaber while (i < acl->acl_cnt - 1) 5214721edaSChris D. Faulhaber acl->acl_entry[i] = acl->acl_entry[++i]; 5314721edaSChris D. Faulhaber /* ...drop the count and zero the unused entry... */ 5414721edaSChris D. Faulhaber acl->acl_cnt--; 5514721edaSChris D. Faulhaber bzero(&acl->acl_entry[i], sizeof(struct acl_entry)); 5614721edaSChris D. Faulhaber return 0; 5714721edaSChris D. Faulhaber } 5814721edaSChris D. Faulhaber } 5914721edaSChris D. Faulhaber 6014721edaSChris D. Faulhaber 6114721edaSChris D. Faulhaber errno = EINVAL; 6214721edaSChris D. Faulhaber return -1; 6314721edaSChris D. Faulhaber } 64