36 #include <sys/param.h>
38 #include <sys/types.h>
42 #include <sys/isa_defs.h>
45 #include "XrdVersion.hh"
130 const char *,
const char *,
136 const char *configFn,
157 char *FSLib[2] = {0,0};
158 std::vector<std::string> FSLPath;
159 std::vector<std::string> RDLPath;
160 std::vector<std::string> RDLParm;
167 static const int asDebug = 0x01;
168 static const int asNoCache = 0x02;
188 const char *configFn,
189 const char *theParms);
193 char *adminp, *rdf, *bP, *tmp, buff[1024];
224 for (i = 1; i < pi->
argc; i++) xexpdo(pi->
argv[i]);
244 rdf = (parms && *parms ? parms : pi->
ConfigFN);
245 if (rdf && Config(rdf))
return 0;
257 else if (bad)
return 0;
269 eDest.
Say(
"Config warning: only '/tmp' will be exported.");
272 n += i+2; xp = xp->
Next();
278 bP = tmp = (
char *)malloc(n);
280 {strcpy(bP,
XPList.
Path(i)); bP += i, *bP++ =
' ';}
282 while(xp) {strcpy(bP, xp->
Path(i)); bP += i; *bP++ =
' '; xp = xp->
Next();}
288 if (!ConfigSecurity(xrootdEnv, pi->
ConfigFN))
return 0;
307 if (theMon) xrootdEnv.
PutPtr(
"XrdMonRoll*", theMon);
313 if (!ConfigMon(pi, xrootdEnv))
return 0;
317 if (!ConfigFS(xrootdEnv, pi->
ConfigFN))
return 0;
332 {
TRACE(
DEBUG,
"Loading dig filesystem builtin");
335 "remote debugging disabled!");
349 eDest.
Emsg(
"Config", tP->
text,
"checksum is not natively supported.");
354 if (csNum) csList +=
',';
366 if (!RDLPath.empty())
367 {
for (
int i = 0; i < (int)RDLPath.size(); i++)
368 {
const char* parm = (RDLParm[i].length() ? RDLParm[i].c_str() : 0);
369 if (!ConfigRedirPI(RDLPath[i].c_str(),xrootdEnv,pi->
ConfigFN,parm))
380 if (!(asyncFlags & asDebug) &&
as_aioOK)
400 eDest.
Say(
"Config sendfile has been disabled by ", why);
413 ProtStack.
Set(n, 60*60);
423 sprintf(buff,
"%%s://%s:%d/&L=%%d&U=%%s", pi->
myName, pi->
Port);
430 if ((rdf = getenv(
"XRDREDIRECT"))
431 && (!strcmp(rdf,
"R") || !strcmp(rdf,
"M")))
444 eDest.
Say(
"Config warning: 'redirect client' ignored; "
445 "not a redirector nor a proxy server");
452 char buff[2048], puff[1024];
456 else sprintf(puff,
"%%%s:%d",
Route[k].Host[1],
Route[k].
Port[1]);
457 sprintf(buff,
" to %s:%d%s",
Route[k].Host[0],
Route[k].
Port[0],puff);
465 const char *cgi1, *cgi2;
466 char buff[2048], puff[1024], xCgi[RD_Num] = {0};
467 if (
isRedir) {cgi1 =
"+"; cgi2 = getenv(
"XRDCMSCLUSTERID");}
468 else {cgi1 =
""; cgi2 = pi->
myName;}
469 myCNlen = snprintf(buff,
sizeof(buff),
"%s%s", cgi1, cgi2);
474 else sprintf(puff,
"%%%s:%d",
Route[k].Host[1],
Route[k].
Port[1]);
475 sprintf(buff,
" to %s:%d%s",
Route[k].Host[0],
Route[k].
Port[0],puff);
477 if (!xCgi[k] && cgi2)
480 for (i = 0; i < 2; i++)
481 {n = snprintf(buff,
sizeof(buff),
"%s?tried=%s%s",
482 Route[k].Host[i], cgi1, cgi2);
531 {
const char *penv = getenv(
"XRDXROOTD_PROXY");
532 if (!penv || *penv !=
'=')
534 eDest.
Say(
"Config warning: 'fsoverload bypass' ignored; "
535 "not a forwarding proxy.");
561 #define TS_Xeq(x,m) (!strcmp(x,var)) GoNo = m(Config)
562 #define TS_Zeq(x,m) (!strcmp(x,var)) GoNo = m(&eDest, Config)
564 int XrdXrootdProtocol::Config(
const char *ConfigFN)
569 int cfgFD, GoNo, NoGo = 0, ismine;
573 if ((cfgFD =
open(ConfigFN, O_RDONLY, 0)) < 0)
574 return eDest.
Emsg(
"Config", errno,
"open config file", ConfigFN);
575 Config.Attach(cfgFD);
579 static const char *cvec[] = {
"*** xroot protocol config:", 0 };
580 Config.Capture(cvec);
584 while((var = Config.GetMyFirstWord()))
585 {
if ((ismine = !strncmp(
"xrootd.", var, 7)) && var[7]) var += 7;
586 else if ((ismine = !strcmp(
"all.export", var))) var += 4;
587 else if ((ismine = !strcmp(
"all.seclib", var))) var += 4;
590 {
if TS_Xeq(
"async", xasync);
591 else if TS_Xeq(
"bindif", xbif);
592 else if TS_Xeq(
"chksum", xcksum);
593 else if TS_Xeq(
"diglib", xdig);
594 else if TS_Xeq(
"export", xexp);
595 else if TS_Xeq(
"fslib", xfsl);
596 else if TS_Xeq(
"fsoverload", xfso);
597 else if TS_Xeq(
"gpflib", xgpf);
598 else if TS_Xeq(
"log", xlog);
599 else if TS_Xeq(
"mongstream", xmongs);
600 else if TS_Xeq(
"monitor", xmon);
602 else if TS_Xeq(
"prep", xprep);
603 else if TS_Xeq(
"redirect", xred);
604 else if TS_Xeq(
"redirlib", xrdl);
605 else if TS_Xeq(
"seclib", xsecl);
606 else if TS_Xeq(
"tls", xtls);
607 else if TS_Xeq(
"tlsreuse", xtlsr);
608 else if TS_Xeq(
"trace", xtrace);
609 else if TS_Xeq(
"limit", xlimit);
610 else {
if (!strcmp(var,
"pidpath"))
611 {
eDest.
Say(
"Config warning: 'xrootd.pidpath' no longer "
612 "supported; use 'all.pidpath'.");
614 eDest.
Say(
"Config warning: ignoring unknown "
615 "directive '", var,
"'.");
620 if (GoNo) {Config.Echo(); NoGo = 1;}
630 {
eDest.
Say(
"Config failure: unable to setup TLS for protocol!");
633 static const char *sessID =
"xroots";
650 int XrdXrootdProtocol::CheckTLS(
const char *tlsProt)
670 {
eDest.
Say(
"Config Authentication protocol(s)", tlsProt,
671 " require TLS; login now requires TLS.");
679 {
eDest.
Say(
"Config failure: unable to honor TLS requirement; "
680 "TLS not configured!");
693 bool XrdXrootdProtocol::ConfigFS(
XrdOucEnv &xEnv,
const char *cfn)
701 {
TRACE(
DEBUG,
"Loading base filesystem library " <<FSLib[0]);
712 {
eDest.
Emsg(
"Config",
"Unable to load base file system using", fsLoc);
719 if (FSLib[1] && !ConfigFS(FSLib[1], xEnv, cfn))
return false;
723 if ((n = FSLPath.size()))
724 for (
int i = 0; i < n; i++)
725 {
if (!ConfigFS(FSLPath[i].c_str(), xEnv, cfn))
return false;}
738 bool XrdXrootdProtocol::ConfigFS(
const char *path,
XrdOucEnv &xEnv,
744 TRACE(
DEBUG,
"Loading wrapper filesystem library " <<path);
747 {
eDest.
Emsg(
"Config",
"Unable to load file system wrapper from", path);
758 bool XrdXrootdProtocol::ConfigRedirPI(
const char *path,
XrdOucEnv &xEnv,
759 const char *cfn,
const char *parms)
764 TRACE(
DEBUG,
"Loading redirect plugin library " <<path);
773 int XrdXrootdProtocol::ConfigSecurity(
XrdOucEnv &xEnv,
const char *cfn)
802 {
eDest.
Say(
"Config warning: 'xrootd.seclib' not specified;"
803 " strong authentication disabled!");
804 xEnv.
PutPtr(
"XrdSecGetProtocol*", (
void *)0);
805 xEnv.
PutPtr(
"XrdSecProtector*" , (
void *)0);
811 TRACE(
DEBUG,
"Loading security library " <<SecLib);
816 (strcmp(SecLib,
"default") ? SecLib : 0),
818 {
eDest.
Emsg(
"Config",
"Unable to load security system.");
824 xEnv.
PutPtr(
"XrdSecGetProtocol*", (
void *)secGetProt);
825 xEnv.
PutPtr(
"XrdSecProtector*" , (
void *)
DHS);
830 if (tlsProt)
return CheckTLS(tlsProt);
876 int V_force=-1, V_syncw = -1, V_off = -1, V_mstall = -1, V_nosf = -1;
877 int V_limit=-1, V_msegs=-1, V_mtot=-1, V_minsz=-1, V_segsz=-1;
878 int V_minsf=-1, V_debug=-1, V_noca=-1, V_tmo=-1;
880 struct asyncopts {
const char *opname;
int minv;
int *oploc;
881 const char *opmsg;} asopts[] =
883 {
"Debug", -1, &V_debug,
""},
884 {
"force", -1, &V_force,
""},
885 {
"off", -1, &V_off,
""},
886 {
"nocache", -1, &V_noca,
""},
887 {
"nosf", -1, &V_nosf,
""},
888 {
"syncw", -1, &V_syncw,
""},
889 {
"limit", 0, &V_limit,
"async limit"},
890 {
"segsize", 4096, &V_segsz,
"async segsize"},
891 {
"timeout", 0, &V_tmo,
"async timeout"},
892 {
"maxsegs", 0, &V_msegs,
"async maxsegs"},
893 {
"maxstalls", 0, &V_mstall,
"async maxstalls"},
894 {
"maxtot", 0, &V_mtot,
"async maxtot"},
895 {
"minsfsz", 1, &V_minsf,
"async minsfsz"},
896 {
"minsize", 4096, &V_minsz,
"async minsize"}};
897 int numopts =
sizeof(asopts)/
sizeof(
struct asyncopts);
899 if (!(val =
Config.GetWord()))
900 {
eDest.
Emsg(
"Config",
"async option not specified");
return 1;}
903 {
for (i = 0; i < numopts; i++)
904 if (!strcmp(val, asopts[i].opname))
905 {
if (asopts[i].minv >= 0 && !(val =
Config.GetWord()))
906 {
eDest.
Emsg(
"Config",
"async",(
char *)asopts[i].opname,
907 "value not specified");
910 if (asopts[i].minv > 0)
912 (
long long)asopts[i].minv))
return 1;
913 else *asopts[i].oploc = (int)llp;
914 else if (asopts[i].minv == 0)
917 else *asopts[i].oploc = ppp;
918 else *asopts[i].oploc = 1;
922 eDest.
Emsg(
"Config",
"Warning, invalid async option", val);
928 if (V_limit > 0 && V_mtot > 0 && V_limit > V_mtot)
929 {
eDest.
Emsg(
"Config",
"async limit may not be greater than maxtot");
937 if (!i) {
eDest.
Emsg(
"Config",
"async segsize is too large");
return 1;}
940 sprintf(buff,
"%d readjusted to %d", V_segsz, i);
941 eDest.
Emsg(
"Config",
"async segsize", buff);
950 if (V_tmo < 1) i = 1;
951 else if (V_tmo > 360) i = 360;
954 sprintf(buff,
"%d readjusted to %d", V_tmo, i);
955 eDest.
Emsg(
"Config",
"async timeout", buff);
969 if (V_debug > 0) asyncFlags |= asDebug;
973 if (V_noca > 0) asyncFlags |= asNoCache;
974 if (V_nosf > 0)
as_nosf =
true;
1004 char *bHost[2], *val, buff[512];
1005 int bPort[2], thePort;
1020 while((val =
Config.GetWord()) && *val)
1021 {
if (!xred_php(val, bHost, bPort,
"bindif",
true))
return 1;
1022 for (
int i = 0; i < 2 && bHost[i] != 0; i++)
1024 snprintf(buff,
sizeof(buff),
"%s%s:%d",
1025 (bSpec[i].length() ?
"," :
""), bHost[i], thePort);
1032 for (
int i = 0; i < 2 && bSpec[i].
length(); i++)
1033 {
int n = brSize + bSpec[i].
length() + 1;
1036 memset(bifRec, 0, n);
1039 strcpy(((
char *)bifRec)+brSize, bSpec[i].c_str());
1080 char *palg, prog[2048];
1081 int jmax = 4, anum[2] = {0,0};
1086 while ((palg =
Config.GetWord()) && *palg !=
'/')
1087 {
if (!strcmp(palg,
"chkcgi")) {
JobCKCGI = 1;
continue;}
1088 if (strcmp(palg,
"max"))
1091 if (algLast) algLast->next = xalg;
1092 else algFirst = xalg;
1096 if (!(palg =
Config.GetWord()))
1097 {
eDest.
Emsg(
"Config",
"chksum max not specified");
return 1;}
1104 {
eDest.
Emsg(
"Config",
"chksum algorithm not specified");
return 1;}
1117 {
int n = strlen(palg);
1118 if (n+2 >= (
int)
sizeof(prog))
1119 {
eDest.
Emsg(
"Config",
"cksum program too long");
return 1;}
1120 strcpy(prog, palg); palg = prog+n; *palg++ =
' '; n =
sizeof(prog)-n-1;
1121 if (!
Config.GetRest(palg, n))
1122 {
eDest.
Emsg(
"Config",
"cksum parameters too long");
return 1;}
1129 else {
JobLCL = 1; Proc = &CheckSum; strcpy(prog,
"chksum");}
1134 if (theProg->
Setup(prog, &
eDest, Proc))
return 1;
1157 char parms[4096], *val;
1161 if (!(val =
Config.GetWord()))
1162 {
eDest.
Emsg(
"Config",
"diglib not specified");
return 1;}
1166 if (strcmp(val,
"*"))
1167 {
eDest.
Emsg(
"Config",
"builtin diglib not specified");
return 1;}
1171 if (!
Config.GetRest(parms,
sizeof(parms)))
1172 {
eDest.
Emsg(
"Config",
"diglib parameters too long");
return 1;}
1173 if (digParm) free(digParm);
1174 digParm = strdup(parms);
1196 char *val, pbuff[1024];
1202 if (!val || !val[0])
1203 {
eDest.
Emsg(
"Config",
"export path not specified");
return 1;}
1204 strlcpy(pbuff, val,
sizeof(pbuff));
1208 while((val =
Config.GetWord()))
1212 else {
Config.RetToken();
break;}
1217 return xexpdo(pbuff, popt);
1222 int XrdXrootdProtocol::xexpdo(
char *path,
int popt)
1233 else {
eDest.
Emsg(
"Config",
"invalid export path -",path);
return 1;}
1241 if (rpCheck(path, &opaque))
1242 {
eDest.
Emsg(
"Config",
"non-absolute export path -", path);
return 1;}
1246 if (!(xopt = Squash(path)) || xopt != (popt|
XROOTDXP_OK))
1279 if (!(val =
Config.GetWord()))
1280 {
eDest.
Emsg(
"Config",
"fslib not specified");
return 1;}
1284 if (!strcmp(
"++", val))
1285 {
if (!(val =
Config.GetWord()))
1286 {
eDest.
Emsg(
"Config",
"fslib wrapper not specified");
return 1;}
1287 if (strcmp(
"throttle", val)) FSLPath.push_back((std::string)val);
1288 else FSLPath.push_back(
"libXrdThrottle.so");
1294 if (FSLib[0]) {free(FSLib[0]); FSLib[0] = 0;}
1295 if (FSLib[1]) {free(FSLib[1]); FSLib[1] = 0;}
1299 if (!strcmp(
"throttle", val))
1300 {FSLib[1] = strdup(
"libXrdThrottle.so");
1301 if (!(val =
Config.GetWord()))
1302 {
eDest.
Emsg(
"Config",
"fslib throttle target library not specified");
1305 return xfsL(Config, val, 0);
1310 if (xfsL(Config, val, 1))
return 1;
1311 if (!FSLib[1])
return 0;
1315 if (!(val =
Config.GetWord()))
1316 {FSLib[0] = FSLib[1]; FSLib[1] = 0;
1322 return xfsL(Config, val, 0);
1333 if (!strcmp(val,
"-2"))
1334 {
if (!(val =
Config.GetWord()))
1335 {
eDest.
Emsg(
"Config",
"fslib not specified");
return 1;}
1341 if (!strcmp(
"default", val))
return 0;
1346 if (!(Slash = rindex(val,
'/'))) Slash = val;
1348 if (!strcmp(Slash,
"libXrdOfs.so"))
1349 eDest.
Say(
"Config warning: 'fslib libXrdOfs.so' is actually built-in.");
1350 else FSLib[lix] = strdup(val);
1374 static const int rHLen = 264;
1375 char rHost[2][rHLen], *hP[2] = {0,0}, *val;
1376 int rPort[2], bypass = -1, stall = -1;
1380 while((val =
Config.GetWord()) && *val)
1381 {
if (!strcmp(val,
"bypass")) bypass = 1;
1382 else if (!strcmp(val,
"nobypass")) bypass = 0;
1383 else if (!strcmp(val,
"redirect"))
1385 if (!xred_php(val, hP, rPort,
"redirect"))
return 1;
1386 for (
int i = 0; i < 2; i++)
1387 {
if (!hP[i]) rHost[i][0] = 0;
1388 else {
strlcpy(rHost[i], hP[i], rHLen);
1393 else if (!strcmp(val,
"stall"))
1394 {
if (!(val =
Config.GetWord()) || !(*val))
1395 {
eDest.
Emsg(
"Config",
"stall value not specified");
1401 else {
eDest.
Emsg(
"config",
"invalid fsoverload option",val);
return 1;}
1406 if (bypass >= 0)
OD_Bypass = (bypass ? true :
false);
1409 {
if (
Route[RD_ovld].Host[0]) free(
Route[RD_ovld].Host[0]);
1410 if (
Route[RD_ovld].Host[1]) free(
Route[RD_ovld].Host[1]);
1415 {
Route[RD_ovld].
Host[1] = strdup(hP[1]);
1445 char parms[4096], *val;
1449 if (gpfLib) {free(gpfLib); gpfLib = 0;}
1450 if (gpfParm) {free(gpfParm); gpfParm = 0;}
1454 if (!(val =
Config.GetWord()))
1455 {
eDest.
Emsg(
"Config",
"gpflib not specified");
return 1;}
1459 if (strcmp(val,
"default")) gpfLib = strdup(val);
1463 if (!
Config.GetRest(parms,
sizeof(parms)))
1464 {
eDest.
Emsg(
"Config",
"gpflib parameters too long");
return 1;}
1465 gpfParm = strdup(parms);
1488 static struct logopts {
const char *opname;
int opval;} lgopts[] =
1494 int i, neg, lgval = -1, numopts =
sizeof(lgopts)/
sizeof(
struct logopts);
1496 if (!(val =
Config.GetWord()))
1497 {
eDest.
Emsg(
"config",
"log option not specified");
return 1;}
1499 {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1500 for (i = 0; i < numopts; i++)
1501 {
if (!strcmp(val, lgopts[i].opname))
1502 {
if (neg) lgval &= ~lgopts[i].opval;
1503 else lgval |= lgopts[i].opval;
1507 if (i >= numopts)
eDest.
Emsg(
"config",
"invalid log option",val);
1529 {
int rc, keep = 0, scrub=0;
1530 char *ldir=0,*val,buff[1024];
1532 if (!(val =
Config.GetWord()))
1533 {
eDest.
Emsg(
"Config",
"prep options not specified");
return 1;}
1535 do {
if (!strcmp(
"keep", val))
1536 {
if (!(val =
Config.GetWord()))
1537 {
eDest.
Emsg(
"Config",
"prep keep value not specified");
1542 else if (!strcmp(
"scrub", val))
1543 {
if (!(val =
Config.GetWord()))
1544 {
eDest.
Emsg(
"Config",
"prep scrub value not specified");
1549 else if (!strcmp(
"logdir", val))
1550 {
if (!(ldir =
Config.GetWord()))
1551 {
eDest.
Emsg(
"Config",
"prep logdir value not specified");
1555 else eDest.
Emsg(
"Config",
"Warning, invalid prep option", val);
1556 }
while((val =
Config.GetWord()));
1565 {
eDest.
Emsg(
"Config", rc,
"process logdir", ldir);
1595 if (!(val =
Config.GetWord()))
1596 {
eDest.
Emsg(
"Config",
"redirlib path not specified");
return 1;}
1600 if (!strcmp(
"++", val))
1601 {
if (!(val =
Config.GetWord()))
1602 {
eDest.
Emsg(
"Config",
"redrilib wrapper not specified");
return 1;}
1603 if (RDLPath.empty())
1604 {
eDest.
Emsg(
"Config",
"base redrilib not specified");
return 1;}
1605 if (*val ==
'+' && !(val = xrdlopt(Config, val)))
return 1;
1606 RDLPath.push_back((std::string)val);
1607 if (!
Config.GetRest(pbuff,
sizeof(pbuff)))
1608 {
eDest.
Emsg(
"Config",
"redirlib parameters too long");
return 1;}
1609 RDLParm.push_back((std::string)pbuff);
1611 }
else if (*val ==
'+' && !(val = xrdlopt(Config, val)))
return 1;
1615 if (RDLPath.empty()) RDLPath.push_back((std::string)val);
1616 else RDLPath[0] = val;
1620 if (!
Config.GetRest(pbuff,
sizeof(pbuff)))
1621 {
eDest.
Emsg(
"Config",
"redirlib parameters too long");
return 1;}
1622 if (RDLParm.empty()) RDLParm.push_back((std::string)pbuff);
1623 else RDLParm[0] = pbuff;
1640 do{
if (!strcmp(val,
"+iphold"))
1641 {
if (!(val =
Config.GetWord()))
1642 {
eDest.
Emsg(
"Config",
"+iphold value not specified");
return 0;}
1646 }
while((val =
Config.GetWord()) && *val ==
'+');
1682 static struct rediropts {
const char *opname; RD_func opval;} rdopts[] =
1684 {
"chmod", RD_chmod},
1685 {
"chksum", RD_chksum},
1686 {
"dirlist", RD_dirlist},
1687 {
"locate", RD_locate},
1688 {
"mkdir", RD_mkdir},
1690 {
"openw", RD_openw},
1691 {
"prepare", RD_prepare},
1692 {
"prepstage",RD_prepstg},
1694 {
"rmdir", RD_rmdir},
1698 static const int rHLen = 264;
1699 char rHost[2][rHLen], *hP[2], *val;
1700 int i, k, neg, numopts =
sizeof(rdopts)/
sizeof(
struct rediropts);
1701 int rPort[2], isQ = 0;
1706 if (!xred_php(val, hP, rPort,
"redirect"))
return 1;
1710 for (i = 0; i < 2; i++)
1711 {
if (!hP[i]) rHost[i][0] = 0;
1712 else {
strlcpy(rHost[i], hP[i], rHLen);
1719 if (!(val =
Config.GetWord()))
1720 {
eDest.
Emsg(
"config",
"redirect option not specified");
return 1;}
1724 if (!strcmp(
"client", val))
return xred_clnt(Config, hP, rPort);
1726 if (*val ==
'/' || (isQ = ((*val ==
'?') || !strcmp(val,
"enoent"))))
1729 if (!(val =
Config.GetWord()))
1730 {
eDest.
Emsg(
"Config",
"redirect path not specified.");
1734 {
eDest.
Emsg(
"Config",
"non-absolute redirect path -", val);
1738 for (k =
static_cast<int>(RD_open1); k < RD_Num; k++)
1739 if (xred_xok(k, hP, rPort))
break;
1741 {
eDest.
Emsg(
"Config",
"too many different path redirects");
return 1;}
1742 xred_set(RD_func(k), hP, rPort);
1745 if ((val =
Config.GetWord()) && *val !=
'/')
1746 {
eDest.
Emsg(
"Config",
"non-absolute redirect path -", val);
1754 {
if (!strcmp(val,
"all"))
1755 {
for (i = 0; i < numopts; i++)
1756 xred_set(rdopts[i].opval, hP, rPort);
1758 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1759 for (i = 0; i < numopts; i++)
1760 {
if (!strcmp(val, rdopts[i].opname))
1761 {
if (neg) xred_set(rdopts[i].opval, 0, 0);
1762 else xred_set(rdopts[i].opval, hP, rPort);
1767 eDest.
Emsg(
"config",
"invalid redirect option", val);
1796 {
eDest.
Emsg(
"Config",
"redirect client argument not specified.");
1803 else if (*val ==
'.')
1806 "Too many redirect client domains specified.");
1811 else {
eDest.
Emsg(
"Config",
"Invalid redirect client domain -", val);
1819 xred_set(RD_client, hP, rPort);
1825 bool XrdXrootdProtocol::xred_php(
char *val,
char *hP[2],
int rPort[2],
1826 const char *what,
bool optport)
1833 if (!val || !(*val))
1834 {
eDest.
Emsg(
"config", what,
"argument not specified");
return false;}
1839 if (!(pp = index(val,
'%'))) hP[1] = 0;
1840 else {hP[1] = pp+1; *pp = 0;}
1844 if (!(*val) || (hP[1] && !*hP[1]))
1845 {
eDest.
Emsg(
"Config",
"malformed", what,
"host specification");
1851 for (
int i = 0; i < 2; i++)
1852 {
if (!(val = hP[i]))
break;
1853 if (!val || !val[0] || val[0] ==
':')
1854 {
eDest.
Emsg(
"Config", what,
"host not specified");
return false;}
1855 if ((pp = rindex(val,
':')))
1860 if (optport) rPort[i] = 0;
1861 else {
eDest.
Emsg(
"Config", what,
"port not specified");
1865 const char *eText = testAddr.
Set(val, 0);
1868 eDest.
Say(
"Config warning: ", eText,
" as ", val);
1869 else {
eDest.
Say(
"Config failure: ", what,
" target ", val,
1870 " is invalid; ", eText);
1881 void XrdXrootdProtocol::xred_set(RD_func func,
char *rHost[2],
int rPort[2])
1886 if (
Route[func].Host[0]) free(
Route[func].Host[0]);
1887 if (
Route[func].Host[0] !=
Route[func].Host[1]) free(
Route[func].Host[1]);
1890 {
Route[func].
Host[0] = strdup(rHost[0]);
1907 bool XrdXrootdProtocol::xred_xok(
int func,
char *rHost[2],
int rPort[2])
1909 if (!
Route[func].Host[0])
return true;
1911 if (strcmp(
Route[func].Host[0], rHost[0])
1912 ||
Route[func].
Port[0] != rPort[0])
return false;
1916 if (strcmp(
Route[func].Host[1], rHost[1])
1917 ||
Route[func].
Port[1] != rPort[1])
return false;
1943 if (!val || !val[0])
1944 {
eDest.
Emsg(
"Config",
"seclib argument not specified");
return 1;}
1948 if (SecLib) free(SecLib);
1949 SecLib = strdup(val);
1983 static struct enforceopts {
const char *opname;
int opval;
int enval;}
1994 int i, numopts =
sizeof(enfopts)/
sizeof(
struct enforceopts);
1995 bool neg, forall =
true;
1997 if (!(val =
Config.GetWord()))
1998 {
eDest.
Emsg(
"config",
"tls parameter not specified");
return 1;}
2000 if (!strcmp(
"capable", val))
2002 if (!(val =
Config.GetWord()))
2003 {
eDest.
Emsg(
"config",
"tls requirement not specified");
return 1;}
2007 {
if (!strcmp(val,
"off") || !strcmp(val,
"none"))
2012 if ((neg = (val[0] ==
'-' && val[1]))) val++;
2013 for (i = 0; i < numopts; i++)
2014 {
if (!strcmp(val, enfopts[i].opname))
2015 {
if (neg)
myRole &= ~enfopts[i].opval;
2016 else myRole |= enfopts[i].opval;
2017 if (neg)
tlsCap &= ~enfopts[i].enval;
2018 else tlsCap |= enfopts[i].enval;
2020 {
if (neg)
tlsNot &= ~enfopts[i].enval;
2021 else tlsNot |= enfopts[i].enval;
2027 {
eDest.
Emsg(
"config",
"Invalid tls requirement -", val);
2045 return (CheckTLS(0) ? 0 : 1);
2072 if (!val || !val[0])
2073 {
eDest.
Emsg(
"Config",
"tlsreuse argument not specified");
return 1;}
2077 if (!strcmp(val,
"off"))
2084 if (!strcmp(val,
"on"))
2086 "'tlsreuse on'; TLS not configured!");
2090 if (!(val =
Config.GetWord()))
return 0;
2091 if (!strcmp(val,
"flush" ))
2092 {
if (!(val =
Config.GetWord()))
2093 {
eDest.
Emsg(
"Config",
"tlsreuse flush value not specified");
2097 if (num < 60) num = 60;
2106 eDest.
Emsg(
"config",
"Invalid tlsreuse option -", val);
2127 static struct traceopts {
const char *opname;
int opval;} tropts[] =
2144 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
2146 if (!(val =
Config.GetWord()))
2147 {
eDest.
Emsg(
"config",
"trace option not specified");
return 1;}
2149 {
if (!strcmp(val,
"off")) trval = 0;
2150 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
2151 for (i = 0; i < numopts; i++)
2152 {
if (!strcmp(val, tropts[i].opname))
2153 {
if (neg) trval &= ~tropts[i].opval;
2154 else trval |= tropts[i].opval;
2159 eDest.
Emsg(
"config",
"invalid trace option", val);
2190 while ( (word =
Config.GetWord()) ) {
2191 if (!strcmp(word,
"prepare")) {
2192 if (!(word =
Config.GetWord()))
2194 eDest.
Emsg(
"Config",
"'limit prepare' value not specified");
2198 }
else if (!strcmp(word,
"noerror")) {
XrdSfsFileSystem * XrdDigGetFS(XrdSfsFileSystem *native_fs, XrdSysLogger *lp, const char *cFN, const char *parms)
XrdSecProtocol *(* XrdSecGetProt_t)(const char *hostname, XrdNetAddrInfo &endPoint, XrdSecParameters §oken, XrdOucErrInfo *einfo)
Typedef to simplify the encoding of methods returning XrdSecProtocol.
XrdSecService * XrdSecLoadSecService(XrdSysError *eDest, const char *cfn, const char *seclib, XrdSecGetProt_t *getP, XrdSecProtector **proP)
const char * XrdXrootdInstance
XrdSysTrace XrdXrootdTrace
XrdSfsFileSystem * XrdSfsGetDefaultFileSystem(XrdSfsFileSystem *nativeFS, XrdSysLogger *Logger, const char *configFn, XrdOucEnv *EnvInfo)
XrdXrootdPrepare * XrdXrootdPrepQ
XrdXrootdRedirPI * XrdXrootdloadRedirLib(XrdSysError *, XrdXrootdRedirPI *, const char *, const char *, const char *, XrdOucEnv *)
XrdOucString * XrdXrootdCF
XrdSfsFileSystem * XrdXrootdloadFileSystem(XrdSysError *, XrdSfsFileSystem *, const char *, const char *, XrdOucEnv *)
static bool isHostName(const char *name)
const char * Set(const char *hSpec, int pNum=PortInSpec)
void Display(const char *pfx="=====> ")
static int Parse(XrdSysError *eLog, XrdOucStream &Config)
static XrdNetPMark * Config(XrdSysError *eLog, XrdScheduler *sched, XrdSysTrace *trc, bool &fatal)
static XrdNetSocket * Create(XrdSysError *Say, const char *path, const char *fn, mode_t mode, int isudp=0)
void Set(int inQMax, time_t agemax=1800)
long GetInt(const char *varname)
static int Export(const char *Var, const char *Val)
void * GetPtr(const char *varname)
char * Get(const char *varname)
void PutPtr(const char *varname, void *value)
int Setup(const char *prog, XrdSysError *errP=0, int(*Proc)(XrdOucStream *, char **, int)=0)
const char * c_str() const
static const mode_t pathMode
static char * genPath(const char *path, const char *inst, const char *psfx=0)
static int GidName(gid_t gID, char *gName, int gNsz, time_t keepT=0)
static int UidName(uid_t uID, char *uName, int uNsz, time_t keepT=0)
static int makePath(char *path, mode_t mode, bool reset=false)
static void toLower(char *str)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2p(XrdSysError &, const char *ptype, const char *val, bool anyOK=true)
virtual const char * protTLS()=0
virtual void EnvInfo(XrdOucEnv *envP)
virtual int chksum(csFunc Func, const char *csName, const char *path, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0, const char *opaque=0)
virtual int FAttr(XrdSfsFACtl *faReq, XrdOucErrInfo &eInfo, const XrdSecEntity *client=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)
void setMsgMask(int mask)
XrdSysLogger * logger(XrdSysLogger *lp=0)
void SetLogger(XrdSysLogger *logp)
XrdTlsContext * Clone(bool full=true, bool startCRLRefresh=false)
int SessionCache(int opts=scNone, const char *id=0, int idlen=0)
static const int scNone
Do not change any option settings.
static const int scOff
Turn off cache.
static const int scSrvr
Turn on cache server mode (default)
static int Init(XrdSysError *erp, XrdNetSocket *asock)
static void addJob(const char *jname, XrdXrootdJob *jp)
static void setVals(XrdSysError *erp, XrdXrootdStats *SIp, XrdScheduler *schp, int port)
static void Init(XrdXrootdFileLock *lp, XrdSysError *erP, bool sfok)
static int setParms(int stime, int skeep)
static XrdXrootdStats * SI
static const char * myInst
static XrdSfsFileSystem * digFS
static XrdNetPMark * PMark
static short as_okstutter
static XrdXrootdXPath RPList
static XrdNetSocket * AdminSock
static const char Req_TLSGPFile
static const char Req_TLSSess
static XrdXrootdJob * JobCKS
static XrdSysError & eDest
static XrdXrootdRedirPI * RedirPI
static const char * myCName
static const char Req_TLSData
static XrdXrootdFileLock * Locker
static const char Req_TLSTPC
static XrdTlsContext * tlsCtx
static XrdXrootdXPath XPList
static XrdScheduler * Sched
static struct XrdXrootdProtocol::RC_Table RouteClient
static const char * myUName
static const char Req_TLSLogin
static int Configure(char *parms, XrdProtocol_Config *pi)
static XrdOucTList * JobCKTLST
static XrdXrootdXPath RQList
static XrdSecProtector * DHS
static XrdBuffManager * BPool
static XrdSecService * CIA
static const char * myGName
static uint64_t fsFeatures
static XrdOucReqID * PrepID
static struct XrdXrootdProtocol::RD_Table Route[RD_Num]
static XrdSfsFileSystem * osFS
void setFS(XrdSfsFileSystem *fsp)
static void Init(XrdScheduler *schedP, int qMax, int qTTL)
Perform one-time initialization.
void Insert(const char *pd, int popt=0, int flags=XROOTDXP_OK)
void Set(int opts, const char *pathdata=0)
struct ServerResponseBifs_Protocol bifReqs
static const int maxRvecsz
static const uint64_t hasPGRW
Feature: pgRead and pgWrite.
static const uint64_t hasPRP2
Feature: Prepare Handler Version 2 (different calling conventions)
static const uint64_t hasGPFA
Feature: gpFile anonymous.
static const uint64_t hasCACH
Feature: Implements a data cache.
static const uint64_t hasNOSF
Feature: Supports no sendfile.
static const uint64_t hasPOSC
Feature: Persist On Successful Close.
static const uint64_t hasGPF
Feature: gpFile.
static const uint64_t hasNAIO
Feature: Supports no async I/O.
static const uint64_t hasPRXY
Feature: Proxy Server.