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);
284 CksPfn = !ofsConfig->
OssCks();
285 CksRdr = !ofsConfig->
LclCks();
286 if (ofsConfig->
Plugin(prepHandler))
291 {ofsConfig->
Plugin(Authorization);
293 if (xrdEnv) xrdEnv->
PutPtr(
"XrdAccAuthorize*",Authorization);
315 {Eroute.
Say(
"++++++ Configuring ", myRole,
" role. . .");
316 if (ConfigRedir(Eroute,
EnvInfo))
317 {Eroute.
Emsg(
"Config",
"Unable to create cluster management client.");
326 {Eroute.
Emsg(
"Config",
"Unable to configure FSctl plugin.");
336 pcEnv.
PutPtr(
"XrdOfsHandle*", dummyHandle);
338 {Eroute.
Emsg(
"Config",
"Unable to configure cache FSctl handler.");
350 {
const char *why = 0;
353 why =
"not a pure manager";
355 {Eroute.
Say(
"Config warning: forwarding turned off; ", why);
365 if (!NoGo && evsObject) NoGo = evsObject->
Start(&Eroute);
386 if (OssIsProxy || getenv(
"XRDXROOTD_NOPOSC"))
387 {
if (poscAuto != -1 && !NoGo)
388 Eroute.
Say(
"Config POSC has been disabled by the osslib plugin.");
389 }
else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute);
398 delete ofsConfig; ofsConfig = 0;
402 tmp = (NoGo ?
" initialization failed." :
" initialization completed.");
403 Eroute.
Say(
"------ File system ", myRole, tmp);
411 #define setBuff(x,y) {strcpy(bp, x); bp += y;}
415 const char *cloc, *pval;
416 char buff[8192], fwbuff[512], *bp;
421 if (!poscQ) pval =
"off";
422 else pval = (poscAuto ?
"auto" :
"manual");
424 snprintf(buff,
sizeof(buff),
"Config effective %s ofs configuration:\n"
428 " ofs.persist %s hold %d%s%s\n"
433 pval, poscHold, (poscLog ?
" logdir " :
""),
442 {Eroute.
Say(buff); strcat(fwbuff,
" ch");}
444 {Eroute.
Say(buff); strcat(fwbuff,
" mk");}
445 if (ConfigDispFwd(buff,
fwdMV))
446 {Eroute.
Say(buff); strcat(fwbuff,
" mv");}
447 if (ConfigDispFwd(buff,
fwdRM))
448 {Eroute.
Say(buff); strcat(fwbuff,
" rm");}
450 {Eroute.
Say(buff); strcat(fwbuff,
" rd");}
452 {Eroute.
Say(buff); strcat(fwbuff,
" tr");}
472 i=sprintf(fwbuff,
"%d %d ",evsObject->
maxSmsg(),evsObject->
maxLmsg());
474 cloc = evsObject->
Prog();
475 if (*cloc !=
'>')
setBuff(
"|",1);
489 int XrdOfs::ConfigDispFwd(
char *buff,
struct fwdOpt &Fwd)
496 if (!(cP = Fwd.Cmd))
return 0;
502 if (*Fwd.Cmd ==
'+'){
setBuff(
"2way ",5); cP++;}
503 else if (!Fwd.Port) {
setBuff(
"1way ",5);}
505 if (Fwd.Port < 0) {
setBuff(
"local ",6);}
506 else {
int n = sprintf(pbuff,
":%d ", Fwd.Port);
507 setBuff(Fwd.Host, strlen(Fwd.Host));
522 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
531 char pBuff[MAXPATHLEN], *aPath;
538 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
544 rc = strlen(aPath)-1;
545 if (aPath[rc] ==
'/') aPath[rc] =
'\0';
546 free(poscLog); poscLog = aPath;
551 {Eroute.
Emsg(
"Config", rc,
"create path for", poscLog);
558 rP = poscQ->
Init(rc);
566 if (qP->
addT && poscHold)
568 {Eroute.
Emsg(
"Config",
"Unable to persist", qP->
User, qP->
LFN);
572 hP->
Retire(hCB, poscHold);
575 if (!(qP->
addT) || !poscHold)
577 {Eroute.
Emsg(
"Config", rc,
"unpersist", qP->
LFN); NoGo = 1;}
578 else {Eroute.
Emsg(
"Config",
"Unpersisted", qP->
User, qP->
LFN);
582 rPP = rP; rP = rP->
Next;
delete rPP;
640 {Eroute.
Emsg(
"Config",
"Unable to determine server's port number.");
648 if (!Balancer)
return 1;
650 {
delete Balancer; Balancer = 0;
return 1;}
673 if (!(
Cfg.
cPath = ConfigTPCDir(Eroute,
".ofs/.tpccreds/", cpath)))
681 if (!(
Cfg.
rPath = ConfigTPCDir(Eroute,
".ofs/.tpcproxy")))
return 1;
705 snprintf(rPBuff,
sizeof(rPBuff),
"%s/%x-%%d.rpx",
Cfg.
rPath,
int(time(0)));
725 char *XrdOfs::ConfigTPCDir(
XrdSysError &Eroute,
const char *sfx,
729 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
730 const int BMode = S_IRWXU| S_IRGRP|S_IXGRP;
733 char pBuff[MAXPATHLEN], *aPath;
740 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
750 {Eroute.
Emsg(
"Config", rc,
"create TPC path", aPath);
757 if (SetMode(aPath, BMode))
758 {Eroute.
Emsg(
"Config", errno,
"protect TPC path", aPath);
768 {Eroute.
Emsg(
"Config", rc,
"list TPC path", aPath);
779 {Eroute.
Emsg(
"Config", errno,
"remove TPC creds", nsX->
Path);
787 if (isBad) {free(aPath);
return 0;}
801 char *val, vBuff[64];
806 TS_XPI(
"authlib", theAutLib);
807 TS_XPI(
"ckslib", theCksLib);
809 TS_XPI(
"cmslib", theCmsLib);
811 TS_XPI(
"ctllib", theCtlLib);
813 TS_Xeq(
"forward", xforward);
814 TS_Xeq(
"maxdelay", xmaxd);
816 TS_Xeq(
"notifymsg", xnmsg);
817 TS_XPI(
"osslib", theOssLib);
819 TS_XPI(
"preplib", thePrpLib);
824 TS_XPI(
"xattrlib", theAtrLib);
836 strlcpy(vBuff, var,
sizeof(vBuff)); var = vBuff;
837 if (!(val =
Config.GetWord()))
838 {Eroute.
Emsg(
"Config",
"value not specified for", var);
return 1;}
842 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
865 static const long long maxRds = 1024*1024*1024;
871 if (!(val =
Config.GetWord()) || !val[0])
872 {Eroute.
Emsg(
"Config",
"cksrdsz size not specified");
return 1;}
876 if (
XrdOuca2x::a2sz(Eroute,
"cksrdsz size", val, &rdsz, 1, maxRds))
return 1;
877 ofsConfig->
SetCksRdSz(
static_cast<int>(rdsz));
918 static const mode_t dMin = 0700, dMax = 0775, fMin = 0600, fMax = 0664;
919 static const mode_t xBit = 0111, wBit = 0002;
921 char *colon, *val, *minM, *maxM;
927 if (!(val =
Config.GetWord()) || !val[0])
928 {Eroute.
Emsg(
"Config",
"crmode argument not specified");
return 1;}
932 do{
if (!strcmp(
"dirs", val)) {isDirs =
true; mtype =
"dirs mode";}
933 else if (!strcmp(
"files", val)) {isDirs =
false; mtype =
"files mode";}
934 else {Eroute.
Emsg(
"Config",
"invalid mode type - ", val);
938 if (!(val =
Config.GetWord()) || !val[0])
939 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
941 if (!strcmp(val,
"common"))
942 {
if (isDirs) {
dMask[0] = dMin;
dMask[1] = dMax;}
947 if (!strcmp(val,
"legacy"))
953 if ((isRaw = !strcmp(val,
"raw")))
954 {
if (!(val =
Config.GetWord()) || !val[0])
955 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
958 colon = index(val,
':');
959 if (!colon || colon == val || *(colon+1) == 0)
960 {Eroute.
Emsg(
"Config",mtype,
"mode spec requires min and max values");
963 minM = val; *colon = 0; maxM = colon + 1;
966 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", minM);
971 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", maxM);
976 {
if (isRaw) {
dMask[0] = mMask[0];
dMask[1] = mMask[1];}
977 else {
if ((mMask[0] | mMask[1]) & wBit)
978 {Eroute.
Say(
"Config warning: 'other' w-mode removed from dirs mode!");
979 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
981 dMask[0] = (mMask[0] | dMin) & dMax;
982 dMask[1] = (mMask[1] | dMin) & dMax;
985 {Eroute.
Emsg(
"Config",
"dirs mode min and max values are inconsistent!");
989 if (isRaw) {
fMask[0] = mMask[0];
fMask[1] = mMask[1];}
990 else {
if ((mMask[0] | mMask[1]) & wBit)
991 {Eroute.
Say(
"Config warning: 'other' w-mode removed from files mode!");
992 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
994 if ((mMask[0] | mMask[1]) & xBit)
995 {Eroute.
Say(
"Config warning: x-mode removed from files mode!");
996 mMask[0] &= ~xBit; mMask[1] &= ~xBit;
998 fMask[0] = (mMask[0] | fMin) & fMax;
999 fMask[1] = (mMask[1] | fMin) & fMax;
1002 {Eroute.
Emsg(
"Config",
"files mode min and max values are inconsistent!");
1006 }
while((val =
Config.GetWord()) && val[0]);
1035 if (!(val =
Config.GetWord()) || !val[0])
1036 {Eroute.
Emsg(
"Config",
"dirlist parameter not specified");
return 1;}
1040 if (!strcmp(val,
"local")) DirRdr =
false;
1041 else if (!strcmp(val,
"remote")) DirRdr =
true;
1042 else {Eroute.
Emsg(
"Config",
"Invalid dirlist parameter -", val);
return 1;}
1061 static struct rwOpts {
const char *opname;
int isRW;} rwtab[] =
1062 {{
"r/o", 0}, {
"readonly", 0},
1063 {
"forcero", 0}, {
"notwritable", 0},
1064 {
"writable", 1}, {
"r/w", 1}
1066 static bool defRW =
true;
1067 int isrw = -1, numopts =
sizeof(rwtab)/
sizeof(
struct rwOpts);
1073 if (isExport && (ossRW ==
'w' || !(val =
Config.GetWord())))
return 0;
1077 while((val =
Config.GetWord()))
1078 {
for (
int i = 0; i < numopts; i++)
1079 if (!strcmp(val, rwtab[i].opname)) isrw = rwtab[i].isRW;
1080 else if (!strcmp(val,
"cache")) {isrw = 0;
break;}
1085 if (isrw < 0) isrw = defRW;
1086 if (isExport) ossRW = (isrw ?
'w' :
'r');
1087 else {defRW = (isrw ? true :
false);
1088 if (ossRW ==
' ' && !isrw) ossRW =
'r';
1113 enum fwdType {OfsFWDALL = 0x3f, OfsFWDCHMOD = 0x01, OfsFWDMKDIR = 0x02,
1114 OfsFWDMV = 0x04, OfsFWDRM = 0x08, OfsFWDRMDIR = 0x10,
1115 OfsFWDREM = 0x18, OfsFWDTRUNC = 0x20, OfsFWDNONE = 0};
1117 static struct fwdopts {
const char *opname; fwdType opval;} fwopts[] =
1120 {
"chmod", OfsFWDCHMOD},
1121 {
"mkdir", OfsFWDMKDIR},
1124 {
"rmdir", OfsFWDRMDIR},
1125 {
"remove", OfsFWDREM},
1126 {
"trunc", OfsFWDTRUNC}
1128 int fwval = OfsFWDNONE, fwspec = OfsFWDNONE;
1129 int numopts =
sizeof(fwopts)/
sizeof(
struct fwdopts);
1130 int i, neg, rPort = 0, is2way = 0, is3way = 0;
1131 char *val, *pp, rHost[512];
1134 if (!(val =
Config.GetWord()))
1135 {Eroute.
Emsg(
"Config",
"forward option not specified");
return 1;}
1136 if ((is2way = !strcmp(
"2way", val)) || !strcmp(
"1way", val)
1137 || (is3way = !strcmp(
"3way", val)))
1138 if (!(val =
Config.GetWord()))
1139 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1142 {
if (!strcmp(
"local", val)) rPort = -1;
1145 {Eroute.
Emsg(
"Config",
"redirect host not specified");
return 1;}
1146 if (!(pp = index(val,
':')))
1147 {Eroute.
Emsg(
"Config",
"redirect port not specified");
return 1;}
1148 if ((rPort = atoi(pp+1)) <= 0)
1149 {Eroute.
Emsg(
"Config",
"redirect port is invalid");
return 1;}
1151 strlcpy(rHost, val,
sizeof(rHost));
1153 if (!(val =
Config.GetWord()))
1154 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1158 {
if (!strcmp(val,
"off")) {fwval = OfsFWDNONE; fwspec = OfsFWDALL;}
1159 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1160 for (i = 0; i < numopts; i++)
1161 {
if (!strcmp(val, fwopts[i].opname))
1162 {
if (neg) fwval &= ~fwopts[i].opval;
1163 else fwval |= fwopts[i].opval;
1164 fwspec |= fwopts[i].opval;
1169 Eroute.
Say(
"Config warning: ignoring invalid forward option '",val,
"'.");
1174 if (fwspec & OfsFWDCHMOD)
1175 {
fwdCHMOD.
Cmd = (fwval&OfsFWDCHMOD ? (is2way ?
"+chmod" :
"chmod") : 0);
1179 if (fwspec&OfsFWDMKDIR)
1180 {
fwdMKDIR.
Cmd = (fwval&OfsFWDMKDIR ? (is2way ?
"+mkdir" :
"mkdir") : 0);
1183 fwdMKPATH.
Cmd= (fwval&OfsFWDMKDIR ? (is2way ?
"+mkpath":
"mkpath") : 0);
1187 if (fwspec&OfsFWDMV)
1188 {
fwdMV .
Cmd = (fwval&OfsFWDMV ? (is2way ?
"+mv" :
"mv") : 0);
1192 if (fwspec&OfsFWDRM)
1193 {
fwdRM .
Cmd = (fwval&OfsFWDRM ? (is2way ?
"+rm" :
"rm") : 0);
1197 if (fwspec&OfsFWDRMDIR)
1198 {
fwdRMDIR.
Cmd = (fwval&OfsFWDRMDIR ? (is2way ?
"+rmdir" :
"rmdir") : 0);
1202 if (fwspec&OfsFWDTRUNC)
1203 {
fwdTRUNC.
Cmd = (fwval&OfsFWDTRUNC ? (is2way ?
"+trunc" :
"trunc") : 0);
1232 if (!(val =
Config.GetWord()))
1233 {Eroute.
Emsg(
"Config",
"maxdelay value not specified");
return 1;}
1234 if (
XrdOuca2x::a2i(Eroute,
"maxdelay", val, &maxd, 30))
return 1;
1275 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1276 char *val, buff[1024];
1282 if (!(val =
Config.GetWord()))
1283 {Eroute.
Emsg(
"Config",
"notifymsg event not specified");
1289 for (i = 0; i < numopts; i++)
if (!strcmp(val, noopts[i].opname))
break;
1291 {Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1294 noval = noopts[i].opval;
1299 myEnv =
Config.SetEnv(0);
1300 if (!
Config.GetRest(buff,
sizeof(buff)))
1301 {Eroute.
Emsg(
"Config",
"notifymsg arguments too long");
1356 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1357 int i, neg, msgL = 90, msgB = 10;
1358 char *val, parms[1024];
1360 if (!(val =
Config.GetWord()))
1361 {Eroute.
Emsg(
"Config",
"notify parameters not specified");
return 1;}
1362 while (val && *val !=
'|' && *val !=
'>')
1363 {
if (!strcmp(val,
"msgs"))
1364 {
if (!(val =
Config.GetWord()))
1365 {Eroute.
Emsg(
"Config",
"notify msgs value not specified");
1368 if (
XrdOuca2x::a2i(Eroute,
"msg count", val, &msgL, 0))
return 1;
1369 if (!(val =
Config.GetWord()))
break;
1372 if (!(val =
Config.GetWord()))
break;
1375 if ((neg = (val[0] ==
'-' && val[1]))) val++;
1377 for (i = 0; i < numopts; i++)
1378 {
if (!strcmp(val, noopts[i].opname))
1385 Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1391 if (!val) {Eroute.
Emsg(
"Config",
"notify program not specified");
return 1;}
1392 if (!noval) {Eroute.
Emsg(
"Config",
"notify events not specified");
return 1;}
1397 if (!
Config.GetRest(parms,
sizeof(parms)))
1398 {Eroute.
Emsg(
"Config",
"notify parameters too long");
return 1;}
1399 val = (*parms ==
'|' ? parms+1 : parms);
1403 if (evsObject)
delete evsObject;
1404 evsObject =
new XrdOfsEvs(noval, val, msgL, msgB);
1434 int snum = -1, htime = -1, popt = -2;
1436 if (!(val =
Config.GetWord()))
1437 {Eroute.
Emsg(
"Config",
"persist option not specified");
return 1;}
1441 if (!strcmp(val,
"auto" )) popt = 1;
1442 else if (!strcmp(val,
"off" )) popt = -1;
1443 else if (!strcmp(val,
"manual" )) popt = 0;
1447 if (popt > -2) val =
Config.GetWord();
1452 {
if (!strcmp(val,
"hold"))
1453 {
if (!(val =
Config.GetWord()))
1454 {Eroute.
Emsg(
"Config",
"persist hold value not specified");
1460 else if (!strcmp(val,
"logdir"))
1461 {
if (!(val =
Config.GetWord()))
1462 {Eroute.
Emsg(
"Config",
"persist logdir path not specified");
1465 if (poscLog) free(poscLog);
1466 poscLog = strdup(val);
1468 else if (!strcmp(val,
"sync"))
1469 {
if (!(val =
Config.GetWord()))
1470 {Eroute.
Emsg(
"Config",
"sync value not specified");
1476 else Eroute.
Say(
"Config warning: ignoring invalid persist option '",val,
"'.");
1482 if (htime >= 0) poscHold = htime;
1483 if (popt > -2) poscAuto = popt;
1484 if (snum > -1) poscSync = snum;
1533 char *val, *Tok1, *Tok2;
1538 if (!(val =
Config.GetWord()) || !strcmp(val,
"if"))
1539 {Eroute.
Emsg(
"Config",
"role not specified");
return 1;}
1544 if ((val =
Config.GetWord()) && strcmp(val,
"if"))
1545 {Tok2 = strdup(val);
1551 if (val && !strcmp(
"if", val))
1554 getenv(
"XRDPROG"))) <= 0)
1555 {free(Tok1);
if (Tok2) free(Tok2);
1556 if (!rc)
Config.noEcho();
1576 default: Eroute.
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
1582 if (Tok2) free(Tok2);
1656 char *val, pgm[1024];
1662 while((val =
Config.GetWord()))
1663 {
if (!strcmp(val,
"redirect"))
1664 {
if (rdrok)
return xtpcr(
Config, Eroute);
1665 Eroute.
Emsg(
"Config",
"tpc redirect must be seprately specified.");
1669 if (!strcmp(val,
"allow"))
1670 {
if (!xtpcal(
Config, Eroute))
return 1;
1673 if (!strcmp(val,
"cksum"))
1674 {
if (!(val =
Config.GetWord()))
1675 {Eroute.
Emsg(
"Config",
"cksum type not specified");
return 1;}
1680 if (!strcmp(val,
"scan"))
1681 {
if (!(val =
Config.GetWord()))
1682 {Eroute.
Emsg(
"Config",
"scan type not specified");
return 1;}
1683 if (strcmp(val,
"stderr")) Parms.
errMon = -2;
1684 else if (strcmp(val,
"stdout")) Parms.
errMon = -1;
1685 else if (strcmp(val,
"all" )) Parms.
errMon = 0;
1686 else {Eroute.
Emsg(
"Config",
"invalid scan type -",val);
return 1;}
1689 if (!strcmp(val,
"echo")) {Parms.
doEcho =
true;
continue;}
1690 if (!strcmp(val,
"logok")) {Parms.
LogOK =
true;
continue;}
1691 if (!strcmp(val,
"autorm")){Parms.
autoRM =
true;
continue;}
1692 if (!strcmp(val,
"oids")) {Parms.
noids =
false;
continue;}
1693 if (!strcmp(val,
"pgm"))
1694 {
if (!
Config.GetRest(pgm,
sizeof(pgm)))
1695 {Eroute.
Emsg(
"Config",
"tpc command line too long");
return 1;}
1697 {Eroute.
Emsg(
"Config",
"tpc program not specified");
return 1;}
1699 Parms.
XfrProg = strdup( pgm );
1702 if (!strcmp(val,
"require"))
1703 {
if (!(val =
Config.GetWord()))
1704 {Eroute.
Emsg(
"Config",
"tpc require parameter not specified");
return 1;}
1708 else {Eroute.
Emsg(
"Config",
"invalid tpc require type -", val);
return 1;}
1710 if (!(val =
Config.GetWord()))
1711 {Eroute.
Emsg(
"Config",
"tpc require auth not specified");
return 1;}
1715 if (!strcmp(val,
"restrict"))
1716 {
if (!(val =
Config.GetWord()))
1717 {Eroute.
Emsg(
"Config",
"tpc restrict path not specified");
return 1;}
1719 {Eroute.
Emsg(
"Config",
"tpc restrict path not absolute");
return 1;}
1723 if (!strcmp(val,
"ttl"))
1724 {
if (!(val =
Config.GetWord()))
1725 {Eroute.
Emsg(
"Config",
"tpc ttl value not specified");
return 1;}
1728 if (!(val =
Config.GetWord()))
break;
1729 if (!(isdigit(*val))) {
Config.RetToken();
continue;}
1734 if (!strcmp(val,
"xfr"))
1735 {
if (!(val =
Config.GetWord()))
1736 {Eroute.
Emsg(
"Config",
"tpc xfr value not specified");
return 1;}
1740 if (!strcmp(val,
"streams"))
1741 {
if (!(val =
Config.GetWord()))
1742 {Eroute.
Emsg(
"Config",
"tpc streams value not specified");
return 1;}
1743 char *comma = index(val,
',');
1747 {Eroute.
Emsg(
"Config",
"tpc streams max value missing");
return 1;}
1754 if (!strcmp(val,
"fcreds"))
1757 if (!(val =
Config.GetWord()) || (*val ==
'?' && *(val+1) ==
'\0'))
1758 {Eroute.
Emsg(
"Config",
"tpc fcreds auth not specified");
return 1;}
1759 if (strlen(val) >=
sizeof(aBuff))
1760 {Eroute.
Emsg(
"Config",
"invalid fcreds auth -", val);
return 1;}
1762 if (!(val =
Config.GetWord()) || *val !=
'=' || *(val+1) == 0)
1763 {Eroute.
Emsg(
"Config",
"tpc fcreds envar not specified");
return 1;}
1765 if (
emsg) {Eroute.
Emsg(
"Config",
emsg,
"-", val);
return 1;}
1768 if (!strcmp(val,
"fcpath"))
1769 {
if (!(val =
Config.GetWord()))
1770 {Eroute.
Emsg(
"Config",
"tpc fcpath arg not specified");
return 1;}
1772 Parms.
cPath = strdup(val);
1775 Eroute.
Say(
"Config warning: ignoring invalid tpc option '",val,
"'.");
1788 struct tpcalopts {
const char *opname;
char *opval;} tpopts[] =
1789 {{
"dn", 0}, {
"group", 0}, {
"host", 0}, {
"vo", 0}};
1790 int i, spec = 0, numopts =
sizeof(tpopts)/
sizeof(
struct tpcalopts);
1793 while((val =
Config.GetWord()))
1794 {
for (i = 0; i < numopts && strcmp(tpopts[i].opname, val); i++) {}
1795 if (i > numopts) {
Config.RetToken();
break;}
1796 {Eroute.
Emsg(
"Config",
"invalid tpc allow parameter -", val);
1799 if (!(val =
Config.GetWord()))
1800 {Eroute.
Emsg(
"Config",
"tpc allow",tpopts[i].opname,
"value not specified");
1803 if (tpopts[i].opval) free(tpopts[i].opval);
1804 tpopts[i].opval = strdup(val);
1808 if (!spec) {Eroute.
Emsg(
"Config",
"tpc allow parms not specified");
return 1;}
1811 tpopts[2].opval, tpopts[3].opval);
1822 const char *cgi, *cgisep, *hBeg, *hEnd, *pBeg, *pEnd, *eText;
1828 if (!(val =
Config.GetWord()))
1829 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1833 if (!strcmp(val,
"delegated")) dlgI = 0;
1834 else if (!strcmp(val,
"undelegated")) dlgI = 1;
1839 if (dlgI >= 0 && !(val =
Config.GetWord()))
1840 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1845 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1850 if (*val ==
'[') n += 2;
1851 if (n >= (
int)
sizeof(hname))
1852 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1853 strncpy(hname, val, n);
1858 if (!strcmp(hname,
"localhost"))
1861 {Eroute.
Emsg(
"Config",
"Unable to determine tpc localhost;",eText);
1864 n = snprintf(hname,
sizeof(hname),
"%s", myHost);
1866 if (n >= (
int)
sizeof(hname))
1867 {Eroute.
Emsg(
"Config",
"Invalid tpc localhost resolution -", hname);
1875 {Eroute.
Emsg(
"Config",
"tpc redirect port not specified");
return 1;}
1880 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect port;",eText);
return 1;}
1884 if (!(cgi =
Config.GetWord())) cgisep = cgi = (
char *)
"";
1885 else cgisep = (*cgi !=
'?' ?
"?" :
"");
1889 int k = (dlgI < 0 ? 0 : dlgI);
1892 n = strlen(hname) + strlen(cgisep) + strlen(cgi) + 1;
1894 snprintf(
tpcRdrHost[k], n,
"%s%s%s", hname, cgisep, cgi);
1897 }
while(dlgI < 0 && k < 2);
1921 static struct traceopts {
const char *opname;
int opval;} tropts[] =
1949 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
1952 if (!(val =
Config.GetWord()))
1953 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
1955 {
if (!strcmp(val,
"off")) trval = 0;
1956 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1957 for (i = 0; i < numopts; i++)
1958 {
if (!strcmp(val, tropts[i].opname))
1959 {
if (neg) trval &= ~tropts[i].opval;
1960 else trval |= tropts[i].opval;
1965 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
2003 static const int xanRsv = 7;
2008 while((val =
Config.GetWord()))
2009 {
if (!strcmp(
"maxnsz", val))
2010 {
if (!(val =
Config.GetWord()))
2011 {Eroute.
Emsg(
"Config",
"xattr maxnsz value not specified");
2016 maxN =
static_cast<int>(vtmp);
2018 else if (!strcmp(
"maxvsz", val))
2019 {
if (!(val =
Config.GetWord()))
2020 {Eroute.
Emsg(
"Config",
"xattr maxvsz value not specified");
2025 maxV =
static_cast<int>(vtmp);
2027 else if (!strcmp(
"uset", val))
2028 {
if (!(val =
Config.GetWord()))
2029 {Eroute.
Emsg(
"Config",
"xattr uset value not specified");
2032 if (!strcmp(
"on", val)) isOn =
true;
2033 else if (!strcmp(
"off", val)) isOn =
false;
2034 else {Eroute.
Emsg(
"Config",
"invalid xattr uset value -", val);
2038 else {Eroute.
Emsg(
"Config",
"invalid xattr option -", val);
2043 usxMaxNsz = (isOn ? maxN-xanRsv : 0);
2052 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.