#include <XrdAccAuthFile.hh>
Definition at line 44 of file XrdAccAuthFile.hh.
◆ XrdAccAuthFile()
Definition at line 54 of file XrdAccAuthFile.cc.
55{
56
57
58
59 authfn = 0;
60 flags = Noflags;
61 modtime = 0;
62 Eroute = erp;
63
64
65
66 strcpy(path_buff, "start of file");
67}
◆ ~XrdAccAuthFile()
XrdAccAuthFile::~XrdAccAuthFile |
( |
| ) |
|
◆ Changed()
int XrdAccAuthFile::Changed |
( |
const char * | dbpath | ) |
|
|
virtual |
Implements XrdAccAuthDB.
Definition at line 89 of file XrdAccAuthFile.cc.
90{
92
93
94
95 if (!authfn || !*authfn) return 0;
96
97
98
99 if (dbfn && strcmp(dbfn, authfn)) return 1;
100
101
102
103 if (
stat(authfn, &statbuff))
104 {Eroute->
Emsg(
"AuthFile", errno,
"find", authfn);
105 return 0;
106 }
107
108
109
110 return (modtime < statbuff.st_mtime);
111}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
References XrdSysError::Emsg(), and stat.
◆ Close()
int XrdAccAuthFile::Close |
( |
| ) |
|
|
virtual |
◆ getID()
char XrdAccAuthFile::getID |
( |
char ** | id | ) |
|
|
virtual |
Implements XrdAccAuthDB.
Definition at line 145 of file XrdAccAuthFile.cc.
146{
147 char *pp, idcode[2] = {0,0};
148
149
150
151 if (!(flags & inRec)) return 0;
152
153
154
156 {flags = (DBflags)(flags & ~inRec);
157 return 0;
158 }
159
160
161
162
163
164 if (strlen(pp) > 2 || !index("ghoru", *pp))
165 {Eroute->
Emsg(
"AuthFile",
"Invalid ID sprecifier -", pp);
166 flags = (DBflags)(flags | dbError);
167 return 0;
168 }
169 idcode[0] = *pp;
170
171
172
174 {flags = (DBflags)(flags & ~inRec);
175 Eroute->
Emsg(
"AuthFile",
"ID value missing after", idcode);
176 flags = (DBflags)(flags | dbError);
177 return 0;
178 }
179
180
181
182 Copy(path_buff, pp, sizeof(path_buff)-1);
183
184
185
186 *id = path_buff;
187 return idcode[0];
188}
char * GetWord(int lowcase=0)
References XrdSysError::Emsg(), and XrdOucStream::GetWord().
◆ getPP()
int XrdAccAuthFile::getPP |
( |
char ** | path, |
|
|
char ** | priv, |
|
|
bool & | istmplt ) |
|
virtual |
Implements XrdAccAuthDB.
Definition at line 194 of file XrdAccAuthFile.cc.
195{
196
197 char *pp;
198
199
200
201 if (!(flags & inRec)) return 0;
202
203
204
206 {flags = (DBflags)(flags & ~inRec);
207 return 0;
208 }
209
210
211
212 istmplt = false;
213 *path = path_buff;
214 if (*pp == '\\')
215 {if (*(pp+1)) pp++;
216 else {Eroute->
Emsg(
"AuthFile",
"Object ID missing after '\\'");
217 *path = 0;
218 flags = (DBflags)(flags | dbError);
219 }
220 } else if (*pp != '/') istmplt = true;
221
222
223
224
225 if (path) Copy(path_buff, pp, sizeof(path_buff)-1);
226
227
228
229 if (istmplt) {*priv = (char *)0; return 1;}
230
231
232
233
234
235
236
237
238
239
241 {flags = (DBflags)(flags & ~inRec);
242 Eroute->
Emsg(
"AuthFile",
"Privileges missing after", path_buff);
243 flags = (DBflags)(flags | dbError);
244 *priv = (char *)0;
245 return 0;
246 }
247
248
249
250 *priv = pp;
251 return 1;
252}
References XrdSysError::Emsg(), and XrdOucStream::GetWord().
◆ getRec()
char XrdAccAuthFile::getRec |
( |
char ** | recname | ) |
|
|
virtual |
Implements XrdAccAuthDB.
Definition at line 258 of file XrdAccAuthFile.cc.
259{
260 char *pp;
261 int idok;
262
263
264
265 while(1)
266 {
267
268
269 if (flags & inRec)
while(DBfile.
GetWord()) {}
270 else flags = (DBflags)(flags | inRec);
271
272
273
275 {*recname = (char *)0; return '\0';}
276
277
278
279 idok = 0;
280 if (strlen(pp) == 1)
281 switch(*pp)
282 {case 'g':
283 case 'h':
284 case 's':
285 case 'n':
286 case 'o':
287 case 'r':
288 case 't':
289 case 'u':
290 case 'x':
291 case '=': idok = 1;
292 break;
293 default: break;
294 }
295
296
297
298 if (!idok) {Eroute->
Emsg(
"AuthFile",
"Invalid id type -", pp);
299 flags = (DBflags)(flags | dbError);
300 continue;
301 }
302 rectype = *pp;
303
304
305
307 {Eroute->
Emsg(
"AuthFile",
"Record name is missing after",path_buff);
308 flags = (DBflags)(flags | dbError);
309 continue;
310 }
311
312
313
314 Copy(recname_buff, pp, sizeof(recname_buff));
315 *recname = recname_buff;
316 return rectype;
317 }
318 return '\0';
319}
References XrdSysError::Emsg(), and XrdOucStream::GetWord().
◆ Open()
int XrdAccAuthFile::Open |
( |
XrdSysError & | eroute, |
|
|
const char * | path = 0 ) |
|
virtual |
Implements XrdAccAuthDB.
Definition at line 325 of file XrdAccAuthFile.cc.
326{
327 struct stat statbuff;
328 int authFD;
329
330
331
333 Eroute = &eroute;
334
335
336
337 if (path)
338 {if (authfn) free(authfn); authfn = strdup(path);}
339 if( !authfn || !*authfn) return Bail(0, "Authorization file not specified.");
340
341
342
343 if (
stat(authfn, &statbuff))
return Bail(errno,
"find", authfn);
344
345
346
347 if ( (authFD =
open(authfn, O_RDONLY, 0)) < 0)
348 return Bail(errno,"open authorization file",authfn);
349
350
351
352 modtime = statbuff.st_mtime;
353 flags = isOpen;
356
357
358
359 if (DBfile.
Attach(authFD))
360 return Bail(DBfile.
LastError(),
"initialize stream for", authfn);
361 return 1;
362}
int Attach(int FileDescriptor, int bsz=2047)
void SetEroute(XrdSysError *eroute)
References XrdOucStream::Attach(), XrdOucStream::LastError(), XrdSysMutex::Lock(), open, XrdOucStream::SetEroute(), stat, and XrdOucStream::Tabs().
The documentation for this class was generated from the following files: