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 " :
""),
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 checksums!");
539 if (CksRTName || CksRTCgi)
540 {
if (csList.size() == 0)
541 {Eroute.
Say(
"Config failure: cksrt directive conflict; "
542 "checksums not configured!");
546 const char* rtDflt = csList[0].c_str();
548 if (!(CksRTCalc = Cks->Object(rtDflt)))
549 {Eroute.
Say(
"Config failure: cksrt default checksum ", rtDflt,
550 " configuration failed!");
556 CksRTName = strdup(rtDflt);
570int XrdOfs::ConfigDispFwd(
char *buff,
struct fwdOpt &Fwd)
577 if (!(cP = Fwd.Cmd))
return 0;
583 if (*Fwd.Cmd ==
'+'){
setBuff(
"2way ",5); cP++;}
584 else if (!Fwd.Port) {
setBuff(
"1way ",5);}
586 if (Fwd.Port < 0) {
setBuff(
"local ",6);}
587 else {
int n = sprintf(pbuff,
":%d ", Fwd.Port);
588 setBuff(Fwd.Host, strlen(Fwd.Host));
603 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
604 class CloseFH :
public XrdOfsHanCB
606 static XrdOfsHanCB *hCB =
static_cast<XrdOfsHanCB *
>(
new CloseFH);
608 XrdOfsPoscq::recEnt *rP, *rPP;
609 XrdOfsPoscq::Request *qP;
612 char pBuff[MAXPATHLEN], *aPath;
619 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
625 rc = strlen(aPath)-1;
626 if (aPath[rc] ==
'/') aPath[rc] =
'\0';
627 free(poscLog); poscLog = aPath;
632 {Eroute.
Emsg(
"Config", rc,
"create path for", poscLog);
639 rP = poscQ->Init(rc);
647 if (qP->
addT && poscHold)
649 {Eroute.
Emsg(
"Config",
"Unable to persist", qP->
User, qP->
LFN);
653 hP->
Retire(hCB, poscHold);
656 if (!(qP->
addT) || !poscHold)
658 {Eroute.
Emsg(
"Config", rc,
"unpersist", qP->
LFN); NoGo = 1;}
659 else {Eroute.
Emsg(
"Config",
"Unpersisted", qP->
User, qP->
LFN);
663 rPP = rP; rP = rP->
Next;
delete rPP;
689 ofsConfig->Plugin(CmsPI);
721 {Eroute.
Emsg(
"Config",
"Unable to determine server's port number.");
729 if (!Balancer)
return 1;
730 if (!ofsConfig->Configure(Balancer,
EnvInfo))
731 {
delete Balancer; Balancer = 0;
return 1;}
753 {
char *cpath =
Cfg.cPath;
754 if (!(
Cfg.cPath = ConfigTPCDir(Eroute,
".ofs/.tpccreds/", cpath)))
762 if (!(
Cfg.rPath = ConfigTPCDir(Eroute,
".ofs/.tpcproxy")))
return 1;
786 snprintf(rPBuff,
sizeof(rPBuff),
"%s/%x-%%d.rpx",
Cfg.rPath,
int(time(0)));
788 Cfg.rPath = strdup(rPBuff);
790 if (
Cfg.rPath) free(
Cfg.rPath);
806char *XrdOfs::ConfigTPCDir(
XrdSysError &Eroute,
const char *sfx,
810 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
811 const int BMode = S_IRWXU| S_IRGRP|S_IXGRP;
814 char pBuff[MAXPATHLEN], *aPath;
821 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
831 {Eroute.
Emsg(
"Config", rc,
"create TPC path", aPath);
838 if (SetMode(aPath, BMode))
839 {Eroute.
Emsg(
"Config", errno,
"protect TPC path", aPath);
846 XrdOucNSWalk nsWalk(&Eroute, aPath, 0, nswOpt);
847 XrdOucNSWalk::NSEnt *nsX, *nsP = nsWalk.Index(rc);
849 {Eroute.
Emsg(
"Config", rc,
"list TPC path", aPath);
860 {Eroute.
Emsg(
"Config", errno,
"remove TPC creds", nsX->
Path);
868 if (isBad) {free(aPath);
return 0;}
882 char *val, vBuff[64];
887 TS_XPI(
"authlib", theAutLib);
888 TS_XPI(
"ckslib", theCksLib);
891 TS_XPI(
"cmslib", theCmsLib);
893 TS_XPI(
"ctllib", theCtlLib);
895 TS_Xeq(
"forward", xforward);
896 TS_Xeq(
"maxdelay", xmaxd);
898 TS_Xeq(
"notifymsg", xnmsg);
899 TS_XPI(
"osslib", theOssLib);
901 TS_XPI(
"preplib", thePrpLib);
906 TS_XPI(
"xattrlib", theAtrLib);
918 strlcpy(vBuff, var,
sizeof(vBuff)); var = vBuff;
919 if (!(val = Config.GetWord()))
920 {Eroute.
Emsg(
"Config",
"value not specified for", var);
return 1;}
924 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
935 std::string csWant(cst);
940 {
for (
const auto& name : csList)
941 {
if (name == csWant)
return true;}
977 bool cgi =
false, spec =
false;
982 if (CksRTName) {free(CksRTName); CksRTName = 0;}
986 while ((val =
Config.GetWord()) && *val)
988 if (!strcmp(val,
"auto"))
989 {
if (!(val =
Config.GetWord()) || *val ==
'\0')
990 {Eroute.
Emsg(
"Config",
"cksrt auto cipher not specified.");
993 if (CksRTName) {free(CksRTName); CksRTName = 0;}
994 if (strcmp(val,
"none") && strcmp(val,
"off"))
995 {
if (strcmp(val,
"on") && strcmp(val,
"default"))
996 {Eroute.
Emsg(
"Config",
"Invalid cksrt auto argument -",val);
999 CksRTName = strdup(val);
1003 if (!strcmp(val,
"chkcgi")) {cgi =
true;
continue;}
1005 Eroute.
Emsg(
"Config",
"Inavlid cksrt parameter -", val);
1012 {Eroute.
Emsg(
"Config",
"No cksrt parameters specified!");
return 1;}
1016 if (cgi) CksRTCgi = cgi;
1038 static const long long maxRds = 1024*1024*1024;
1044 if (!(val =
Config.GetWord()) || !val[0])
1045 {Eroute.
Emsg(
"Config",
"cksrdsz size not specified");
return 1;}
1049 if (
XrdOuca2x::a2sz(Eroute,
"cksrdsz size", val, &rdsz, 1, maxRds))
return 1;
1050 ofsConfig->SetCksRdSz(
static_cast<int>(rdsz));
1096 static const mode_t dMin = 0700, dMax = 0775, fMin = 0600, fMax = 0664;
1097 static const mode_t xBit = 0111, wBit = 0002;
1099 char *colon, *val, *minM, *maxM;
1105 if (!(val =
Config.GetWord()) || !val[0])
1106 {Eroute.
Emsg(
"Config",
"crmode argument not specified");
return 1;}
1110do{
if (!strcmp(
"dirs", val)) {isDirs =
true; mtype =
"dirs mode";}
1111 else if (!strcmp(
"files", val)) {isDirs =
false; mtype =
"files mode";}
1112 else {Eroute.
Emsg(
"Config",
"invalid mode type - ", val);
1116 if (!(val =
Config.GetWord()) || !val[0])
1117 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
1119 if (!strcmp(val,
"common"))
1120 {
if (isDirs) {
dMask[0] = dMin;
dMask[1] = dMax;}
1125 if (!strcmp(val,
"legacy"))
1126 {
if (isDirs) {
dMask[0] = 0;
dMask[1] = 0775;}
1131 if ((isRaw = !strcmp(val,
"raw")))
1132 {
if (!(val =
Config.GetWord()) || !val[0])
1133 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
1136 colon = index(val,
':');
1137 if (!colon || colon == val || *(colon+1) == 0)
1138 {Eroute.
Emsg(
"Config",mtype,
"mode spec requires min and max values");
1141 minM = val; *colon = 0; maxM = colon + 1;
1144 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", minM);
1149 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", maxM);
1154 {
if (isRaw) {
dMask[0] = mMask[0];
dMask[1] = mMask[1];}
1155 else {
if ((mMask[0] | mMask[1]) & wBit)
1156 {Eroute.
Say(
"Config warning: 'other' w-mode removed from dirs mode!");
1157 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
1159 dMask[0] = (mMask[0] | dMin) & dMax;
1160 dMask[1] = (mMask[1] | dMin) & dMax;
1163 {Eroute.
Emsg(
"Config",
"dirs mode min and max values are inconsistent!");
1167 if (isRaw) {
fMask[0] = mMask[0];
fMask[1] = mMask[1];}
1168 else {
if ((mMask[0] | mMask[1]) & wBit)
1169 {Eroute.
Say(
"Config warning: 'other' w-mode removed from files mode!");
1170 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
1172 if ((mMask[0] | mMask[1]) & xBit)
1173 {Eroute.
Say(
"Config warning: x-mode removed from files mode!");
1174 mMask[0] &= ~xBit; mMask[1] &= ~xBit;
1176 fMask[0] = (mMask[0] | fMin) & fMax;
1177 fMask[1] = (mMask[1] | fMin) & fMax;
1180 {Eroute.
Emsg(
"Config",
"files mode min and max values are inconsistent!");
1184 }
while((val =
Config.GetWord()) && val[0]);
1213 if (!(val =
Config.GetWord()) || !val[0])
1214 {Eroute.
Emsg(
"Config",
"dirlist parameter not specified");
return 1;}
1218 if (!strcmp(val,
"local")) DirRdr =
false;
1219 else if (!strcmp(val,
"remote")) DirRdr =
true;
1220 else {Eroute.
Emsg(
"Config",
"Invalid dirlist parameter -", val);
return 1;}
1239 static struct rwOpts {
const char *opname;
int isRW;} rwtab[] =
1240 {{
"r/o", 0}, {
"readonly", 0},
1241 {
"forcero", 0}, {
"notwritable", 0},
1242 {
"writable", 1}, {
"r/w", 1}
1244 static bool defRW =
true;
1245 int isrw = -1, numopts =
sizeof(rwtab)/
sizeof(
struct rwOpts);
1251 if (isExport && (ossRW ==
'w' || !(val =
Config.GetWord())))
return 0;
1255 while((val =
Config.GetWord()))
1256 {
for (
int i = 0; i < numopts; i++)
1257 if (!strcmp(val, rwtab[i].opname)) isrw = rwtab[i].isRW;
1258 else if (!strcmp(val,
"cache")) {isrw = 0;
break;}
1263 if (isrw < 0) isrw = defRW;
1264 if (isExport) ossRW = (isrw ?
'w' :
'r');
1265 else {defRW = (isrw ? true :
false);
1266 if (ossRW ==
' ' && !isrw) ossRW =
'r';
1291 enum fwdType {OfsFWDALL = 0x3f, OfsFWDCHMOD = 0x01, OfsFWDMKDIR = 0x02,
1292 OfsFWDMV = 0x04, OfsFWDRM = 0x08, OfsFWDRMDIR = 0x10,
1293 OfsFWDREM = 0x18, OfsFWDTRUNC = 0x20, OfsFWDNONE = 0};
1295 static struct fwdopts {
const char *opname; fwdType opval;} fwopts[] =
1298 {
"chmod", OfsFWDCHMOD},
1299 {
"mkdir", OfsFWDMKDIR},
1302 {
"rmdir", OfsFWDRMDIR},
1303 {
"remove", OfsFWDREM},
1304 {
"trunc", OfsFWDTRUNC}
1306 int fwval = OfsFWDNONE, fwspec = OfsFWDNONE;
1307 int numopts =
sizeof(fwopts)/
sizeof(
struct fwdopts);
1308 int i, neg, rPort = 0, is2way = 0, is3way = 0;
1309 char *val, *pp, rHost[512];
1312 if (!(val =
Config.GetWord()))
1313 {Eroute.
Emsg(
"Config",
"forward option not specified");
return 1;}
1314 if ((is2way = !strcmp(
"2way", val)) || !strcmp(
"1way", val)
1315 || (is3way = !strcmp(
"3way", val)))
1316 if (!(val =
Config.GetWord()))
1317 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1320 {
if (!strcmp(
"local", val)) rPort = -1;
1323 {Eroute.
Emsg(
"Config",
"redirect host not specified");
return 1;}
1324 if (!(pp = index(val,
':')))
1325 {Eroute.
Emsg(
"Config",
"redirect port not specified");
return 1;}
1326 if ((rPort = atoi(pp+1)) <= 0)
1327 {Eroute.
Emsg(
"Config",
"redirect port is invalid");
return 1;}
1329 strlcpy(rHost, val,
sizeof(rHost));
1331 if (!(val =
Config.GetWord()))
1332 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1336 {
if (!strcmp(val,
"off")) {fwval = OfsFWDNONE; fwspec = OfsFWDALL;}
1337 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1338 for (i = 0; i < numopts; i++)
1339 {
if (!strcmp(val, fwopts[i].opname))
1340 {
if (neg) fwval &= ~fwopts[i].opval;
1341 else fwval |= fwopts[i].opval;
1342 fwspec |= fwopts[i].opval;
1347 Eroute.
Say(
"Config warning: ignoring invalid forward option '",val,
"'.");
1352 if (fwspec & OfsFWDCHMOD)
1353 {
fwdCHMOD.
Cmd = (fwval&OfsFWDCHMOD ? (is2way ?
"+chmod" :
"chmod") : 0);
1357 if (fwspec&OfsFWDMKDIR)
1358 {
fwdMKDIR.
Cmd = (fwval&OfsFWDMKDIR ? (is2way ?
"+mkdir" :
"mkdir") : 0);
1361 fwdMKPATH.
Cmd= (fwval&OfsFWDMKDIR ? (is2way ?
"+mkpath":
"mkpath") : 0);
1365 if (fwspec&OfsFWDMV)
1366 {
fwdMV .
Cmd = (fwval&OfsFWDMV ? (is2way ?
"+mv" :
"mv") : 0);
1370 if (fwspec&OfsFWDRM)
1371 {
fwdRM .
Cmd = (fwval&OfsFWDRM ? (is2way ?
"+rm" :
"rm") : 0);
1375 if (fwspec&OfsFWDRMDIR)
1376 {
fwdRMDIR.
Cmd = (fwval&OfsFWDRMDIR ? (is2way ?
"+rmdir" :
"rmdir") : 0);
1380 if (fwspec&OfsFWDTRUNC)
1381 {
fwdTRUNC.
Cmd = (fwval&OfsFWDTRUNC ? (is2way ?
"+trunc" :
"trunc") : 0);
1410 if (!(val =
Config.GetWord()))
1411 {Eroute.
Emsg(
"Config",
"maxdelay value not specified");
return 1;}
1412 if (
XrdOuca2x::a2i(Eroute,
"maxdelay", val, &maxd, 30))
return 1;
1453 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1454 char *val, buff[1024];
1460 if (!(val =
Config.GetWord()))
1461 {Eroute.
Emsg(
"Config",
"notifymsg event not specified");
1467 for (i = 0; i < numopts; i++)
if (!strcmp(val, noopts[i].opname))
break;
1469 {Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1472 noval = noopts[i].opval;
1477 myEnv =
Config.SetEnv(0);
1478 if (!
Config.GetRest(buff,
sizeof(buff)))
1479 {Eroute.
Emsg(
"Config",
"notifymsg arguments too long");
1534 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1535 int i, neg, msgL = 90, msgB = 10;
1536 char *val, parms[1024];
1538 if (!(val =
Config.GetWord()))
1539 {Eroute.
Emsg(
"Config",
"notify parameters not specified");
return 1;}
1540 while (val && *val !=
'|' && *val !=
'>')
1541 {
if (!strcmp(val,
"msgs"))
1542 {
if (!(val =
Config.GetWord()))
1543 {Eroute.
Emsg(
"Config",
"notify msgs value not specified");
1546 if (
XrdOuca2x::a2i(Eroute,
"msg count", val, &msgL, 0))
return 1;
1547 if (!(val =
Config.GetWord()))
break;
1550 if (!(val =
Config.GetWord()))
break;
1553 if ((neg = (val[0] ==
'-' && val[1]))) val++;
1555 for (i = 0; i < numopts; i++)
1556 {
if (!strcmp(val, noopts[i].opname))
1563 Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1569 if (!val) {Eroute.
Emsg(
"Config",
"notify program not specified");
return 1;}
1570 if (!noval) {Eroute.
Emsg(
"Config",
"notify events not specified");
return 1;}
1575 if (!
Config.GetRest(parms,
sizeof(parms)))
1576 {Eroute.
Emsg(
"Config",
"notify parameters too long");
return 1;}
1577 val = (*parms ==
'|' ? parms+1 : parms);
1581 if (evsObject)
delete evsObject;
1582 evsObject =
new XrdOfsEvs(noval, val, msgL, msgB);
1612 int snum = -1, htime = -1, popt = -2;
1614 if (!(val =
Config.GetWord()))
1615 {Eroute.
Emsg(
"Config",
"persist option not specified");
return 1;}
1619 if (!strcmp(val,
"auto" )) popt = 1;
1620 else if (!strcmp(val,
"off" )) popt = -1;
1621 else if (!strcmp(val,
"manual" )) popt = 0;
1625 if (popt > -2) val =
Config.GetWord();
1630 {
if (!strcmp(val,
"hold"))
1631 {
if (!(val =
Config.GetWord()))
1632 {Eroute.
Emsg(
"Config",
"persist hold value not specified");
1638 else if (!strcmp(val,
"logdir"))
1639 {
if (!(val =
Config.GetWord()))
1640 {Eroute.
Emsg(
"Config",
"persist logdir path not specified");
1643 if (poscLog) free(poscLog);
1644 poscLog = strdup(val);
1646 else if (!strcmp(val,
"sync"))
1647 {
if (!(val =
Config.GetWord()))
1648 {Eroute.
Emsg(
"Config",
"sync value not specified");
1654 else Eroute.
Say(
"Config warning: ignoring invalid persist option '",val,
"'.");
1660 if (htime >= 0) poscHold = htime;
1661 if (popt > -2) poscAuto = popt;
1662 if (snum > -1) poscSync = snum;
1711 char *val, *Tok1, *Tok2;
1716 if (!(val =
Config.GetWord()) || !strcmp(val,
"if"))
1717 {Eroute.
Emsg(
"Config",
"role not specified");
return 1;}
1722 if ((val =
Config.GetWord()) && strcmp(val,
"if"))
1723 {Tok2 = strdup(val);
1729 if (val && !strcmp(
"if", val))
1732 getenv(
"XRDPROG"))) <= 0)
1733 {free(Tok1);
if (Tok2) free(Tok2);
1734 if (!rc)
Config.noEcho();
1754 default: Eroute.
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
1760 if (Tok2) free(Tok2);
1834 char *val, pgm[1024];
1840 while((val =
Config.GetWord()))
1841 {
if (!strcmp(val,
"redirect"))
1842 {
if (rdrok)
return xtpcr(Config, Eroute);
1843 Eroute.
Emsg(
"Config",
"tpc redirect must be seprately specified.");
1847 if (!strcmp(val,
"allow"))
1848 {
if (!xtpcal(Config, Eroute))
return 1;
1851 if (!strcmp(val,
"cksum"))
1852 {
if (!(val =
Config.GetWord()))
1853 {Eroute.
Emsg(
"Config",
"cksum type not specified");
return 1;}
1858 if (!strcmp(val,
"scan"))
1859 {
if (!(val =
Config.GetWord()))
1860 {Eroute.
Emsg(
"Config",
"scan type not specified");
return 1;}
1861 if (strcmp(val,
"stderr")) Parms.
errMon = -2;
1862 else if (strcmp(val,
"stdout")) Parms.
errMon = -1;
1863 else if (strcmp(val,
"all" )) Parms.
errMon = 0;
1864 else {Eroute.
Emsg(
"Config",
"invalid scan type -",val);
return 1;}
1867 if (!strcmp(val,
"echo")) {Parms.
doEcho =
true;
continue;}
1868 if (!strcmp(val,
"logok")) {Parms.
LogOK =
true;
continue;}
1869 if (!strcmp(val,
"autorm")){Parms.
autoRM =
true;
continue;}
1870 if (!strcmp(val,
"oids")) {Parms.
noids =
false;
continue;}
1871 if (!strcmp(val,
"pgm"))
1872 {
if (!
Config.GetRest(pgm,
sizeof(pgm)))
1873 {Eroute.
Emsg(
"Config",
"tpc command line too long");
return 1;}
1875 {Eroute.
Emsg(
"Config",
"tpc program not specified");
return 1;}
1877 Parms.
XfrProg = strdup( pgm );
1880 if (!strcmp(val,
"require"))
1881 {
if (!(val =
Config.GetWord()))
1882 {Eroute.
Emsg(
"Config",
"tpc require parameter not specified");
return 1;}
1886 else {Eroute.
Emsg(
"Config",
"invalid tpc require type -", val);
return 1;}
1888 if (!(val =
Config.GetWord()))
1889 {Eroute.
Emsg(
"Config",
"tpc require auth not specified");
return 1;}
1893 if (!strcmp(val,
"restrict"))
1894 {
if (!(val =
Config.GetWord()))
1895 {Eroute.
Emsg(
"Config",
"tpc restrict path not specified");
return 1;}
1897 {Eroute.
Emsg(
"Config",
"tpc restrict path not absolute");
return 1;}
1901 if (!strcmp(val,
"ttl"))
1902 {
if (!(val =
Config.GetWord()))
1903 {Eroute.
Emsg(
"Config",
"tpc ttl value not specified");
return 1;}
1906 if (!(val =
Config.GetWord()))
break;
1907 if (!(isdigit(*val))) {
Config.RetToken();
continue;}
1912 if (!strcmp(val,
"xfr"))
1913 {
if (!(val =
Config.GetWord()))
1914 {Eroute.
Emsg(
"Config",
"tpc xfr value not specified");
return 1;}
1918 if (!strcmp(val,
"streams"))
1919 {
if (!(val =
Config.GetWord()))
1920 {Eroute.
Emsg(
"Config",
"tpc streams value not specified");
return 1;}
1921 char *comma = index(val,
',');
1925 {Eroute.
Emsg(
"Config",
"tpc streams max value missing");
return 1;}
1932 if (!strcmp(val,
"fcreds"))
1935 if (!(val =
Config.GetWord()) || (*val ==
'?' && *(val+1) ==
'\0'))
1936 {Eroute.
Emsg(
"Config",
"tpc fcreds auth not specified");
return 1;}
1937 if (strlen(val) >=
sizeof(aBuff))
1938 {Eroute.
Emsg(
"Config",
"invalid fcreds auth -", val);
return 1;}
1940 if (!(val =
Config.GetWord()) || *val !=
'=' || *(val+1) == 0)
1941 {Eroute.
Emsg(
"Config",
"tpc fcreds envar not specified");
return 1;}
1943 if (
emsg) {Eroute.
Emsg(
"Config",
emsg,
"-", val);
return 1;}
1946 if (!strcmp(val,
"fcpath"))
1947 {
if (!(val =
Config.GetWord()))
1948 {Eroute.
Emsg(
"Config",
"tpc fcpath arg not specified");
return 1;}
1950 Parms.
cPath = strdup(val);
1953 Eroute.
Say(
"Config warning: ignoring invalid tpc option '",val,
"'.");
1966 struct tpcalopts {
const char *opname;
char *opval;} tpopts[] =
1967 {{
"dn", 0}, {
"group", 0}, {
"host", 0}, {
"vo", 0}};
1968 int i, spec = 0, numopts =
sizeof(tpopts)/
sizeof(
struct tpcalopts);
1971 while((val =
Config.GetWord()))
1972 {
for (i = 0; i < numopts && strcmp(tpopts[i].opname, val); i++) {}
1973 if (i > numopts) {
Config.RetToken();
break;}
1974 {Eroute.
Emsg(
"Config",
"invalid tpc allow parameter -", val);
1977 if (!(val =
Config.GetWord()))
1978 {Eroute.
Emsg(
"Config",
"tpc allow",tpopts[i].opname,
"value not specified");
1981 if (tpopts[i].opval) free(tpopts[i].opval);
1982 tpopts[i].opval = strdup(val);
1986 if (!spec) {Eroute.
Emsg(
"Config",
"tpc allow parms not specified");
return 1;}
1989 tpopts[2].opval, tpopts[3].opval);
2000 const char *cgi, *cgisep, *hBeg, *hEnd, *pBeg, *pEnd, *eText;
2006 if (!(val =
Config.GetWord()))
2007 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
2011 if (!strcmp(val,
"delegated")) dlgI = 0;
2012 else if (!strcmp(val,
"undelegated")) dlgI = 1;
2017 if (dlgI >= 0 && !(val =
Config.GetWord()))
2018 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
2023 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
2028 if (*val ==
'[') n += 2;
2029 if (n >= (
int)
sizeof(hname))
2030 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
2031 strncpy(hname, val, n);
2036 if (!strcmp(hname,
"localhost"))
2039 {Eroute.
Emsg(
"Config",
"Unable to determine tpc localhost;",eText);
2042 n = snprintf(hname,
sizeof(hname),
"%s", myHost);
2044 if (n >= (
int)
sizeof(hname))
2045 {Eroute.
Emsg(
"Config",
"Invalid tpc localhost resolution -", hname);
2053 {Eroute.
Emsg(
"Config",
"tpc redirect port not specified");
return 1;}
2058 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect port;",eText);
return 1;}
2062 if (!(cgi =
Config.GetWord())) cgisep = cgi = (
char *)
"";
2063 else cgisep = (*cgi !=
'?' ?
"?" :
"");
2067 int k = (dlgI < 0 ? 0 : dlgI);
2070 n = strlen(hname) + strlen(cgisep) + strlen(cgi) + 1;
2072 snprintf(
tpcRdrHost[k], n,
"%s%s%s", hname, cgisep, cgi);
2075 }
while(dlgI < 0 && k < 2);
2099 static struct traceopts {
const char *opname;
int opval;} tropts[] =
2127 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
2130 if (!(val =
Config.GetWord()))
2131 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
2133 {
if (!strcmp(val,
"off")) trval = 0;
2134 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
2135 for (i = 0; i < numopts; i++)
2136 {
if (!strcmp(val, tropts[i].opname))
2137 {
if (neg) trval &= ~tropts[i].opval;
2138 else trval |= tropts[i].opval;
2143 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
2181 static const int xanRsv = 7;
2186 while((val =
Config.GetWord()))
2187 {
if (!strcmp(
"maxnsz", val))
2188 {
if (!(val =
Config.GetWord()))
2189 {Eroute.
Emsg(
"Config",
"xattr maxnsz value not specified");
2194 maxN =
static_cast<int>(vtmp);
2196 else if (!strcmp(
"maxvsz", val))
2197 {
if (!(val =
Config.GetWord()))
2198 {Eroute.
Emsg(
"Config",
"xattr maxvsz value not specified");
2203 maxV =
static_cast<int>(vtmp);
2205 else if (!strcmp(
"uset", val))
2206 {
if (!(val =
Config.GetWord()))
2207 {Eroute.
Emsg(
"Config",
"xattr uset value not specified");
2210 if (!strcmp(
"on", val)) isOn =
true;
2211 else if (!strcmp(
"off", val)) isOn =
false;
2212 else {Eroute.
Emsg(
"Config",
"invalid xattr uset value -", val);
2216 else {Eroute.
Emsg(
"Config",
"invalid xattr option -", val);
2221 usxMaxNsz = (isOn ? maxN-xanRsv : 0);
2230const char *XrdOfs::theRole(
int opts)
XrdVERSIONINFO(XrdClGetPlugIn, XrdClGetPlugIn) extern "C"
XrdCmsClient *(*) XrdCmsClient_t(XrdSysLogger *, int, int, XrdOss *)
XrdSysTrace OfsTrace("ofs")
int emsg(int rc, char *msg)
virtual XrdOucTList * Managers()
XrdCmsFinderRMT(XrdSysLogger *lp, int whoami=0, int Port=0)
static bool VCheck(XrdVersionInfo &urVersion)
XrdCmsFinderTRG(XrdSysLogger *, int, int, XrdOss *theSS=0)
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.
int Init(XrdSysError *eObj)
static int Parse(XrdSysError &Eroute, Event eNum, char *mText)
XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10)
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)
XrdOfsPoscq(XrdSysError *erp, XrdOss *oss, const char *fn, int sv=1)
void setRole(const char *theRole)
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 uint64_t Features()
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 hasPOSC
Feature: Persist On Successful Close.