38 #include <sys/param.h>
60 #define TS_Xeq(x,m) if (!strcmp(x,var)) return m(Config,Eroute);
62 #define TS_Str(x,m) if (!strcmp(x,var)) {free(m); m = strdup(val); return 0;}
64 #define TS_PList(x,m) if (!strcmp(x,var)) \
65 {m.Insert(new XrdOucPList(val,1)); return 0;}
67 #define TS_Chr(x,m) if (!strcmp(x,var)) {m = val[0]; return 0;}
69 #define TS_Bit(x,m,v) if (!strcmp(x,var)) {m |= v; Config.Echo(); return 0;}
71 #define Max(x,y) (x > y ? x : y)
86 int cfgFD, retc, NoGo = 0;
92 Eroute.
Say(
"++++++ Bwm initialization started.");
101 Eroute.
Emsg(
"Config",
"Configuration file not specified.");
106 return Eroute.
Emsg(
"Config", errno,
"open config file",
109 static const char *cvec[] = {
"*** bwm ofs plugin config:", 0 };
114 while((var =
Config.GetMyFirstWord()))
115 {
if (!strncmp(var,
"bwm.", 4))
121 if ((retc =
Config.LastError()))
122 NoGo = Eroute.
Emsg(
"Config", -retc,
"read config file",
129 if (
Authorize) NoGo |= setupAuth(Eroute);
133 if (PolLib) NoGo |= setupPolicy(Eroute);
138 if (!NoGo && Logger) NoGo = Logger->
Start(&Eroute);
146 Eroute.
Say(
"------ Bwm initialization ", (NoGo ?
"failed." :
"completed."));
168 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
189 char *val, parms[1024];
193 if (!(val =
Config.GetWord()) || !val[0])
194 {Eroute.
Emsg(
"Config",
"authlib not specified");
return 1;}
198 if (AuthLib) free(AuthLib);
199 AuthLib = strdup(val);
203 if (!
Config.GetRest(parms,
sizeof(parms)))
204 {Eroute.
Emsg(
"Config",
"authlib parameters too long");
return 1;}
205 if (AuthParm) free(AuthParm);
206 AuthParm = (*parms ? strdup(parms) : 0);
229 char *val, parms[1024];
231 if (!(val =
Config.GetWord()))
232 {Eroute.
Emsg(
"Config",
"log parameters not specified");
return 1;}
237 if (!
Config.GetRest(parms,
sizeof(parms)))
238 {Eroute.
Emsg(
"Config",
"log parameters too long");
return 1;}
239 val = (*parms ==
'|' ? parms+1 : parms);
243 if (Logger)
delete Logger;
271 char *val, parms[2048];
276 if (!(val =
Config.GetWord()) || !val[0])
277 {Eroute.
Emsg(
"Config",
"policy not specified");
return 1;}
281 if (PolLib) {free(PolLib); PolLib = 0;}
282 if (PolParm) {free(PolParm); PolParm = 0;}
283 PolSlotsIn = PolSlotsOut = 0;
287 if (!strcmp(
"maxslots", val))
288 {
if (!(val =
Config.GetWord()) || !val[0])
289 {Eroute.
Emsg(
"Config",
"policy in slots not specified");
return 1;}
290 if (
XrdOuca2x::a2i(Eroute,
"policy in slots",val,&pl,0,32767))
return 1;
292 if (!(val =
Config.GetWord()) || !val[0])
293 {Eroute.
Emsg(
"Config",
"policy out slots not specified");
return 1;}
294 if (
XrdOuca2x::a2i(Eroute,
"policy out slots",val,&pl,0,32767))
return 1;
301 if (strcmp(
"lib", val))
302 {Eroute.
Emsg(
"Config",
"invalid policy keyword -", val);
return 1;}
303 if (!(val =
Config.GetWord()) || !val[0])
304 {Eroute.
Emsg(
"Config",
"policy library not specified");
return 1;}
308 PolLib = strdup(val);
312 if (!
Config.GetRest(parms,
sizeof(parms)))
313 {Eroute.
Emsg(
"Config",
"policy lib parameters too long");
return 1;}
314 PolParm = (*parms ? strdup(parms) : 0);
337 static struct traceopts {
const char *opname;
int opval;} tropts[] =
346 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
349 if (!(val =
Config.GetWord()))
350 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
352 {
if (!strcmp(val,
"off")) trval = 0;
353 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
354 for (i = 0; i < numopts; i++)
355 {
if (!strcmp(val, tropts[i].opname))
356 {
if (neg) trval &= ~tropts[i].opval;
357 else trval |= tropts[i].opval;
362 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
400 (myLib->
Resolve(
"XrdAccAuthorizeObject"));
408 return (Authorization == 0);
423 (myLib.
Resolve(
"XrdBwmPolicyObject"));
424 if (!ep) {myLib.
Unload();
return 1;}
429 return (Policy == 0);
XrdAccAuthorize * XrdAccDefaultAuthorizeObject(XrdSysLogger *lp, const char *cfn, const char *parm, XrdVersionInfo &urVer)
int open(const char *path, int oflag,...)
static int setPolicy(XrdBwmPolicy *pP, XrdBwmLogger *lP)
int Start(XrdSysError *eobj)
XrdVersionInfo * myVersion
virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &)
virtual int Configure(XrdSysError &)
void * Resolve(const char *symbl, int mcnt=1)
void Unload(bool dodel=false)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
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)
XrdSysLogger * logger(XrdSysLogger *lp=0)