36#include <unordered_set>
43#include "XrdSys/XrdWin32.hh"
66#define ENODATA ENOATTR
79 idInfo(
const char *name, time_t keep)
80 : Expr(time(0)+keep), Name(strdup(name)) {}
81 ~idInfo() {free(Name);}
84typedef std::map<unsigned int, struct idInfo*> idMap_t;
90void AddID(idMap_t &idMap,
unsigned int id,
const char *name, time_t keepT)
92 std::pair<idMap_t::iterator,bool> ret;
93 idInfo *infoP =
new idInfo(name, keepT);
96 ret = idMap.insert(std::pair<unsigned int, struct idInfo*>(
id, infoP));
97 if (ret.second ==
false)
delete infoP;
101int LookUp(idMap_t &idMap,
unsigned int id,
char *buff,
int blen)
103 idMap_t::iterator it;
108 if (it != idMap.end())
109 {
if (it->second->Expr <= time(0))
113 if (blen > 0) luRet = snprintf(buff, blen,
"%s", it->second->Name);
132for (j = 0; j < argC; j++)
133 {
while(*aP ==
' ') aP++;
136 if (*aP ==
'"' || *aP ==
'\'')
138 aP = index(aP+1, *aP);
139 if (!aP || (*(aP+1) !=
' ' && *(aP+1)))
140 {
if (!j) argV[0] = 0;
return -EINVAL;}
144 if ((aP = index(aP+1,
' '))) *aP++ =
'\0';
152 if (j > argC-1)
return -E2BIG;
167 static const char hv[] =
"0123456789abcdef";
168 char *outbuff = buff;
169 for (
int i = 0; i < dlen && blen > 2; i++) {
170 *outbuff++ = hv[(inbuff[i] >> 4) & 0x0f];
171 *outbuff++ = hv[ inbuff[i] & 0x0f];
173 if (sep && blen > 1 && ((i & 0x03) == 0x03 || i+1 == dlen))
174 {*outbuff++ =
' '; blen--;}
186 int len = 0, lo = -1, hi = -1;
188 while (
int c = *hex++) {
189 if (c ==
' ' || c ==
'\n')
217 bin[len++] = (hi << 4) | lo;
220 if (hi >= 0 || lo >= 0 || len == 0)
231 int tlen = strlen(text);
233 return (tlen >= endlen && !strcmp(text+(tlen-endlen), ending));
278 const char *what,
const char *hname,
279 const char *nname,
const char *pname)
281 static const char *brk[] = {
"defined",
"exec",
"named", 0};
288 if (!(val = Config.GetWord()))
289 {
if (
eDest)
eDest->Emsg(
"Config",
"Host name missing after 'if' in", what);
295 if (!
is1of(val, brk))
297 val = Config.GetWord();
298 }
while(!hostok && val && !
is1of(val, brk));
300 {
while(val && !
is1of(val, brk)) val = Config.GetWord();
308 while(!strcmp(val,
"defined"))
309 {
if (!(val = Config.GetWord()) || *val !=
'?')
311 {
eDest->Emsg(
"Config",
"'?var' missing after 'defined' in",what);}
316 if (!theEnv && (theEnv = Config.SetEnv(0))) Config.SetEnv(theEnv);
317 if (!theEnv && *(val+1) !=
'~')
return 0;
322 while(val && *val ==
'?')
323 {
if (*(val+1) ==
'~' ? getenv(val+2) : theEnv->
Get(val+1)) isDef=1;
324 val = Config.GetWord();
326 if (!val || !isDef)
return isDef;
327 if (strcmp(val,
"&&"))
329 {
eDest->Emsg(
"Config",val,
"is invalid for defined test in",what);}
332 if (!(val = Config.GetWord()))
334 {
eDest->Emsg(
"Config",
"missing keyword after '&&' in",what);}
338 if (!
is1of(val, brk))
340 {
eDest->Emsg(
"Config",val,
"is invalid after '&&' in",what);}
348 if (!strcmp(val,
"exec"))
349 {
if (!(val = Config.GetWord()) || !strcmp(val,
"&&"))
351 {
eDest->Emsg(
"Config",
"Program name missing after 'if exec' in",what);}
357 if (!pname)
return 0;
358 while(val && strcmp(val, pname))
359 if (!strcmp(val,
"&&"))
return 0;
360 else val = Config.GetWord();
362 while(val && strcmp(val,
"&&")) val = Config.GetWord();
365 if (!(val = Config.GetWord()))
367 {
eDest->Emsg(
"Config",
"Keyword missing after '&&' in",what);}
370 if (strcmp(val,
"named"))
372 {
eDest->Emsg(
"Config",val,
"is invalid after '&&' in",what);}
380 if (!(val = Config.GetWord()))
382 {
eDest->Emsg(
"Config",
"Instance name missing after 'if named' in", what);}
388 if (!nname)
return 0;
389 while(val && strcmp(val, nname)) val = Config.GetWord();
407 {
if (
stat(pgm, &
Stat) || !(
Stat.st_mode & S_IXOTH))
return false;
414 const char *pEnv = getenv(
"PATH");
415 if (!pEnv)
return false;
421 prog +=
'/'; prog += pgm;
425 while((from = pList.
tokenize(path, from,
':')) != -1)
438 static const long long Kval = 1024LL;
439 static const long long Mval = 1024LL*1024LL;
440 static const long long Gval = 1024LL*1024LL*1024LL;
441 static const long long Tval = 1024LL*1024LL*1024LL*1024LL;
447 if (val < 1024)
return snprintf(buff, bsz,
"%lld", val);
448 if (val < Mval) {val = val*10/Kval; sName =
'K';}
449 else if (val < Gval) {val = val*10/Mval; sName =
'M';}
450 else if (val < Tval) {val = val*10/Gval; sName =
'G';}
451 else {val = val*10/Tval; sName =
'T';}
452 resid = val%10LL; val = val/10LL;
456 return snprintf(buff, bsz,
"%lld.%d%c", val, resid, sName);
467 int i =
strlcpy(buff, p_path,
sizeof(buff));
469 if (buff[i-1] !=
'/') {buff[i++] =
'/'; buff[i] =
'\0';}
470 if (inst) {strcpy(buff+i, inst); strcat(buff,
"/");}
471 if (s_path) strcat(buff, s_path);
474 if (buff[i-1] !=
'/') {buff[i++] =
'/'; buff[i] =
'\0';}
486 j = (psfx ? strlen(psfx) : 0);
487 if (i+j+3 > blen)
return -ENAMETOOLONG;
491 {
if (buff[i-1] !=
'/') buff[i++] =
'/';
492 strcpy(&buff[i], psfx);
493 if (psfx[j-1] !=
'/') strcat(buff,
"/");
508 ~fdHelper() {
if (fd >= 0)
close(fd);}
519 if ((file.fd =
open(path, O_RDONLY)) < 0) {rc = errno;
return 0;}
523 if (
fstat(file.fd, &
Stat)) {rc = errno;
return 0;}
527 if (
Stat.st_size > maxsz) {rc = EFBIG;
return 0;}
531 if (
Stat.st_size == 0 && notempty) {rc =
ENODATA;
return 0;}
535 if ((buff = (
char *)malloc(
Stat.st_size+1)) == 0)
536 {rc = errno;
return 0;}
541 {
if ((flen =
read(file.fd, buff,
Stat.st_size)) < 0)
542 {rc = errno; free(buff);
return 0;}
561 struct group Grp, *result;
564 getgrnam_r(gName, &Grp, buff,
sizeof(buff), &result);
565 if (!result)
return false;
577 struct passwd pwd, *result;
580 getpwnam_r(uName, &pwd, buff,
sizeof(buff), &result);
581 if (!result)
return false;
584 if (gID) *gID = pwd.pw_gid;
595 static const int maxgBsz = 256*1024;
596 static const int addGsz = 4096;
597 struct group *gEnt, gStruct;
598 char gBuff[1024], *gBp = gBuff;
599 int glen = 0, gBsz =
sizeof(gBuff), aOK = 1;
605 {
int n = LookUp(gidMap,
static_cast<unsigned int>(gID),gName,gNsz);
606 if (n > 0)
return (n < gNsz ? n : 0);
612 while(( retVal = getgrgid_r(gID, &gStruct, gBp, gBsz, &gEnt) ) == ERANGE)
613 {
if (gBsz >= maxgBsz) {aOK = 0;
break;}
614 if (gBsz > addGsz) free(gBp);
616 if (!(gBp = (
char *)malloc(gBsz))) {aOK = 0;
break;}
621 if (aOK && retVal == 0 && gEnt != NULL)
623 AddID(gidMap,
static_cast<unsigned int>(gID), gEnt->gr_name, keepT);
624 glen = strlen(gEnt->gr_name);
625 if (glen >= gNsz) glen = 0;
626 else strcpy(gName, gEnt->gr_name);
628 n = snprintf(gName, gNsz,
"%ud",
static_cast<unsigned int>(gID));
629 if (n >= gNsz) glen = 0;
634 if (gBsz > addGsz && gBp) free(gBp);
644 static const int maxgBsz = 256*1024;
645 static const int addGsz = 4096;
646 struct group *gEnt, gStruct;
647 char gBuff[1024], *gBp = gBuff;
648 int glen, gBsz =
sizeof(gBuff), aOK = 1;
654 while(( retVal = getgrgid_r(gID, &gStruct, gBp, gBsz, &gEnt) ) == ERANGE)
655 {
if (gBsz >= maxgBsz) {aOK = 0;
break;}
656 if (gBsz > addGsz) free(gBp);
658 if (!(gBp = (
char *)malloc(gBsz))) {aOK = 0;
break;}
663 if (aOK && retVal == 0 && gEnt != NULL)
664 {glen = strlen(gEnt->gr_name);
665 if (glen >= gNsz) glen = 0;
666 else strcpy(gName, gEnt->gr_name);
671 if (gBsz > addGsz && gBp) free(gBp);
685 {snprintf(buff, bsz,
"%zu", bytes);
691 const char *suffix =
" KMGTPEYZ";
692 double dBytes =
static_cast<double>(bytes);
694do{dBytes /= 1024.0; suffix++;
695 }
while(dBytes >= 1024.0 && *(suffix+1));
700 double whole, frac = modf(dBytes, &whole);
701 if (frac >= .005) snprintf(buff, bsz,
"%.02lf%c", dBytes, *suffix);
702 else snprintf(buff, bsz,
"%g%c", whole, *suffix);
712 char zo[2] = {
'0',
'1'};
714 if (blen < 2)
return "";
717 if (!val) buff[blen--] =
'0';
718 else while(val && blen >= 0)
719 {buff[blen--] = zo[val & 0x01];
723 if (blen >= 0 && pad)
while(blen >= 0) buff[blen--] =
'0';
725 return &buff[blen+1];
734long long genSID(
char *&urSID,
const char *iHost,
int iPort,
735 const char *iName,
const char *iProg)
738 static const uint32_t fpOffs = 2, fpSize = 6;
740 const char *iSite = getenv(
"XRDSITE");
741 unsigned char mDigest[mdLen];
743 union {uint64_t mdLL;
unsigned char mdUC[8];};
747 if (iSite) myID = iSite;
750 if (iName) myID += iName;
755 memset(mDigest, 0,
sizeof(mDigest));
765 uint64_t fpPos =
crc32c % (((uint32_t)mdLen) - fpSize);
767 memcpy(mdUC+fpOffs, mDigest+fpPos, fpSize);
768 long long fpVal =
static_cast<long long>(ntohll(mdLL));
773 snprintf(fpBuff,
sizeof(fpBuff),
"%lld", fpVal);
774 urSID = strdup(fpBuff);
780 const char *iHost,
const char *iProg,
781 const char *iName,
int iPort)
784 static long long theSID = genSID(theSIN, iHost, iPort, iName, iProg);
785 const char *sP = getenv(
"XRDSITE");
787 int myPid =
static_cast<int>(getpid());
791 if (
UserName(getuid(), uName,
sizeof(uName)))
792 sprintf(uName,
"%d",
static_cast<int>(getuid()));
796 snprintf(iBuff,iBlen,
"%s.%d:%s@%s\n&site=%s&port=%d&inst=%s&pgm=%s",
797 uName, myPid, theSIN, iHost, (sP ? sP :
""), iPort, iName, iProg);
801 h2nll(theSID, mySID);
802 return strdup(theSIN);
811 const char *iName = getenv(
"XRDNAME");
815 if (!TranOpt)
return iName;
820 if (TranOpt > 0) {
if (!iName || !*iName) iName =
"anon";}
821 else if (iName && !strcmp(iName,
"anon")) iName = 0;
827{
return (Fillit ? name && *name ? name :
"anon"
828 : name && strcmp(name,
"anon") && *name ? name : 0);
838 while(clist[i])
if (!strcmp(val, clist[i]))
return 1;
850 const char *hName, *hNend, *hPort, *hPend, *hP = path;
854 if (*path ==
'/') hP++;
855 if (*hP ==
'x') hP++;
856 if (strncmp(
"root:/", hP, 6))
return 0;
857 if (hBuff == 0 || hBLen <= 0)
return (hP - path) + 6;
861 if (*hNend ==
']') hNend++;
862 else {
if (!(*hNend) && !(hNend = index(hName,
'/')))
return 0;
863 if (!(*hPend)) hPend = hNend;
866 if (pTrim || !(*hPort)) n = hNend - hP;
868 if (n >= hBLen)
return 0;
869 strncpy(hBuff, hP, n);
873 {
if (*hNend !=
':') *port = 0;
874 else {*port = strtol(hPort, &eP, 10);
875 if (*port < 0 || *port > 65535 || eP != hPend)
return 0;
899 #define SHFT(k) if (n >= (1ULL << k)) { i += k; n >>= k; }
914 #define SHFT(k, m) if (n >= m) { i += k; n /= m; }
916 SHFT(16,10000000000000000ULL);
SHFT(8,100000000ULL);
931 if (!inst || !getcwd(buff,
sizeof(buff)))
return;
933 strcat(buff,
"/"); strcat(buff, inst);
935 {
eDest.Emsg(
"Config", errno,
"create home directory", buff);
940 eDest.Emsg(
"Config", errno,
"chdir to home directory", buff);
946 const char *path, mode_t mode)
949 const char *slash =
"", *slash2 =
"";
955 if (!path || !(n = strlen(path)))
962 if (path[n-1] !=
'/') slash =
"/";
963 if (!inst || !(n = strlen(inst))) inst =
"";
965 n = snprintf(cwDir,
sizeof(cwDir),
"%s%s%s%s", path, slash, inst, slash2);
966 if (n >= (
int)
sizeof(cwDir))
967 {
eDest.Emsg(
"Config", ENAMETOOLONG,
"create home directory", cwDir);
973 if ((rc =
makePath(cwDir, mode,
true)))
974 {
eDest.Emsg(
"Config", rc,
"create home directory", cwDir);
980 if (
chdir(cwDir) < 0)
981 {
eDest.Emsg(
"Config", errno,
"chdir to home directory", cwDir);
996 char *next_path = path+1;
998 bool dochmod =
false;
1002 if (!reset && !
stat(path, &buf))
return 0;
1006 while((next_path = index(next_path,
int(
'/'))))
1009 if (errno != EEXIST)
return -errno;
1010 if (dochmod)
CHMOD(path, mode);
1013 next_path = next_path+1;
1027 mode_t mval[3] = {0}, mbit[3] = {0x04, 0x02, 0x01};
1028 const char *mok =
"rwx";
1035 mask = strtol(mode, &eP, 8);
1041 int n = strlen(mode);
1042 if (!n || n > 9 || n/3*3 != n)
return false;
1047 do {
for (
int i = 0; i < 3; i++)
1050 {
if (mlet != mok[i])
return false;
1054 }
while(++k < 3 && *mode);
1058 mask = mval[0]<<6 | mval[1]<<3 | mval[2];
1067 const char *libName,
char *&libPath,
char **libParm)
1069 char *val, parms[2048];
1073 val = Config.GetWord();
1077 if (val && !strcmp(
"++", val))
1078 {
eDest.Say(
"Config warning: stacked plugins are not supported in "
1079 "this context; directive ignored!");
1085 while(val && *val && *val ==
'+') val = Config.GetWord();
1089 if (!val || !val[0])
1090 {
eDest.Emsg(
"Config", libName,
"not specified");
return false;}
1094 if (libPath) free(libPath);
1095 libPath = strdup(val);
1099 if (!libParm)
return true;
1100 if (*libParm) free(*libParm);
1106 if (!Config.GetRest(parms,
sizeof(parms)))
1107 {
eDest.Emsg(
"Config", libName,
"parameters too long");
return false;}
1108 if (*parms) *libParm = strdup(parms);
1118 char *pval, *val, *HomePath = 0;
1122 pval = Config.GetWord();
1123 if (!pval || !pval[0])
1124 {
eDest.Emsg(
"Config",
"home path not specified");
return 0;}
1129 {
eDest.Emsg(
"Config",
"home path not absolute");
return 0;}
1133 HomePath = strdup(pval);
1138 if ((val = Config.GetWord()) && val[0])
1139 {
if (!strcmp(
"group", val)) mode |= (S_IRGRP | S_IXGRP);
1140 else {
eDest.Emsg(
"Config",
"invalid home path modifier -", val);
1154 const mode_t AMode = S_IRWXU;
1155 char pbuff[MAXPATHLEN+64];
1161 if (n >= (
int)
sizeof(pbuff))
return ENAMETOOLONG;
1162 strcpy(pbuff, path);
1167 makePath(pbuff, (mode ? mode : AMode));
1168 if (symlink(target, path))
return errno;
1183 {
if (*str ==
'-') *str = subc;
1184 else if (*str ==
' ') *str = subc;
1185 char *blank = rindex(str,
' ');
1186 if (blank)
while(*blank ==
' ') *blank-- = 0;
1188 {
if (!isalnum(*str) && index(
"_-.", *str) == 0) *str = subc;
1200 const mode_t lfm = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
1201 char buff[2048], *sp;
1204 if (!inst || !*inst)
return logfn;
1205 if (!(sp = rindex(logfn,
'/'))) strcpy(buff,
"./");
1206 else {*sp =
'\0'; strcpy(buff, logfn); strcat(buff,
"/");}
1208 strcat(buff, inst); strcat(buff,
"/");
1211 {
eDest.Emsg(
"Config", rc,
"create log file path", buff);
1215 if (sp) {*sp =
'/'; strcat(buff, sp+1);}
1216 else strcat(buff, logfn);
1219 return strdup(buff);
1228 unsigned char* ustr = (
unsigned char*)str;
1232 while(*ustr) {*ustr = tolower(*ustr); ustr++;}
1241 const char *eP, *bP = *str;
1246 while(*bP && *bP == delim) bP++;
1247 if (*bP == 0) {*buff = 0;
return 0;}
1252 while(*eP && *eP != delim) eP++;
1256 if (*eP == 0) *str = eP;
1262 if (aLen >= bsz) mLen = bsz-1;
1267 strncpy(buff, bP, mLen);
1285 static const int maxFiles = 256;
1287 int myfd, logFD =
eDest.baseFD();
1291 if (noLog)
eDest.Emsg(
"Config",
"Warning! No log file specified; "
1292 "backgrounding disables all logging!");
1296 if ((mypid = fork()) < 0)
1297 {
eDest.Emsg(
"Config", errno,
"fork process 1 for backgrounding");
1311 if(
read( pipeFD[0], &status,
sizeof(status) ) !=
sizeof(status) )
1325 {
eDest.Emsg(
"Config", errno,
"doing setsid() for backgrounding");
1331 if ((mypid = fork()) < 0)
1332 {
eDest.Emsg(
"Config", errno,
"fork process 2 for backgrounding");
1335 else if (mypid) _exit(0);
1340 if ((myfd =
open(
"/dev/null", O_RDWR)) < 0)
1341 {
eDest.Emsg(
"Config", errno,
"open /dev/null for backgrounding");
1344 dup2(myfd, 0); dup2(myfd, 1); dup2(myfd, 2); dup2(myfd, logFD);
1349 for (myfd = 3; myfd < maxFiles; myfd++)
1350 if( (!pipeFD || myfd != pipeFD[1]) && myfd != logFD )
close(myfd);
1359 struct passwd *pEnt, pStruct;
1366 {
int n = LookUp(uidMap,
static_cast<unsigned int>(uID),uName,uNsz);
1367 if (n > 0)
return (n < uNsz ? n : 0);
1373 rc = getpwuid_r(uID, &pStruct, pBuff,
sizeof(pBuff), &pEnt);
1375 {n = snprintf(uName, uNsz,
"%ud",
static_cast<unsigned int>(uID));
1376 return (n >= uNsz ? 0 : n);
1382 AddID(uidMap,
static_cast<unsigned int>(uID), pEnt->pw_name, keepT);
1386 n = strlen(pEnt->pw_name);
1387 if (uNsz <= (
int)strlen(pEnt->pw_name))
return 0;
1388 strcpy(uName, pEnt->pw_name);
1398 struct passwd *pEnt, pStruct;
1405 rc = getpwuid_r(uID, &pStruct, pBuff,
sizeof(pBuff), &pEnt);
1407 if (!pEnt)
return ESRCH;
1411 if (uNsz <= (
int)strlen(pEnt->pw_name))
return ENAMETOOLONG;
1412 strcpy(uName, pEnt->pw_name);
1422 static const mode_t mMask = S_IRWXU | S_IRWXG | S_IRWXO;
1427 if (
stat(path, &buf))
1428 {
if (errno == ENOENT)
return "does not exist.";
1435 {
if (!S_ISDIR(buf.st_mode))
return "is not a directory.";
1437 if (!S_ISREG(buf.st_mode))
return "is not a file.";
1442 if ((buf.st_mode & mMask) & ~allow)
return "has excessive access rights.";
1458 if( (fd =
open( path, O_WRONLY|O_CREAT|O_TRUNC, 0644 )) < 0 )
1460 eDest.Emsg(
"Config", errno,
"create pidfile" );
1464 if(
write( fd, buff, snprintf( buff,
sizeof(buff),
"%d",
1465 static_cast<int>(getpid()) ) ) < 0 )
1467 eDest.Emsg(
"Config", errno,
"write to pidfile" );
1480 int statRet =
::stat(path,&buf);
1482 modificationTime = buf.st_mtime;
1489 while( str.size() && !isgraph(str[0]) ) str.erase(str.begin());
1493 while( str.size() && !isgraph(str[str.size()-1]) )
1494 str.resize (str.size () - 1);
1498 const auto toTrim = [](
char c) {
return !isgraph(c); };
1500 size_t end = sv.size();
1502 while (start < end && toTrim(sv[start])) ++start;
1503 while (end > start && toTrim(sv[end - 1])) --end;
1505 sv = sv.substr(start, end - start);
1517 static constexpr char token_chars[] =
"-._~+/=:%";
1519 for (
char ch : token_chars)
1536 static const regex_t auth_regex = []() {
1537 constexpr char re[] =
1538 "(authz=|(transferheader)?(www-|proxy-)?auth(orization|enticate)[[:space:]]*:[[:space:]]*)"
1539 "(Bearer([[:space:]]|%20)?(token([[:space:]]|%20)?)?)?";
1543 if (regcomp(®ex, re, REG_EXTENDED | REG_ICASE) != 0)
1544 throw std::runtime_error(
"Failed to compile regular expression");
1551 std::string redacted;
1552 const char *
const text = input.c_str();
1554 while (regexec(&auth_regex, text + offset, 1, &match, 0) == 0) {
1555 redacted.append(text + offset, match.rm_eo).append(
"REDACTED");
1557 offset += match.rm_eo;
1563 return redacted.append(text + offset);
static XrdSysError eDest(0,"crypto_")
uint32_t crc32c(uint32_t crc, void const *buf, size_t len)
static bool is_token_character(int c)
std::string obfuscateAuth(const std::string &input)
const char * XrdSysE2T(int errcode)
static bool Match(const char *hName, const char *pattern)
static bool Parse(const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)
static uint32_t Calc32C(const void *data, size_t count, uint32_t prevcs=0)
char * Get(const char *varname)
MDLen
SHA3 digest lengths (bits to bytes).
static void * Calc(const void *in, size_t inlen, void *md, MDLen mdlen)
int tokenize(XrdOucString &tok, int from, char del=':')
const char * c_str() const
static char * parseHome(XrdSysError &eDest, XrdOucStream &Config, int &mode)
static void Sanitize(char *instr, char subc='_')
static bool getGID(const char *gName, gid_t &gID)
static const mode_t pathMode
static const char * HSize(size_t bytes, char *buff, int bsz)
static int isFWD(const char *path, int *port=0, char *hBuff=0, int hBLen=0, bool pTrim=false)
static int UserName(uid_t uID, char *uName, int uNsz)
static char * Ident(long long &mySID, char *iBuff, int iBlen, const char *iHost, const char *iProg, const char *iName, int Port)
static bool getUID(const char *uName, uid_t &uID, gid_t *gID=0)
static int getModificationTime(const char *path, time_t &modificationTime)
static const char * ValPath(const char *path, mode_t allow, bool isdir)
static char * genPath(const char *path, const char *inst, const char *psfx=0)
static int Token(const char **str, char delim, char *buff, int bsz)
static int ReLink(const char *path, const char *target, mode_t mode=0)
static bool parseLib(XrdSysError &eDest, XrdOucStream &Config, const char *libName, char *&path, char **libparm)
static int hex2bin(const char *hex, char *bin, int size)
static int is1of(char *val, const char **clist)
static const char * InstName(int TranOpt=0)
static char * eText(int rc, char *eBuff, int eBlen)
static int argList(char *args, char **argV, int argC)
static bool mode2mask(const char *mode, mode_t &mask)
static int GidName(gid_t gID, char *gName, int gNsz, time_t keepT=0)
static int UidName(uid_t uID, char *uName, int uNsz, time_t keepT=0)
static char * bin2hex(char *inbuff, int dlen, char *buff, int blen, bool sep=true)
static int Log10(unsigned long long n)
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 GroupName(gid_t gID, char *gName, int gNsz)
static void trim(std::string &str)
static bool findPgm(const char *pgm, XrdOucString &path)
static bool PidFile(XrdSysError &eDest, const char *path)
static const char * i2bstr(char *buff, int blen, int val, bool pad=false)
static void toLower(char *str)
static int fmtBytes(long long val, char *buff, int bsz)
static int Log2(unsigned long long n)
static void makeHome(XrdSysError &eDest, const char *inst)
static bool endsWith(const char *text, const char *ending, int endlen)
static void Undercover(XrdSysError &eDest, int noLog, int *pipeFD=0)
static char * getFile(const char *path, int &rc, int maxsz=10240, bool notempty=true)
static char * subLogfn(XrdSysError &eDest, const char *inst, char *logfn)