78#define Duplicate(x,y) if (y) free(y); y = strdup(x)
80#define TS_String(x,m) if (!strcmp(x,var)) {Duplicate(val,m); return 0;}
82#define TS_Xeq(x,m) if (!strcmp(x,var)) return m(&eDest, Config);
84#define TS_PSX(x,m) if (!strcmp(x,var)) \
85 return (psxConfig->m(&eDest, Config) ? 0 : 1);
87#define TS_DBG(x,m) if (!strcmp(x,var)) {SysTrace.What |= m; return 0;}
148std::vector<const char *> protVec;
172 myHost = getenv(
"XRDHOST");
186 if (getenv(
"XRDDEBUG"))
187 {psxConfig->traceLvl = 4;
209 if ((NoGo = ConfigProc(cfn)))
return NoGo;
214 {
eDest.
Emsg(
"Config",
"Origin for proxy service not specified.");
230 if (LocalRoot) psxConfig->SetRoot(LocalRoot);
234 if (
outProxy && psxConfig->xLfn2Pfn)
236 if (!(psxConfig->xNameLib)) txt =
"localroot directive";
237 else if (psxConfig->xPfn2Lfn) txt =
"namelib -lfn2pfn option";
238 else txt =
"namelib directive";
239 eDest.
Say(
"Config warning: ignoring ",txt,
"; this is forwarding proxy!");
240 psxConfig->xLfn2Pfn =
false;
253 {
eDest.
Say(
"Config warning: ignoring 'pss.reproxy'; TPC is not enabled!");
255 myFeatures &= ~XRDOSS_HASRPXY;
257 rpFD = XrdSysFD_Open(rPath, O_DIRECTORY);
259 {
eDest.
Emsg(
"Config",
"to open reproxy directory", rPath);
267 if (!(psxConfig->ConfigSetup(
eDest)))
return 1;
275 if (psxConfig->xLfn2Pfn)
xLfn2Pfn = (theN2N = psxConfig->theN2N) != 0;
308 {
eDest.
Emsg(
"Config",
"Unable to add origin protocol to protocol list.");
315 {
for (
int i = 0; i < (int)protVec.size(); i++)
317 {
eDest.
Emsg(
"Config",
"Unable to add", protVec[i],
318 "protocol to protocol list.");
327 const char *outeq = (
outProxy ?
"= " :
"");
330 else strcpy(theRdr, outeq);
338 {
hdrLen = sprintf(theRdr,
"%s%%s%s:%d/%s%%s",
340 (HostArena ? HostArena :
""));
356 {snprintf(theRdr,
sizeof(theRdr),
hdrData,
"",
"");
391 deferID = psxConfig->hasCache();
397 {
eDest.
Emsg(
"Config",
"Client personas are not supported for "
398 "caching proxy servers.");
408 {
eDest.
Emsg(
"Config",
"Client personas are not supported for "
409 "strictly forwarding proxy servers.");
412 eDest.
Say(
"Config warning: client personas only apply to "
413 "the origin server!");
424 idMapper =
new XrdSecsssID(sssMap, 0, conTracker, &isOK);
426 {
eDest.
Emsg(
"Config",
"Unable to render persona; persona mapper failed!");
444int XrdPssSys::ConfigProc(
const char *Cfn)
447 int cfgFD, retc, NoGo = 0;
454 {
eDest.
Emsg(
"Config",
"pss configuration file not specified.");
460 if ( (cfgFD =
open(Cfn, O_RDONLY, 0)) < 0)
461 {
eDest.
Emsg(
"Config", errno,
"open config file", Cfn);
465 static const char *cvec[] = {
"*** pss (oss) plugin config:", 0 };
470 while((var =
Config.GetMyFirstWord()))
471 {
if (!strncmp(var,
"pss.", 4)
472 || !strcmp(var,
"oss.defaults")
473 || !strcmp(var,
"all.export"))
474 if (ConfigXeq(var+4, Config)) {
Config.Echo(); NoGo = 1;}
479 if ((retc =
Config.LastError()))
480 NoGo =
eDest.
Emsg(
"Config", retc,
"read config file", Cfn);
496int XrdPssSys::ConfigXeq(
char *var,
XrdOucStream &Config)
498 char myVar[80], *val;
502 TS_PSX(
"namelib", ParseNLib);
503 TS_PSX(
"memcache", ParseCache);
504 TS_PSX(
"cache", ParseCache);
505 TS_PSX(
"cachelib", ParseCLib);
506 TS_PSX(
"ccmlib", ParseMLib);
507 TS_PSX(
"ciosync", ParseCio);
513 TS_PSX(
"inetmode", ParseINet);
517 TS_PSX(
"setopt", ParseSet);
518 TS_PSX(
"trace", ParseTrace);
520 if (!strcmp(
"reproxy", var))
530 strlcpy(myVar, var,
sizeof(myVar)); var = myVar;
531 if (!(val =
Config.GetWord()))
532 {
eDest.
Emsg(
"Config",
"no value for directive", var);
543 eDest.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
567 struct Xtab {
const char *Key;
int *Val;} Xopts[] =
570 int i, numopts =
sizeof(Xopts)/
sizeof(
struct Xtab);
572 if (!(val =
Config.GetWord()))
573 {Eroute->
Emsg(
"Config",
"options argument not specified.");
return 1;}
575do{
for (i = 0; i < numopts; i++)
if (!strcmp(Xopts[i].Key, val))
break;
578 Eroute->
Say(
"Config warning: ignoring unknown config option '",val,
"'.");
579 else {
if (!(val =
Config.GetWord()))
580 {Eroute->
Emsg(
"Config",
"config",Xopts[i].Key,
"value not specified.");
584 kval = strtol(val, &kvp, 10);
586 {Eroute->
Emsg(
"Config", Xopts[i].Key,
587 "config value is invalid -", val);
590 *(Xopts[i].Val) = kval;
593 }
while(val && *val);
615 static const int maxsz = 0x7fffffff;
626 while((val =
Config.GetWord()))
627 {
if (!strcmp(val,
"world"))
dcaWorld =
true;
628 else if (!strcmp(val,
"group"))
dcaWorld =
false;
629 else if (!strcmp(val,
"recheck"))
630 {
if (!strcmp(val,
"off"))
dcaCTime = 0;
631 else {
if (!(val =
Config.GetWord()))
632 {errp->
Emsg(
"Config",
633 "dca recheck value not specified");
640 else {errp->
Emsg(
"Config",
"invalid dca option -", val);
return 1;}
715 char *val, *colon, *slash, *mval = 0;
721 if (!(val =
Config.GetWord()))
722 {errp->
Emsg(
"Config",
"origin host name not specified");
return 1;}
729 {std::vector<char *> pVec;
730 char *pData = strdup(val+1);
734 {errp->
Emsg(
"Config",
"Malformed forwarding specification");
738 protVec.reserve(pVec.size());
739 for (
int i = 0; i < (int)pVec.size(); i++)
740 {
int n = strlen(pVec[i]);
742 {errp->
Emsg(
"Config",
"Unsupported forwarding protocol -",pVec[i]);
746 protVec.push_back(pName);
750 if (!(val =
Config.GetWord()))
return 0;
761 {
char *vP = val +strlen(val) - 1;
762 while(*vP ==
'/'&& vP != val) {*vP-- = 0;}
772 if ((colon = index(val,
':')) && *(colon+1) ==
'/' && *(colon+2) ==
'/')
776 {errp->
Emsg(
"Config",
"Unsupported origin protocol -", val);
782 if ((slash = index(val,
'/')))
784 {errp->
Emsg(
"Config",
"badly formed origin URL");
return 1;}
798 if (!(val = index(mval,
':')) && !isURL) val =
Config.GetWord();
799 else if (val) {*val =
'\0'; val++;}
804 {errp->
Emsg(
"Config",
"origin host name not specified");
return 1;}
814 {errp->
Emsg(
"Config",
"unable to find tcp service", val);
820 port = *
protName ==
'h' ? (strncmp(
protName,
"https", 5) == 0 ? 443 : 80) : 1094;
825 errp->
Say(
"Config warning: origin port not specified, using port ",
826 std::to_string(port).c_str(),
" as default for ",
protName);
831 if (!port) {free(mval);
return 1;}
835 if ((i = strlen(mval)) > 1 && mval[i-1] ==
'+') mval[i-1] = 0;
852 if (!index(mval,
'.')
879 bool pType[
PolNum] = {
false,
false};
882do {
if (!(val =
Config.GetWord()))
883 {Eroute->
Emsg(
"Config",
"permit target not specified");
return 1;}
884 if (!strcmp(val,
"/")) pType[
PolPath] =
true;
885 else if (!strcmp(val,
"*")) pType[
PolObj ] =
true;
892 for (i = 0; i <
PolNum; i++)
924 bool isClient =
false, strict =
false;
929 if (!(val =
Config.GetWord()))
930 {Eroute->
Emsg(
"Config",
"persona not specified");
return 1;}
934 if (!strcmp(val,
"client")) isClient =
true;
935 else if (!strcmp(val,
"server")) isClient =
false;
936 else {Eroute->
Emsg(
"Config",
"Invalid persona - ", val);
return 1;}
940 while ((val =
Config.GetWord()))
941 {
if (!strcmp(val,
"strict" )) strict =
true;
942 else if (!strcmp(val,
"nonstrict" )) strict =
false;
943 else if (!strcmp(val,
"verify" )) doVer = 1;
944 else if (!strcmp(val,
"noverify" )) doVer = 0;
945 else {Eroute->
Emsg(
"Config",
"Invalid persona option - ", val);
953 {
idMapAll = (strict ? true :
false);
954 if (doVer < 0) doVer = 1;
XrdSysError eDest(0, "HttpMon")
void AddHost(char *hname)
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
char * Get(const char *varname)
static int Export(const char *Var, const char *Val)
void * GetPtr(const char *varname)
static unsigned long long ParseDefs(XrdOucStream &Config, XrdSysError &Eroute, unsigned long long Flags)
static XrdOucPList * ParsePath(XrdOucStream &Config, XrdSysError &Eroute, XrdOucPListAnchor &Export, unsigned long long Defopts)
XrdOucPsx(XrdVersionInfo *vInfo, const char *cfn, XrdSysLogger *lp=0, XrdOucEnv *vp=0)
XrdOucSid(int numSid=256, bool mtproof=true, XrdOucSid *glblSid=0)
XrdOucTList(const char *tval, long long *dv, XrdOucTList *np=0)
static const char * InstName(int TranOpt=0)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static void SetEnv(const char *kword, int kval)
static void setOids(bool isok)
static XrdSecsssCon * conTracker(bool debug=false)
static bool SetConfig(XrdOucPsx &parms)
static bool AddProto(const char *proto)
POSIX interface to XRootD with some extensions, as noted.
XrdPosixXrootd(int maxfd=255, int maxdir=0, int maxthr=0)
static const char * ConfigFN
static const char * hdrData
static XrdOucTList * ManList
static XrdNetSecurity * Police[PolNum]
static const char * myName
static XrdOucPListAnchor XPList
static const char * myHost
static const char * protName
static void setMapID(bool onoff)
static const char * getDomain(const char *hName)
static const char * valProt(const char *pname, int &plen, int adj=0)
static bool Vectorize(char *str, std::vector< char * > &vec, char sep)
XrdSecsssID(authType aType=idStatic, const XrdSecEntity *Ident=0, XrdSecsssCon *Tracker=0, bool *isOK=0)
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)
XrdSysTrace SysTrace("Pss", 0)
XrdSysError eDest(0, "pss_")
static XrdPosixXrootd * Xroot