XRootD
Loading...
Searching...
No Matches
XrdOucUtils Class Reference

#include <XrdOucUtils.hh>

+ Collaboration diagram for XrdOucUtils:

Public Member Functions

 XrdOucUtils ()
 
 ~XrdOucUtils ()
 

Static Public Member Functions

static int argList (char *args, char **argV, int argC)
 
static char * bin2hex (char *inbuff, int dlen, char *buff, int blen, bool sep=true)
 
static int doIf (XrdSysError *eDest, XrdOucStream &Config, const char *what, const char *hname, const char *nname, const char *pname)
 
static bool endsWith (const char *text, const char *ending, int endlen)
 
static char * eText (int rc, char *eBuff, int eBlen)
 
static bool findPgm (const char *pgm, XrdOucString &path)
 
static int fmtBytes (long long val, char *buff, int bsz)
 
static int genPath (char *buff, int blen, const char *path, const char *psfx=0)
 
static char * genPath (const char *path, const char *inst, const char *psfx=0)
 
static char * getFile (const char *path, int &rc, int maxsz=10240, bool notempty=true)
 
static bool getGID (const char *gName, gid_t &gID)
 
static int getModificationTime (const char *path, time_t &modificationTime)
 
static bool getUID (const char *uName, uid_t &uID, gid_t *gID=0)
 
static int GidName (gid_t gID, char *gName, int gNsz, time_t keepT=0)
 
static int GroupName (gid_t gID, char *gName, int gNsz)
 
static const char * HSize (size_t bytes, char *buff, int bsz)
 
static const char * i2bstr (char *buff, int blen, int val, bool pad=false)
 
static char * Ident (long long &mySID, char *iBuff, int iBlen, const char *iHost, const char *iProg, const char *iName, int Port)
 
static const char * InstName (const char *name, int Fillit=1)
 
static const char * InstName (int TranOpt=0)
 
static int is1of (char *val, const char **clist)
 
static int isFWD (const char *path, int *port=0, char *hBuff=0, int hBLen=0, bool pTrim=false)
 
static int Log10 (unsigned long long n)
 
static int Log2 (unsigned long long n)
 
static void makeHome (XrdSysError &eDest, const char *inst)
 
static bool makeHome (XrdSysError &eDest, const char *inst, const char *path, mode_t mode)
 
static int makePath (char *path, mode_t mode, bool reset=false)
 
static bool mode2mask (const char *mode, mode_t &mask)
 
static char * parseHome (XrdSysError &eDest, XrdOucStream &Config, int &mode)
 
static bool parseLib (XrdSysError &eDest, XrdOucStream &Config, const char *libName, char *&path, char **libparm)
 
static bool PidFile (XrdSysError &eDest, const char *path)
 
static int ReLink (const char *path, const char *target, mode_t mode=0)
 
static void Sanitize (char *instr, char subc='_')
 
static char * subLogfn (XrdSysError &eDest, const char *inst, char *logfn)
 
static int Token (const char **str, char delim, char *buff, int bsz)
 
static void toLower (char *str)
 
static void trim (std::string &str)
 
static int UidName (uid_t uID, char *uName, int uNsz, time_t keepT=0)
 
static void Undercover (XrdSysError &eDest, int noLog, int *pipeFD=0)
 
static int UserName (uid_t uID, char *uName, int uNsz)
 
static const char * ValPath (const char *path, mode_t allow, bool isdir)
 

Static Public Attributes

static const mode_t pathMode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH
 

Detailed Description

Definition at line 43 of file XrdOucUtils.hh.

Constructor & Destructor Documentation

◆ XrdOucUtils()

XrdOucUtils::XrdOucUtils ( )
inline

Definition at line 140 of file XrdOucUtils.hh.

140{}

◆ ~XrdOucUtils()

XrdOucUtils::~XrdOucUtils ( )
inline

Definition at line 141 of file XrdOucUtils.hh.

141{}

Member Function Documentation

◆ argList()

int XrdOucUtils::argList ( char * args,
char ** argV,
int argC )
static

Definition at line 125 of file XrdOucUtils.cc.

126{
127 char *aP = args;
128 int j;
129
130// Construct the argv array based on passed command line.
131//
132for (j = 0; j < argC; j++)
133 {while(*aP == ' ') aP++;
134 if (!(*aP)) break;
135
136 if (*aP == '"' || *aP == '\'')
137 {argV[j] = aP+1;
138 aP = index(aP+1, *aP);
139 if (!aP || (*(aP+1) != ' ' && *(aP+1)))
140 {if (!j) argV[0] = 0; return -EINVAL;}
141 *aP++ = '\0';
142 } else {
143 argV[j] = aP;
144 if ((aP = index(aP+1, ' '))) *aP++ = '\0';
145 else {j++; break;}
146 }
147
148 }
149
150// Make sure we did not overflow the vector
151//
152 if (j > argC-1) return -E2BIG;
153
154// End list with a null pointer and return the actual number of arguments
155//
156 argV[j] = 0;
157 return j;
158}

Referenced by XrdOucProg::Setup().

+ Here is the caller graph for this function:

◆ bin2hex()

char * XrdOucUtils::bin2hex ( char * inbuff,
int dlen,
char * buff,
int blen,
bool sep = true )
static

Definition at line 164 of file XrdOucUtils.cc.

166{
167 static 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];
172 blen -= 2;
173 if (sep && blen > 1 && ((i & 0x03) == 0x03 || i+1 == dlen))
174 {*outbuff++ = ' '; blen--;}
175 }
176 *outbuff = '\0';
177 return buff;
178}

Referenced by XrdOssMio::Map().

+ Here is the caller graph for this function:

◆ doIf()

int XrdOucUtils::doIf ( XrdSysError * eDest,
XrdOucStream & Config,
const char * what,
const char * hname,
const char * nname,
const char * pname )
static

Definition at line 232 of file XrdOucUtils.cc.

235{
236 static const char *brk[] = {"defined", "exec", "named", 0};
237 XrdOucEnv *theEnv = 0;
238 char *val;
239 int hostok, isDef;
240
241// Make sure that at least one thing appears after the if
242//
243 if (!(val = Config.GetWord()))
244 {if (eDest) eDest->Emsg("Config","Host name missing after 'if' in", what);
245 return -1;
246 }
247
248// Check if we are one of the listed hosts
249//
250 if (!is1of(val, brk))
251 {do {hostok = XrdNetUtils::Match(hname, val);
252 val = Config.GetWord();
253 } while(!hostok && val && !is1of(val, brk));
254 if (hostok)
255 { while(val && !is1of(val, brk)) val = Config.GetWord();
256 // No more directives
257 if (!val) return 1;
258 } else return 0;
259 }
260
261// Check if this is a defined test
262//
263 while(!strcmp(val, "defined"))
264 {if (!(val = Config.GetWord()) || *val != '?')
265 {if (eDest)
266 {eDest->Emsg("Config","'?var' missing after 'defined' in",what);}
267 return -1;
268 }
269 // Get environment if we have none
270 //
271 if (!theEnv && (theEnv = Config.SetEnv(0))) Config.SetEnv(theEnv);
272 if (!theEnv && *(val+1) != '~') return 0;
273
274 // Check if any listed variable is defined.
275 //
276 isDef = 0;
277 while(val && *val == '?')
278 {if (*(val+1) == '~' ? getenv(val+2) : theEnv->Get(val+1)) isDef=1;
279 val = Config.GetWord();
280 }
281 if (!val || !isDef) return isDef;
282 if (strcmp(val, "&&"))
283 {if (eDest)
284 {eDest->Emsg("Config",val,"is invalid for defined test in",what);}
285 return -1;
286 } else {
287 if (!(val = Config.GetWord()))
288 {if (eDest)
289 {eDest->Emsg("Config","missing keyword after '&&' in",what);}
290 return -1;
291 }
292 }
293 if (!is1of(val, brk))
294 {if (eDest)
295 {eDest->Emsg("Config",val,"is invalid after '&&' in",what);}
296 return -1;
297 }
298 }
299
300// Check if we need to compare program names (we are here only if we either
301// passed the hostlist test or there was no hostlist present)
302//
303 if (!strcmp(val, "exec"))
304 {if (!(val = Config.GetWord()) || !strcmp(val, "&&"))
305 {if (eDest)
306 {eDest->Emsg("Config","Program name missing after 'if exec' in",what);}
307 return -1;
308 }
309
310 // Check if we are one of the programs.
311 //
312 if (!pname) return 0;
313 while(val && strcmp(val, pname))
314 if (!strcmp(val, "&&")) return 0;
315 else val = Config.GetWord();
316 if (!val) return 0;
317 while(val && strcmp(val, "&&")) val = Config.GetWord();
318 if (!val) return 1;
319
320 if (!(val = Config.GetWord()))
321 {if (eDest)
322 {eDest->Emsg("Config","Keyword missing after '&&' in",what);}
323 return -1;
324 }
325 if (strcmp(val, "named"))
326 {if (eDest)
327 {eDest->Emsg("Config",val,"is invalid after '&&' in",what);}
328 return -1;
329 }
330 }
331
332// Check if we need to compare net names (we are here only if we either
333// passed the hostlist test or there was no hostlist present)
334//
335 if (!(val = Config.GetWord()))
336 {if (eDest)
337 {eDest->Emsg("Config","Instance name missing after 'if named' in", what);}
338 return -1;
339 }
340
341// Check if we are one of the names
342//
343 if (!nname) return 0;
344 while(val && strcmp(val, nname)) val = Config.GetWord();
345
346// All done
347//
348 return (val != 0);
349}
static XrdSysError eDest(0,"crypto_")
static bool Match(const char *hName, const char *pattern)
static int is1of(char *val, const char **clist)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdCmsConfig Config
XrdOucEnv theEnv

References eDest, XrdSysError::Emsg(), XrdOucEnv::Get(), is1of(), and XrdNetUtils::Match().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ endsWith()

bool XrdOucUtils::endsWith ( const char * text,
const char * ending,
int endlen )
static

Definition at line 184 of file XrdOucUtils.cc.

185{
186 int tlen = strlen(text);
187
188 return (tlen >= endlen && !strcmp(text+(tlen-endlen), ending));
189}

Referenced by XrdBwmFile::open().

+ Here is the caller graph for this function:

◆ eText()

char * XrdOucUtils::eText ( int rc,
char * eBuff,
int eBlen )
static

Definition at line 198 of file XrdOucUtils.cc.

199{
200 const char *etP;
201
202// Get error text
203//
204 etP = XrdSysE2T(rc);
205
206// Copy the text and lower case the first letter
207//
208 strlcpy(eBuff, etP, eBlen);
209
210// All done
211//
212 return eBuff;
213}
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104
size_t strlcpy(char *dst, const char *src, size_t sz)

References strlcpy(), and XrdSysE2T().

+ Here is the call graph for this function:

◆ findPgm()

bool XrdOucUtils::findPgm ( const char * pgm,
XrdOucString & path )
static

Definition at line 355 of file XrdOucUtils.cc.

356{
357 struct stat Stat;
358
359// Check if only executable bit needs to be checked
360//
361 if (*pgm == '/')
362 {if (stat(pgm, &Stat) || !(Stat.st_mode & S_IXOTH)) return false;
363 path = pgm;
364 return true;
365 }
366
367// Make sure we have the paths to check
368//
369 const char *pEnv = getenv("PATH");
370 if (!pEnv) return false;
371
372// Setup to find th executable
373//
374 XrdOucString prog, pList(pEnv);
375 int from = 0;;
376 prog += '/'; prog += pgm;
377
378// Find it!
379//
380 while((from = pList.tokenize(path, from, ':')) != -1)
381 {path += prog;
382 if (!stat(path.c_str(), &Stat) && Stat.st_mode & S_IXOTH) return true;
383 }
384 return false;
385}
struct stat Stat
Definition XrdCks.cc:49
#define stat(a, b)
Definition XrdPosix.hh:101
const char * c_str() const

References XrdOucString::c_str(), Stat, stat, and XrdOucString::tokenize().

Referenced by XrdNetPMarkCfg::Parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fmtBytes()

int XrdOucUtils::fmtBytes ( long long val,
char * buff,
int bsz )
static

Definition at line 391 of file XrdOucUtils.cc.

392{
393 static const long long Kval = 1024LL;
394 static const long long Mval = 1024LL*1024LL;
395 static const long long Gval = 1024LL*1024LL*1024LL;
396 static const long long Tval = 1024LL*1024LL*1024LL*1024LL;
397 char sName = ' ';
398 int resid;
399
400// Get correct scaling
401//
402 if (val < 1024) return snprintf(buff, bsz, "%lld", val);
403 if (val < Mval) {val = val*10/Kval; sName = 'K';}
404 else if (val < Gval) {val = val*10/Mval; sName = 'M';}
405 else if (val < Tval) {val = val*10/Gval; sName = 'G';}
406 else {val = val*10/Tval; sName = 'T';}
407 resid = val%10LL; val = val/10LL;
408
409// Format it
410//
411 return snprintf(buff, bsz, "%lld.%d%c", val, resid, sName);
412}

Referenced by XrdFrmPurge::Display().

+ Here is the caller graph for this function:

◆ genPath() [1/2]

int XrdOucUtils::genPath ( char * buff,
int blen,
const char * path,
const char * psfx = 0 )
static

Definition at line 436 of file XrdOucUtils.cc.

437{
438 int i, j;
439
440 i = strlen(path);
441 j = (psfx ? strlen(psfx) : 0);
442 if (i+j+3 > blen) return -ENAMETOOLONG;
443
444 strcpy(buff, path);
445 if (psfx)
446 {if (buff[i-1] != '/') buff[i++] = '/';
447 strcpy(&buff[i], psfx);
448 if (psfx[j-1] != '/') strcat(buff, "/");
449 }
450 return 0;
451}

◆ genPath() [2/2]

char * XrdOucUtils::genPath ( const char * path,
const char * inst,
const char * psfx = 0 )
static

Definition at line 418 of file XrdOucUtils.cc.

420{
421 char buff[2048];
422 int i = strlcpy(buff, p_path, sizeof(buff));
423
424 if (buff[i-1] != '/') {buff[i++] = '/'; buff[i] = '\0';}
425 if (inst) {strcpy(buff+i, inst); strcat(buff, "/");}
426 if (s_path) strcat(buff, s_path);
427
428 i = strlen(buff);
429 if (buff[i-1] != '/') {buff[i++] = '/'; buff[i] = '\0';}
430
431 return strdup(buff);
432}

References strlcpy().

Referenced by XrdNetCmsNotify::XrdNetCmsNotify(), XrdXrootdProtocol::Configure(), XrdCmsClientConfig::Configure(), XrdCmsConfig::Configure0(), XrdCmsConfig::Configure2(), XrdOfsConfigCP::Init(), and XrdFrcUtils::makePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFile()

char * XrdOucUtils::getFile ( const char * path,
int & rc,
int maxsz = 10240,
bool notempty = true )
static

Definition at line 457 of file XrdOucUtils.cc.

458{
459 struct stat Stat;
460 struct fdHelper
461 {int fd = -1;
462 fdHelper() {}
463 ~fdHelper() {if (fd >= 0) close(fd);}
464 } file;
465 char *buff;
466 int flen;
467
468// Preset RC
469//
470 rc = 0;
471
472// Open the file in read mode
473//
474 if ((file.fd = open(path, O_RDONLY)) < 0) {rc = errno; return 0;}
475
476// Get the size of the file
477//
478 if (fstat(file.fd, &Stat)) {rc = errno; return 0;}
479
480// Check if the size exceeds the maximum allowed
481//
482 if (Stat.st_size > maxsz) {rc = EFBIG; return 0;}
483
484// Make sure the file is not empty if empty files are disallowed
485//
486 if (Stat.st_size == 0 && notempty) {rc = ENODATA; return 0;}
487
488// Allocate a buffer
489//
490 if ((buff = (char *)malloc(Stat.st_size+1)) == 0)
491 {rc = errno; return 0;}
492
493// Read the contents of the file into the buffer
494//
495 if (Stat.st_size)
496 {if ((flen = read(file.fd, buff, Stat.st_size)) < 0)
497 {rc = errno; free(buff); return 0;}
498 } else flen = 0;
499
500// Add null byte. recall the buffer is bigger by one byte
501//
502 buff[flen] = 0;
503
504// Return the size aand the buffer
505//
506 rc = flen;
507 return buff;
508}
#define ENODATA
#define close(a)
Definition XrdPosix.hh:48
#define fstat(a, b)
Definition XrdPosix.hh:62
#define open
Definition XrdPosix.hh:76
#define read(a, b, c)
Definition XrdPosix.hh:82

References close, ENODATA, fstat, open, read, Stat, and stat.

◆ getGID()

bool XrdOucUtils::getGID ( const char * gName,
gid_t & gID )
static

Definition at line 514 of file XrdOucUtils.cc.

515{
516 struct group Grp, *result;
517 char buff[65536];
518
519 getgrnam_r(gName, &Grp, buff, sizeof(buff), &result);
520 if (!result) return false;
521
522 gID = Grp.gr_gid;
523 return true;
524}

Referenced by XrdSecProtocolsss::Authenticate().

+ Here is the caller graph for this function:

◆ getModificationTime()

int XrdOucUtils::getModificationTime ( const char * path,
time_t & modificationTime )
static

Definition at line 1433 of file XrdOucUtils.cc.

1433 {
1434 struct stat buf;
1435 int statRet = ::stat(path,&buf);
1436 if(!statRet) {
1437 modificationTime = buf.st_mtime;
1438 }
1439 return statRet;
1440}

References stat.

Referenced by XrdTlsContext::XrdTlsContext(), and XrdTlsContext::newHostCertificateDetected().

+ Here is the caller graph for this function:

◆ getUID()

bool XrdOucUtils::getUID ( const char * uName,
uid_t & uID,
gid_t * gID = 0 )
static

Definition at line 530 of file XrdOucUtils.cc.

531{
532 struct passwd pwd, *result;
533 char buff[16384];
534
535 getpwnam_r(uName, &pwd, buff, sizeof(buff), &result);
536 if (!result) return false;
537
538 uID = pwd.pw_uid;
539 if (gID) *gID = pwd.pw_gid;
540
541 return true;
542}

Referenced by XrdSecProtocolsss::Authenticate().

+ Here is the caller graph for this function:

◆ GidName()

int XrdOucUtils::GidName ( gid_t gID,
char * gName,
int gNsz,
time_t keepT = 0 )
static

Definition at line 548 of file XrdOucUtils.cc.

549{
550 static const int maxgBsz = 256*1024;
551 static const int addGsz = 4096;
552 struct group *gEnt, gStruct;
553 char gBuff[1024], *gBp = gBuff;
554 int glen = 0, gBsz = sizeof(gBuff), aOK = 1;
555 int n, retVal = 0;
556
557// Get ID from cache, if allowed
558//
559 if (keepT)
560 {int n = LookUp(gidMap, static_cast<unsigned int>(gID),gName,gNsz);
561 if (n > 0) return (n < gNsz ? n : 0);
562 }
563
564// Get the the group struct. If we don't have a large enough buffer, get a
565// larger one and try again up to the maximum buffer we will tolerate.
566//
567 while(( retVal = getgrgid_r(gID, &gStruct, gBp, gBsz, &gEnt) ) == ERANGE)
568 {if (gBsz >= maxgBsz) {aOK = 0; break;}
569 if (gBsz > addGsz) free(gBp);
570 gBsz += addGsz;
571 if (!(gBp = (char *)malloc(gBsz))) {aOK = 0; break;}
572 }
573
574// Return a group name if all went well
575//
576 if (aOK && retVal == 0 && gEnt != NULL)
577 {if (keepT)
578 AddID(gidMap, static_cast<unsigned int>(gID), gEnt->gr_name, keepT);
579 glen = strlen(gEnt->gr_name);
580 if (glen >= gNsz) glen = 0;
581 else strcpy(gName, gEnt->gr_name);
582 } else {
583 n = snprintf(gName, gNsz, "%ud", static_cast<unsigned int>(gID));
584 if (n >= gNsz) glen = 0;
585 }
586
587// Free any allocated buffer and return result
588//
589 if (gBsz > addGsz && gBp) free(gBp);
590 return glen;
591}

◆ GroupName()

int XrdOucUtils::GroupName ( gid_t gID,
char * gName,
int gNsz )
static

Definition at line 597 of file XrdOucUtils.cc.

598{
599 static const int maxgBsz = 256*1024;
600 static const int addGsz = 4096;
601 struct group *gEnt, gStruct;
602 char gBuff[1024], *gBp = gBuff;
603 int glen, gBsz = sizeof(gBuff), aOK = 1;
604 int retVal = 0;
605
606// Get the the group struct. If we don't have a large enough buffer, get a
607// larger one and try again up to the maximum buffer we will tolerate.
608//
609 while(( retVal = getgrgid_r(gID, &gStruct, gBp, gBsz, &gEnt) ) == ERANGE)
610 {if (gBsz >= maxgBsz) {aOK = 0; break;}
611 if (gBsz > addGsz) free(gBp);
612 gBsz += addGsz;
613 if (!(gBp = (char *)malloc(gBsz))) {aOK = 0; break;}
614 }
615
616// Return a group name if all went well
617//
618 if (aOK && retVal == 0 && gEnt != NULL)
619 {glen = strlen(gEnt->gr_name);
620 if (glen >= gNsz) glen = 0;
621 else strcpy(gName, gEnt->gr_name);
622 } else glen = 0;
623
624// Free any allocated buffer and return result
625//
626 if (gBsz > addGsz && gBp) free(gBp);
627 return glen;
628}

Referenced by XrdSecProtocolunix::getCredentials().

+ Here is the caller graph for this function:

◆ HSize()

const char * XrdOucUtils::HSize ( size_t bytes,
char * buff,
int bsz )
static

Definition at line 634 of file XrdOucUtils.cc.

635{
636
637// Do fast conversion of the quantity is less than 1K
638//
639 if (bytes < 1024)
640 {snprintf(buff, bsz, "%zu", bytes);
641 return buff;
642 }
643
644// Scale this down
645//
646 const char *suffix = " KMGTPEYZ";
647 double dBytes = static_cast<double>(bytes);
648
649do{dBytes /= 1024.0; suffix++;
650 } while(dBytes >= 1024.0 && *(suffix+1));
651
652
653// Format and return result. Include fractions only if they meaningfully exist.
654//
655 double whole, frac = modf(dBytes, &whole);
656 if (frac >= .005) snprintf(buff, bsz, "%.02lf%c", dBytes, *suffix);
657 else snprintf(buff, bsz, "%g%c", whole, *suffix);
658 return buff;
659}

◆ i2bstr()

const char * XrdOucUtils::i2bstr ( char * buff,
int blen,
int val,
bool pad = false )
static

Definition at line 665 of file XrdOucUtils.cc.

666{
667 char zo[2] = {'0', '1'};
668
669 if (blen < 2) return "";
670
671 buff[--blen] = 0;
672 if (!val) buff[blen--] = '0';
673 else while(val && blen >= 0)
674 {buff[blen--] = zo[val & 0x01];
675 val >>= 1;
676 }
677
678 if (blen >= 0 && pad) while(blen >= 0) buff[blen--] = '0';
679
680 return &buff[blen+1];
681}

◆ Ident()

char * XrdOucUtils::Ident ( long long & mySID,
char * iBuff,
int iBlen,
const char * iHost,
const char * iProg,
const char * iName,
int Port )
static

Definition at line 734 of file XrdOucUtils.cc.

737{
738 static char *theSIN;
739 static long long theSID = genSID(theSIN, iHost, iPort, iName, iProg);
740 const char *sP = getenv("XRDSITE");
741 char uName[256];
742 int myPid = static_cast<int>(getpid());
743
744// Get our username
745//
746 if (UserName(getuid(), uName, sizeof(uName)))
747 sprintf(uName, "%d", static_cast<int>(getuid()));
748
749// Create identification record
750//
751 snprintf(iBuff,iBlen,"%s.%d:%s@%s\n&site=%s&port=%d&inst=%s&pgm=%s",
752 uName, myPid, theSIN, iHost, (sP ? sP : ""), iPort, iName, iProg);
753
754// Return a copy of the sid key
755//
756 h2nll(theSID, mySID);
757 return strdup(theSIN);
758}
static int UserName(uid_t uID, char *uName, int uNsz)

References UserName().

Referenced by XrdFrmMonitor::Init(), and XrdXrootdMonitor::Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstName() [1/2]

const char * XrdOucUtils::InstName ( const char * name,
int Fillit = 1 )
static

Definition at line 781 of file XrdOucUtils.cc.

782{ return (Fillit ? name && *name ? name : "anon"
783 : name && strcmp(name,"anon") && *name ? name : 0);
784}

◆ InstName() [2/2]

const char * XrdOucUtils::InstName ( int TranOpt = 0)
static

Definition at line 764 of file XrdOucUtils.cc.

765{
766 const char *iName = getenv("XRDNAME");
767
768// If tran is zero, return what we have
769//
770 if (!TranOpt) return iName;
771
772// If trans is positive then make sure iName has a value. Otherwise, make sure
773// iName has no value if it's actually "anon".
774//
775 if (TranOpt > 0) {if (!iName || !*iName) iName = "anon";}
776 else if (iName && !strcmp(iName, "anon")) iName = 0;
777 return iName;
778}

Referenced by XrdFrcProxy::XrdFrcProxy(), XrdFrmConfig::XrdFrmConfig(), XrdNetCmsNotify::XrdNetCmsNotify(), XrdSsiSfsConfig::XrdSsiSfsConfig(), XrdOssSys::ConfigStage(), XrdCmsClientConfig::Configure(), XrdConfig::Configure(), XrdFrmConfig::Configure(), XrdCmsConfig::Configure0(), XrdCmsConfig::Configure1(), XrdOfsConfigCP::Init(), XrdOssSpace::Init(), main(), and XrdFrcReqAgent::Start().

+ Here is the caller graph for this function:

◆ is1of()

int XrdOucUtils::is1of ( char * val,
const char ** clist )
static

Definition at line 790 of file XrdOucUtils.cc.

791{
792 int i = 0;
793 while(clist[i]) if (!strcmp(val, clist[i])) return 1;
794 else i++;
795 return 0;
796}

Referenced by doIf().

+ Here is the caller graph for this function:

◆ isFWD()

int XrdOucUtils::isFWD ( const char * path,
int * port = 0,
char * hBuff = 0,
int hBLen = 0,
bool pTrim = false )
static

Definition at line 802 of file XrdOucUtils.cc.

804{
805 const char *hName, *hNend, *hPort, *hPend, *hP = path;
806 char *eP;
807 int n;
808
809 if (*path == '/') hP++; // Note: It's assumed an objectid if no slash
810 if (*hP == 'x') hP++;
811 if (strncmp("root:/", hP, 6)) return 0;
812 if (hBuff == 0 || hBLen <= 0) return (hP - path) + 6;
813 hP += 6;
814
815 if (!XrdNetUtils::Parse(hP, &hName, &hNend, &hPort, &hPend)) return 0;
816 if (*hNend == ']') hNend++;
817 else {if (!(*hNend) && !(hNend = index(hName, '/'))) return 0;
818 if (!(*hPend)) hPend = hNend;
819 }
820
821 if (pTrim || !(*hPort)) n = hNend - hP;
822 else n = hPend - hP;
823 if (n >= hBLen) return 0;
824 strncpy(hBuff, hP, n);
825 hBuff[n] = 0;
826
827 if (port)
828 {if (*hNend != ':') *port = 0;
829 else {*port = strtol(hPort, &eP, 10);
830 if (*port < 0 || *port > 65535 || eP != hPend) return 0;
831 }
832 }
833
834 return hPend-path;
835}
static bool Parse(const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)

References XrdNetUtils::Parse().

+ Here is the call graph for this function:

◆ Log10()

int XrdOucUtils::Log10 ( unsigned long long n)
static

Definition at line 865 of file XrdOucUtils.cc.

866{
867 int i = 0;
868
869 #define SHFT(k, m) if (n >= m) { i += k; n /= m; }
870
871 SHFT(16,10000000000000000ULL); SHFT(8,100000000ULL);
872 SHFT(4,10000ULL); SHFT(2,100ULL); SHFT(1,10ULL);
873 return i;
874
875 #undef SHFT
876}
#define SHFT(k)

References SHFT.

◆ Log2()

int XrdOucUtils::Log2 ( unsigned long long n)
static

Definition at line 850 of file XrdOucUtils.cc.

851{
852 int i = 0;
853
854 #define SHFT(k) if (n >= (1ULL << k)) { i += k; n >>= k; }
855
856 SHFT(32); SHFT(16); SHFT(8); SHFT(4); SHFT(2); SHFT(1); return i;
857
858 #undef SHFT
859}

References SHFT.

Referenced by XrdBuffXL::Init(), XrdBuffManager::Obtain(), XrdBuffXL::Obtain(), XrdBuffManager::Recalc(), and XrdBuffXL::Recalc().

+ Here is the caller graph for this function:

◆ makeHome() [1/2]

void XrdOucUtils::makeHome ( XrdSysError & eDest,
const char * inst )
static

Definition at line 882 of file XrdOucUtils.cc.

883{
884 char buff[2048];
885
886 if (!inst || !getcwd(buff, sizeof(buff))) return;
887
888 strcat(buff, "/"); strcat(buff, inst);
889 if (MAKEDIR(buff, pathMode) && errno != EEXIST)
890 {eDest.Emsg("Config", errno, "create home directory", buff);
891 return;
892 }
893
894 if (chdir(buff) < 0)
895 eDest.Emsg("Config", errno, "chdir to home directory", buff);
896}
#define chdir(a)
Definition XrdPosix.hh:46
#define MAKEDIR(path, mode)
static const mode_t pathMode

References chdir, eDest, XrdSysError::Emsg(), MAKEDIR, and pathMode.

Referenced by XrdConfig::Configure(), XrdFrmConfig::Configure(), and makeHome().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeHome() [2/2]

bool XrdOucUtils::makeHome ( XrdSysError & eDest,
const char * inst,
const char * path,
mode_t mode )
static

Definition at line 900 of file XrdOucUtils.cc.

902{
903 char cwDir[2048];
904 const char *slash = "", *slash2 = "";
905 int n, rc;
906
907// Provide backward compatibility for instance name qualification
908//
909
910 if (!path || !(n = strlen(path)))
911 {if (inst) makeHome(eDest, inst);
912 return true;
913 }
914
915// Augment the path with instance name, if need be
916//
917 if (path[n-1] != '/') slash = "/";
918 if (!inst || !(n = strlen(inst))) inst = "";
919 else slash2 = "/";
920 n = snprintf(cwDir, sizeof(cwDir), "%s%s%s%s", path, slash, inst, slash2);
921 if (n >= (int)sizeof(cwDir))
922 {eDest.Emsg("Config", ENAMETOOLONG, "create home directory", cwDir);
923 return false;
924 }
925
926// Create the path if it doesn't exist
927//
928 if ((rc = makePath(cwDir, mode, true)))
929 {eDest.Emsg("Config", rc, "create home directory", cwDir);
930 return false;
931 }
932
933// Switch to this directory
934//
935 if (chdir(cwDir) < 0)
936 {eDest.Emsg("Config", errno, "chdir to home directory", cwDir);
937 return false;
938 }
939
940// All done
941//
942 return true;
943}
static int makePath(char *path, mode_t mode, bool reset=false)
static void makeHome(XrdSysError &eDest, const char *inst)

References chdir, eDest, XrdSysError::Emsg(), makeHome(), and makePath().

+ Here is the call graph for this function:

◆ makePath()

int XrdOucUtils::makePath ( char * path,
mode_t mode,
bool reset = false )
static

Definition at line 949 of file XrdOucUtils.cc.

950{
951 char *next_path = path+1;
952 struct stat buf;
953 bool dochmod = false; // The 1st component stays as is
954
955// Typically, the path exists. So, do a quick check before launching into it
956//
957 if (!reset && !stat(path, &buf)) return 0;
958
959// Start creating directories starting with the root
960//
961 while((next_path = index(next_path, int('/'))))
962 {*next_path = '\0';
963 if (MAKEDIR(path, mode))
964 if (errno != EEXIST) return -errno;
965 if (dochmod) CHMOD(path, mode);
966 dochmod = reset;
967 *next_path = '/';
968 next_path = next_path+1;
969 }
970
971// All done
972//
973 return 0;
974}
#define CHMOD(path, mode)

References CHMOD, MAKEDIR, and stat.

Referenced by XrdOssSys::Create(), XrdOfsConfigCP::Init(), makeHome(), XrdFrcUtils::makePath(), XrdFrcUtils::makeQDir(), ReLink(), XrdOssSys::Reloc(), XrdOssSys::Rename(), XrdSecsssKT::Rewrite(), XrdNetSocket::socketPath(), and subLogfn().

+ Here is the caller graph for this function:

◆ mode2mask()

bool XrdOucUtils::mode2mask ( const char * mode,
mode_t & mask )
static

Definition at line 980 of file XrdOucUtils.cc.

981{
982 mode_t mval[3] = {0}, mbit[3] = {0x04, 0x02, 0x01};
983 const char *mok = "rwx";
984 char mlet;
985
986// Accept octal mode
987//
988 if (isdigit(*mode))
989 {char *eP;
990 mask = strtol(mode, &eP, 8);
991 return *eP == 0;
992 }
993
994// Make sure we have the correct number of characters
995//
996 int n = strlen(mode);
997 if (!n || n > 9 || n/3*3 != n) return false;
998
999// Convert groups of three
1000//
1001 int k = 0;
1002 do {for (int i = 0; i < 3; i++)
1003 {mlet = *mode++;
1004 if (mlet != '-')
1005 {if (mlet != mok[i]) return false;
1006 mval[k] |= mbit[i];
1007 }
1008 }
1009 } while(++k < 3 && *mode);
1010
1011// Combine the modes and return success
1012//
1013 mask = mval[0]<<6 | mval[1]<<3 | mval[2];
1014 return true;
1015}

◆ parseHome()

char * XrdOucUtils::parseHome ( XrdSysError & eDest,
XrdOucStream & Config,
int & mode )
static

Definition at line 1071 of file XrdOucUtils.cc.

1072{
1073 char *pval, *val, *HomePath = 0;
1074
1075// Get the path
1076//
1077 pval = Config.GetWord();
1078 if (!pval || !pval[0])
1079 {eDest.Emsg("Config", "home path not specified"); return 0;}
1080
1081// Make sure it's an absolute path
1082//
1083 if (*pval != '/')
1084 {eDest.Emsg("Config", "home path not absolute"); return 0;}
1085
1086// Record the path
1087//
1088 HomePath = strdup(pval);
1089
1090// Get the optional access rights
1091//
1092 mode = S_IRWXU;
1093 if ((val = Config.GetWord()) && val[0])
1094 {if (!strcmp("group", val)) mode |= (S_IRGRP | S_IXGRP);
1095 else {eDest.Emsg("Config", "invalid home path modifier -", val);
1096 free(HomePath);
1097 return 0;
1098 }
1099 }
1100 return HomePath;
1101}

References eDest, and XrdSysError::Emsg().

+ Here is the call graph for this function:

◆ parseLib()

bool XrdOucUtils::parseLib ( XrdSysError & eDest,
XrdOucStream & Config,
const char * libName,
char *& path,
char ** libparm )
static

Definition at line 1021 of file XrdOucUtils.cc.

1023{
1024 char *val, parms[2048];
1025
1026// Get the next token
1027//
1028 val = Config.GetWord();
1029
1030// We do not support stacking as the caller does not support stacking
1031//
1032 if (val && !strcmp("++", val))
1033 {eDest.Say("Config warning: stacked plugins are not supported in "
1034 "this context; directive ignored!");
1035 return true;
1036 }
1037
1038// Now skip over any options
1039//
1040 while(val && *val && *val == '+') val = Config.GetWord();
1041
1042// Check if we actually have a path
1043//
1044 if (!val || !val[0])
1045 {eDest.Emsg("Config", libName, "not specified"); return false;}
1046
1047// Record the path
1048//
1049 if (libPath) free(libPath);
1050 libPath = strdup(val);
1051
1052// Handle optional parameter
1053//
1054 if (!libParm) return true;
1055 if (*libParm) free(*libParm);
1056 *libParm = 0;
1057
1058// Record any parms
1059//
1060 *parms = 0;
1061 if (!Config.GetRest(parms, sizeof(parms)))
1062 {eDest.Emsg("Config", libName, "parameters too long"); return false;}
1063 if (*parms) *libParm = strdup(parms);
1064 return true;
1065}
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)

References eDest, XrdSysError::Emsg(), and XrdSysError::Say().

+ Here is the call graph for this function:

◆ PidFile()

bool XrdOucUtils::PidFile ( XrdSysError & eDest,
const char * path )
static

Definition at line 1408 of file XrdOucUtils.cc.

1409{
1410 char buff[32];
1411 int fd;
1412
1413 if( (fd = open( path, O_WRONLY|O_CREAT|O_TRUNC, 0644 )) < 0 )
1414 {
1415 eDest.Emsg( "Config", errno, "create pidfile" );
1416 return false;
1417 }
1418
1419 if( write( fd, buff, snprintf( buff, sizeof(buff), "%d",
1420 static_cast<int>(getpid()) ) ) < 0 )
1421 {
1422 eDest.Emsg( "Config", errno, "write to pidfile" );
1423 close(fd);
1424 return false;
1425 }
1426
1427 close(fd);
1428 return true;
1429}
#define write(a, b, c)
Definition XrdPosix.hh:115

References close, eDest, XrdSysError::Emsg(), open, and write.

Referenced by XrdFrmConfig::Configure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReLink()

int XrdOucUtils::ReLink ( const char * path,
const char * target,
mode_t mode = 0 )
static

Definition at line 1107 of file XrdOucUtils.cc.

1108{
1109 const mode_t AMode = S_IRWXU; // Only us as a default
1110 char pbuff[MAXPATHLEN+64];
1111 int n;
1112
1113// Copy the path
1114//
1115 n = strlen(path);
1116 if (n >= (int)sizeof(pbuff)) return ENAMETOOLONG;
1117 strcpy(pbuff, path);
1118
1119// Unlink the target, make the path, and create the symlink
1120//
1121 unlink(path);
1122 makePath(pbuff, (mode ? mode : AMode));
1123 if (symlink(target, path)) return errno;
1124 return 0;
1125}
#define unlink(a)
Definition XrdPosix.hh:113

References makePath(), and unlink.

+ Here is the call graph for this function:

◆ Sanitize()

void XrdOucUtils::Sanitize ( char * instr,
char subc = '_' )
static

Definition at line 1131 of file XrdOucUtils.cc.

1132{
1133
1134// Sanitize string according to POSIX.1-2008 stanadard using only the
1135// Portable Filename Character Set: a-z A-Z 0-9 ._- with 1st char not being -
1136//
1137 if (*str)
1138 {if (*str == '-') *str = subc;
1139 else if (*str == ' ') *str = subc;
1140 char *blank = rindex(str, ' ');
1141 if (blank) while(*blank == ' ') *blank-- = 0;
1142 while(*str)
1143 {if (!isalnum(*str) && index("_-.", *str) == 0) *str = subc;
1144 str++;
1145 }
1146 }
1147}

◆ subLogfn()

char * XrdOucUtils::subLogfn ( XrdSysError & eDest,
const char * inst,
char * logfn )
static

Definition at line 1153 of file XrdOucUtils.cc.

1154{
1155 const mode_t lfm = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
1156 char buff[2048], *sp;
1157 int rc;
1158
1159 if (!inst || !*inst) return logfn;
1160 if (!(sp = rindex(logfn, '/'))) strcpy(buff, "./");
1161 else {*sp = '\0'; strcpy(buff, logfn); strcat(buff, "/");}
1162
1163 strcat(buff, inst); strcat(buff, "/");
1164
1165 if ((rc = XrdOucUtils::makePath(buff, lfm)))
1166 {eDest.Emsg("Config", rc, "create log file path", buff);
1167 return 0;
1168 }
1169
1170 if (sp) {*sp = '/'; strcat(buff, sp+1);}
1171 else strcat(buff, logfn);
1172
1173 free(logfn);
1174 return strdup(buff);
1175}

References eDest, XrdSysError::Emsg(), and makePath().

Referenced by XrdOucLogging::configLog(), and XrdFrmConfig::Configure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Token()

int XrdOucUtils::Token ( const char ** str,
char delim,
char * buff,
int bsz )
static

Definition at line 1194 of file XrdOucUtils.cc.

1195{
1196 const char *eP, *bP = *str;
1197 int aLen, mLen;
1198
1199// Trim off the delimeters. Return zero if nothing left.
1200//
1201 while(*bP && *bP == delim) bP++;
1202 if (*bP == 0) {*buff = 0; return 0;}
1203
1204// Find the next delimiter
1205//
1206 eP = bP;
1207 while(*eP && *eP != delim) eP++;
1208
1209// If we ended at a null, make sure next call will return zero
1210//
1211 if (*eP == 0) *str = eP;
1212 else *str = eP+1;
1213
1214// Calculate length and make sure we don't overrun the buffer
1215//
1216 aLen = eP-bP;
1217 if (aLen >= bsz) mLen = bsz-1;
1218 else mLen = aLen;
1219
1220// Copy token into buffer and end with null byte
1221//
1222 strncpy(buff, bP, mLen);
1223 buff[mLen] = 0;
1224
1225// Return actual length
1226//
1227 return aLen;
1228}

◆ toLower()

void XrdOucUtils::toLower ( char * str)
static

Definition at line 1181 of file XrdOucUtils.cc.

1182{
1183 unsigned char* ustr = (unsigned char*)str; // Avoid undefined behaviour
1184
1185// Change each character to lower case
1186//
1187 while(*ustr) {*ustr = tolower(*ustr); ustr++;}
1188}

Referenced by XrdCksManager::Config(), XrdOfsConfigPI::DefaultCS(), XrdNetUtils::NetConfig(), and XrdCksConfig::ParseLib().

+ Here is the caller graph for this function:

◆ trim()

void XrdOucUtils::trim ( std::string & str)
static

Definition at line 1442 of file XrdOucUtils.cc.

1442 {
1443 // Trim leading non-letters
1444 while( str.size() && !isgraph(str[0]) ) str.erase(str.begin());
1445
1446 // Trim trailing non-letters
1447
1448 while( str.size() && !isgraph(str[str.size()-1]) )
1449 str.resize (str.size () - 1);
1450}

Referenced by XrdHttpReadRangeHandler::Configure(), and trim().

+ Here is the caller graph for this function:

◆ UidName()

int XrdOucUtils::UidName ( uid_t uID,
char * uName,
int uNsz,
time_t keepT = 0 )
static

Definition at line 1312 of file XrdOucUtils.cc.

1313{
1314 struct passwd *pEnt, pStruct;
1315 char pBuff[1024];
1316 int n, rc;
1317
1318// Get ID from cache, if allowed
1319//
1320 if (keepT)
1321 {int n = LookUp(uidMap, static_cast<unsigned int>(uID),uName,uNsz);
1322 if (n > 0) return (n < uNsz ? n : 0);
1323 }
1324
1325// Try to obtain the username. We use this form to make sure we are using
1326// the standards conforming version (compilation error otherwise).
1327//
1328 rc = getpwuid_r(uID, &pStruct, pBuff, sizeof(pBuff), &pEnt);
1329 if (rc || !pEnt)
1330 {n = snprintf(uName, uNsz, "%ud", static_cast<unsigned int>(uID));
1331 return (n >= uNsz ? 0 : n);
1332 }
1333
1334// Add entry to the cache if need be
1335//
1336 if (keepT)
1337 AddID(uidMap, static_cast<unsigned int>(uID), pEnt->pw_name, keepT);
1338
1339// Return length of username or zero if it is too big
1340//
1341 n = strlen(pEnt->pw_name);
1342 if (uNsz <= (int)strlen(pEnt->pw_name)) return 0;
1343 strcpy(uName, pEnt->pw_name);
1344 return n;
1345}

◆ Undercover()

void XrdOucUtils::Undercover ( XrdSysError & eDest,
int noLog,
int * pipeFD = 0 )
static

Definition at line 1238 of file XrdOucUtils.cc.

1239{
1240 static const int maxFiles = 256;
1241 pid_t mypid;
1242 int myfd, logFD = eDest.baseFD();
1243
1244// Issue warning if there is no logfile attached
1245//
1246 if (noLog) eDest.Emsg("Config", "Warning! No log file specified; "
1247 "backgrounding disables all logging!");
1248
1249// Fork so that we are not tied to a shell
1250//
1251 if ((mypid = fork()) < 0)
1252 {eDest.Emsg("Config", errno, "fork process 1 for backgrounding");
1253 return;
1254 }
1255 else if (mypid)
1256 {
1257 // we have been given a pair of pipe descriptors to be able to read the
1258 // status of the child process
1259 if( pipeFD )
1260 {
1261 int status = 1;
1262 close( pipeFD[1] );
1263 // read will wait untill the status is communicated by the
1264 // child process, if the child process dies before being able
1265 // to comunicate the status then read will see EOF
1266 if( read( pipeFD[0], &status, sizeof(status) ) != sizeof(status) )
1267 _exit(1);
1268 _exit(status);
1269 }
1270 // no pipes given, return success
1271 else _exit(0);
1272 }
1273
1274 if( pipeFD )
1275 close( pipeFD[0] );
1276
1277// Become the process group leader
1278//
1279 if (setsid() < 0)
1280 {eDest.Emsg("Config", errno, "doing setsid() for backgrounding");
1281 return;
1282 }
1283
1284// Fork to that we are cannot get a controlling terminal
1285//
1286 if ((mypid = fork()) < 0)
1287 {eDest.Emsg("Config", errno, "fork process 2 for backgrounding");
1288 return;
1289 }
1290 else if (mypid) _exit(0);
1291
1292// Switch stdin, stdout, and stderr to /dev/null (we can't use /dev/console
1293// unless we are root which is unlikely).
1294//
1295 if ((myfd = open("/dev/null", O_RDWR)) < 0)
1296 {eDest.Emsg("Config", errno, "open /dev/null for backgrounding");
1297 return;
1298 }
1299 dup2(myfd, 0); dup2(myfd, 1); dup2(myfd, 2); dup2(myfd, logFD);
1300
1301// Close any open file descriptors left open by the parent process
1302// but the communication pipe and the logger's shadow file descriptor.
1303//
1304 for (myfd = 3; myfd < maxFiles; myfd++)
1305 if( (!pipeFD || myfd != pipeFD[1]) && myfd != logFD ) close(myfd);
1306}

References XrdSysError::baseFD(), close, eDest, XrdSysError::Emsg(), open, and read.

Referenced by XrdConfig::Configure(), and XrdFrmConfig::Configure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UserName()

int XrdOucUtils::UserName ( uid_t uID,
char * uName,
int uNsz )
static

Definition at line 1351 of file XrdOucUtils.cc.

1352{
1353 struct passwd *pEnt, pStruct;
1354 char pBuff[1024];
1355 int rc;
1356
1357// Try to obtain the username. We use this form to make sure we are using
1358// the standards conforming version (compilation error otherwise).
1359//
1360 rc = getpwuid_r(uID, &pStruct, pBuff, sizeof(pBuff), &pEnt);
1361 if (rc) return rc;
1362 if (!pEnt) return ESRCH;
1363
1364// Return length of username or zero if it is too big
1365//
1366 if (uNsz <= (int)strlen(pEnt->pw_name)) return ENAMETOOLONG;
1367 strcpy(uName, pEnt->pw_name);
1368 return 0;
1369}

Referenced by XrdPfc::Cache::Config(), XrdSecProtocolunix::getCredentials(), and Ident().

+ Here is the caller graph for this function:

◆ ValPath()

const char * XrdOucUtils::ValPath ( const char * path,
mode_t allow,
bool isdir )
static

Definition at line 1375 of file XrdOucUtils.cc.

1376{
1377 static const mode_t mMask = S_IRWXU | S_IRWXG | S_IRWXO;
1378 struct stat buf;
1379
1380// Check if this really exists
1381//
1382 if (stat(path, &buf))
1383 {if (errno == ENOENT) return "does not exist.";
1384 return XrdSysE2T(errno);
1385 }
1386
1387// Verify that this is the correct type of file
1388//
1389 if (isdir)
1390 {if (!S_ISDIR(buf.st_mode)) return "is not a directory.";
1391 } else {
1392 if (!S_ISREG(buf.st_mode)) return "is not a file.";
1393 }
1394
1395// Verify that the does not have excessive privileges
1396//
1397 if ((buf.st_mode & mMask) & ~allow) return "has excessive access rights.";
1398
1399// All went well
1400//
1401 return 0;
1402}

References stat, and XrdSysE2T().

Referenced by XrdCl::InitTLS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ pathMode

const mode_t XrdOucUtils::pathMode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH
static

Definition at line 47 of file XrdOucUtils.hh.

Referenced by makeHome().


The documentation for this class was generated from the following files: