| 1 |
/** BEGIN COPYRIGHT BLOCK |
| 2 |
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. |
| 3 |
* Copyright (C) 2005 Red Hat, Inc. |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* License: GPL (version 3 or any later version). |
| 7 |
* See LICENSE for details. |
| 8 |
* END COPYRIGHT BLOCK **/ |
| 9 |
|
| 10 |
#ifdef HAVE_CONFIG_H |
| 11 |
#include <config.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifndef __aclstruct_h |
| 15 |
#define __aclstruct_h |
| 16 |
|
| 17 |
/* |
| 18 |
* Description (aclstruct.h) |
| 19 |
* |
| 20 |
* This file defines types and data structures used to construct |
| 21 |
* representations of Access Control Lists (ACLs) in memory. |
| 22 |
*/ |
| 23 |
|
| 24 |
#include "base/systems.h" |
| 25 |
#include "base/file.h" |
| 26 |
#include "nsauth.h" /* authentication types */ |
| 27 |
#include "symbols.h" /* typed symbol support */ |
| 28 |
#include "ipfstruct.h" /* IP address filter structures */ |
| 29 |
#include "dnfstruct.h" /* DNS name filter structures */ |
| 30 |
|
| 31 |
|
| 32 |
NSPR_BEGIN_EXTERN_C |
| 33 |
|
| 34 |
/* Forward type definitions */ |
| 35 |
typedef struct ACL_s ACL_t; |
| 36 |
|
| 37 |
/* |
| 38 |
* Description (InetHost_t) |
| 39 |
* |
| 40 |
* This type defines a structure which represents a list of Internet |
| 41 |
* hosts by IP address and netmask, or by fully or partially |
| 42 |
* qualified DNS name. |
| 43 |
*/ |
| 44 |
|
| 45 |
typedef struct InetHost_s InetHost_t; |
| 46 |
struct InetHost_s |
| 47 |
{ |
| 48 |
IPFilter_t inh_ipf; /* reference to IP filter */ |
| 49 |
DNSFilter_t inh_dnf; /* reference to DNS filter */ |
| 50 |
}; |
| 51 |
|
| 52 |
/* |
| 53 |
* Description (HostSpec_t) |
| 54 |
* |
| 55 |
* This type describes a named list of hosts. |
| 56 |
*/ |
| 57 |
|
| 58 |
typedef struct HostSpec_s HostSpec_t; |
| 59 |
struct HostSpec_s |
| 60 |
{ |
| 61 |
Symbol_t hs_sym; /* symbol name, type ACLSYMHOST */ |
| 62 |
InetHost_t hs_host; /* host information */ |
| 63 |
}; |
| 64 |
|
| 65 |
/* |
| 66 |
* Description (UidUser_t) |
| 67 |
* |
| 68 |
* This type represents a list of users and groups using unique |
| 69 |
* integer identifiers. |
| 70 |
*/ |
| 71 |
|
| 72 |
typedef struct UidUser_s UidUser_t; |
| 73 |
struct UidUser_s |
| 74 |
{ |
| 75 |
USIList_t uu_user; /* list of user ids */ |
| 76 |
USIList_t uu_group; /* list of group ids */ |
| 77 |
}; |
| 78 |
|
| 79 |
/* |
| 80 |
* Description (UserSpec_t) |
| 81 |
* |
| 82 |
* This type describes a named list of users and groups. |
| 83 |
*/ |
| 84 |
|
| 85 |
typedef struct UserSpec_s UserSpec_t; |
| 86 |
struct UserSpec_s |
| 87 |
{ |
| 88 |
Symbol_t us_sym; /* list name, type ACLSYMUSER */ |
| 89 |
int us_flags; /* bit flags */ |
| 90 |
#define ACL_USALL 0x1 /* any authenticated user */ |
| 91 |
|
| 92 |
UidUser_t us_user; /* user list structure */ |
| 93 |
}; |
| 94 |
|
| 95 |
/* |
| 96 |
* Description (ACClients_t) |
| 97 |
* |
| 98 |
* This type defines the structure of action-specific information |
| 99 |
* for access control directives with action codes ACD_ALLOW and |
| 100 |
* ACD_DENY. These directives specify access control constraints |
| 101 |
* on users/groups and hosts. |
| 102 |
*/ |
| 103 |
|
| 104 |
typedef struct ACClients_s ACClients_t; |
| 105 |
struct ACClients_s |
| 106 |
{ |
| 107 |
ACClients_t *cl_next; /* list link */ |
| 108 |
HostSpec_t *cl_host; /* host specification pointer */ |
| 109 |
UserSpec_t *cl_user; /* user list pointer */ |
| 110 |
}; |
| 111 |
|
| 112 |
/* |
| 113 |
* Description (RealmSpec_t) |
| 114 |
* |
| 115 |
* This type describes a named realm. |
| 116 |
*/ |
| 117 |
|
| 118 |
typedef struct RealmSpec_s RealmSpec_t; |
| 119 |
struct RealmSpec_s |
| 120 |
{ |
| 121 |
Symbol_t rs_sym; /* realm name, type ACLSYMREALM */ |
| 122 |
Realm_t rs_realm; /* realm information */ |
| 123 |
}; |
| 124 |
|
| 125 |
/* |
| 126 |
* Description (ACAuth_t) |
| 127 |
* |
| 128 |
* This type defines the structure of action-specific information |
| 129 |
* for an access control directive with action code ACD_AUTH, |
| 130 |
* which specifies information about authentication requirements. |
| 131 |
*/ |
| 132 |
|
| 133 |
typedef struct ACAuth_s ACAuth_t; |
| 134 |
struct ACAuth_s |
| 135 |
{ |
| 136 |
RealmSpec_t *au_realm; /* pointer to realm information */ |
| 137 |
}; |
| 138 |
|
| 139 |
/* |
| 140 |
* Description (ACDirective_t) |
| 141 |
* |
| 142 |
* This type defines a structure which represents an access control |
| 143 |
* directive. Each directive specifies an access control action |
| 144 |
* to be taken during ACL evaluation. The ACDirective_t structure |
| 145 |
* begins an action-specific structure which contains the |
| 146 |
* parameters for an action. |
| 147 |
*/ |
| 148 |
|
| 149 |
typedef struct ACDirective_s ACDirective_t; |
| 150 |
struct ACDirective_s |
| 151 |
{ |
| 152 |
ACDirective_t *acd_next; /* next directive in ACL */ |
| 153 |
short acd_action; /* directive action code */ |
| 154 |
short acd_flags; /* action modifier flags */ |
| 155 |
|
| 156 |
/* Begin action-specific information */ |
| 157 |
union |
| 158 |
{ |
| 159 |
ACClients_t *acu_cl; /* ACD_ALLOW, ACD_DENY */ |
| 160 |
ACAuth_t acu_auth; /* ACD_AUTH */ |
| 161 |
} acd_u; |
| 162 |
}; |
| 163 |
|
| 164 |
#define acd_cl acd_u.acu_cl |
| 165 |
#define acd_auth acd_u.acu_auth |
| 166 |
|
| 167 |
/* Define acd_action codes */ |
| 168 |
#define ACD_ALLOW 1 /* allow access */ |
| 169 |
#define ACD_DENY 2 /* deny access */ |
| 170 |
#define ACD_AUTH 3 /* specify authentication realm */ |
| 171 |
#define ACD_EXEC 4 /* execute (conditionally) */ |
| 172 |
|
| 173 |
/* Define acd_flags values */ |
| 174 |
#define ACD_ACTION 0xf /* bits reserved for acd_action */ |
| 175 |
#define ACD_FORCE 0x10 /* force of action */ |
| 176 |
#define ACD_DEFAULT 0 /* default action */ |
| 177 |
#define ACD_ALWAYS ACD_FORCE /* immediate action */ |
| 178 |
#define ACD_EXALLOW 0x20 /* execute if allow */ |
| 179 |
#define ACD_EXDENY 0x40 /* execute if deny */ |
| 180 |
#define ACD_EXAUTH 0x80 /* execute if authenticate */ |
| 181 |
|
| 182 |
/* |
| 183 |
* Description (RightDef_t) |
| 184 |
* |
| 185 |
* This type describes a named access right. Each access right has |
| 186 |
* an associated unique integer id. A list of all access rights |
| 187 |
* known in an ACL context is maintained, with its head in the |
| 188 |
* ACContext_t structure. |
| 189 |
*/ |
| 190 |
|
| 191 |
typedef struct RightDef_s RightDef_t; |
| 192 |
struct RightDef_s |
| 193 |
{ |
| 194 |
Symbol_t rd_sym; /* right name, type ACLSYMRIGHT */ |
| 195 |
RightDef_t *rd_next; /* next on ACContext_t list */ |
| 196 |
USI_t rd_id; /* unique id */ |
| 197 |
}; |
| 198 |
|
| 199 |
/* |
| 200 |
* Description (RightSpec_t) |
| 201 |
* |
| 202 |
* This type describes a named list of access rights. |
| 203 |
*/ |
| 204 |
|
| 205 |
typedef struct RightSpec_s RightSpec_t; |
| 206 |
struct RightSpec_s |
| 207 |
{ |
| 208 |
Symbol_t rs_sym; /* list name, type ACLSYMRDEF */ |
| 209 |
USIList_t rs_list; /* list of right ids */ |
| 210 |
}; |
| 211 |
|
| 212 |
/* |
| 213 |
* Description (ACContext_t) |
| 214 |
* |
| 215 |
* This type defines a structure that defines a context for a set |
| 216 |
* of Access Control Lists. This includes references to an |
| 217 |
* authentication database, if any, and a symbol table containing |
| 218 |
* access right definitions. It also serves as a list head for the |
| 219 |
* ACLs which are defined in the specified context. |
| 220 |
*/ |
| 221 |
|
| 222 |
typedef struct ACContext_s ACContext_t; |
| 223 |
struct ACContext_s |
| 224 |
{ |
| 225 |
void *acc_stp; /* symbol table handle */ |
| 226 |
ACL_t *acc_acls; /* list of ACLs */ |
| 227 |
RightDef_t *acc_rights; /* list of access right definitions */ |
| 228 |
int acc_refcnt; /* reference count */ |
| 229 |
}; |
| 230 |
|
| 231 |
/* |
| 232 |
* Description (ACL_t) |
| 233 |
* |
| 234 |
* This type defines the structure that represents an Access Control |
| 235 |
* List (ACL). An ACL has a user-assigned name and an internally |
| 236 |
* assigned identifier (which is an index in an object directory). |
| 237 |
* It references a list of access rights which are to be allowed or |
| 238 |
* denied, according to the ACL specifications. It references an |
| 239 |
* ordered list of ACL directives, which specify who has and who does |
| 240 |
* not have the associated access rights. |
| 241 |
*/ |
| 242 |
|
| 243 |
struct ACL_s |
| 244 |
{ |
| 245 |
Symbol_t acl_sym; /* ACL name, type ACLSYMACL */ |
| 246 |
ACL_t *acl_next; /* next ACL on a list */ |
| 247 |
ACContext_t *acl_acc; /* context for this ACL */ |
| 248 |
USI_t acl_id; /* id of this ACL */ |
| 249 |
int acl_refcnt; /* reference count */ |
| 250 |
RightSpec_t *acl_rights; /* access rights list */ |
| 251 |
ACDirective_t *acl_dirf; /* first directive pointer */ |
| 252 |
ACDirective_t *acl_dirl; /* last directive pointer */ |
| 253 |
}; |
| 254 |
|
| 255 |
/* Define symbol type codes */ |
| 256 |
#define ACLSYMACL 0 /* ACL */ |
| 257 |
#define ACLSYMRIGHT 1 /* access right */ |
| 258 |
#define ACLSYMRDEF 2 /* access rights list */ |
| 259 |
#define ACLSYMREALM 3 /* realm name */ |
| 260 |
#define ACLSYMHOST 4 /* host specifications */ |
| 261 |
#define ACLSYMUSER 5 /* user/group list */ |
| 262 |
|
| 263 |
/* |
| 264 |
* Description (ACLFile_t) |
| 265 |
* |
| 266 |
* This type describes a structure containing information about |
| 267 |
* an open ACL description file. |
| 268 |
*/ |
| 269 |
|
| 270 |
typedef struct ACLFile_s ACLFile_t; |
| 271 |
struct ACLFile_s |
| 272 |
{ |
| 273 |
ACLFile_t *acf_next; /* list link */ |
| 274 |
char *acf_filename; /* pointer to filename string */ |
| 275 |
SYS_FILE acf_fd; /* file descriptor */ |
| 276 |
int acf_flags; /* bit flags (unused) */ |
| 277 |
int acf_lineno; /* current line number */ |
| 278 |
void *acf_token; /* LEX token handle */ |
| 279 |
int acf_ttype; /* current token type */ |
| 280 |
}; |
| 281 |
|
| 282 |
NSPR_END_EXTERN_C |
| 283 |
|
| 284 |
#endif /* __aclstruct_h */ |