40#include <netinet/in.h>
45#include "XrdVersion.hh"
111int SetMode(
const char *path, mode_t mode) {
return chmod(path, mode);}
113std::vector<std::string> csList;
120#define TS_Xeq(x,m) if (!strcmp(x,var)) return m(Config,Eroute);
122#define TS_XPI(x,m) if (!strcmp(x,var))\
123 return !ofsConfig->Parse(XrdOfsConfigPI:: m);
125#define TS_Str(x,m) if (!strcmp(x,var)) {free(m); m = strdup(val); return 0;}
127#define TS_PList(x,m) if (!strcmp(x,var)) \
128 {m.Insert(new XrdOucPList(val,1)); return 0;}
130#define TS_Chr(x,m) if (!strcmp(x,var)) {m = val[0]; return 0;}
132#define TS_Bit(x,m,v) if (!strcmp(x,var)) {m |= v; Config.Echo(); return 0;}
134#define Max(x,y) (x > y ? x : y)
158 int cfgFD, retc, NoGo = 0;
160 XrdOucStream Config(&Eroute, getenv(
"XRDINSTANCE"), &myEnv,
"=====> ");
164 Eroute.
Say(
"++++++ File system initialization started.");
174 {Eroute.
Emsg(
"Finder",
"Network i/f undefined; unable to self-locate.");
191 Eroute.
Emsg(
"Config",
"Configuration file not specified.");
196 return Eroute.
Emsg(
"Config", errno,
"open config file",
198 Config.Attach(cfgFD);
199 static const char *cvec[] = {
"*** ofs plugin config:",0};
200 Config.Capture(cvec);
204 while((var = Config.GetMyFirstWord()))
205 {
if (!strncmp(var,
"ofs.", 4)
206 || !strcmp(var,
"all.role")
207 || !strcmp(var,
"all.subcluster"))
208 {
if (
ConfigXeq(var+4,Config,Eroute)) {Config.Echo();NoGo=1;}}
209 else if (!strcmp(var,
"oss.defaults")
210 || !strcmp(var,
"all.export"))
211 {xexp(Config, Eroute, *var ==
'a');
218 if ((retc = Config.LastError()))
219 NoGo = Eroute.
Emsg(
"Config", -retc,
"read config file",
226 if (ossRW ==
' ') ossRW =
'w';
230 mode_t uMask = 0777 & (~(
dMask[1] |
fMask[1]));
246 {
char buff[2048], *bp, *libofs = getenv(
"XRDOFSLIB");
247 if (!libofs) bp = buff;
248 else {strcpy(buff, libofs); bp = buff+strlen(buff)-1;
249 while(bp != buff && *(bp-1) !=
'/') bp--;
251 strcpy(bp,
"libXrdPss.so");
260 NoGo |= ConfigTPC(Eroute,
EnvInfo);
282 if (!ofsConfig->Load(piOpts,
EnvInfo)) NoGo = 1;
288 if (xrdEnv) xrdEnv->
Put(
"XrdCache",
"T");
294 ofsConfig->Plugin(Cks);
295 CksPfn = !ofsConfig->OssCks();
296 CksRdr = !ofsConfig->LclCks();
297 if (ofsConfig->Plugin(prepHandler))
298 {prepAuth = ofsConfig->PrepAuth();
302 {ofsConfig->Plugin(Authorization);
304 if (xrdEnv) xrdEnv->
PutPtr(
"XrdAccAuthorize*",Authorization);
326 {Eroute.
Say(
"++++++ Configuring ", myRole,
" role. . .");
327 if (ConfigRedir(Eroute,
EnvInfo))
328 {Eroute.
Emsg(
"Config",
"Unable to create cluster management client.");
336 if (ofsConfig->Plugin(FSctl_PI) && !ofsConfig->ConfigCtl(
Finder,
EnvInfo))
337 {Eroute.
Emsg(
"Config",
"Unable to configure FSctl plugin.");
347 pcEnv.
PutPtr(
"XrdOfsHandle*", dummyHandle);
348 if (!FSctl_PC->Configure(
ConfigFN, 0, &pcEnv, thePI))
349 {Eroute.
Emsg(
"Config",
"Unable to configure cache FSctl handler.");
361 {
const char *why = 0;
364 why =
"not a pure manager";
366 {Eroute.
Say(
"Config warning: forwarding turned off; ", why);
376 if (!NoGo && evsObject) NoGo = evsObject->Start(&Eroute);
397 if (OssIsProxy || getenv(
"XRDXROOTD_NOPOSC"))
398 {
if (poscAuto != -1 && !NoGo)
399 Eroute.
Say(
"Config POSC has been disabled by the osslib plugin.");
400 }
else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute);
404 if (CksRTCgi || CksRTName) NoGo |= ConfigCksRT(Eroute,
EnvInfo);
413 delete ofsConfig; ofsConfig = 0;
417 tmp = (NoGo ?
" initialization failed." :
" initialization completed.");
418 Eroute.
Say(
"------ File system ", myRole, tmp);
426#define setBuff(x,y) {strcpy(bp, x); bp += y;}
430 const char *cloc, *pval;
431 char buff[8192], fwbuff[512], *bp;
436 if (!poscQ) pval =
"off";
437 else pval = (poscAuto ?
"auto" :
"manual");
439 snprintf(buff,
sizeof(buff),
"Config effective %s ofs configuration:\n"
443 " ofs.persist %s hold %d%s%s\n"
448 pval, poscHold, (poscLog ?
" logdir " :
""),
449 (poscLog ? poscLog :
""),
OfsTrace.What);
453 if (CksRTCgi || CksRTName)
454 {snprintf(buff,
sizeof(buff),
" ofs.cksrt auto %s%s",
455 (CksRTName ? CksRTName:
"none"),(CksRTCgi ?
" chkcgi":
""));
459 ofsConfig->Display();
464 {Eroute.
Say(buff); strcat(fwbuff,
" ch");}
466 {Eroute.
Say(buff); strcat(fwbuff,
" mk");}
467 if (ConfigDispFwd(buff,
fwdMV))
468 {Eroute.
Say(buff); strcat(fwbuff,
" mv");}
469 if (ConfigDispFwd(buff,
fwdRM))
470 {Eroute.
Say(buff); strcat(fwbuff,
" rm");}
472 {Eroute.
Say(buff); strcat(fwbuff,
" rd");}
474 {Eroute.
Say(buff); strcat(fwbuff,
" tr");}
494 i=sprintf(fwbuff,
"%d %d ",evsObject->maxSmsg(),evsObject->maxLmsg());
496 cloc = evsObject->Prog();
497 if (*cloc !=
'>')
setBuff(
"|",1);
514 const char *csSpec = 0;
518 if (OssIsProxy) why =
"not applicable to proxies";
520 else if (!Cks || !(csSpec = envP->
Get(
"csList")))
521 why =
"checksums not configured";
523 {Eroute.
Say(
"Config warning: Ignoring cksrt directive ", why);
524 if (CksRTName) {free(CksRTName); CksRTName = 0;}
532 if (csList.size() == 0)
533 {Eroute.
Say(
"Config failure: Unable to determine configured cheksums!");
540 {
if (!strcmp(CksRTName,
"default"))
542 CksRTName = strdup(csList[0].c_str());
545 if (!(CksRTCalc = Cks->Object(CksRTName)))
546 {Eroute.
Say(
"Config failure: cksrt auto ", CksRTName,
547 " checksum either non-native or not configured!");
562int XrdOfs::ConfigDispFwd(
char *buff,
struct fwdOpt &Fwd)
569 if (!(cP = Fwd.Cmd))
return 0;
575 if (*Fwd.Cmd ==
'+'){
setBuff(
"2way ",5); cP++;}
576 else if (!Fwd.Port) {
setBuff(
"1way ",5);}
578 if (Fwd.Port < 0) {
setBuff(
"local ",6);}
579 else {
int n = sprintf(pbuff,
":%d ", Fwd.Port);
580 setBuff(Fwd.Host, strlen(Fwd.Host));
595 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
596 class CloseFH :
public XrdOfsHanCB
598 static XrdOfsHanCB *hCB =
static_cast<XrdOfsHanCB *
>(
new CloseFH);
600 XrdOfsPoscq::recEnt *rP, *rPP;
601 XrdOfsPoscq::Request *qP;
604 char pBuff[MAXPATHLEN], *aPath;
611 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
617 rc = strlen(aPath)-1;
618 if (aPath[rc] ==
'/') aPath[rc] =
'\0';
619 free(poscLog); poscLog = aPath;
624 {Eroute.
Emsg(
"Config", rc,
"create path for", poscLog);
630 poscQ =
new XrdOfsPoscq(&Eroute,
XrdOfsOss, poscLog,
int(poscSync));
631 rP = poscQ->Init(rc);
639 if (qP->
addT && poscHold)
641 {Eroute.
Emsg(
"Config",
"Unable to persist", qP->
User, qP->
LFN);
645 hP->
Retire(hCB, poscHold);
648 if (!(qP->
addT) || !poscHold)
650 {Eroute.
Emsg(
"Config", rc,
"unpersist", qP->
LFN); NoGo = 1;}
651 else {Eroute.
Emsg(
"Config",
"Unpersisted", qP->
User, qP->
LFN);
655 rPP = rP; rP = rP->
Next;
delete rPP;
681 ofsConfig->Plugin(CmsPI);
713 {Eroute.
Emsg(
"Config",
"Unable to determine server's port number.");
718 Balancer = (XrdCmsClient *)
new XrdCmsFinderTRG(
myLogger,
721 if (!Balancer)
return 1;
722 if (!ofsConfig->Configure(Balancer,
EnvInfo))
723 {
delete Balancer; Balancer = 0;
return 1;}
745 {
char *cpath =
Cfg.cPath;
746 if (!(
Cfg.cPath = ConfigTPCDir(Eroute,
".ofs/.tpccreds/", cpath)))
754 if (!(
Cfg.rPath = ConfigTPCDir(Eroute,
".ofs/.tpcproxy")))
return 1;
778 snprintf(rPBuff,
sizeof(rPBuff),
"%s/%x-%%d.rpx",
Cfg.rPath,
int(time(0)));
780 Cfg.rPath = strdup(rPBuff);
782 if (
Cfg.rPath) free(
Cfg.rPath);
798char *XrdOfs::ConfigTPCDir(
XrdSysError &Eroute,
const char *sfx,
802 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
803 const int BMode = S_IRWXU| S_IRGRP|S_IXGRP;
806 char pBuff[MAXPATHLEN], *aPath;
813 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
823 {Eroute.
Emsg(
"Config", rc,
"create TPC path", aPath);
830 if (SetMode(aPath, BMode))
831 {Eroute.
Emsg(
"Config", errno,
"protect TPC path", aPath);
838 XrdOucNSWalk nsWalk(&Eroute, aPath, 0, nswOpt);
839 XrdOucNSWalk::NSEnt *nsX, *nsP = nsWalk.Index(rc);
841 {Eroute.
Emsg(
"Config", rc,
"list TPC path", aPath);
852 {Eroute.
Emsg(
"Config", errno,
"remove TPC creds", nsX->
Path);
860 if (isBad) {free(aPath);
return 0;}
874 char *val, vBuff[64];
879 TS_XPI(
"authlib", theAutLib);
880 TS_XPI(
"ckslib", theCksLib);
883 TS_XPI(
"cmslib", theCmsLib);
885 TS_XPI(
"ctllib", theCtlLib);
887 TS_Xeq(
"forward", xforward);
888 TS_Xeq(
"maxdelay", xmaxd);
890 TS_Xeq(
"notifymsg", xnmsg);
891 TS_XPI(
"osslib", theOssLib);
893 TS_XPI(
"preplib", thePrpLib);
898 TS_XPI(
"xattrlib", theAtrLib);
910 strlcpy(vBuff, var,
sizeof(vBuff)); var = vBuff;
911 if (!(val = Config.GetWord()))
912 {Eroute.
Emsg(
"Config",
"value not specified for", var);
return 1;}
916 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
927 std::string csWant(cst);
932 {
for (
const auto& name : csList)
933 {
if (name == csWant)
return true;}
969 bool cgi =
false, spec =
false;
974 if (CksRTName) {free(CksRTName); CksRTName = 0;}
978 while ((val =
Config.GetWord()) && *val)
980 if (!strcmp(val,
"auto"))
981 {
if (!(val =
Config.GetWord()) || *val ==
'\0')
982 {Eroute.
Emsg(
"Config",
"cksrt auto cipher not specified.");
985 if (CksRTName) {free(CksRTName); CksRTName = 0;}
986 if (strcmp(val,
"none") && strcmp(val,
"off"))
987 CksRTName = strdup(val);
990 if (!strcmp(val,
"chkcgi")) {cgi =
true;
continue;}
992 Eroute.
Emsg(
"Config",
"Inavlid cksrt parameter -", val);
999 {Eroute.
Emsg(
"Config",
"No cksrt parameters specified!");
return 1;}
1003 if (cgi) CksRTCgi = cgi;
1025 static const long long maxRds = 1024*1024*1024;
1031 if (!(val =
Config.GetWord()) || !val[0])
1032 {Eroute.
Emsg(
"Config",
"cksrdsz size not specified");
return 1;}
1036 if (
XrdOuca2x::a2sz(Eroute,
"cksrdsz size", val, &rdsz, 1, maxRds))
return 1;
1037 ofsConfig->SetCksRdSz(
static_cast<int>(rdsz));
1083 static const mode_t dMin = 0700, dMax = 0775, fMin = 0600, fMax = 0664;
1084 static const mode_t xBit = 0111, wBit = 0002;
1086 char *colon, *val, *minM, *maxM;
1092 if (!(val =
Config.GetWord()) || !val[0])
1093 {Eroute.
Emsg(
"Config",
"crmode argument not specified");
return 1;}
1097do{
if (!strcmp(
"dirs", val)) {isDirs =
true; mtype =
"dirs mode";}
1098 else if (!strcmp(
"files", val)) {isDirs =
false; mtype =
"files mode";}
1099 else {Eroute.
Emsg(
"Config",
"invalid mode type - ", val);
1103 if (!(val =
Config.GetWord()) || !val[0])
1104 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
1106 if (!strcmp(val,
"common"))
1107 {
if (isDirs) {
dMask[0] = dMin;
dMask[1] = dMax;}
1112 if (!strcmp(val,
"legacy"))
1113 {
if (isDirs) {
dMask[0] = 0;
dMask[1] = 0775;}
1118 if ((isRaw = !strcmp(val,
"raw")))
1119 {
if (!(val =
Config.GetWord()) || !val[0])
1120 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
1123 colon = index(val,
':');
1124 if (!colon || colon == val || *(colon+1) == 0)
1125 {Eroute.
Emsg(
"Config",mtype,
"mode spec requires min and max values");
1128 minM = val; *colon = 0; maxM = colon + 1;
1131 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", minM);
1136 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", maxM);
1141 {
if (isRaw) {
dMask[0] = mMask[0];
dMask[1] = mMask[1];}
1142 else {
if ((mMask[0] | mMask[1]) & wBit)
1143 {Eroute.
Say(
"Config warning: 'other' w-mode removed from dirs mode!");
1144 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
1146 dMask[0] = (mMask[0] | dMin) & dMax;
1147 dMask[1] = (mMask[1] | dMin) & dMax;
1150 {Eroute.
Emsg(
"Config",
"dirs mode min and max values are inconsistent!");
1154 if (isRaw) {
fMask[0] = mMask[0];
fMask[1] = mMask[1];}
1155 else {
if ((mMask[0] | mMask[1]) & wBit)
1156 {Eroute.
Say(
"Config warning: 'other' w-mode removed from files mode!");
1157 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
1159 if ((mMask[0] | mMask[1]) & xBit)
1160 {Eroute.
Say(
"Config warning: x-mode removed from files mode!");
1161 mMask[0] &= ~xBit; mMask[1] &= ~xBit;
1163 fMask[0] = (mMask[0] | fMin) & fMax;
1164 fMask[1] = (mMask[1] | fMin) & fMax;
1167 {Eroute.
Emsg(
"Config",
"files mode min and max values are inconsistent!");
1171 }
while((val =
Config.GetWord()) && val[0]);
1200 if (!(val =
Config.GetWord()) || !val[0])
1201 {Eroute.
Emsg(
"Config",
"dirlist parameter not specified");
return 1;}
1205 if (!strcmp(val,
"local")) DirRdr =
false;
1206 else if (!strcmp(val,
"remote")) DirRdr =
true;
1207 else {Eroute.
Emsg(
"Config",
"Invalid dirlist parameter -", val);
return 1;}
1226 static struct rwOpts {
const char *opname;
int isRW;} rwtab[] =
1227 {{
"r/o", 0}, {
"readonly", 0},
1228 {
"forcero", 0}, {
"notwritable", 0},
1229 {
"writable", 1}, {
"r/w", 1}
1231 static bool defRW =
true;
1232 int isrw = -1, numopts =
sizeof(rwtab)/
sizeof(
struct rwOpts);
1238 if (isExport && (ossRW ==
'w' || !(val =
Config.GetWord())))
return 0;
1242 while((val =
Config.GetWord()))
1243 {
for (
int i = 0; i < numopts; i++)
1244 if (!strcmp(val, rwtab[i].opname)) isrw = rwtab[i].isRW;
1245 else if (!strcmp(val,
"cache")) {isrw = 0;
break;}
1250 if (isrw < 0) isrw = defRW;
1251 if (isExport) ossRW = (isrw ?
'w' :
'r');
1252 else {defRW = (isrw ? true :
false);
1253 if (ossRW ==
' ' && !isrw) ossRW =
'r';
1278 enum fwdType {OfsFWDALL = 0x3f, OfsFWDCHMOD = 0x01, OfsFWDMKDIR = 0x02,
1279 OfsFWDMV = 0x04, OfsFWDRM = 0x08, OfsFWDRMDIR = 0x10,
1280 OfsFWDREM = 0x18, OfsFWDTRUNC = 0x20, OfsFWDNONE = 0};
1282 static struct fwdopts {
const char *opname; fwdType opval;} fwopts[] =
1285 {
"chmod", OfsFWDCHMOD},
1286 {
"mkdir", OfsFWDMKDIR},
1289 {
"rmdir", OfsFWDRMDIR},
1290 {
"remove", OfsFWDREM},
1291 {
"trunc", OfsFWDTRUNC}
1293 int fwval = OfsFWDNONE, fwspec = OfsFWDNONE;
1294 int numopts =
sizeof(fwopts)/
sizeof(
struct fwdopts);
1295 int i, neg, rPort = 0, is2way = 0, is3way = 0;
1296 char *val, *pp, rHost[512];
1299 if (!(val =
Config.GetWord()))
1300 {Eroute.
Emsg(
"Config",
"forward option not specified");
return 1;}
1301 if ((is2way = !strcmp(
"2way", val)) || !strcmp(
"1way", val)
1302 || (is3way = !strcmp(
"3way", val)))
1303 if (!(val =
Config.GetWord()))
1304 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1307 {
if (!strcmp(
"local", val)) rPort = -1;
1310 {Eroute.
Emsg(
"Config",
"redirect host not specified");
return 1;}
1311 if (!(pp = index(val,
':')))
1312 {Eroute.
Emsg(
"Config",
"redirect port not specified");
return 1;}
1313 if ((rPort = atoi(pp+1)) <= 0)
1314 {Eroute.
Emsg(
"Config",
"redirect port is invalid");
return 1;}
1316 strlcpy(rHost, val,
sizeof(rHost));
1318 if (!(val =
Config.GetWord()))
1319 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1323 {
if (!strcmp(val,
"off")) {fwval = OfsFWDNONE; fwspec = OfsFWDALL;}
1324 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1325 for (i = 0; i < numopts; i++)
1326 {
if (!strcmp(val, fwopts[i].opname))
1327 {
if (neg) fwval &= ~fwopts[i].opval;
1328 else fwval |= fwopts[i].opval;
1329 fwspec |= fwopts[i].opval;
1334 Eroute.
Say(
"Config warning: ignoring invalid forward option '",val,
"'.");
1339 if (fwspec & OfsFWDCHMOD)
1340 {
fwdCHMOD.Cmd = (fwval&OfsFWDCHMOD ? (is2way ?
"+chmod" :
"chmod") : 0);
1344 if (fwspec&OfsFWDMKDIR)
1345 {
fwdMKDIR.Cmd = (fwval&OfsFWDMKDIR ? (is2way ?
"+mkdir" :
"mkdir") : 0);
1348 fwdMKPATH.Cmd= (fwval&OfsFWDMKDIR ? (is2way ?
"+mkpath":
"mkpath") : 0);
1352 if (fwspec&OfsFWDMV)
1353 {
fwdMV .Cmd = (fwval&OfsFWDMV ? (is2way ?
"+mv" :
"mv") : 0);
1355 fwdMV.Host = strdup(rHost);
fwdMV.Port = rPort;
1357 if (fwspec&OfsFWDRM)
1358 {
fwdRM .Cmd = (fwval&OfsFWDRM ? (is2way ?
"+rm" :
"rm") : 0);
1360 fwdRM.Host = strdup(rHost);
fwdRM.Port = rPort;
1362 if (fwspec&OfsFWDRMDIR)
1363 {
fwdRMDIR.Cmd = (fwval&OfsFWDRMDIR ? (is2way ?
"+rmdir" :
"rmdir") : 0);
1367 if (fwspec&OfsFWDTRUNC)
1368 {
fwdTRUNC.Cmd = (fwval&OfsFWDTRUNC ? (is2way ?
"+trunc" :
"trunc") : 0);
1397 if (!(val =
Config.GetWord()))
1398 {Eroute.
Emsg(
"Config",
"maxdelay value not specified");
return 1;}
1399 if (
XrdOuca2x::a2i(Eroute,
"maxdelay", val, &maxd, 30))
return 1;
1440 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1441 char *val, buff[1024];
1447 if (!(val =
Config.GetWord()))
1448 {Eroute.
Emsg(
"Config",
"notifymsg event not specified");
1454 for (i = 0; i < numopts; i++)
if (!strcmp(val, noopts[i].opname))
break;
1456 {Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1459 noval = noopts[i].opval;
1464 myEnv =
Config.SetEnv(0);
1465 if (!
Config.GetRest(buff,
sizeof(buff)))
1466 {Eroute.
Emsg(
"Config",
"notifymsg arguments too long");
1521 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1522 int i, neg, msgL = 90, msgB = 10;
1523 char *val, parms[1024];
1525 if (!(val =
Config.GetWord()))
1526 {Eroute.
Emsg(
"Config",
"notify parameters not specified");
return 1;}
1527 while (val && *val !=
'|' && *val !=
'>')
1528 {
if (!strcmp(val,
"msgs"))
1529 {
if (!(val =
Config.GetWord()))
1530 {Eroute.
Emsg(
"Config",
"notify msgs value not specified");
1533 if (
XrdOuca2x::a2i(Eroute,
"msg count", val, &msgL, 0))
return 1;
1534 if (!(val =
Config.GetWord()))
break;
1537 if (!(val =
Config.GetWord()))
break;
1540 if ((neg = (val[0] ==
'-' && val[1]))) val++;
1542 for (i = 0; i < numopts; i++)
1543 {
if (!strcmp(val, noopts[i].opname))
1550 Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1556 if (!val) {Eroute.
Emsg(
"Config",
"notify program not specified");
return 1;}
1557 if (!noval) {Eroute.
Emsg(
"Config",
"notify events not specified");
return 1;}
1562 if (!
Config.GetRest(parms,
sizeof(parms)))
1563 {Eroute.
Emsg(
"Config",
"notify parameters too long");
return 1;}
1564 val = (*parms ==
'|' ? parms+1 : parms);
1568 if (evsObject)
delete evsObject;
1569 evsObject =
new XrdOfsEvs(noval, val, msgL, msgB);
1599 int snum = -1, htime = -1, popt = -2;
1601 if (!(val =
Config.GetWord()))
1602 {Eroute.
Emsg(
"Config",
"persist option not specified");
return 1;}
1606 if (!strcmp(val,
"auto" )) popt = 1;
1607 else if (!strcmp(val,
"off" )) popt = -1;
1608 else if (!strcmp(val,
"manual" )) popt = 0;
1612 if (popt > -2) val =
Config.GetWord();
1617 {
if (!strcmp(val,
"hold"))
1618 {
if (!(val =
Config.GetWord()))
1619 {Eroute.
Emsg(
"Config",
"persist hold value not specified");
1625 else if (!strcmp(val,
"logdir"))
1626 {
if (!(val =
Config.GetWord()))
1627 {Eroute.
Emsg(
"Config",
"persist logdir path not specified");
1630 if (poscLog) free(poscLog);
1631 poscLog = strdup(val);
1633 else if (!strcmp(val,
"sync"))
1634 {
if (!(val =
Config.GetWord()))
1635 {Eroute.
Emsg(
"Config",
"sync value not specified");
1641 else Eroute.
Say(
"Config warning: ignoring invalid persist option '",val,
"'.");
1647 if (htime >= 0) poscHold = htime;
1648 if (popt > -2) poscAuto = popt;
1649 if (snum > -1) poscSync = snum;
1698 char *val, *Tok1, *Tok2;
1703 if (!(val =
Config.GetWord()) || !strcmp(val,
"if"))
1704 {Eroute.
Emsg(
"Config",
"role not specified");
return 1;}
1709 if ((val =
Config.GetWord()) && strcmp(val,
"if"))
1710 {Tok2 = strdup(val);
1716 if (val && !strcmp(
"if", val))
1719 getenv(
"XRDPROG"))) <= 0)
1720 {free(Tok1);
if (Tok2) free(Tok2);
1721 if (!rc)
Config.noEcho();
1741 default: Eroute.
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
1747 if (Tok2) free(Tok2);
1821 char *val, pgm[1024];
1827 while((val =
Config.GetWord()))
1828 {
if (!strcmp(val,
"redirect"))
1829 {
if (rdrok)
return xtpcr(Config, Eroute);
1830 Eroute.
Emsg(
"Config",
"tpc redirect must be seprately specified.");
1834 if (!strcmp(val,
"allow"))
1835 {
if (!xtpcal(Config, Eroute))
return 1;
1838 if (!strcmp(val,
"cksum"))
1839 {
if (!(val =
Config.GetWord()))
1840 {Eroute.
Emsg(
"Config",
"cksum type not specified");
return 1;}
1845 if (!strcmp(val,
"scan"))
1846 {
if (!(val =
Config.GetWord()))
1847 {Eroute.
Emsg(
"Config",
"scan type not specified");
return 1;}
1848 if (strcmp(val,
"stderr")) Parms.
errMon = -2;
1849 else if (strcmp(val,
"stdout")) Parms.
errMon = -1;
1850 else if (strcmp(val,
"all" )) Parms.
errMon = 0;
1851 else {Eroute.
Emsg(
"Config",
"invalid scan type -",val);
return 1;}
1854 if (!strcmp(val,
"echo")) {Parms.
doEcho =
true;
continue;}
1855 if (!strcmp(val,
"logok")) {Parms.
LogOK =
true;
continue;}
1856 if (!strcmp(val,
"autorm")){Parms.
autoRM =
true;
continue;}
1857 if (!strcmp(val,
"oids")) {Parms.
noids =
false;
continue;}
1858 if (!strcmp(val,
"pgm"))
1859 {
if (!
Config.GetRest(pgm,
sizeof(pgm)))
1860 {Eroute.
Emsg(
"Config",
"tpc command line too long");
return 1;}
1862 {Eroute.
Emsg(
"Config",
"tpc program not specified");
return 1;}
1864 Parms.
XfrProg = strdup( pgm );
1867 if (!strcmp(val,
"require"))
1868 {
if (!(val =
Config.GetWord()))
1869 {Eroute.
Emsg(
"Config",
"tpc require parameter not specified");
return 1;}
1873 else {Eroute.
Emsg(
"Config",
"invalid tpc require type -", val);
return 1;}
1875 if (!(val =
Config.GetWord()))
1876 {Eroute.
Emsg(
"Config",
"tpc require auth not specified");
return 1;}
1880 if (!strcmp(val,
"restrict"))
1881 {
if (!(val =
Config.GetWord()))
1882 {Eroute.
Emsg(
"Config",
"tpc restrict path not specified");
return 1;}
1884 {Eroute.
Emsg(
"Config",
"tpc restrict path not absolute");
return 1;}
1888 if (!strcmp(val,
"ttl"))
1889 {
if (!(val =
Config.GetWord()))
1890 {Eroute.
Emsg(
"Config",
"tpc ttl value not specified");
return 1;}
1893 if (!(val =
Config.GetWord()))
break;
1894 if (!(isdigit(*val))) {
Config.RetToken();
continue;}
1899 if (!strcmp(val,
"xfr"))
1900 {
if (!(val =
Config.GetWord()))
1901 {Eroute.
Emsg(
"Config",
"tpc xfr value not specified");
return 1;}
1905 if (!strcmp(val,
"streams"))
1906 {
if (!(val =
Config.GetWord()))
1907 {Eroute.
Emsg(
"Config",
"tpc streams value not specified");
return 1;}
1908 char *comma = index(val,
',');
1912 {Eroute.
Emsg(
"Config",
"tpc streams max value missing");
return 1;}
1919 if (!strcmp(val,
"fcreds"))
1922 if (!(val =
Config.GetWord()) || (*val ==
'?' && *(val+1) ==
'\0'))
1923 {Eroute.
Emsg(
"Config",
"tpc fcreds auth not specified");
return 1;}
1924 if (strlen(val) >=
sizeof(aBuff))
1925 {Eroute.
Emsg(
"Config",
"invalid fcreds auth -", val);
return 1;}
1927 if (!(val =
Config.GetWord()) || *val !=
'=' || *(val+1) == 0)
1928 {Eroute.
Emsg(
"Config",
"tpc fcreds envar not specified");
return 1;}
1930 if (
emsg) {Eroute.
Emsg(
"Config",
emsg,
"-", val);
return 1;}
1933 if (!strcmp(val,
"fcpath"))
1934 {
if (!(val =
Config.GetWord()))
1935 {Eroute.
Emsg(
"Config",
"tpc fcpath arg not specified");
return 1;}
1937 Parms.
cPath = strdup(val);
1940 Eroute.
Say(
"Config warning: ignoring invalid tpc option '",val,
"'.");
1953 struct tpcalopts {
const char *opname;
char *opval;} tpopts[] =
1954 {{
"dn", 0}, {
"group", 0}, {
"host", 0}, {
"vo", 0}};
1955 int i, spec = 0, numopts =
sizeof(tpopts)/
sizeof(
struct tpcalopts);
1958 while((val =
Config.GetWord()))
1959 {
for (i = 0; i < numopts && strcmp(tpopts[i].opname, val); i++) {}
1960 if (i > numopts) {
Config.RetToken();
break;}
1961 {Eroute.
Emsg(
"Config",
"invalid tpc allow parameter -", val);
1964 if (!(val =
Config.GetWord()))
1965 {Eroute.
Emsg(
"Config",
"tpc allow",tpopts[i].opname,
"value not specified");
1968 if (tpopts[i].opval) free(tpopts[i].opval);
1969 tpopts[i].opval = strdup(val);
1973 if (!spec) {Eroute.
Emsg(
"Config",
"tpc allow parms not specified");
return 1;}
1976 tpopts[2].opval, tpopts[3].opval);
1987 const char *cgi, *cgisep, *hBeg, *hEnd, *pBeg, *pEnd, *eText;
1993 if (!(val =
Config.GetWord()))
1994 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1998 if (!strcmp(val,
"delegated")) dlgI = 0;
1999 else if (!strcmp(val,
"undelegated")) dlgI = 1;
2004 if (dlgI >= 0 && !(val =
Config.GetWord()))
2005 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
2010 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
2015 if (*val ==
'[') n += 2;
2016 if (n >= (
int)
sizeof(hname))
2017 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
2018 strncpy(hname, val, n);
2023 if (!strcmp(hname,
"localhost"))
2026 {Eroute.
Emsg(
"Config",
"Unable to determine tpc localhost;",eText);
2029 n = snprintf(hname,
sizeof(hname),
"%s", myHost);
2031 if (n >= (
int)
sizeof(hname))
2032 {Eroute.
Emsg(
"Config",
"Invalid tpc localhost resolution -", hname);
2040 {Eroute.
Emsg(
"Config",
"tpc redirect port not specified");
return 1;}
2045 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect port;",eText);
return 1;}
2049 if (!(cgi =
Config.GetWord())) cgisep = cgi = (
char *)
"";
2050 else cgisep = (*cgi !=
'?' ?
"?" :
"");
2054 int k = (dlgI < 0 ? 0 : dlgI);
2057 n = strlen(hname) + strlen(cgisep) + strlen(cgi) + 1;
2059 snprintf(
tpcRdrHost[k], n,
"%s%s%s", hname, cgisep, cgi);
2062 }
while(dlgI < 0 && k < 2);
2086 static struct traceopts {
const char *opname;
int opval;} tropts[] =
2114 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
2117 if (!(val =
Config.GetWord()))
2118 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
2120 {
if (!strcmp(val,
"off")) trval = 0;
2121 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
2122 for (i = 0; i < numopts; i++)
2123 {
if (!strcmp(val, tropts[i].opname))
2124 {
if (neg) trval &= ~tropts[i].opval;
2125 else trval |= tropts[i].opval;
2130 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
2168 static const int xanRsv = 7;
2173 while((val =
Config.GetWord()))
2174 {
if (!strcmp(
"maxnsz", val))
2175 {
if (!(val =
Config.GetWord()))
2176 {Eroute.
Emsg(
"Config",
"xattr maxnsz value not specified");
2181 maxN =
static_cast<int>(vtmp);
2183 else if (!strcmp(
"maxvsz", val))
2184 {
if (!(val =
Config.GetWord()))
2185 {Eroute.
Emsg(
"Config",
"xattr maxvsz value not specified");
2190 maxV =
static_cast<int>(vtmp);
2192 else if (!strcmp(
"uset", val))
2193 {
if (!(val =
Config.GetWord()))
2194 {Eroute.
Emsg(
"Config",
"xattr uset value not specified");
2197 if (!strcmp(
"on", val)) isOn =
true;
2198 else if (!strcmp(
"off", val)) isOn =
false;
2199 else {Eroute.
Emsg(
"Config",
"invalid xattr uset value -", val);
2203 else {Eroute.
Emsg(
"Config",
"invalid xattr option -", val);
2208 usxMaxNsz = (isOn ? maxN-xanRsv : 0);
2217const char *XrdOfs::theRole(
int opts)
XrdCmsClient *(* XrdCmsClient_t)(XrdSysLogger *, int, int, XrdOss *)
XrdVERSIONINFO(XrdOfs, XrdOfs)
XrdSysTrace OfsTrace("ofs")
int emsg(int rc, char *msg)
static bool VCheck(XrdVersionInfo &urVersion)
static bool VCheck(XrdVersionInfo &urVersion)
static const char * Name(RoleID rid)
static const char * Type(RoleID rid)
static RoleID Convert(const char *Tok1, const char *Tok2)
static char * MyHostName(const char *eName="*unknown*", const char **eText=0)
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
static bool Parse(const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)
static void Init(XrdCks *cp, XrdOucEnv *ep)
static void setRDSZ(int sz)
static bool Parse(XrdOucStream &Config)
static XrdOfsConfigPI * New(const char *cfn, XrdOucStream *cfgP, XrdSysError *errP, XrdVersionInfo *verP=0, XrdSfsFileSystem *sfsP=0)
@ allXXXLib
All plugins (Load() only).
@ theCksLib
Checksum manager plugin.
static int Parse(XrdSysError &Eroute, Event eNum, char *mText)
The Plugins struct is used to pass plugin pointers to configure.
int Retire(int &retc, long long *retsz=0, char *buff=0, int blen=0)
int PoscSet(const char *User, int Unum, short Mode)
static int Alloc(const char *thePath, int Opts, XrdOfsHandle **Handle)
static int Restrict(const char *Path)
static const char * AddAuth(const char *auth, const char *avar)
static void Require(const char *Auth, int RType)
static void Allow(char *vDN, char *vGN, char *vHN, char *vVO)
virtual int Configure(XrdSysError &)
void Config_Display(XrdSysError &)
const char * getVersion()
virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &)
bool ValidCST(const char *cst)
void Unpersist(XrdOfsHandle *hP, int xcev=1)
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
char * Get(const char *varname)
static int Export(const char *Var, const char *Val)
void * GetPtr(const char *varname)
void PutPtr(const char *varname, void *value)
void Put(const char *varname, const char *value)
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
static char * genPath(const char *path, const char *inst, const char *psfx=0)
static const char * InstName(int TranOpt=0)
static bool mode2mask(const char *mode, mode_t &mask)
static int doIf(XrdSysError *eDest, XrdOucStream &Config, const char *what, const char *hname, const char *nname, const char *pname)
static int makePath(char *path, mode_t mode, bool reset=false)
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)
virtual void EnvInfo(XrdOucEnv *envP)
uint64_t FeatureSet
Adjust features at initialization.
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)
@ IsTarget
The role is server and will be a redirection target.
@ IsProxy
The role is proxy {plus one or more of the below}.
@ IsRedir
The role is manager and will redirect users.
@ IsMeta
The role is meta {plus one or more of the above}.
static const uint64_t hasAUTZ
Feature: Authorization.
static const uint64_t hasPRP2
Feature: Prepare Handler Version 2 (different calling conventions).
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 hasFICL
Feature: Supports file cloning and samefs.
static const uint64_t hasNAIO
Feature: Supports no async I/O.
static const uint64_t hasPRXY
Feature: Proxy Server.