36 #include <sys/param.h>
37 #include <sys/types.h>
41 #include "XrdVersion.hh"
80 #define Duplicate(x,y) if (y) free(y); y = strdup(x)
82 #define TS_String(x,m) if (!strcmp(x,var)) {Duplicate(val,m); return 0;}
84 #define TS_Xeq(x,m) if (!strcmp(x,var)) return m(&eDest, Config);
86 #define TS_PSX(x,m) if (!strcmp(x,var)) \
87 return (psxConfig->m(&eDest, Config) ? 0 : 1);
89 #define TS_DBG(x,m) if (!strcmp(x,var)) {SysTrace.What |= m; return 0;}
150 std::vector<const char *> protVec;
173 myHost = getenv(
"XRDHOST");
187 if (getenv(
"XRDDEBUG"))
188 {psxConfig->traceLvl = 4;
210 if ((NoGo = ConfigProc(cfn)))
return NoGo;
214 if (!ManList && !
outProxy && !fileOrgn)
215 {
eDest.
Emsg(
"Config",
"Origin for proxy service not specified.");
221 if (sssMap && !ConfigMapID())
return 1;
225 if (LocalRoot) psxConfig->SetRoot(LocalRoot);
229 if (
outProxy && psxConfig->xLfn2Pfn)
231 if (!(psxConfig->xNameLib)) txt =
"localroot directive";
232 else if (psxConfig->xPfn2Lfn) txt =
"namelib -lfn2pfn option";
233 else txt =
"namelib directive";
234 eDest.
Say(
"Config warning: ignoring ",txt,
"; this is forwarding proxy!");
235 psxConfig->xLfn2Pfn =
false;
248 {
eDest.
Say(
"Config warning: ignoring 'pss.reproxy'; TPC is not enabled!");
252 rpFD = XrdSysFD_Open(rPath, O_DIRECTORY);
254 {
eDest.
Emsg(
"Config",
"to open reproxy directory", rPath);
262 if (!(psxConfig->ConfigSetup(
eDest)))
return 1;
270 if (psxConfig->xLfn2Pfn) xLfn2Pfn = (
theN2N = psxConfig->theN2N) != 0;
292 if (Streams)
sidP =
new XrdOucSid((Streams > 8192 ? 8192 : Streams));
303 {
eDest.
Emsg(
"Config",
"Unable to add origin protocol to protocol list.");
310 {
for (
int i = 0; i < (int)protVec.size(); i++)
312 {
eDest.
Emsg(
"Config",
"Unable to add", protVec[i],
313 "protocol to protocol list.");
322 const char *outeq = (
outProxy ?
"= " :
"");
323 if (ManList) sprintf(theRdr,
"%s%s:%d", outeq, ManList->text, ManList->val);
324 else if (fileOrgn) sprintf(theRdr,
"%s%s", outeq, fileOrgn);
325 else strcpy(theRdr, outeq);
333 {hdrLen = sprintf(theRdr,
"%s%%s%s:%d/%s%%s",
334 protName, ManList->text, ManList->val,
335 (HostArena ? HostArena :
""));
336 hdrData = strdup(theRdr);
343 {hdrLen = sprintf(theRdr,
"%s%s%%s", protName, fileOrgn);
344 hdrData = strdup(theRdr);
350 if (hdrData && *hdrData)
351 {snprintf(theRdr,
sizeof(theRdr), hdrData,
"",
"");
386 deferID = psxConfig->hasCache();
392 {
eDest.
Emsg(
"Config",
"Client personas are not supported for "
393 "caching proxy servers.");
403 {
eDest.
Emsg(
"Config",
"Client personas are not supported for "
404 "strictly forwarding proxy servers.");
407 eDest.
Say(
"Config warning: client personas only apply to "
408 "the origin server!");
421 {
eDest.
Emsg(
"Config",
"Unable to render persona; persona mapper failed!");
439 int XrdPssSys::ConfigProc(
const char *Cfn)
442 int cfgFD, retc, NoGo = 0;
449 {
eDest.
Emsg(
"Config",
"pss configuration file not specified.");
455 if ( (cfgFD =
open(Cfn, O_RDONLY, 0)) < 0)
456 {
eDest.
Emsg(
"Config", errno,
"open config file", Cfn);
460 static const char *cvec[] = {
"*** pss (oss) plugin config:", 0 };
465 while((var =
Config.GetMyFirstWord()))
466 {
if (!strncmp(var,
"pss.", 4)
467 || !strcmp(var,
"oss.defaults")
468 || !strcmp(var,
"all.export"))
469 if (ConfigXeq(var+4,
Config)) {
Config.Echo(); NoGo = 1;}
474 if ((retc =
Config.LastError()))
475 NoGo =
eDest.
Emsg(
"Config", retc,
"read config file", Cfn);
480 XPList.Set(DirFlags);
493 char myVar[80], *val;
497 TS_PSX(
"namelib", ParseNLib);
498 TS_PSX(
"memcache", ParseCache);
499 TS_PSX(
"cache", ParseCache);
500 TS_PSX(
"cachelib", ParseCLib);
501 TS_PSX(
"ccmlib", ParseMLib);
502 TS_PSX(
"ciosync", ParseCio);
508 TS_PSX(
"inetmode", ParseINet);
512 TS_PSX(
"setopt", ParseSet);
513 TS_PSX(
"trace", ParseTrace);
515 if (!strcmp(
"reproxy", var))
525 strlcpy(myVar, var,
sizeof(myVar)); var = myVar;
526 if (!(val =
Config.GetWord()))
527 {
eDest.
Emsg(
"Config",
"no value for directive", var);
538 eDest.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
562 struct Xtab {
const char *Key;
int *Val;} Xopts[] =
563 {{
"streams", &Streams},
564 {
"workers", &Workers}};
565 int i, numopts =
sizeof(Xopts)/
sizeof(
struct Xtab);
567 if (!(val =
Config.GetWord()))
568 {Eroute->
Emsg(
"Config",
"options argument not specified.");
return 1;}
570 do{
for (i = 0; i < numopts; i++)
if (!strcmp(Xopts[i].Key, val))
break;
573 Eroute->
Say(
"Config warning: ignoring unknown config option '",val,
"'.");
574 else {
if (!(val =
Config.GetWord()))
575 {Eroute->
Emsg(
"Config",
"config",Xopts[i].Key,
"value not specified.");
579 kval = strtol(val, &kvp, 10);
581 {Eroute->
Emsg(
"Config", Xopts[i].Key,
582 "config value is invalid -", val);
585 *(Xopts[i].Val) = kval;
588 }
while(val && *val);
610 static const int maxsz = 0x7fffffff;
621 while((val =
Config.GetWord()))
622 {
if (!strcmp(val,
"world")) dcaWorld =
true;
623 else if (!strcmp(val,
"group")) dcaWorld =
false;
624 else if (!strcmp(val,
"recheck"))
625 {
if (!strcmp(val,
"off")) dcaCTime = 0;
626 else {
if (!(val =
Config.GetWord()))
627 {errp->
Emsg(
"Config",
628 "dca recheck value not specified");
632 &dcaCTime,10,maxsz))
return 1;
635 else {errp->
Emsg(
"Config",
"invalid dca option -", val);
return 1;}
710 char *val, *colon, *slash, *mval = 0;
716 if (!(val =
Config.GetWord()))
717 {errp->
Emsg(
"Config",
"origin host name not specified");
return 1;}
724 {std::vector<char *> pVec;
725 char *pData = strdup(val+1);
729 {errp->
Emsg(
"Config",
"Malformed forwarding specification");
733 protVec.reserve(pVec.size());
734 for (
int i = 0; i < (int)pVec.size(); i++)
735 {
int n = strlen(pVec[i]);
737 {errp->
Emsg(
"Config",
"Unsupported forwarding protocol -",pVec[i]);
741 protVec.push_back(pName);
745 if (!(val =
Config.GetWord()))
return 0;
751 if (fileOrgn) {free(fileOrgn); fileOrgn = 0;}
756 {
char *vP = val +strlen(val) - 1;
757 while(*vP ==
'/'&& vP != val) {*vP-- = 0;}
758 if (ManList) {
delete ManList; ManList = 0;}
759 protName =
"file://";
760 fileOrgn = strdup(val);
767 if ((colon = index(val,
':')) && *(colon+1) ==
'/' && *(colon+2) ==
'/')
771 {errp->
Emsg(
"Config",
"Unsupported origin protocol -", val);
774 if (*val ==
'x') protName++;
777 if ((slash = index(val,
'/')))
779 {errp->
Emsg(
"Config",
"badly formed origin URL");
return 1;}
785 protName =
"root://";
793 if (!(val = index(mval,
':')) && !isURL) val =
Config.GetWord();
794 else if (val) {*val =
'\0'; val++;}
799 {errp->
Emsg(
"Config",
"origin host name not specified");
return 1;}
809 {errp->
Emsg(
"Config",
"unable to find tcp service", val);
815 port = *protName ==
'h' ? (strncmp(protName,
"https", 5) == 0 ? 443 : 80) : 1094;
820 errp->
Say(
"Config warning: origin port not specified, using port ",
821 std::to_string(port).c_str(),
" as default for ", protName);
826 if (!port) {free(mval);
return 1;}
830 if ((i = strlen(mval)) > 1 && mval[i-1] ==
'+') mval[i-1] = 0;
841 if (ManList)
delete ManList;
847 if (!index(mval,
'.')
849 && !strcmp(protName,
"http://") && !strcmp(protName,
"https://")))
874 bool pType[PolNum] = {
false,
false};
877 do {
if (!(val =
Config.GetWord()))
878 {Eroute->
Emsg(
"Config",
"permit target not specified");
return 1;}
879 if (!strcmp(val,
"/")) pType[PolPath] =
true;
880 else if (!strcmp(val,
"*")) pType[PolObj ] =
true;
884 if (!pType[PolPath] && !pType[PolObj])
885 pType[PolPath] = pType[PolObj] =
true;
887 for (i = 0; i < PolNum; i++)
890 Police[i]->AddHost(val);
919 bool isClient =
false, strict =
false;
924 if (!(val =
Config.GetWord()))
925 {Eroute->
Emsg(
"Config",
"persona not specified");
return 1;}
929 if (!strcmp(val,
"client")) isClient =
true;
930 else if (!strcmp(val,
"server")) isClient =
false;
931 else {Eroute->
Emsg(
"Config",
"Invalid persona - ", val);
return 1;}
935 while ((val =
Config.GetWord()))
936 {
if (!strcmp(val,
"strict" )) strict =
true;
937 else if (!strcmp(val,
"nonstrict" )) strict =
false;
938 else if (!strcmp(val,
"verify" )) doVer = 1;
939 else if (!strcmp(val,
"noverify" )) doVer = 0;
940 else {Eroute->
Emsg(
"Config",
"Invalid persona option - ", val);
948 {
idMapAll = (strict ? true :
false);
949 if (doVer < 0) doVer = 1;
int open(const char *path, int oflag,...)
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
static int Export(const char *Var, const char *Val)
char * Get(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)
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.
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)
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