39#include <netinet/in.h>
43#include "XrdVersion.hh"
107int SetMode(
const char *path, mode_t mode) {
return chmod(path, mode);}
114#define TS_Xeq(x,m) if (!strcmp(x,var)) return m(Config,Eroute);
116#define TS_XPI(x,m) if (!strcmp(x,var))\
117 return !ofsConfig->Parse(XrdOfsConfigPI:: m);
119#define TS_Str(x,m) if (!strcmp(x,var)) {free(m); m = strdup(val); return 0;}
121#define TS_PList(x,m) if (!strcmp(x,var)) \
122 {m.Insert(new XrdOucPList(val,1)); return 0;}
124#define TS_Chr(x,m) if (!strcmp(x,var)) {m = val[0]; return 0;}
126#define TS_Bit(x,m,v) if (!strcmp(x,var)) {m |= v; Config.Echo(); return 0;}
128#define Max(x,y) (x > y ? x : y)
152 int cfgFD, retc, NoGo = 0;
154 XrdOucStream Config(&Eroute, getenv(
"XRDINSTANCE"), &myEnv,
"=====> ");
158 Eroute.
Say(
"++++++ File system initialization started.");
168 {Eroute.
Emsg(
"Finder",
"Network i/f undefined; unable to self-locate.");
185 Eroute.
Emsg(
"Config",
"Configuration file not specified.");
190 return Eroute.
Emsg(
"Config", errno,
"open config file",
192 Config.Attach(cfgFD);
193 static const char *cvec[] = {
"*** ofs plugin config:",0};
194 Config.Capture(cvec);
198 while((var = Config.GetMyFirstWord()))
199 {
if (!strncmp(var,
"ofs.", 4)
200 || !strcmp(var,
"all.role")
201 || !strcmp(var,
"all.subcluster"))
202 {
if (
ConfigXeq(var+4,Config,Eroute)) {Config.Echo();NoGo=1;}}
203 else if (!strcmp(var,
"oss.defaults")
204 || !strcmp(var,
"all.export"))
205 {xexp(Config, Eroute, *var ==
'a');
212 if ((retc = Config.LastError()))
213 NoGo = Eroute.
Emsg(
"Config", -retc,
"read config file",
220 if (ossRW ==
' ') ossRW =
'w';
224 mode_t uMask = 0777 & (~(
dMask[1] |
fMask[1]));
240 {
char buff[2048], *bp, *libofs = getenv(
"XRDOFSLIB");
241 if (!libofs) bp = buff;
242 else {strcpy(buff, libofs); bp = buff+strlen(buff)-1;
243 while(bp != buff && *(bp-1) !=
'/') bp--;
245 strcpy(bp,
"libXrdPss.so");
254 NoGo |= ConfigTPC(Eroute,
EnvInfo);
276 if (!ofsConfig->Load(piOpts,
EnvInfo)) NoGo = 1;
282 if (xrdEnv) xrdEnv->
Put(
"XrdCache",
"T");
288 ofsConfig->Plugin(Cks);
289 CksPfn = !ofsConfig->OssCks();
290 CksRdr = !ofsConfig->LclCks();
291 if (ofsConfig->Plugin(prepHandler))
292 {prepAuth = ofsConfig->PrepAuth();
296 {ofsConfig->Plugin(Authorization);
298 if (xrdEnv) xrdEnv->
PutPtr(
"XrdAccAuthorize*",Authorization);
320 {Eroute.
Say(
"++++++ Configuring ", myRole,
" role. . .");
321 if (ConfigRedir(Eroute,
EnvInfo))
322 {Eroute.
Emsg(
"Config",
"Unable to create cluster management client.");
330 if (ofsConfig->Plugin(FSctl_PI) && !ofsConfig->ConfigCtl(
Finder,
EnvInfo))
331 {Eroute.
Emsg(
"Config",
"Unable to configure FSctl plugin.");
341 pcEnv.
PutPtr(
"XrdOfsHandle*", dummyHandle);
342 if (!FSctl_PC->Configure(
ConfigFN, 0, &pcEnv, thePI))
343 {Eroute.
Emsg(
"Config",
"Unable to configure cache FSctl handler.");
355 {
const char *why = 0;
358 why =
"not a pure manager";
360 {Eroute.
Say(
"Config warning: forwarding turned off; ", why);
370 if (!NoGo && evsObject) NoGo = evsObject->Start(&Eroute);
391 if (OssIsProxy || getenv(
"XRDXROOTD_NOPOSC"))
392 {
if (poscAuto != -1 && !NoGo)
393 Eroute.
Say(
"Config POSC has been disabled by the osslib plugin.");
394 }
else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute);
403 delete ofsConfig; ofsConfig = 0;
407 tmp = (NoGo ?
" initialization failed." :
" initialization completed.");
408 Eroute.
Say(
"------ File system ", myRole, tmp);
416#define setBuff(x,y) {strcpy(bp, x); bp += y;}
420 const char *cloc, *pval;
421 char buff[8192], fwbuff[512], *bp;
426 if (!poscQ) pval =
"off";
427 else pval = (poscAuto ?
"auto" :
"manual");
429 snprintf(buff,
sizeof(buff),
"Config effective %s ofs configuration:\n"
433 " ofs.persist %s hold %d%s%s\n"
438 pval, poscHold, (poscLog ?
" logdir " :
""),
439 (poscLog ? poscLog :
""),
OfsTrace.What);
442 ofsConfig->Display();
447 {Eroute.
Say(buff); strcat(fwbuff,
" ch");}
449 {Eroute.
Say(buff); strcat(fwbuff,
" mk");}
450 if (ConfigDispFwd(buff,
fwdMV))
451 {Eroute.
Say(buff); strcat(fwbuff,
" mv");}
452 if (ConfigDispFwd(buff,
fwdRM))
453 {Eroute.
Say(buff); strcat(fwbuff,
" rm");}
455 {Eroute.
Say(buff); strcat(fwbuff,
" rd");}
457 {Eroute.
Say(buff); strcat(fwbuff,
" tr");}
477 i=sprintf(fwbuff,
"%d %d ",evsObject->maxSmsg(),evsObject->maxLmsg());
479 cloc = evsObject->Prog();
480 if (*cloc !=
'>')
setBuff(
"|",1);
494int XrdOfs::ConfigDispFwd(
char *buff,
struct fwdOpt &Fwd)
501 if (!(cP = Fwd.Cmd))
return 0;
507 if (*Fwd.Cmd ==
'+'){
setBuff(
"2way ",5); cP++;}
508 else if (!Fwd.Port) {
setBuff(
"1way ",5);}
510 if (Fwd.Port < 0) {
setBuff(
"local ",6);}
511 else {
int n = sprintf(pbuff,
":%d ", Fwd.Port);
512 setBuff(Fwd.Host, strlen(Fwd.Host));
527 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
528 class CloseFH :
public XrdOfsHanCB
530 static XrdOfsHanCB *hCB =
static_cast<XrdOfsHanCB *
>(
new CloseFH);
532 XrdOfsPoscq::recEnt *rP, *rPP;
533 XrdOfsPoscq::Request *qP;
536 char pBuff[MAXPATHLEN], *aPath;
543 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
549 rc = strlen(aPath)-1;
550 if (aPath[rc] ==
'/') aPath[rc] =
'\0';
551 free(poscLog); poscLog = aPath;
556 {Eroute.
Emsg(
"Config", rc,
"create path for", poscLog);
562 poscQ =
new XrdOfsPoscq(&Eroute,
XrdOfsOss, poscLog,
int(poscSync));
563 rP = poscQ->Init(rc);
571 if (qP->
addT && poscHold)
573 {Eroute.
Emsg(
"Config",
"Unable to persist", qP->
User, qP->
LFN);
577 hP->
Retire(hCB, poscHold);
580 if (!(qP->
addT) || !poscHold)
582 {Eroute.
Emsg(
"Config", rc,
"unpersist", qP->
LFN); NoGo = 1;}
583 else {Eroute.
Emsg(
"Config",
"Unpersisted", qP->
User, qP->
LFN);
587 rPP = rP; rP = rP->
Next;
delete rPP;
613 ofsConfig->Plugin(CmsPI);
645 {Eroute.
Emsg(
"Config",
"Unable to determine server's port number.");
650 Balancer = (XrdCmsClient *)
new XrdCmsFinderTRG(
myLogger,
653 if (!Balancer)
return 1;
654 if (!ofsConfig->Configure(Balancer,
EnvInfo))
655 {
delete Balancer; Balancer = 0;
return 1;}
677 {
char *cpath =
Cfg.cPath;
678 if (!(
Cfg.cPath = ConfigTPCDir(Eroute,
".ofs/.tpccreds/", cpath)))
686 if (!(
Cfg.rPath = ConfigTPCDir(Eroute,
".ofs/.tpcproxy")))
return 1;
710 snprintf(rPBuff,
sizeof(rPBuff),
"%s/%x-%%d.rpx",
Cfg.rPath,
int(time(0)));
712 Cfg.rPath = strdup(rPBuff);
714 if (
Cfg.rPath) free(
Cfg.rPath);
730char *XrdOfs::ConfigTPCDir(
XrdSysError &Eroute,
const char *sfx,
734 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
735 const int BMode = S_IRWXU| S_IRGRP|S_IXGRP;
738 char pBuff[MAXPATHLEN], *aPath;
745 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
755 {Eroute.
Emsg(
"Config", rc,
"create TPC path", aPath);
762 if (SetMode(aPath, BMode))
763 {Eroute.
Emsg(
"Config", errno,
"protect TPC path", aPath);
770 XrdOucNSWalk nsWalk(&Eroute, aPath, 0, nswOpt);
771 XrdOucNSWalk::NSEnt *nsX, *nsP = nsWalk.Index(rc);
773 {Eroute.
Emsg(
"Config", rc,
"list TPC path", aPath);
784 {Eroute.
Emsg(
"Config", errno,
"remove TPC creds", nsX->
Path);
792 if (isBad) {free(aPath);
return 0;}
806 char *val, vBuff[64];
811 TS_XPI(
"authlib", theAutLib);
812 TS_XPI(
"ckslib", theCksLib);
814 TS_XPI(
"cmslib", theCmsLib);
816 TS_XPI(
"ctllib", theCtlLib);
818 TS_Xeq(
"forward", xforward);
819 TS_Xeq(
"maxdelay", xmaxd);
821 TS_Xeq(
"notifymsg", xnmsg);
822 TS_XPI(
"osslib", theOssLib);
824 TS_XPI(
"preplib", thePrpLib);
829 TS_XPI(
"xattrlib", theAtrLib);
841 strlcpy(vBuff, var,
sizeof(vBuff)); var = vBuff;
842 if (!(val = Config.GetWord()))
843 {Eroute.
Emsg(
"Config",
"value not specified for", var);
return 1;}
847 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
870 static const long long maxRds = 1024*1024*1024;
876 if (!(val = Config.GetWord()) || !val[0])
877 {Eroute.
Emsg(
"Config",
"cksrdsz size not specified");
return 1;}
881 if (
XrdOuca2x::a2sz(Eroute,
"cksrdsz size", val, &rdsz, 1, maxRds))
return 1;
882 ofsConfig->SetCksRdSz(
static_cast<int>(rdsz));
923 static const mode_t dMin = 0700, dMax = 0775, fMin = 0600, fMax = 0664;
924 static const mode_t xBit = 0111, wBit = 0002;
926 char *colon, *val, *minM, *maxM;
932 if (!(val =
Config.GetWord()) || !val[0])
933 {Eroute.
Emsg(
"Config",
"crmode argument not specified");
return 1;}
937do{
if (!strcmp(
"dirs", val)) {isDirs =
true; mtype =
"dirs mode";}
938 else if (!strcmp(
"files", val)) {isDirs =
false; mtype =
"files mode";}
939 else {Eroute.
Emsg(
"Config",
"invalid mode type - ", val);
943 if (!(val =
Config.GetWord()) || !val[0])
944 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
946 if (!strcmp(val,
"common"))
947 {
if (isDirs) {
dMask[0] = dMin;
dMask[1] = dMax;}
952 if (!strcmp(val,
"legacy"))
958 if ((isRaw = !strcmp(val,
"raw")))
959 {
if (!(val =
Config.GetWord()) || !val[0])
960 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
963 colon = index(val,
':');
964 if (!colon || colon == val || *(colon+1) == 0)
965 {Eroute.
Emsg(
"Config",mtype,
"mode spec requires min and max values");
968 minM = val; *colon = 0; maxM = colon + 1;
971 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", minM);
976 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", maxM);
981 {
if (isRaw) {
dMask[0] = mMask[0];
dMask[1] = mMask[1];}
982 else {
if ((mMask[0] | mMask[1]) & wBit)
983 {Eroute.
Say(
"Config warning: 'other' w-mode removed from dirs mode!");
984 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
986 dMask[0] = (mMask[0] | dMin) & dMax;
987 dMask[1] = (mMask[1] | dMin) & dMax;
990 {Eroute.
Emsg(
"Config",
"dirs mode min and max values are inconsistent!");
994 if (isRaw) {
fMask[0] = mMask[0];
fMask[1] = mMask[1];}
995 else {
if ((mMask[0] | mMask[1]) & wBit)
996 {Eroute.
Say(
"Config warning: 'other' w-mode removed from files mode!");
997 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
999 if ((mMask[0] | mMask[1]) & xBit)
1000 {Eroute.
Say(
"Config warning: x-mode removed from files mode!");
1001 mMask[0] &= ~xBit; mMask[1] &= ~xBit;
1003 fMask[0] = (mMask[0] | fMin) & fMax;
1004 fMask[1] = (mMask[1] | fMin) & fMax;
1007 {Eroute.
Emsg(
"Config",
"files mode min and max values are inconsistent!");
1011 }
while((val =
Config.GetWord()) && val[0]);
1040 if (!(val =
Config.GetWord()) || !val[0])
1041 {Eroute.
Emsg(
"Config",
"dirlist parameter not specified");
return 1;}
1045 if (!strcmp(val,
"local")) DirRdr =
false;
1046 else if (!strcmp(val,
"remote")) DirRdr =
true;
1047 else {Eroute.
Emsg(
"Config",
"Invalid dirlist parameter -", val);
return 1;}
1066 static struct rwOpts {
const char *opname;
int isRW;} rwtab[] =
1067 {{
"r/o", 0}, {
"readonly", 0},
1068 {
"forcero", 0}, {
"notwritable", 0},
1069 {
"writable", 1}, {
"r/w", 1}
1071 static bool defRW =
true;
1072 int isrw = -1, numopts =
sizeof(rwtab)/
sizeof(
struct rwOpts);
1078 if (isExport && (ossRW ==
'w' || !(val =
Config.GetWord())))
return 0;
1082 while((val =
Config.GetWord()))
1083 {
for (
int i = 0; i < numopts; i++)
1084 if (!strcmp(val, rwtab[i].opname)) isrw = rwtab[i].isRW;
1085 else if (!strcmp(val,
"cache")) {isrw = 0;
break;}
1090 if (isrw < 0) isrw = defRW;
1091 if (isExport) ossRW = (isrw ?
'w' :
'r');
1092 else {defRW = (isrw ? true :
false);
1093 if (ossRW ==
' ' && !isrw) ossRW =
'r';
1118 enum fwdType {OfsFWDALL = 0x3f, OfsFWDCHMOD = 0x01, OfsFWDMKDIR = 0x02,
1119 OfsFWDMV = 0x04, OfsFWDRM = 0x08, OfsFWDRMDIR = 0x10,
1120 OfsFWDREM = 0x18, OfsFWDTRUNC = 0x20, OfsFWDNONE = 0};
1122 static struct fwdopts {
const char *opname; fwdType opval;} fwopts[] =
1125 {
"chmod", OfsFWDCHMOD},
1126 {
"mkdir", OfsFWDMKDIR},
1129 {
"rmdir", OfsFWDRMDIR},
1130 {
"remove", OfsFWDREM},
1131 {
"trunc", OfsFWDTRUNC}
1133 int fwval = OfsFWDNONE, fwspec = OfsFWDNONE;
1134 int numopts =
sizeof(fwopts)/
sizeof(
struct fwdopts);
1135 int i, neg, rPort = 0, is2way = 0, is3way = 0;
1136 char *val, *pp, rHost[512];
1139 if (!(val =
Config.GetWord()))
1140 {Eroute.
Emsg(
"Config",
"forward option not specified");
return 1;}
1141 if ((is2way = !strcmp(
"2way", val)) || !strcmp(
"1way", val)
1142 || (is3way = !strcmp(
"3way", val)))
1143 if (!(val =
Config.GetWord()))
1144 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1147 {
if (!strcmp(
"local", val)) rPort = -1;
1150 {Eroute.
Emsg(
"Config",
"redirect host not specified");
return 1;}
1151 if (!(pp = index(val,
':')))
1152 {Eroute.
Emsg(
"Config",
"redirect port not specified");
return 1;}
1153 if ((rPort = atoi(pp+1)) <= 0)
1154 {Eroute.
Emsg(
"Config",
"redirect port is invalid");
return 1;}
1156 strlcpy(rHost, val,
sizeof(rHost));
1158 if (!(val =
Config.GetWord()))
1159 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1163 {
if (!strcmp(val,
"off")) {fwval = OfsFWDNONE; fwspec = OfsFWDALL;}
1164 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1165 for (i = 0; i < numopts; i++)
1166 {
if (!strcmp(val, fwopts[i].opname))
1167 {
if (neg) fwval &= ~fwopts[i].opval;
1168 else fwval |= fwopts[i].opval;
1169 fwspec |= fwopts[i].opval;
1174 Eroute.
Say(
"Config warning: ignoring invalid forward option '",val,
"'.");
1179 if (fwspec & OfsFWDCHMOD)
1180 {
fwdCHMOD.Cmd = (fwval&OfsFWDCHMOD ? (is2way ?
"+chmod" :
"chmod") : 0);
1184 if (fwspec&OfsFWDMKDIR)
1185 {
fwdMKDIR.Cmd = (fwval&OfsFWDMKDIR ? (is2way ?
"+mkdir" :
"mkdir") : 0);
1188 fwdMKPATH.Cmd= (fwval&OfsFWDMKDIR ? (is2way ?
"+mkpath":
"mkpath") : 0);
1192 if (fwspec&OfsFWDMV)
1193 {
fwdMV .Cmd = (fwval&OfsFWDMV ? (is2way ?
"+mv" :
"mv") : 0);
1195 fwdMV.Host = strdup(rHost);
fwdMV.Port = rPort;
1197 if (fwspec&OfsFWDRM)
1198 {
fwdRM .Cmd = (fwval&OfsFWDRM ? (is2way ?
"+rm" :
"rm") : 0);
1200 fwdRM.Host = strdup(rHost);
fwdRM.Port = rPort;
1202 if (fwspec&OfsFWDRMDIR)
1203 {
fwdRMDIR.Cmd = (fwval&OfsFWDRMDIR ? (is2way ?
"+rmdir" :
"rmdir") : 0);
1207 if (fwspec&OfsFWDTRUNC)
1208 {
fwdTRUNC.Cmd = (fwval&OfsFWDTRUNC ? (is2way ?
"+trunc" :
"trunc") : 0);
1237 if (!(val =
Config.GetWord()))
1238 {Eroute.
Emsg(
"Config",
"maxdelay value not specified");
return 1;}
1239 if (
XrdOuca2x::a2i(Eroute,
"maxdelay", val, &maxd, 30))
return 1;
1280 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1281 char *val, buff[1024];
1287 if (!(val =
Config.GetWord()))
1288 {Eroute.
Emsg(
"Config",
"notifymsg event not specified");
1294 for (i = 0; i < numopts; i++)
if (!strcmp(val, noopts[i].opname))
break;
1296 {Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1299 noval = noopts[i].opval;
1304 myEnv =
Config.SetEnv(0);
1305 if (!
Config.GetRest(buff,
sizeof(buff)))
1306 {Eroute.
Emsg(
"Config",
"notifymsg arguments too long");
1361 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1362 int i, neg, msgL = 90, msgB = 10;
1363 char *val, parms[1024];
1365 if (!(val =
Config.GetWord()))
1366 {Eroute.
Emsg(
"Config",
"notify parameters not specified");
return 1;}
1367 while (val && *val !=
'|' && *val !=
'>')
1368 {
if (!strcmp(val,
"msgs"))
1369 {
if (!(val =
Config.GetWord()))
1370 {Eroute.
Emsg(
"Config",
"notify msgs value not specified");
1373 if (
XrdOuca2x::a2i(Eroute,
"msg count", val, &msgL, 0))
return 1;
1374 if (!(val =
Config.GetWord()))
break;
1377 if (!(val =
Config.GetWord()))
break;
1380 if ((neg = (val[0] ==
'-' && val[1]))) val++;
1382 for (i = 0; i < numopts; i++)
1383 {
if (!strcmp(val, noopts[i].opname))
1390 Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1396 if (!val) {Eroute.
Emsg(
"Config",
"notify program not specified");
return 1;}
1397 if (!noval) {Eroute.
Emsg(
"Config",
"notify events not specified");
return 1;}
1402 if (!
Config.GetRest(parms,
sizeof(parms)))
1403 {Eroute.
Emsg(
"Config",
"notify parameters too long");
return 1;}
1404 val = (*parms ==
'|' ? parms+1 : parms);
1408 if (evsObject)
delete evsObject;
1409 evsObject =
new XrdOfsEvs(noval, val, msgL, msgB);
1439 int snum = -1, htime = -1, popt = -2;
1441 if (!(val =
Config.GetWord()))
1442 {Eroute.
Emsg(
"Config",
"persist option not specified");
return 1;}
1446 if (!strcmp(val,
"auto" )) popt = 1;
1447 else if (!strcmp(val,
"off" )) popt = -1;
1448 else if (!strcmp(val,
"manual" )) popt = 0;
1452 if (popt > -2) val =
Config.GetWord();
1457 {
if (!strcmp(val,
"hold"))
1458 {
if (!(val =
Config.GetWord()))
1459 {Eroute.
Emsg(
"Config",
"persist hold value not specified");
1465 else if (!strcmp(val,
"logdir"))
1466 {
if (!(val =
Config.GetWord()))
1467 {Eroute.
Emsg(
"Config",
"persist logdir path not specified");
1470 if (poscLog) free(poscLog);
1471 poscLog = strdup(val);
1473 else if (!strcmp(val,
"sync"))
1474 {
if (!(val =
Config.GetWord()))
1475 {Eroute.
Emsg(
"Config",
"sync value not specified");
1481 else Eroute.
Say(
"Config warning: ignoring invalid persist option '",val,
"'.");
1487 if (htime >= 0) poscHold = htime;
1488 if (popt > -2) poscAuto = popt;
1489 if (snum > -1) poscSync = snum;
1538 char *val, *Tok1, *Tok2;
1543 if (!(val =
Config.GetWord()) || !strcmp(val,
"if"))
1544 {Eroute.
Emsg(
"Config",
"role not specified");
return 1;}
1549 if ((val =
Config.GetWord()) && strcmp(val,
"if"))
1550 {Tok2 = strdup(val);
1556 if (val && !strcmp(
"if", val))
1559 getenv(
"XRDPROG"))) <= 0)
1560 {free(Tok1);
if (Tok2) free(Tok2);
1561 if (!rc)
Config.noEcho();
1581 default: Eroute.
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
1587 if (Tok2) free(Tok2);
1661 char *val, pgm[1024];
1667 while((val =
Config.GetWord()))
1668 {
if (!strcmp(val,
"redirect"))
1669 {
if (rdrok)
return xtpcr(Config, Eroute);
1670 Eroute.
Emsg(
"Config",
"tpc redirect must be seprately specified.");
1674 if (!strcmp(val,
"allow"))
1675 {
if (!xtpcal(Config, Eroute))
return 1;
1678 if (!strcmp(val,
"cksum"))
1679 {
if (!(val =
Config.GetWord()))
1680 {Eroute.
Emsg(
"Config",
"cksum type not specified");
return 1;}
1685 if (!strcmp(val,
"scan"))
1686 {
if (!(val =
Config.GetWord()))
1687 {Eroute.
Emsg(
"Config",
"scan type not specified");
return 1;}
1688 if (strcmp(val,
"stderr")) Parms.
errMon = -2;
1689 else if (strcmp(val,
"stdout")) Parms.
errMon = -1;
1690 else if (strcmp(val,
"all" )) Parms.
errMon = 0;
1691 else {Eroute.
Emsg(
"Config",
"invalid scan type -",val);
return 1;}
1694 if (!strcmp(val,
"echo")) {Parms.
doEcho =
true;
continue;}
1695 if (!strcmp(val,
"logok")) {Parms.
LogOK =
true;
continue;}
1696 if (!strcmp(val,
"autorm")){Parms.
autoRM =
true;
continue;}
1697 if (!strcmp(val,
"oids")) {Parms.
noids =
false;
continue;}
1698 if (!strcmp(val,
"pgm"))
1699 {
if (!
Config.GetRest(pgm,
sizeof(pgm)))
1700 {Eroute.
Emsg(
"Config",
"tpc command line too long");
return 1;}
1702 {Eroute.
Emsg(
"Config",
"tpc program not specified");
return 1;}
1704 Parms.
XfrProg = strdup( pgm );
1707 if (!strcmp(val,
"require"))
1708 {
if (!(val =
Config.GetWord()))
1709 {Eroute.
Emsg(
"Config",
"tpc require parameter not specified");
return 1;}
1713 else {Eroute.
Emsg(
"Config",
"invalid tpc require type -", val);
return 1;}
1715 if (!(val =
Config.GetWord()))
1716 {Eroute.
Emsg(
"Config",
"tpc require auth not specified");
return 1;}
1720 if (!strcmp(val,
"restrict"))
1721 {
if (!(val =
Config.GetWord()))
1722 {Eroute.
Emsg(
"Config",
"tpc restrict path not specified");
return 1;}
1724 {Eroute.
Emsg(
"Config",
"tpc restrict path not absolute");
return 1;}
1728 if (!strcmp(val,
"ttl"))
1729 {
if (!(val =
Config.GetWord()))
1730 {Eroute.
Emsg(
"Config",
"tpc ttl value not specified");
return 1;}
1733 if (!(val =
Config.GetWord()))
break;
1734 if (!(isdigit(*val))) {
Config.RetToken();
continue;}
1739 if (!strcmp(val,
"xfr"))
1740 {
if (!(val =
Config.GetWord()))
1741 {Eroute.
Emsg(
"Config",
"tpc xfr value not specified");
return 1;}
1745 if (!strcmp(val,
"streams"))
1746 {
if (!(val =
Config.GetWord()))
1747 {Eroute.
Emsg(
"Config",
"tpc streams value not specified");
return 1;}
1748 char *comma = index(val,
',');
1752 {Eroute.
Emsg(
"Config",
"tpc streams max value missing");
return 1;}
1759 if (!strcmp(val,
"fcreds"))
1762 if (!(val =
Config.GetWord()) || (*val ==
'?' && *(val+1) ==
'\0'))
1763 {Eroute.
Emsg(
"Config",
"tpc fcreds auth not specified");
return 1;}
1764 if (strlen(val) >=
sizeof(aBuff))
1765 {Eroute.
Emsg(
"Config",
"invalid fcreds auth -", val);
return 1;}
1767 if (!(val =
Config.GetWord()) || *val !=
'=' || *(val+1) == 0)
1768 {Eroute.
Emsg(
"Config",
"tpc fcreds envar not specified");
return 1;}
1770 if (
emsg) {Eroute.
Emsg(
"Config",
emsg,
"-", val);
return 1;}
1773 if (!strcmp(val,
"fcpath"))
1774 {
if (!(val =
Config.GetWord()))
1775 {Eroute.
Emsg(
"Config",
"tpc fcpath arg not specified");
return 1;}
1777 Parms.
cPath = strdup(val);
1780 Eroute.
Say(
"Config warning: ignoring invalid tpc option '",val,
"'.");
1793 struct tpcalopts {
const char *opname;
char *opval;} tpopts[] =
1794 {{
"dn", 0}, {
"group", 0}, {
"host", 0}, {
"vo", 0}};
1795 int i, spec = 0, numopts =
sizeof(tpopts)/
sizeof(
struct tpcalopts);
1798 while((val =
Config.GetWord()))
1799 {
for (i = 0; i < numopts && strcmp(tpopts[i].opname, val); i++) {}
1800 if (i > numopts) {
Config.RetToken();
break;}
1801 {Eroute.
Emsg(
"Config",
"invalid tpc allow parameter -", val);
1804 if (!(val =
Config.GetWord()))
1805 {Eroute.
Emsg(
"Config",
"tpc allow",tpopts[i].opname,
"value not specified");
1808 if (tpopts[i].opval) free(tpopts[i].opval);
1809 tpopts[i].opval = strdup(val);
1813 if (!spec) {Eroute.
Emsg(
"Config",
"tpc allow parms not specified");
return 1;}
1816 tpopts[2].opval, tpopts[3].opval);
1827 const char *cgi, *cgisep, *hBeg, *hEnd, *pBeg, *pEnd, *eText;
1833 if (!(val =
Config.GetWord()))
1834 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1838 if (!strcmp(val,
"delegated")) dlgI = 0;
1839 else if (!strcmp(val,
"undelegated")) dlgI = 1;
1844 if (dlgI >= 0 && !(val =
Config.GetWord()))
1845 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1850 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1855 if (*val ==
'[') n += 2;
1856 if (n >= (
int)
sizeof(hname))
1857 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1858 strncpy(hname, val, n);
1863 if (!strcmp(hname,
"localhost"))
1866 {Eroute.
Emsg(
"Config",
"Unable to determine tpc localhost;",eText);
1869 n = snprintf(hname,
sizeof(hname),
"%s", myHost);
1871 if (n >= (
int)
sizeof(hname))
1872 {Eroute.
Emsg(
"Config",
"Invalid tpc localhost resolution -", hname);
1880 {Eroute.
Emsg(
"Config",
"tpc redirect port not specified");
return 1;}
1885 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect port;",eText);
return 1;}
1889 if (!(cgi =
Config.GetWord())) cgisep = cgi = (
char *)
"";
1890 else cgisep = (*cgi !=
'?' ?
"?" :
"");
1894 int k = (dlgI < 0 ? 0 : dlgI);
1897 n = strlen(hname) + strlen(cgisep) + strlen(cgi) + 1;
1899 snprintf(
tpcRdrHost[k], n,
"%s%s%s", hname, cgisep, cgi);
1902 }
while(dlgI < 0 && k < 2);
1926 static struct traceopts {
const char *opname;
int opval;} tropts[] =
1954 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
1957 if (!(val =
Config.GetWord()))
1958 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
1960 {
if (!strcmp(val,
"off")) trval = 0;
1961 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1962 for (i = 0; i < numopts; i++)
1963 {
if (!strcmp(val, tropts[i].opname))
1964 {
if (neg) trval &= ~tropts[i].opval;
1965 else trval |= tropts[i].opval;
1970 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
2008 static const int xanRsv = 7;
2013 while((val =
Config.GetWord()))
2014 {
if (!strcmp(
"maxnsz", val))
2015 {
if (!(val =
Config.GetWord()))
2016 {Eroute.
Emsg(
"Config",
"xattr maxnsz value not specified");
2021 maxN =
static_cast<int>(vtmp);
2023 else if (!strcmp(
"maxvsz", val))
2024 {
if (!(val =
Config.GetWord()))
2025 {Eroute.
Emsg(
"Config",
"xattr maxvsz value not specified");
2030 maxV =
static_cast<int>(vtmp);
2032 else if (!strcmp(
"uset", val))
2033 {
if (!(val =
Config.GetWord()))
2034 {Eroute.
Emsg(
"Config",
"xattr uset value not specified");
2037 if (!strcmp(
"on", val)) isOn =
true;
2038 else if (!strcmp(
"off", val)) isOn =
false;
2039 else {Eroute.
Emsg(
"Config",
"invalid xattr uset value -", val);
2043 else {Eroute.
Emsg(
"Config",
"invalid xattr option -", val);
2048 usxMaxNsz = (isOn ? maxN-xanRsv : 0);
2057const 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 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 &)
void Unpersist(XrdOfsHandle *hP, int xcev=1)
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
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 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.