39 #include <netinet/in.h>
40 #include <sys/param.h>
43 #include "XrdVersion.hh"
107 int 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;
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",
193 static const char *cvec[] = {
"*** ofs plugin config:",0};
198 while((var =
Config.GetMyFirstWord()))
199 {
if (!strncmp(var,
"ofs.", 4)
200 || !strcmp(var,
"all.role")
201 || !strcmp(var,
"all.subcluster"))
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);
282 if (xrdEnv) xrdEnv->
Put(
"XrdCache",
"T");
287 CksPfn = !ofsConfig->
OssCks();
288 CksRdr = !ofsConfig->
LclCks();
289 if (ofsConfig->
Plugin(prepHandler))
294 {ofsConfig->
Plugin(Authorization);
296 if (xrdEnv) xrdEnv->
PutPtr(
"XrdAccAuthorize*",Authorization);
318 {Eroute.
Say(
"++++++ Configuring ", myRole,
" role. . .");
319 if (ConfigRedir(Eroute,
EnvInfo))
320 {Eroute.
Emsg(
"Config",
"Unable to create cluster management client.");
329 {Eroute.
Emsg(
"Config",
"Unable to configure FSctl plugin.");
339 pcEnv.
PutPtr(
"XrdOfsHandle*", dummyHandle);
341 {Eroute.
Emsg(
"Config",
"Unable to configure cache FSctl handler.");
353 {
const char *why = 0;
356 why =
"not a pure manager";
358 {Eroute.
Say(
"Config warning: forwarding turned off; ", why);
368 if (!NoGo && evsObject) NoGo = evsObject->
Start(&Eroute);
389 if (OssIsProxy || getenv(
"XRDXROOTD_NOPOSC"))
390 {
if (poscAuto != -1 && !NoGo)
391 Eroute.
Say(
"Config POSC has been disabled by the osslib plugin.");
392 }
else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute);
401 delete ofsConfig; ofsConfig = 0;
405 tmp = (NoGo ?
" initialization failed." :
" initialization completed.");
406 Eroute.
Say(
"------ File system ", myRole, tmp);
414 #define setBuff(x,y) {strcpy(bp, x); bp += y;}
418 const char *cloc, *pval;
419 char buff[8192], fwbuff[512], *bp;
424 if (!poscQ) pval =
"off";
425 else pval = (poscAuto ?
"auto" :
"manual");
427 snprintf(buff,
sizeof(buff),
"Config effective %s ofs configuration:\n"
431 " ofs.persist %s hold %d%s%s\n"
436 pval, poscHold, (poscLog ?
" logdir " :
""),
445 {Eroute.
Say(buff); strcat(fwbuff,
" ch");}
447 {Eroute.
Say(buff); strcat(fwbuff,
" mk");}
448 if (ConfigDispFwd(buff,
fwdMV))
449 {Eroute.
Say(buff); strcat(fwbuff,
" mv");}
450 if (ConfigDispFwd(buff,
fwdRM))
451 {Eroute.
Say(buff); strcat(fwbuff,
" rm");}
453 {Eroute.
Say(buff); strcat(fwbuff,
" rd");}
455 {Eroute.
Say(buff); strcat(fwbuff,
" tr");}
475 i=sprintf(fwbuff,
"%d %d ",evsObject->
maxSmsg(),evsObject->
maxLmsg());
477 cloc = evsObject->
Prog();
478 if (*cloc !=
'>')
setBuff(
"|",1);
492 int XrdOfs::ConfigDispFwd(
char *buff,
struct fwdOpt &Fwd)
499 if (!(cP = Fwd.Cmd))
return 0;
505 if (*Fwd.Cmd ==
'+'){
setBuff(
"2way ",5); cP++;}
506 else if (!Fwd.Port) {
setBuff(
"1way ",5);}
508 if (Fwd.Port < 0) {
setBuff(
"local ",6);}
509 else {
int n = sprintf(pbuff,
":%d ", Fwd.Port);
510 setBuff(Fwd.Host, strlen(Fwd.Host));
525 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
534 char pBuff[MAXPATHLEN], *aPath;
541 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
547 rc = strlen(aPath)-1;
548 if (aPath[rc] ==
'/') aPath[rc] =
'\0';
549 free(poscLog); poscLog = aPath;
554 {Eroute.
Emsg(
"Config", rc,
"create path for", poscLog);
561 rP = poscQ->
Init(rc);
569 if (qP->
addT && poscHold)
571 {Eroute.
Emsg(
"Config",
"Unable to persist", qP->
User, qP->
LFN);
575 hP->
Retire(hCB, poscHold);
578 if (!(qP->
addT) || !poscHold)
580 {Eroute.
Emsg(
"Config", rc,
"unpersist", qP->
LFN); NoGo = 1;}
581 else {Eroute.
Emsg(
"Config",
"Unpersisted", qP->
User, qP->
LFN);
585 rPP = rP; rP = rP->
Next;
delete rPP;
643 {Eroute.
Emsg(
"Config",
"Unable to determine server's port number.");
651 if (!Balancer)
return 1;
653 {
delete Balancer; Balancer = 0;
return 1;}
676 if (!(
Cfg.
cPath = ConfigTPCDir(Eroute,
".ofs/.tpccreds/", cpath)))
684 if (!(
Cfg.
rPath = ConfigTPCDir(Eroute,
".ofs/.tpcproxy")))
return 1;
708 snprintf(rPBuff,
sizeof(rPBuff),
"%s/%x-%%d.rpx",
Cfg.
rPath,
int(time(0)));
728 char *XrdOfs::ConfigTPCDir(
XrdSysError &Eroute,
const char *sfx,
732 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
733 const int BMode = S_IRWXU| S_IRGRP|S_IXGRP;
736 char pBuff[MAXPATHLEN], *aPath;
743 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
753 {Eroute.
Emsg(
"Config", rc,
"create TPC path", aPath);
760 if (SetMode(aPath, BMode))
761 {Eroute.
Emsg(
"Config", errno,
"protect TPC path", aPath);
771 {Eroute.
Emsg(
"Config", rc,
"list TPC path", aPath);
782 {Eroute.
Emsg(
"Config", errno,
"remove TPC creds", nsX->
Path);
790 if (isBad) {free(aPath);
return 0;}
804 char *val, vBuff[64];
809 TS_XPI(
"authlib", theAutLib);
810 TS_XPI(
"ckslib", theCksLib);
812 TS_XPI(
"cmslib", theCmsLib);
814 TS_XPI(
"ctllib", theCtlLib);
816 TS_Xeq(
"forward", xforward);
817 TS_Xeq(
"maxdelay", xmaxd);
819 TS_Xeq(
"notifymsg", xnmsg);
820 TS_XPI(
"osslib", theOssLib);
822 TS_XPI(
"preplib", thePrpLib);
827 TS_XPI(
"xattrlib", theAtrLib);
839 strlcpy(vBuff, var,
sizeof(vBuff)); var = vBuff;
840 if (!(val =
Config.GetWord()))
841 {Eroute.
Emsg(
"Config",
"value not specified for", var);
return 1;}
845 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
868 static const long long maxRds = 1024*1024*1024;
874 if (!(val =
Config.GetWord()) || !val[0])
875 {Eroute.
Emsg(
"Config",
"cksrdsz size not specified");
return 1;}
879 if (
XrdOuca2x::a2sz(Eroute,
"cksrdsz size", val, &rdsz, 1, maxRds))
return 1;
880 ofsConfig->
SetCksRdSz(
static_cast<int>(rdsz));
921 static const mode_t dMin = 0700, dMax = 0775, fMin = 0600, fMax = 0664;
922 static const mode_t xBit = 0111, wBit = 0002;
924 char *colon, *val, *minM, *maxM;
930 if (!(val =
Config.GetWord()) || !val[0])
931 {Eroute.
Emsg(
"Config",
"crmode argument not specified");
return 1;}
935 do{
if (!strcmp(
"dirs", val)) {isDirs =
true; mtype =
"dirs mode";}
936 else if (!strcmp(
"files", val)) {isDirs =
false; mtype =
"files mode";}
937 else {Eroute.
Emsg(
"Config",
"invalid mode type - ", val);
941 if (!(val =
Config.GetWord()) || !val[0])
942 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
944 if (!strcmp(val,
"common"))
945 {
if (isDirs) {
dMask[0] = dMin;
dMask[1] = dMax;}
950 if (!strcmp(val,
"legacy"))
956 if ((isRaw = !strcmp(val,
"raw")))
957 {
if (!(val =
Config.GetWord()) || !val[0])
958 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
961 colon = index(val,
':');
962 if (!colon || colon == val || *(colon+1) == 0)
963 {Eroute.
Emsg(
"Config",mtype,
"mode spec requires min and max values");
966 minM = val; *colon = 0; maxM = colon + 1;
969 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", minM);
974 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", maxM);
979 {
if (isRaw) {
dMask[0] = mMask[0];
dMask[1] = mMask[1];}
980 else {
if ((mMask[0] | mMask[1]) & wBit)
981 {Eroute.
Say(
"Config warning: 'other' w-mode removed from dirs mode!");
982 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
984 dMask[0] = (mMask[0] | dMin) & dMax;
985 dMask[1] = (mMask[1] | dMin) & dMax;
988 {Eroute.
Emsg(
"Config",
"dirs mode min and max values are inconsistent!");
992 if (isRaw) {
fMask[0] = mMask[0];
fMask[1] = mMask[1];}
993 else {
if ((mMask[0] | mMask[1]) & wBit)
994 {Eroute.
Say(
"Config warning: 'other' w-mode removed from files mode!");
995 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
997 if ((mMask[0] | mMask[1]) & xBit)
998 {Eroute.
Say(
"Config warning: x-mode removed from files mode!");
999 mMask[0] &= ~xBit; mMask[1] &= ~xBit;
1001 fMask[0] = (mMask[0] | fMin) & fMax;
1002 fMask[1] = (mMask[1] | fMin) & fMax;
1005 {Eroute.
Emsg(
"Config",
"files mode min and max values are inconsistent!");
1009 }
while((val =
Config.GetWord()) && val[0]);
1038 if (!(val =
Config.GetWord()) || !val[0])
1039 {Eroute.
Emsg(
"Config",
"dirlist parameter not specified");
return 1;}
1043 if (!strcmp(val,
"local")) DirRdr =
false;
1044 else if (!strcmp(val,
"remote")) DirRdr =
true;
1045 else {Eroute.
Emsg(
"Config",
"Invalid dirlist parameter -", val);
return 1;}
1064 static struct rwOpts {
const char *opname;
int isRW;} rwtab[] =
1065 {{
"r/o", 0}, {
"readonly", 0},
1066 {
"forcero", 0}, {
"notwritable", 0},
1067 {
"writable", 1}, {
"r/w", 1}
1069 static bool defRW =
true;
1070 int isrw = -1, numopts =
sizeof(rwtab)/
sizeof(
struct rwOpts);
1076 if (isExport && (ossRW ==
'w' || !(val =
Config.GetWord())))
return 0;
1080 while((val =
Config.GetWord()))
1081 {
for (
int i = 0; i < numopts; i++)
1082 if (!strcmp(val, rwtab[i].opname)) isrw = rwtab[i].isRW;
1083 else if (!strcmp(val,
"cache")) {isrw = 0;
break;}
1088 if (isrw < 0) isrw = defRW;
1089 if (isExport) ossRW = (isrw ?
'w' :
'r');
1090 else {defRW = (isrw ? true :
false);
1091 if (ossRW ==
' ' && !isrw) ossRW =
'r';
1116 enum fwdType {OfsFWDALL = 0x3f, OfsFWDCHMOD = 0x01, OfsFWDMKDIR = 0x02,
1117 OfsFWDMV = 0x04, OfsFWDRM = 0x08, OfsFWDRMDIR = 0x10,
1118 OfsFWDREM = 0x18, OfsFWDTRUNC = 0x20, OfsFWDNONE = 0};
1120 static struct fwdopts {
const char *opname; fwdType opval;} fwopts[] =
1123 {
"chmod", OfsFWDCHMOD},
1124 {
"mkdir", OfsFWDMKDIR},
1127 {
"rmdir", OfsFWDRMDIR},
1128 {
"remove", OfsFWDREM},
1129 {
"trunc", OfsFWDTRUNC}
1131 int fwval = OfsFWDNONE, fwspec = OfsFWDNONE;
1132 int numopts =
sizeof(fwopts)/
sizeof(
struct fwdopts);
1133 int i, neg, rPort = 0, is2way = 0, is3way = 0;
1134 char *val, *pp, rHost[512];
1137 if (!(val =
Config.GetWord()))
1138 {Eroute.
Emsg(
"Config",
"forward option not specified");
return 1;}
1139 if ((is2way = !strcmp(
"2way", val)) || !strcmp(
"1way", val)
1140 || (is3way = !strcmp(
"3way", val)))
1141 if (!(val =
Config.GetWord()))
1142 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1145 {
if (!strcmp(
"local", val)) rPort = -1;
1148 {Eroute.
Emsg(
"Config",
"redirect host not specified");
return 1;}
1149 if (!(pp = index(val,
':')))
1150 {Eroute.
Emsg(
"Config",
"redirect port not specified");
return 1;}
1151 if ((rPort = atoi(pp+1)) <= 0)
1152 {Eroute.
Emsg(
"Config",
"redirect port is invalid");
return 1;}
1154 strlcpy(rHost, val,
sizeof(rHost));
1156 if (!(val =
Config.GetWord()))
1157 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1161 {
if (!strcmp(val,
"off")) {fwval = OfsFWDNONE; fwspec = OfsFWDALL;}
1162 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1163 for (i = 0; i < numopts; i++)
1164 {
if (!strcmp(val, fwopts[i].opname))
1165 {
if (neg) fwval &= ~fwopts[i].opval;
1166 else fwval |= fwopts[i].opval;
1167 fwspec |= fwopts[i].opval;
1172 Eroute.
Say(
"Config warning: ignoring invalid forward option '",val,
"'.");
1177 if (fwspec & OfsFWDCHMOD)
1178 {
fwdCHMOD.
Cmd = (fwval&OfsFWDCHMOD ? (is2way ?
"+chmod" :
"chmod") : 0);
1182 if (fwspec&OfsFWDMKDIR)
1183 {
fwdMKDIR.
Cmd = (fwval&OfsFWDMKDIR ? (is2way ?
"+mkdir" :
"mkdir") : 0);
1186 fwdMKPATH.
Cmd= (fwval&OfsFWDMKDIR ? (is2way ?
"+mkpath":
"mkpath") : 0);
1190 if (fwspec&OfsFWDMV)
1191 {
fwdMV .
Cmd = (fwval&OfsFWDMV ? (is2way ?
"+mv" :
"mv") : 0);
1195 if (fwspec&OfsFWDRM)
1196 {
fwdRM .
Cmd = (fwval&OfsFWDRM ? (is2way ?
"+rm" :
"rm") : 0);
1200 if (fwspec&OfsFWDRMDIR)
1201 {
fwdRMDIR.
Cmd = (fwval&OfsFWDRMDIR ? (is2way ?
"+rmdir" :
"rmdir") : 0);
1205 if (fwspec&OfsFWDTRUNC)
1206 {
fwdTRUNC.
Cmd = (fwval&OfsFWDTRUNC ? (is2way ?
"+trunc" :
"trunc") : 0);
1235 if (!(val =
Config.GetWord()))
1236 {Eroute.
Emsg(
"Config",
"maxdelay value not specified");
return 1;}
1237 if (
XrdOuca2x::a2i(Eroute,
"maxdelay", val, &maxd, 30))
return 1;
1278 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1279 char *val, buff[1024];
1285 if (!(val =
Config.GetWord()))
1286 {Eroute.
Emsg(
"Config",
"notifymsg event not specified");
1292 for (i = 0; i < numopts; i++)
if (!strcmp(val, noopts[i].opname))
break;
1294 {Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1297 noval = noopts[i].opval;
1302 myEnv =
Config.SetEnv(0);
1303 if (!
Config.GetRest(buff,
sizeof(buff)))
1304 {Eroute.
Emsg(
"Config",
"notifymsg arguments too long");
1359 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1360 int i, neg, msgL = 90, msgB = 10;
1361 char *val, parms[1024];
1363 if (!(val =
Config.GetWord()))
1364 {Eroute.
Emsg(
"Config",
"notify parameters not specified");
return 1;}
1365 while (val && *val !=
'|' && *val !=
'>')
1366 {
if (!strcmp(val,
"msgs"))
1367 {
if (!(val =
Config.GetWord()))
1368 {Eroute.
Emsg(
"Config",
"notify msgs value not specified");
1371 if (
XrdOuca2x::a2i(Eroute,
"msg count", val, &msgL, 0))
return 1;
1372 if (!(val =
Config.GetWord()))
break;
1375 if (!(val =
Config.GetWord()))
break;
1378 if ((neg = (val[0] ==
'-' && val[1]))) val++;
1380 for (i = 0; i < numopts; i++)
1381 {
if (!strcmp(val, noopts[i].opname))
1388 Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1394 if (!val) {Eroute.
Emsg(
"Config",
"notify program not specified");
return 1;}
1395 if (!noval) {Eroute.
Emsg(
"Config",
"notify events not specified");
return 1;}
1400 if (!
Config.GetRest(parms,
sizeof(parms)))
1401 {Eroute.
Emsg(
"Config",
"notify parameters too long");
return 1;}
1402 val = (*parms ==
'|' ? parms+1 : parms);
1406 if (evsObject)
delete evsObject;
1407 evsObject =
new XrdOfsEvs(noval, val, msgL, msgB);
1437 int snum = -1, htime = -1, popt = -2;
1439 if (!(val =
Config.GetWord()))
1440 {Eroute.
Emsg(
"Config",
"persist option not specified");
return 1;}
1444 if (!strcmp(val,
"auto" )) popt = 1;
1445 else if (!strcmp(val,
"off" )) popt = -1;
1446 else if (!strcmp(val,
"manual" )) popt = 0;
1450 if (popt > -2) val =
Config.GetWord();
1455 {
if (!strcmp(val,
"hold"))
1456 {
if (!(val =
Config.GetWord()))
1457 {Eroute.
Emsg(
"Config",
"persist hold value not specified");
1463 else if (!strcmp(val,
"logdir"))
1464 {
if (!(val =
Config.GetWord()))
1465 {Eroute.
Emsg(
"Config",
"persist logdir path not specified");
1468 if (poscLog) free(poscLog);
1469 poscLog = strdup(val);
1471 else if (!strcmp(val,
"sync"))
1472 {
if (!(val =
Config.GetWord()))
1473 {Eroute.
Emsg(
"Config",
"sync value not specified");
1479 else Eroute.
Say(
"Config warning: ignoring invalid persist option '",val,
"'.");
1485 if (htime >= 0) poscHold = htime;
1486 if (popt > -2) poscAuto = popt;
1487 if (snum > -1) poscSync = snum;
1536 char *val, *Tok1, *Tok2;
1541 if (!(val =
Config.GetWord()) || !strcmp(val,
"if"))
1542 {Eroute.
Emsg(
"Config",
"role not specified");
return 1;}
1547 if ((val =
Config.GetWord()) && strcmp(val,
"if"))
1548 {Tok2 = strdup(val);
1554 if (val && !strcmp(
"if", val))
1557 getenv(
"XRDPROG"))) <= 0)
1558 {free(Tok1);
if (Tok2) free(Tok2);
1559 if (!rc)
Config.noEcho();
1579 default: Eroute.
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
1585 if (Tok2) free(Tok2);
1659 char *val, pgm[1024];
1665 while((val =
Config.GetWord()))
1666 {
if (!strcmp(val,
"redirect"))
1667 {
if (rdrok)
return xtpcr(
Config, Eroute);
1668 Eroute.
Emsg(
"Config",
"tpc redirect must be seprately specified.");
1672 if (!strcmp(val,
"allow"))
1673 {
if (!xtpcal(
Config, Eroute))
return 1;
1676 if (!strcmp(val,
"cksum"))
1677 {
if (!(val =
Config.GetWord()))
1678 {Eroute.
Emsg(
"Config",
"cksum type not specified");
return 1;}
1683 if (!strcmp(val,
"scan"))
1684 {
if (!(val =
Config.GetWord()))
1685 {Eroute.
Emsg(
"Config",
"scan type not specified");
return 1;}
1686 if (strcmp(val,
"stderr")) Parms.
errMon = -2;
1687 else if (strcmp(val,
"stdout")) Parms.
errMon = -1;
1688 else if (strcmp(val,
"all" )) Parms.
errMon = 0;
1689 else {Eroute.
Emsg(
"Config",
"invalid scan type -",val);
return 1;}
1692 if (!strcmp(val,
"echo")) {Parms.
doEcho =
true;
continue;}
1693 if (!strcmp(val,
"logok")) {Parms.
LogOK =
true;
continue;}
1694 if (!strcmp(val,
"autorm")){Parms.
autoRM =
true;
continue;}
1695 if (!strcmp(val,
"oids")) {Parms.
noids =
false;
continue;}
1696 if (!strcmp(val,
"pgm"))
1697 {
if (!
Config.GetRest(pgm,
sizeof(pgm)))
1698 {Eroute.
Emsg(
"Config",
"tpc command line too long");
return 1;}
1700 {Eroute.
Emsg(
"Config",
"tpc program not specified");
return 1;}
1702 Parms.
XfrProg = strdup( pgm );
1705 if (!strcmp(val,
"require"))
1706 {
if (!(val =
Config.GetWord()))
1707 {Eroute.
Emsg(
"Config",
"tpc require parameter not specified");
return 1;}
1711 else {Eroute.
Emsg(
"Config",
"invalid tpc require type -", val);
return 1;}
1713 if (!(val =
Config.GetWord()))
1714 {Eroute.
Emsg(
"Config",
"tpc require auth not specified");
return 1;}
1718 if (!strcmp(val,
"restrict"))
1719 {
if (!(val =
Config.GetWord()))
1720 {Eroute.
Emsg(
"Config",
"tpc restrict path not specified");
return 1;}
1722 {Eroute.
Emsg(
"Config",
"tpc restrict path not absolute");
return 1;}
1726 if (!strcmp(val,
"ttl"))
1727 {
if (!(val =
Config.GetWord()))
1728 {Eroute.
Emsg(
"Config",
"tpc ttl value not specified");
return 1;}
1731 if (!(val =
Config.GetWord()))
break;
1732 if (!(isdigit(*val))) {
Config.RetToken();
continue;}
1737 if (!strcmp(val,
"xfr"))
1738 {
if (!(val =
Config.GetWord()))
1739 {Eroute.
Emsg(
"Config",
"tpc xfr value not specified");
return 1;}
1743 if (!strcmp(val,
"streams"))
1744 {
if (!(val =
Config.GetWord()))
1745 {Eroute.
Emsg(
"Config",
"tpc streams value not specified");
return 1;}
1746 char *comma = index(val,
',');
1750 {Eroute.
Emsg(
"Config",
"tpc streams max value missing");
return 1;}
1757 if (!strcmp(val,
"fcreds"))
1760 if (!(val =
Config.GetWord()) || (*val ==
'?' && *(val+1) ==
'\0'))
1761 {Eroute.
Emsg(
"Config",
"tpc fcreds auth not specified");
return 1;}
1762 if (strlen(val) >=
sizeof(aBuff))
1763 {Eroute.
Emsg(
"Config",
"invalid fcreds auth -", val);
return 1;}
1765 if (!(val =
Config.GetWord()) || *val !=
'=' || *(val+1) == 0)
1766 {Eroute.
Emsg(
"Config",
"tpc fcreds envar not specified");
return 1;}
1768 if (
emsg) {Eroute.
Emsg(
"Config",
emsg,
"-", val);
return 1;}
1771 if (!strcmp(val,
"fcpath"))
1772 {
if (!(val =
Config.GetWord()))
1773 {Eroute.
Emsg(
"Config",
"tpc fcpath arg not specified");
return 1;}
1775 Parms.
cPath = strdup(val);
1778 Eroute.
Say(
"Config warning: ignoring invalid tpc option '",val,
"'.");
1791 struct tpcalopts {
const char *opname;
char *opval;} tpopts[] =
1792 {{
"dn", 0}, {
"group", 0}, {
"host", 0}, {
"vo", 0}};
1793 int i, spec = 0, numopts =
sizeof(tpopts)/
sizeof(
struct tpcalopts);
1796 while((val =
Config.GetWord()))
1797 {
for (i = 0; i < numopts && strcmp(tpopts[i].opname, val); i++) {}
1798 if (i > numopts) {
Config.RetToken();
break;}
1799 {Eroute.
Emsg(
"Config",
"invalid tpc allow parameter -", val);
1802 if (!(val =
Config.GetWord()))
1803 {Eroute.
Emsg(
"Config",
"tpc allow",tpopts[i].opname,
"value not specified");
1806 if (tpopts[i].opval) free(tpopts[i].opval);
1807 tpopts[i].opval = strdup(val);
1811 if (!spec) {Eroute.
Emsg(
"Config",
"tpc allow parms not specified");
return 1;}
1814 tpopts[2].opval, tpopts[3].opval);
1825 const char *cgi, *cgisep, *hBeg, *hEnd, *pBeg, *pEnd, *eText;
1831 if (!(val =
Config.GetWord()))
1832 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1836 if (!strcmp(val,
"delegated")) dlgI = 0;
1837 else if (!strcmp(val,
"undelegated")) dlgI = 1;
1842 if (dlgI >= 0 && !(val =
Config.GetWord()))
1843 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1848 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1853 if (*val ==
'[') n += 2;
1854 if (n >= (
int)
sizeof(hname))
1855 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1856 strncpy(hname, val, n);
1861 if (!strcmp(hname,
"localhost"))
1864 {Eroute.
Emsg(
"Config",
"Unable to determine tpc localhost;",eText);
1867 n = snprintf(hname,
sizeof(hname),
"%s", myHost);
1869 if (n >= (
int)
sizeof(hname))
1870 {Eroute.
Emsg(
"Config",
"Invalid tpc localhost resolution -", hname);
1878 {Eroute.
Emsg(
"Config",
"tpc redirect port not specified");
return 1;}
1883 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect port;",eText);
return 1;}
1887 if (!(cgi =
Config.GetWord())) cgisep = cgi = (
char *)
"";
1888 else cgisep = (*cgi !=
'?' ?
"?" :
"");
1892 int k = (dlgI < 0 ? 0 : dlgI);
1895 n = strlen(hname) + strlen(cgisep) + strlen(cgi) + 1;
1897 snprintf(
tpcRdrHost[k], n,
"%s%s%s", hname, cgisep, cgi);
1900 }
while(dlgI < 0 && k < 2);
1924 static struct traceopts {
const char *opname;
int opval;} tropts[] =
1952 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
1955 if (!(val =
Config.GetWord()))
1956 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
1958 {
if (!strcmp(val,
"off")) trval = 0;
1959 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1960 for (i = 0; i < numopts; i++)
1961 {
if (!strcmp(val, tropts[i].opname))
1962 {
if (neg) trval &= ~tropts[i].opval;
1963 else trval |= tropts[i].opval;
1968 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
2006 static const int xanRsv = 7;
2011 while((val =
Config.GetWord()))
2012 {
if (!strcmp(
"maxnsz", val))
2013 {
if (!(val =
Config.GetWord()))
2014 {Eroute.
Emsg(
"Config",
"xattr maxnsz value not specified");
2019 maxN =
static_cast<int>(vtmp);
2021 else if (!strcmp(
"maxvsz", val))
2022 {
if (!(val =
Config.GetWord()))
2023 {Eroute.
Emsg(
"Config",
"xattr maxvsz value not specified");
2028 maxV =
static_cast<int>(vtmp);
2030 else if (!strcmp(
"uset", val))
2031 {
if (!(val =
Config.GetWord()))
2032 {Eroute.
Emsg(
"Config",
"xattr uset value not specified");
2035 if (!strcmp(
"on", val)) isOn =
true;
2036 else if (!strcmp(
"off", val)) isOn =
false;
2037 else {Eroute.
Emsg(
"Config",
"invalid xattr uset value -", val);
2041 else {Eroute.
Emsg(
"Config",
"invalid xattr option -", val);
2046 usxMaxNsz = (isOn ? maxN-xanRsv : 0);
2055 const char *XrdOfs::theRole(
int opts)
XrdCmsClient *(* XrdCmsClient_t)(XrdSysLogger *, int, int, XrdOss *)
XrdVERSIONINFO(XrdOfs, XrdOfs)
int open(const char *path, int oflag,...)
int unlink(const char *path)
int emsg(int rc, char *msg)
virtual XrdOucTList * Managers()
static bool VCheck(XrdVersionInfo &urVersion)
static bool VCheck(XrdVersionInfo &urVersion)
static const char * Name(RoleID rid)
static RoleID Convert(const char *Tok1, const char *Tok2)
static const char * Type(RoleID rid)
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)
bool ConfigCtl(XrdCmsClient *cmscP, XrdOucEnv *envP=0)
void Default(TheLib what, const char *lpath, const char *lparm=0)
void SetCksRdSz(int rdsz)
bool Plugin(XrdAccAuthorize *&piP)
Get Authorization plugin.
static XrdOfsConfigPI * New(const char *cfn, XrdOucStream *cfgP, XrdSysError *errP, XrdVersionInfo *verP=0, XrdSfsFileSystem *sfsP=0)
bool Load(int what, XrdOucEnv *envP=0)
bool Configure(XrdCmsClient *cmscP, XrdOucEnv *envP)
@ allXXXLib
All plugins (Load() only)
@ theCksLib
Checksum manager plugin.
void Display()
Display configuration settings.
int Init(XrdSysError *eObj)
static int Parse(XrdSysError &Eroute, Event eNum, char *mText)
int Start(XrdSysError *eobj)
int Enabled(Event theEvents)
virtual bool Configure(const char *CfgFN, const char *Parms, XrdOucEnv *envP, const Plugins &plugs)
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)
int Del(const char *Lfn, int Offset, int Unlink=0)
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 &)
void Unpersist(XrdOfsHandle *hP, int xcev=1)
virtual uint64_t Features()
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 hasNAIO
Feature: Supports no async I/O.
static const uint64_t hasPRXY
Feature: Proxy Server.