313{
314 if (tried_configure) {
315 auto result = mapper.get();
316 if (result) {
317 result->SetErrorStream(erp);
318 }
319 return result;
320 }
321
322 tried_configure = true;
323
324
325 if (erp) erp->
setMsgMask(LogMask::Error | LogMask::Warning);
326
327 char *config_filename = nullptr;
330 }
331 XrdOucEnv myEnv;
332 XrdOucStream stream(erp, getenv("XRDINSTANCE"), &myEnv, "=====> ");
333
334 int cfg_fd;
335 if ((cfg_fd =
open(config_filename, O_RDONLY, 0)) < 0) {
336 if (erp) erp->
Emsg(
"Config", errno,
"open config file", config_filename);
338 }
339 stream.Attach(cfg_fd);
340 char *var;
341 std::string map_filename;
342 while ((var = stream.GetMyFirstWord())) {
343 if (!strcmp(var, "voms.mapfile")) {
344 auto val = stream.GetWord();
345 if (!val || !val[0]) {
346 if (erp) erp->
Emsg(
"Config",
"VOMS mapfile not specified");
348 }
349 map_filename = val;
350 } else if (!strcmp(var, "voms.trace")) {
351 auto val = stream.GetWord();
352 if (!val || !val[0]) {
353 if (erp) erp->
Emsg(
"Config",
"VOMS logging level not specified");
355 }
357 if (erp) do {
363 else if (!strcmp(val,
"none")) {erp->
setMsgMask(0);}
364 else {erp->
Emsg(
"Config",
"voms.trace encountered an unknown directive:", val);}
365 val = stream.GetWord();
366 } while (val);
367 }
368 }
369
370 if (!map_filename.empty()) {
371 if (erp) erp->
Emsg(
"Config",
"Will initialize VOMS mapfile", map_filename.c_str());
372 mapper.reset(new XrdVomsMapfile(erp, map_filename));
373 if (!mapper->IsValid()) {
374 mapper.reset(nullptr);
376 }
377 }
378
379 return mapper.get();
380}
static bool Import(const char *var, char *&val)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void setMsgMask(int mask)