acl_entry.c revision 75185
174667Sjedgar/* 274667Sjedgar * Copyright (c) 2001 Chris D. Faulhaber 374667Sjedgar * All rights reserved. 474667Sjedgar * 574667Sjedgar * Redistribution and use in source and binary forms, with or without 674667Sjedgar * modification, are permitted provided that the following conditions 774667Sjedgar * are met: 874667Sjedgar * 1. Redistributions of source code must retain the above copyright 974667Sjedgar * notice, this list of conditions and the following disclaimer. 1074667Sjedgar * 2. Redistributions in binary form must reproduce the above copyright 1174667Sjedgar * notice, this list of conditions and the following disclaimer in the 1274667Sjedgar * documentation and/or other materials provided with the distribution. 1374667Sjedgar * 1474667Sjedgar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1574667Sjedgar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1674667Sjedgar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1774667Sjedgar * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1874667Sjedgar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1974667Sjedgar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2074667Sjedgar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2174667Sjedgar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2274667Sjedgar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2374667Sjedgar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2474667Sjedgar * SUCH DAMAGE. 2574667Sjedgar * 2674667Sjedgar * $FreeBSD: head/lib/libc/posix1e/acl_entry.c 75185 2001-04-04 18:00:52Z tmm $ 2774667Sjedgar */ 2874667Sjedgar 2974667Sjedgar#include <sys/types.h> 3075185Stmm#include "namespace.h" 3174667Sjedgar#include <sys/acl.h> 3275185Stmm#include "un-namespace.h" 3374667Sjedgar 3474667Sjedgar#include <errno.h> 3574667Sjedgar#include <stdlib.h> 3674667Sjedgar 3774667Sjedgar#define ACL_UNDEFINED_ID -1 3874667Sjedgar#define ACL_UNDEFINED_TAG -1 3974667Sjedgar 4074667Sjedgarint 4174667Sjedgaracl_create_entry(acl_t *acl_p, acl_entry_t *entry_p) 4274667Sjedgar{ 4374667Sjedgar acl_t acl; 4474667Sjedgar struct acl_entry newentry; 4574667Sjedgar 4674667Sjedgar if (!acl_p || !*acl_p || ((*acl_p)->acl_cnt >= ACL_MAX_ENTRIES) || 4774667Sjedgar ((*acl_p)->acl_cnt < 0)) { 4874667Sjedgar errno = EINVAL; 4974667Sjedgar return -1; 5074667Sjedgar } 5174667Sjedgar 5274667Sjedgar entry_p = malloc(sizeof(acl_entry_t)); 5374667Sjedgar if (!entry_p) 5474667Sjedgar return -1; 5574667Sjedgar *entry_p = malloc(sizeof(struct acl_entry)); 5674667Sjedgar if (!*entry_p) 5774667Sjedgar return -1; 5874667Sjedgar 5974667Sjedgar acl = *acl_p; 6074667Sjedgar 6174667Sjedgar **entry_p = acl->acl_entry[acl->acl_cnt]; 6274667Sjedgar 6374667Sjedgar (**entry_p).ae_tag = ACL_UNDEFINED_TAG; 6474667Sjedgar (**entry_p).ae_id = ACL_UNDEFINED_ID; 6574667Sjedgar (**entry_p).ae_perm = ACL_PERM_NONE; 6674667Sjedgar 6774667Sjedgar acl->acl_entry[acl->acl_cnt] = newentry; 6874667Sjedgar acl->acl_cnt++; 6974667Sjedgar 7074667Sjedgar **entry_p = newentry; 7174667Sjedgar 7274667Sjedgar /* XXX - ok? */ 7374667Sjedgar free(*entry_p); 7474667Sjedgar free(entry_p); 7574667Sjedgar 7674667Sjedgar return 0; 7774667Sjedgar} 7874667Sjedgar 7974667Sjedgarint 8074667Sjedgaracl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p) 8174667Sjedgar{ 8274667Sjedgar 8374667Sjedgar errno = ENOSYS; 8474667Sjedgar return -1; 8574667Sjedgar} 86