XRootD
Loading...
Searching...
No Matches
XrdAccConfig Class Reference

#include <XrdAccConfig.hh>

Collaboration diagram for XrdAccConfig:

Public Member Functions

 XrdAccConfig ()
 ~XrdAccConfig ()
int ConfigDB (int Warm, XrdSysError &Eroute)
int Configure (XrdSysError &Eroute, const char *cfn)

Public Attributes

XrdAccAccessAuthorization
int AuthRT
XrdAccGroups GroupMaster

Detailed Description

Definition at line 64 of file XrdAccConfig.hh.

Constructor & Destructor Documentation

◆ XrdAccConfig()

XrdAccConfig::XrdAccConfig ( )

Definition at line 103 of file XrdAccConfig.cc.

104{
105
106// Initialize path value and databse pointer to nil
107//
108 Database = 0;
109 Authorization = 0;
110 spChar = 0;
111 uriPath = false;
112
113 const char *dbpath_defaults[] = {
114 "/opt/xrd/etc/Authfile",
115 "/etc/xrootd/authdb"
116 };
117
118 dbpath = nullptr;
119 for (const char *path : dbpath_defaults)
120 if (access(path, R_OK) == 0)
121 dbpath = strdup(path);
122
123// Establish other defaults
124//
125 ConfigDefaults();
126}
#define access(a, b)
Definition XrdPosix.hh:44
XrdAccAccess * Authorization

References access, and Authorization.

◆ ~XrdAccConfig()

XrdAccConfig::~XrdAccConfig ( )
inline

Definition at line 84 of file XrdAccConfig.hh.

84{ free(dbpath); }

Member Function Documentation

◆ ConfigDB()

int XrdAccConfig::ConfigDB ( int Warm,
XrdSysError & Eroute )

Definition at line 175 of file XrdAccConfig.cc.

176{
177/*
178 Function: Establish default values using a configuration file.
179
180 Input: None.
181
182 Output: 0 upon success or !0 otherwise.
183*/
184 char buff[128];
185 int retc, anum = 0, NoGo = 0;
186 struct XrdAccAccess_Tables tabs;
187 XrdOucLock cdb_Lock(&Config_Context);
188
189// Indicate type of start we are doing
190//
191 if (!Database) NoGo = !(Database = XrdAccAuthDBObject(&Eroute));
192 else if (Warm && !Database->Changed(dbpath)) return 0;
193
194// Try to open the authorization database
195//
196 if (!Database || !Database->Open(Eroute, dbpath)) return 1;
197
198// Allocate new hash tables
199//
200 if (!(tabs.G_Hash = new XrdOucHash<XrdAccCapability>()) ||
201 !(tabs.H_Hash = new XrdOucHash<XrdAccCapability>()) ||
202 !(tabs.N_Hash = new XrdOucHash<XrdAccCapability>()) ||
203 !(tabs.O_Hash = new XrdOucHash<XrdAccCapability>()) ||
204 !(tabs.R_Hash = new XrdOucHash<XrdAccCapability>()) ||
205 !(tabs.T_Hash = new XrdOucHash<XrdAccCapability>()) ||
206 !(tabs.U_Hash = new XrdOucHash<XrdAccCapability>()) )
207 {Eroute.Emsg("ConfigDB","Insufficient storage for id tables.");
208 Database->Close(); return 1;
209 }
210
211// Now start processing records until eof.
212//
213 rulenum = 0;
214 while((retc = ConfigDBrec(Eroute, tabs))) {NoGo |= retc < 0; anum++;}
215 snprintf(buff, sizeof(buff), "%d auth entries processed in ", anum);
216 Eroute.Say("Config ", buff, dbpath);
217
218// All done, close the database and return if we failed
219//
220 if (!Database->Close() || NoGo) return 1;
221
222// Do final setup for special identifiers (this will correctly order them)
223//
224 if (tabs.SYList) idChk(Eroute, tabs.SYList, tabs);
225
226// Set the access control tables
227//
228 if (!tabs.G_Hash->Num()) {delete tabs.G_Hash; tabs.G_Hash=0;}
229 if (!tabs.H_Hash->Num()) {delete tabs.H_Hash; tabs.H_Hash=0;}
230 if (!tabs.N_Hash->Num()) {delete tabs.N_Hash; tabs.N_Hash=0;}
231 if (!tabs.O_Hash->Num()) {delete tabs.O_Hash; tabs.O_Hash=0;}
232 if (!tabs.R_Hash->Num()) {delete tabs.R_Hash; tabs.R_Hash=0;}
233 if (!tabs.T_Hash->Num()) {delete tabs.T_Hash; tabs.T_Hash=0;}
234 if (!tabs.U_Hash->Num()) {delete tabs.U_Hash; tabs.U_Hash=0;}
235 Authorization->SwapTabs(tabs);
236
237// All done
238//
239 return NoGo;
240}
XrdAccAuthDB * XrdAccAuthDBObject(XrdSysError *erp)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)

References Authorization, XrdSysError::Emsg(), XrdAccAccess_Tables::G_Hash, XrdAccAccess_Tables::H_Hash, XrdAccAccess_Tables::N_Hash, XrdOucHash< T >::Num(), XrdAccAccess_Tables::O_Hash, XrdAccAccess_Tables::R_Hash, XrdSysError::Say(), XrdAccAccess_Tables::SYList, XrdAccAccess_Tables::T_Hash, XrdAccAccess_Tables::U_Hash, and XrdAccAuthDBObject().

Referenced by Configure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Configure()

int XrdAccConfig::Configure ( XrdSysError & Eroute,
const char * cfn )

Definition at line 132 of file XrdAccConfig.cc.

132 {
133/*
134 Function: Establish default values using a configuration file.
135
136 Input: None.
137
138 Output: 0 upon success or !0 otherwise.
139*/
140 char *var;
141 int retc, NoGo = 0, Cold = (Database == 0);
142 pthread_t reftid;
143
144// Print warm-up message
145//
146 Eroute.Say("++++++ Authorization system initialization started.");
147
148// Process the configuration file and authorization database
149//
150 if (!(Authorization = new XrdAccAccess(&Eroute))
151 || (NoGo = ConfigFile(Eroute, cfn))
152 || (NoGo = ConfigDB(0, Eroute)))
153 {if (Authorization) {delete Authorization, Authorization = 0;}
154 NoGo = 1;
155 }
156
157// Start a refresh thread unless this was a refresh thread call
158//
159 if (Cold && !NoGo)
160 {if ((retc=XrdSysThread::Run(&reftid,XrdAccConfig_Refresh,(void *)&Eroute)))
161 Eroute.Emsg("ConfigDB",retc,"start refresh thread.");
162 }
163
164// All done
165//
166 var = (NoGo > 0 ? (char *)"failed." : (char *)"completed.");
167 Eroute.Say("------ Authorization system initialization ", var);
168 return (NoGo > 0);
169}
void * XrdAccConfig_Refresh(void *start_data)
int ConfigDB(int Warm, XrdSysError &Eroute)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)

References Authorization, ConfigDB(), XrdSysThread::Run(), XrdSysError::Say(), and XrdAccConfig_Refresh().

Here is the call graph for this function:

Member Data Documentation

◆ Authorization

XrdAccAccess* XrdAccConfig::Authorization

Definition at line 78 of file XrdAccConfig.hh.

Referenced by XrdAccConfig(), ConfigDB(), and Configure().

◆ AuthRT

int XrdAccConfig::AuthRT

Definition at line 81 of file XrdAccConfig.hh.

◆ GroupMaster

XrdAccGroups XrdAccConfig::GroupMaster

Definition at line 79 of file XrdAccConfig.hh.


The documentation for this class was generated from the following files: