1/* 2 File: sys/acl.h 3 4 (C) 1999 Andreas Gruenbacher, <a.gruenbacher@computer.org> 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Library General Public 8 License as published by the Free Software Foundation; either 9 version 2 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. the GNU 14 Library General Public License for more details. 15 16 You should have received a copy of the GNU Library General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19*/ 20 21#ifndef __SYS_ACL_H 22#define __SYS_ACL_H 23 24#include <sys/types.h> 25 26#ifdef __cplusplus 27extern "C" { 28#endif 29 30/*=== Data types ===*/ 31 32struct __acl_ext; 33struct __acl_entry_ext; 34struct __acl_permset_ext; 35 36typedef unsigned int acl_type_t; 37typedef int acl_tag_t; 38typedef unsigned int acl_perm_t; 39 40typedef struct __acl_ext *acl_t; 41typedef struct __acl_entry_ext *acl_entry_t; 42typedef struct __acl_permset_ext *acl_permset_t; 43 44/*=== Constants ===*/ 45 46/* 23.2.2 acl_perm_t values */ 47 48#define ACL_READ (0x04) 49#define ACL_WRITE (0x02) 50#define ACL_EXECUTE (0x01) 51//#define ACL_ADD (0x08) 52//#define ACL_DELETE (0x10) 53 54/* 23.2.5 acl_tag_t values */ 55 56#define ACL_UNDEFINED_TAG (0x00) 57#define ACL_USER_OBJ (0x01) 58#define ACL_USER (0x02) 59#define ACL_GROUP_OBJ (0x04) 60#define ACL_GROUP (0x08) 61#define ACL_MASK (0x10) 62#define ACL_OTHER (0x20) 63 64/* 23.3.6 acl_type_t values */ 65 66#define ACL_TYPE_ACCESS (0x8000) 67#define ACL_TYPE_DEFAULT (0x4000) 68 69/* 23.2.7 ACL qualifier constants */ 70 71#define ACL_UNDEFINED_ID ((id_t)-1) 72 73/* 23.2.8 ACL Entry Constants */ 74 75#define ACL_FIRST_ENTRY 0 76#define ACL_NEXT_ENTRY 1 77 78/*=== ACL manipulation ===*/ 79 80extern acl_t acl_init(int count); 81extern acl_t acl_dup(acl_t acl); 82extern int acl_free(void *obj_p); 83extern int acl_valid(acl_t acl); 84 85/*=== Entry manipulation ===*/ 86 87extern int 88acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d); 89extern int acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p); 90extern int acl_delete_entry(acl_t acl, acl_entry_t entry_d); 91extern int acl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p); 92 93/* Manipulate ACL entry permissions */ 94 95extern int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm); 96extern int acl_calc_mask(acl_t *acl_p); 97extern int acl_clear_perms(acl_permset_t permset_d); 98extern int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm); 99extern int acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p); 100extern int acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d); 101 102/* Manipulate ACL entry tag type and qualifier */ 103 104extern void * acl_get_qualifier(acl_entry_t entry_d); 105extern int acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p); 106extern int acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p); 107extern int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type); 108 109/*=== Format translation ===*/ 110 111extern ssize_t acl_copy_ext(void *buf_p, acl_t acl, ssize_t size); 112extern acl_t acl_copy_int(const void *buf_p); 113extern acl_t acl_from_text(const char *buf_p); 114extern ssize_t acl_size(acl_t acl); 115extern char *acl_to_text(acl_t acl, ssize_t *len_p); 116 117/*=== Object manipulation ===*/ 118 119extern int acl_delete_def_file(const char *path_p); 120extern acl_t acl_get_fd(int fd); 121extern acl_t acl_get_file(const char *path_p, acl_type_t type); 122extern int acl_set_fd(int fd, acl_t acl); 123extern int acl_set_file(const char *path_p, acl_type_t type, acl_t acl); 124 125#ifdef __cplusplus 126} 127#endif 128 129#endif /* __SYS_ACL_H */ 130 131