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);
303 if (xrdEnv && FSctl_PC) xrdEnv->
PutPtr(
"XrdFSCtl_PC*", FSctl_PC);
317 {Eroute.
Say(
"++++++ Configuring ", myRole,
" role. . .");
318 if (ConfigRedir(Eroute,
EnvInfo))
319 {Eroute.
Emsg(
"Config",
"Unable to create cluster management client.");
328 {Eroute.
Emsg(
"Config",
"Unable to configure FSctl plugin.");
338 pcEnv.
PutPtr(
"XrdOfsHandle*", dummyHandle);
340 {Eroute.
Emsg(
"Config",
"Unable to configure cache FSctl handler.");
352 {
const char *why = 0;
355 why =
"not a pure manager";
357 {Eroute.
Say(
"Config warning: forwarding turned off; ", why);
367 if (!NoGo && evsObject) NoGo = evsObject->
Start(&Eroute);
388 if (OssIsProxy || getenv(
"XRDXROOTD_NOPOSC"))
389 {
if (poscAuto != -1 && !NoGo)
390 Eroute.
Say(
"Config POSC has been disabled by the osslib plugin.");
391 }
else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute);
400 delete ofsConfig; ofsConfig = 0;
404 tmp = (NoGo ?
" initialization failed." :
" initialization completed.");
405 Eroute.
Say(
"------ File system ", myRole, tmp);
413 #define setBuff(x,y) {strcpy(bp, x); bp += y;}
417 const char *cloc, *pval;
418 char buff[8192], fwbuff[512], *bp;
423 if (!poscQ) pval =
"off";
424 else pval = (poscAuto ?
"auto" :
"manual");
426 snprintf(buff,
sizeof(buff),
"Config effective %s ofs configuration:\n"
430 " ofs.persist %s hold %d%s%s\n"
435 pval, poscHold, (poscLog ?
" logdir " :
""),
444 {Eroute.
Say(buff); strcat(fwbuff,
" ch");}
446 {Eroute.
Say(buff); strcat(fwbuff,
" mk");}
447 if (ConfigDispFwd(buff,
fwdMV))
448 {Eroute.
Say(buff); strcat(fwbuff,
" mv");}
449 if (ConfigDispFwd(buff,
fwdRM))
450 {Eroute.
Say(buff); strcat(fwbuff,
" rm");}
452 {Eroute.
Say(buff); strcat(fwbuff,
" rd");}
454 {Eroute.
Say(buff); strcat(fwbuff,
" tr");}
474 i=sprintf(fwbuff,
"%d %d ",evsObject->
maxSmsg(),evsObject->
maxLmsg());
476 cloc = evsObject->
Prog();
477 if (*cloc !=
'>')
setBuff(
"|",1);
491 int XrdOfs::ConfigDispFwd(
char *buff,
struct fwdOpt &Fwd)
498 if (!(cP = Fwd.Cmd))
return 0;
504 if (*Fwd.Cmd ==
'+'){
setBuff(
"2way ",5); cP++;}
505 else if (!Fwd.Port) {
setBuff(
"1way ",5);}
507 if (Fwd.Port < 0) {
setBuff(
"local ",6);}
508 else {
int n = sprintf(pbuff,
":%d ", Fwd.Port);
509 setBuff(Fwd.Host, strlen(Fwd.Host));
524 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
533 char pBuff[MAXPATHLEN], *aPath;
540 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
546 rc = strlen(aPath)-1;
547 if (aPath[rc] ==
'/') aPath[rc] =
'\0';
548 free(poscLog); poscLog = aPath;
553 {Eroute.
Emsg(
"Config", rc,
"create path for", poscLog);
560 rP = poscQ->
Init(rc);
568 if (qP->
addT && poscHold)
570 {Eroute.
Emsg(
"Config",
"Unable to persist", qP->
User, qP->
LFN);
574 hP->
Retire(hCB, poscHold);
577 if (!(qP->
addT) || !poscHold)
579 {Eroute.
Emsg(
"Config", rc,
"unpersist", qP->
LFN); NoGo = 1;}
580 else {Eroute.
Emsg(
"Config",
"Unpersisted", qP->
User, qP->
LFN);
584 rPP = rP; rP = rP->
Next;
delete rPP;
642 {Eroute.
Emsg(
"Config",
"Unable to determine server's port number.");
650 if (!Balancer)
return 1;
652 {
delete Balancer; Balancer = 0;
return 1;}
675 if (!(
Cfg.
cPath = ConfigTPCDir(Eroute,
".ofs/.tpccreds/", cpath)))
683 if (!(
Cfg.
rPath = ConfigTPCDir(Eroute,
".ofs/.tpcproxy")))
return 1;
707 snprintf(rPBuff,
sizeof(rPBuff),
"%s/%x-%%d.rpx",
Cfg.
rPath,
int(time(0)));
727 char *XrdOfs::ConfigTPCDir(
XrdSysError &Eroute,
const char *sfx,
731 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
732 const int BMode = S_IRWXU| S_IRGRP|S_IXGRP;
735 char pBuff[MAXPATHLEN], *aPath;
742 else {
if (!(aPath = getenv(
"XRDADMINPATH")))
752 {Eroute.
Emsg(
"Config", rc,
"create TPC path", aPath);
759 if (SetMode(aPath, BMode))
760 {Eroute.
Emsg(
"Config", errno,
"protect TPC path", aPath);
770 {Eroute.
Emsg(
"Config", rc,
"list TPC path", aPath);
781 {Eroute.
Emsg(
"Config", errno,
"remove TPC creds", nsX->
Path);
789 if (isBad) {free(aPath);
return 0;}
803 char *val, vBuff[64];
808 TS_XPI(
"authlib", theAutLib);
809 TS_XPI(
"ckslib", theCksLib);
811 TS_XPI(
"cmslib", theCmsLib);
813 TS_XPI(
"ctllib", theCtlLib);
815 TS_Xeq(
"forward", xforward);
816 TS_Xeq(
"maxdelay", xmaxd);
818 TS_Xeq(
"notifymsg", xnmsg);
819 TS_XPI(
"osslib", theOssLib);
821 TS_XPI(
"preplib", thePrpLib);
826 TS_XPI(
"xattrlib", theAtrLib);
838 strlcpy(vBuff, var,
sizeof(vBuff)); var = vBuff;
839 if (!(val =
Config.GetWord()))
840 {Eroute.
Emsg(
"Config",
"value not specified for", var);
return 1;}
844 Eroute.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
867 static const long long maxRds = 1024*1024*1024;
873 if (!(val =
Config.GetWord()) || !val[0])
874 {Eroute.
Emsg(
"Config",
"cksrdsz size not specified");
return 1;}
878 if (
XrdOuca2x::a2sz(Eroute,
"cksrdsz size", val, &rdsz, 1, maxRds))
return 1;
879 ofsConfig->
SetCksRdSz(
static_cast<int>(rdsz));
920 static const mode_t dMin = 0700, dMax = 0775, fMin = 0600, fMax = 0664;
921 static const mode_t xBit = 0111, wBit = 0002;
923 char *colon, *val, *minM, *maxM;
929 if (!(val =
Config.GetWord()) || !val[0])
930 {Eroute.
Emsg(
"Config",
"crmode argument not specified");
return 1;}
934 do{
if (!strcmp(
"dirs", val)) {isDirs =
true; mtype =
"dirs mode";}
935 else if (!strcmp(
"files", val)) {isDirs =
false; mtype =
"files mode";}
936 else {Eroute.
Emsg(
"Config",
"invalid mode type - ", val);
940 if (!(val =
Config.GetWord()) || !val[0])
941 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
943 if (!strcmp(val,
"common"))
944 {
if (isDirs) {
dMask[0] = dMin;
dMask[1] = dMax;}
949 if (!strcmp(val,
"legacy"))
955 if ((isRaw = !strcmp(val,
"raw")))
956 {
if (!(val =
Config.GetWord()) || !val[0])
957 {Eroute.
Emsg(
"Config", mtype,
"value not specified");
return 1;}
960 colon = index(val,
':');
961 if (!colon || colon == val || *(colon+1) == 0)
962 {Eroute.
Emsg(
"Config",mtype,
"mode spec requires min and max values");
965 minM = val; *colon = 0; maxM = colon + 1;
968 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", minM);
973 {Eroute.
Emsg(
"Config", mtype,
"value is invalid -", maxM);
978 {
if (isRaw) {
dMask[0] = mMask[0];
dMask[1] = mMask[1];}
979 else {
if ((mMask[0] | mMask[1]) & wBit)
980 {Eroute.
Say(
"Config warning: 'other' w-mode removed from dirs mode!");
981 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
983 dMask[0] = (mMask[0] | dMin) & dMax;
984 dMask[1] = (mMask[1] | dMin) & dMax;
987 {Eroute.
Emsg(
"Config",
"dirs mode min and max values are inconsistent!");
991 if (isRaw) {
fMask[0] = mMask[0];
fMask[1] = mMask[1];}
992 else {
if ((mMask[0] | mMask[1]) & wBit)
993 {Eroute.
Say(
"Config warning: 'other' w-mode removed from files mode!");
994 mMask[0] &= ~wBit; mMask[1] &= ~wBit;
996 if ((mMask[0] | mMask[1]) & xBit)
997 {Eroute.
Say(
"Config warning: x-mode removed from files mode!");
998 mMask[0] &= ~xBit; mMask[1] &= ~xBit;
1000 fMask[0] = (mMask[0] | fMin) & fMax;
1001 fMask[1] = (mMask[1] | fMin) & fMax;
1004 {Eroute.
Emsg(
"Config",
"files mode min and max values are inconsistent!");
1008 }
while((val =
Config.GetWord()) && val[0]);
1037 if (!(val =
Config.GetWord()) || !val[0])
1038 {Eroute.
Emsg(
"Config",
"dirlist parameter not specified");
return 1;}
1042 if (!strcmp(val,
"local")) DirRdr =
false;
1043 else if (!strcmp(val,
"remote")) DirRdr =
true;
1044 else {Eroute.
Emsg(
"Config",
"Invalid dirlist parameter -", val);
return 1;}
1063 static struct rwOpts {
const char *opname;
int isRW;} rwtab[] =
1064 {{
"r/o", 0}, {
"readonly", 0},
1065 {
"forcero", 0}, {
"notwritable", 0},
1066 {
"writable", 1}, {
"r/w", 1}
1068 static bool defRW =
true;
1069 int isrw = -1, numopts =
sizeof(rwtab)/
sizeof(
struct rwOpts);
1075 if (isExport && (ossRW ==
'w' || !(val =
Config.GetWord())))
return 0;
1079 while((val =
Config.GetWord()))
1080 {
for (
int i = 0; i < numopts; i++)
1081 if (!strcmp(val, rwtab[i].opname)) isrw = rwtab[i].isRW;
1082 else if (!strcmp(val,
"cache")) {isrw = 0;
break;}
1087 if (isrw < 0) isrw = defRW;
1088 if (isExport) ossRW = (isrw ?
'w' :
'r');
1089 else {defRW = (isrw ? true :
false);
1090 if (ossRW ==
' ' && !isrw) ossRW =
'r';
1115 enum fwdType {OfsFWDALL = 0x3f, OfsFWDCHMOD = 0x01, OfsFWDMKDIR = 0x02,
1116 OfsFWDMV = 0x04, OfsFWDRM = 0x08, OfsFWDRMDIR = 0x10,
1117 OfsFWDREM = 0x18, OfsFWDTRUNC = 0x20, OfsFWDNONE = 0};
1119 static struct fwdopts {
const char *opname; fwdType opval;} fwopts[] =
1122 {
"chmod", OfsFWDCHMOD},
1123 {
"mkdir", OfsFWDMKDIR},
1126 {
"rmdir", OfsFWDRMDIR},
1127 {
"remove", OfsFWDREM},
1128 {
"trunc", OfsFWDTRUNC}
1130 int fwval = OfsFWDNONE, fwspec = OfsFWDNONE;
1131 int numopts =
sizeof(fwopts)/
sizeof(
struct fwdopts);
1132 int i, neg, rPort = 0, is2way = 0, is3way = 0;
1133 char *val, *pp, rHost[512];
1136 if (!(val =
Config.GetWord()))
1137 {Eroute.
Emsg(
"Config",
"forward option not specified");
return 1;}
1138 if ((is2way = !strcmp(
"2way", val)) || !strcmp(
"1way", val)
1139 || (is3way = !strcmp(
"3way", val)))
1140 if (!(val =
Config.GetWord()))
1141 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1144 {
if (!strcmp(
"local", val)) rPort = -1;
1147 {Eroute.
Emsg(
"Config",
"redirect host not specified");
return 1;}
1148 if (!(pp = index(val,
':')))
1149 {Eroute.
Emsg(
"Config",
"redirect port not specified");
return 1;}
1150 if ((rPort = atoi(pp+1)) <= 0)
1151 {Eroute.
Emsg(
"Config",
"redirect port is invalid");
return 1;}
1153 strlcpy(rHost, val,
sizeof(rHost));
1155 if (!(val =
Config.GetWord()))
1156 {Eroute.
Emsg(
"Config",
"forward operation not specified");
return 1;}
1160 {
if (!strcmp(val,
"off")) {fwval = OfsFWDNONE; fwspec = OfsFWDALL;}
1161 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1162 for (i = 0; i < numopts; i++)
1163 {
if (!strcmp(val, fwopts[i].opname))
1164 {
if (neg) fwval &= ~fwopts[i].opval;
1165 else fwval |= fwopts[i].opval;
1166 fwspec |= fwopts[i].opval;
1171 Eroute.
Say(
"Config warning: ignoring invalid forward option '",val,
"'.");
1176 if (fwspec & OfsFWDCHMOD)
1177 {
fwdCHMOD.
Cmd = (fwval&OfsFWDCHMOD ? (is2way ?
"+chmod" :
"chmod") : 0);
1181 if (fwspec&OfsFWDMKDIR)
1182 {
fwdMKDIR.
Cmd = (fwval&OfsFWDMKDIR ? (is2way ?
"+mkdir" :
"mkdir") : 0);
1185 fwdMKPATH.
Cmd= (fwval&OfsFWDMKDIR ? (is2way ?
"+mkpath":
"mkpath") : 0);
1189 if (fwspec&OfsFWDMV)
1190 {
fwdMV .
Cmd = (fwval&OfsFWDMV ? (is2way ?
"+mv" :
"mv") : 0);
1194 if (fwspec&OfsFWDRM)
1195 {
fwdRM .
Cmd = (fwval&OfsFWDRM ? (is2way ?
"+rm" :
"rm") : 0);
1199 if (fwspec&OfsFWDRMDIR)
1200 {
fwdRMDIR.
Cmd = (fwval&OfsFWDRMDIR ? (is2way ?
"+rmdir" :
"rmdir") : 0);
1204 if (fwspec&OfsFWDTRUNC)
1205 {
fwdTRUNC.
Cmd = (fwval&OfsFWDTRUNC ? (is2way ?
"+trunc" :
"trunc") : 0);
1234 if (!(val =
Config.GetWord()))
1235 {Eroute.
Emsg(
"Config",
"maxdelay value not specified");
return 1;}
1236 if (
XrdOuca2x::a2i(Eroute,
"maxdelay", val, &maxd, 30))
return 1;
1277 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1278 char *val, buff[1024];
1284 if (!(val =
Config.GetWord()))
1285 {Eroute.
Emsg(
"Config",
"notifymsg event not specified");
1291 for (i = 0; i < numopts; i++)
if (!strcmp(val, noopts[i].opname))
break;
1293 {Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1296 noval = noopts[i].opval;
1301 myEnv =
Config.SetEnv(0);
1302 if (!
Config.GetRest(buff,
sizeof(buff)))
1303 {Eroute.
Emsg(
"Config",
"notifymsg arguments too long");
1358 int numopts =
sizeof(noopts)/
sizeof(
struct notopts);
1359 int i, neg, msgL = 90, msgB = 10;
1360 char *val, parms[1024];
1362 if (!(val =
Config.GetWord()))
1363 {Eroute.
Emsg(
"Config",
"notify parameters not specified");
return 1;}
1364 while (val && *val !=
'|' && *val !=
'>')
1365 {
if (!strcmp(val,
"msgs"))
1366 {
if (!(val =
Config.GetWord()))
1367 {Eroute.
Emsg(
"Config",
"notify msgs value not specified");
1370 if (
XrdOuca2x::a2i(Eroute,
"msg count", val, &msgL, 0))
return 1;
1371 if (!(val =
Config.GetWord()))
break;
1374 if (!(val =
Config.GetWord()))
break;
1377 if ((neg = (val[0] ==
'-' && val[1]))) val++;
1379 for (i = 0; i < numopts; i++)
1380 {
if (!strcmp(val, noopts[i].opname))
1387 Eroute.
Say(
"Config warning: ignoring invalid notify event '",val,
"'.");
1393 if (!val) {Eroute.
Emsg(
"Config",
"notify program not specified");
return 1;}
1394 if (!noval) {Eroute.
Emsg(
"Config",
"notify events not specified");
return 1;}
1399 if (!
Config.GetRest(parms,
sizeof(parms)))
1400 {Eroute.
Emsg(
"Config",
"notify parameters too long");
return 1;}
1401 val = (*parms ==
'|' ? parms+1 : parms);
1405 if (evsObject)
delete evsObject;
1406 evsObject =
new XrdOfsEvs(noval, val, msgL, msgB);
1436 int snum = -1, htime = -1, popt = -2;
1438 if (!(val =
Config.GetWord()))
1439 {Eroute.
Emsg(
"Config",
"persist option not specified");
return 1;}
1443 if (!strcmp(val,
"auto" )) popt = 1;
1444 else if (!strcmp(val,
"off" )) popt = -1;
1445 else if (!strcmp(val,
"manual" )) popt = 0;
1449 if (popt > -2) val =
Config.GetWord();
1454 {
if (!strcmp(val,
"hold"))
1455 {
if (!(val =
Config.GetWord()))
1456 {Eroute.
Emsg(
"Config",
"persist hold value not specified");
1462 else if (!strcmp(val,
"logdir"))
1463 {
if (!(val =
Config.GetWord()))
1464 {Eroute.
Emsg(
"Config",
"persist logdir path not specified");
1467 if (poscLog) free(poscLog);
1468 poscLog = strdup(val);
1470 else if (!strcmp(val,
"sync"))
1471 {
if (!(val =
Config.GetWord()))
1472 {Eroute.
Emsg(
"Config",
"sync value not specified");
1478 else Eroute.
Say(
"Config warning: ignoring invalid persist option '",val,
"'.");
1484 if (htime >= 0) poscHold = htime;
1485 if (popt > -2) poscAuto = popt;
1486 if (snum > -1) poscSync = snum;
1535 char *val, *Tok1, *Tok2;
1540 if (!(val =
Config.GetWord()) || !strcmp(val,
"if"))
1541 {Eroute.
Emsg(
"Config",
"role not specified");
return 1;}
1546 if ((val =
Config.GetWord()) && strcmp(val,
"if"))
1547 {Tok2 = strdup(val);
1553 if (val && !strcmp(
"if", val))
1556 getenv(
"XRDPROG"))) <= 0)
1557 {free(Tok1);
if (Tok2) free(Tok2);
1558 if (!rc)
Config.noEcho();
1578 default: Eroute.
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
1584 if (Tok2) free(Tok2);
1658 char *val, pgm[1024];
1664 while((val =
Config.GetWord()))
1665 {
if (!strcmp(val,
"redirect"))
1666 {
if (rdrok)
return xtpcr(
Config, Eroute);
1667 Eroute.
Emsg(
"Config",
"tpc redirect must be seprately specified.");
1671 if (!strcmp(val,
"allow"))
1672 {
if (!xtpcal(
Config, Eroute))
return 1;
1675 if (!strcmp(val,
"cksum"))
1676 {
if (!(val =
Config.GetWord()))
1677 {Eroute.
Emsg(
"Config",
"cksum type not specified");
return 1;}
1682 if (!strcmp(val,
"scan"))
1683 {
if (!(val =
Config.GetWord()))
1684 {Eroute.
Emsg(
"Config",
"scan type not specified");
return 1;}
1685 if (strcmp(val,
"stderr")) Parms.
errMon = -2;
1686 else if (strcmp(val,
"stdout")) Parms.
errMon = -1;
1687 else if (strcmp(val,
"all" )) Parms.
errMon = 0;
1688 else {Eroute.
Emsg(
"Config",
"invalid scan type -",val);
return 1;}
1691 if (!strcmp(val,
"echo")) {Parms.
doEcho =
true;
continue;}
1692 if (!strcmp(val,
"logok")) {Parms.
LogOK =
true;
continue;}
1693 if (!strcmp(val,
"autorm")){Parms.
autoRM =
true;
continue;}
1694 if (!strcmp(val,
"oids")) {Parms.
noids =
false;
continue;}
1695 if (!strcmp(val,
"pgm"))
1696 {
if (!
Config.GetRest(pgm,
sizeof(pgm)))
1697 {Eroute.
Emsg(
"Config",
"tpc command line too long");
return 1;}
1699 {Eroute.
Emsg(
"Config",
"tpc program not specified");
return 1;}
1701 Parms.
XfrProg = strdup( pgm );
1704 if (!strcmp(val,
"require"))
1705 {
if (!(val =
Config.GetWord()))
1706 {Eroute.
Emsg(
"Config",
"tpc require parameter not specified");
return 1;}
1710 else {Eroute.
Emsg(
"Config",
"invalid tpc require type -", val);
return 1;}
1712 if (!(val =
Config.GetWord()))
1713 {Eroute.
Emsg(
"Config",
"tpc require auth not specified");
return 1;}
1717 if (!strcmp(val,
"restrict"))
1718 {
if (!(val =
Config.GetWord()))
1719 {Eroute.
Emsg(
"Config",
"tpc restrict path not specified");
return 1;}
1721 {Eroute.
Emsg(
"Config",
"tpc restrict path not absolute");
return 1;}
1725 if (!strcmp(val,
"ttl"))
1726 {
if (!(val =
Config.GetWord()))
1727 {Eroute.
Emsg(
"Config",
"tpc ttl value not specified");
return 1;}
1730 if (!(val =
Config.GetWord()))
break;
1731 if (!(isdigit(*val))) {
Config.RetToken();
continue;}
1736 if (!strcmp(val,
"xfr"))
1737 {
if (!(val =
Config.GetWord()))
1738 {Eroute.
Emsg(
"Config",
"tpc xfr value not specified");
return 1;}
1742 if (!strcmp(val,
"streams"))
1743 {
if (!(val =
Config.GetWord()))
1744 {Eroute.
Emsg(
"Config",
"tpc streams value not specified");
return 1;}
1745 char *comma = index(val,
',');
1749 {Eroute.
Emsg(
"Config",
"tpc streams max value missing");
return 1;}
1756 if (!strcmp(val,
"fcreds"))
1759 if (!(val =
Config.GetWord()) || (*val ==
'?' && *(val+1) ==
'\0'))
1760 {Eroute.
Emsg(
"Config",
"tpc fcreds auth not specified");
return 1;}
1761 if (strlen(val) >=
sizeof(aBuff))
1762 {Eroute.
Emsg(
"Config",
"invalid fcreds auth -", val);
return 1;}
1764 if (!(val =
Config.GetWord()) || *val !=
'=' || *(val+1) == 0)
1765 {Eroute.
Emsg(
"Config",
"tpc fcreds envar not specified");
return 1;}
1767 if (
emsg) {Eroute.
Emsg(
"Config",
emsg,
"-", val);
return 1;}
1770 if (!strcmp(val,
"fcpath"))
1771 {
if (!(val =
Config.GetWord()))
1772 {Eroute.
Emsg(
"Config",
"tpc fcpath arg not specified");
return 1;}
1774 Parms.
cPath = strdup(val);
1777 Eroute.
Say(
"Config warning: ignoring invalid tpc option '",val,
"'.");
1790 struct tpcalopts {
const char *opname;
char *opval;} tpopts[] =
1791 {{
"dn", 0}, {
"group", 0}, {
"host", 0}, {
"vo", 0}};
1792 int i, spec = 0, numopts =
sizeof(tpopts)/
sizeof(
struct tpcalopts);
1795 while((val =
Config.GetWord()))
1796 {
for (i = 0; i < numopts && strcmp(tpopts[i].opname, val); i++) {}
1797 if (i > numopts) {
Config.RetToken();
break;}
1798 {Eroute.
Emsg(
"Config",
"invalid tpc allow parameter -", val);
1801 if (!(val =
Config.GetWord()))
1802 {Eroute.
Emsg(
"Config",
"tpc allow",tpopts[i].opname,
"value not specified");
1805 if (tpopts[i].opval) free(tpopts[i].opval);
1806 tpopts[i].opval = strdup(val);
1810 if (!spec) {Eroute.
Emsg(
"Config",
"tpc allow parms not specified");
return 1;}
1813 tpopts[2].opval, tpopts[3].opval);
1824 const char *cgi, *cgisep, *hBeg, *hEnd, *pBeg, *pEnd, *eText;
1830 if (!(val =
Config.GetWord()))
1831 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1835 if (!strcmp(val,
"delegated")) dlgI = 0;
1836 else if (!strcmp(val,
"undelegated")) dlgI = 1;
1841 if (dlgI >= 0 && !(val =
Config.GetWord()))
1842 {Eroute.
Emsg(
"Config",
"tpc redirect host not specified");
return 1;}
1847 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1852 if (*val ==
'[') n += 2;
1853 if (n >= (
int)
sizeof(hname))
1854 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect target -", val);
return 1;}
1855 strncpy(hname, val, n);
1860 if (!strcmp(hname,
"localhost"))
1863 {Eroute.
Emsg(
"Config",
"Unable to determine tpc localhost;",eText);
1866 n = snprintf(hname,
sizeof(hname),
"%s", myHost);
1868 if (n >= (
int)
sizeof(hname))
1869 {Eroute.
Emsg(
"Config",
"Invalid tpc localhost resolution -", hname);
1877 {Eroute.
Emsg(
"Config",
"tpc redirect port not specified");
return 1;}
1882 {Eroute.
Emsg(
"Config",
"Invalid tpc redirect port;",eText);
return 1;}
1886 if (!(cgi =
Config.GetWord())) cgisep = cgi = (
char *)
"";
1887 else cgisep = (*cgi !=
'?' ?
"?" :
"");
1891 int k = (dlgI < 0 ? 0 : dlgI);
1894 n = strlen(hname) + strlen(cgisep) + strlen(cgi) + 1;
1896 snprintf(
tpcRdrHost[k], n,
"%s%s%s", hname, cgisep, cgi);
1899 }
while(dlgI < 0 && k < 2);
1923 static struct traceopts {
const char *opname;
int opval;} tropts[] =
1951 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
1954 if (!(val =
Config.GetWord()))
1955 {Eroute.
Emsg(
"Config",
"trace option not specified");
return 1;}
1957 {
if (!strcmp(val,
"off")) trval = 0;
1958 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
1959 for (i = 0; i < numopts; i++)
1960 {
if (!strcmp(val, tropts[i].opname))
1961 {
if (neg) trval &= ~tropts[i].opval;
1962 else trval |= tropts[i].opval;
1967 Eroute.
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
2005 static const int xanRsv = 7;
2010 while((val =
Config.GetWord()))
2011 {
if (!strcmp(
"maxnsz", val))
2012 {
if (!(val =
Config.GetWord()))
2013 {Eroute.
Emsg(
"Config",
"xattr maxnsz value not specified");
2018 maxN =
static_cast<int>(vtmp);
2020 else if (!strcmp(
"maxvsz", val))
2021 {
if (!(val =
Config.GetWord()))
2022 {Eroute.
Emsg(
"Config",
"xattr maxvsz value not specified");
2027 maxV =
static_cast<int>(vtmp);
2029 else if (!strcmp(
"uset", val))
2030 {
if (!(val =
Config.GetWord()))
2031 {Eroute.
Emsg(
"Config",
"xattr uset value not specified");
2034 if (!strcmp(
"on", val)) isOn =
true;
2035 else if (!strcmp(
"off", val)) isOn =
false;
2036 else {Eroute.
Emsg(
"Config",
"invalid xattr uset value -", val);
2040 else {Eroute.
Emsg(
"Config",
"invalid xattr option -", val);
2045 usxMaxNsz = (isOn ? maxN-xanRsv : 0);
2054 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.