xrootd
XrdAccAccess.hh
Go to the documentation of this file.
1 #ifndef __ACC_ACCESS__
2 #define __ACC_ACCESS__
3 /******************************************************************************/
4 /* */
5 /* X r d A c c A c c e s s . h h */
6 /* */
7 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include "XrdAcc/XrdAccAudit.hh"
36 #include "XrdSec/XrdSecEntity.hh"
37 #include "XrdOuc/XrdOucHash.hh"
38 #include "XrdSys/XrdSysXSLock.hh"
39 #include "XrdSys/XrdSysPlatform.hh"
40 
41 /******************************************************************************/
42 /* S e t T a b s P a r a m e t e r */
43 /******************************************************************************/
44 
46  {char *name;
47  char *grp;
48  char *host;
49  char *org;
50  char *role;
51  char *user;
54  int rule;
55  short hlen;
56  short glen;
57 
58  bool Applies(const XrdSecEntity *Entity);
59 
61  {XrdAccAccess_ID *xID;
62  xID = new XrdAccAccess_ID;
63  *xID = *this;
64  name = grp = host = org = role = user = 0;
65  caps = 0;
66  return xID;
67  }
68 
69  XrdAccAccess_ID(const char *Name=0)
70  : name(Name ? strdup(Name) : 0),
71  grp(0), host(0), org(0), role(0), user(0),
72  caps(0), next(0), rule(0), hlen(0), glen(0) {}
73  ~XrdAccAccess_ID() {if (name) free(name);
74  if (grp) free(grp);
75  if (host) free(host);
76  if (org) free(org);
77  if (role) free(role);
78  if (user) free(user);
79  if (caps) delete caps;
80  }
81  };
82 
92  XrdAccCapName *D_List; // Domains
93  XrdAccCapName *E_List; // Domains (end of list)
94  XrdAccCapability *X_List; // Fungable capbailities
95  XrdAccCapability *Z_List; // Default capbailities
96  XrdAccAccess_ID *SXList; // 's' exclusive list
97  XrdAccAccess_ID *SYList; // 's' inclusive list
98 
100  O_Hash = 0; R_Hash = 0;
101  S_Hash = 0; T_Hash = 0; U_Hash = 0;
102  D_List = 0; E_List = 0;
103  X_List = 0; Z_List = 0;
104  SXList = 0; SYList = 0;
105  }
107  if (H_Hash) delete H_Hash;
108  if (N_Hash) delete N_Hash;
109  if (O_Hash) delete O_Hash;
110  if (R_Hash) delete R_Hash;
111  if (S_Hash) delete S_Hash; //Deletes SX & SYList
112  if (T_Hash) delete T_Hash;
113  if (U_Hash) delete U_Hash;
114  if (X_List) delete X_List;
115  if (Z_List) delete Z_List;
116  }
117  };
118 
119 /******************************************************************************/
120 /* X r d A c c A c c e s s */
121 /******************************************************************************/
122 
123 class xrdOucError;
124 
126 {
127 public:
128 
129 friend class XrdAccConfig;
130 
131  XrdAccPrivs Access(const XrdSecEntity *Entity,
132  const char *path,
133  const Access_Operation oper,
134  XrdOucEnv *Env=0);
135 
136  int Audit(const int accok,
137  const XrdSecEntity *Entity,
138  const char *path,
139  const Access_Operation oper,
140  XrdOucEnv *Env=0);
141 
142 static
143 const char *Resolve(const XrdSecEntity *Entity);
144 
145 // SwapTabs() is used by the configuration object to establish new access
146 // control tables. It may be called whenever the tables change.
147 //
148 void SwapTabs(struct XrdAccAccess_Tables &newtab);
149 
150  int Test(const XrdAccPrivs priv, const Access_Operation oper);
151 
153 
154  ~XrdAccAccess() {} // The access object is never deleted
155 
156 private:
157 
159  const XrdSecEntity *Entity,
160  const char *path,
161  const Access_Operation oper);
162 
164 
166 
168 };
169 #endif
Definition: XrdAccCapability.hh:43
XrdAccAccess_Tables()
Definition: XrdAccAccess.hh:99
XrdAccAccess_ID * SXList
Definition: XrdAccAccess.hh:96
XrdOucHash< XrdAccCapability > * G_Hash
Definition: XrdAccAccess.hh:84
void SwapTabs(struct XrdAccAccess_Tables &newtab)
Definition: XrdAccAccess.hh:125
~XrdAccAccess_Tables()
Definition: XrdAccAccess.hh:106
XrdOucHash< XrdAccCapability > * N_Hash
Definition: XrdAccAccess.hh:86
Definition: XrdAccAudit.hh:65
XrdAccPrivs
Definition: XrdAccPrivs.hh:39
XrdAccPrivs Access(const XrdSecEntity *Entity, const char *path, const Access_Operation oper, XrdOucEnv *Env=0)
Definition: XrdSysXSLock.hh:44
char * user
Definition: XrdAccAccess.hh:51
XrdOucHash< XrdAccCapability > * R_Hash
Definition: XrdAccAccess.hh:88
XrdOucHash< XrdAccCapability > * T_Hash
Definition: XrdAccAccess.hh:90
XrdAccCapName * E_List
Definition: XrdAccAccess.hh:93
short hlen
Definition: XrdAccAccess.hh:55
int rule
Definition: XrdAccAccess.hh:54
Definition: XrdAccAuthorize.hh:64
XrdAccCapName * D_List
Definition: XrdAccAccess.hh:92
Definition: XrdSysError.hh:89
XrdAccAccess(XrdSysError *erp)
char * host
Definition: XrdAccAccess.hh:48
~XrdAccAccess_ID()
Definition: XrdAccAccess.hh:73
Definition: XrdAccCapability.hh:105
XrdOucHash< XrdAccCapability > * U_Hash
Definition: XrdAccAccess.hh:91
struct XrdAccAccess_Tables Atab
Definition: XrdAccAccess.hh:163
Definition: XrdOucEnv.hh:41
XrdAccAccess_ID * SYList
Definition: XrdAccAccess.hh:97
XrdAccAccess_ID * next
Definition: XrdAccAccess.hh:53
Access_Operation
The following are supported operations.
Definition: XrdAccAuthorize.hh:41
char * role
Definition: XrdAccAccess.hh:50
int Audit(const int accok, const XrdSecEntity *Entity, const char *path, const Access_Operation oper, XrdOucEnv *Env=0)
XrdOucHash< XrdAccCapability > * O_Hash
Definition: XrdAccAccess.hh:87
Definition: XrdAccPrivs.hh:77
short glen
Definition: XrdAccAccess.hh:56
bool Applies(const XrdSecEntity *Entity)
XrdAccAudit * Auditor
Definition: XrdAccAccess.hh:167
XrdSysXSLock Access_Context
Definition: XrdAccAccess.hh:165
char * name
Definition: XrdAccAccess.hh:46
XrdAccCapability * X_List
Definition: XrdAccAccess.hh:94
~XrdAccAccess()
Definition: XrdAccAccess.hh:154
XrdAccAccess_ID * Export()
Definition: XrdAccAccess.hh:60
XrdAccAccess_ID(const char *Name=0)
Definition: XrdAccAccess.hh:69
char * grp
Definition: XrdAccAccess.hh:47
Definition: XrdSecEntity.hh:51
Definition: XrdAccAccess.hh:45
Definition: XrdAccAccess.hh:83
XrdAccCapability * Z_List
Definition: XrdAccAccess.hh:95
XrdOucHash< XrdAccAccess_ID > * S_Hash
Definition: XrdAccAccess.hh:89
Definition: XrdAccConfig.hh:64
char * org
Definition: XrdAccAccess.hh:49
int Test(const XrdAccPrivs priv, const Access_Operation oper)
XrdOucHash< XrdAccCapability > * H_Hash
Definition: XrdAccAccess.hh:85
XrdAccCapability * caps
Definition: XrdAccAccess.hh:52
static const char * Resolve(const XrdSecEntity *Entity)