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

#include <XrdAccCapability.hh>

+ Collaboration diagram for XrdAccCapability:

Public Member Functions

 XrdAccCapability (char *pathval, XrdAccPrivCaps &privval)
 
 XrdAccCapability (XrdAccCapability *taddr)
 
 ~XrdAccCapability ()
 
void Add (XrdAccCapability *newcap)
 
XrdAccCapabilityNext ()
 
int Privs (XrdAccPrivCaps &pathpriv, const char *pathname, const char *pathsub=0)
 
int Privs (XrdAccPrivCaps &pathpriv, const char *pathname, const int pathlen, const char *pathsub=0)
 
int Privs (XrdAccPrivCaps &pathpriv, const char *pathname, const int pathlen, const unsigned long pathhash, const char *pathsub=0)
 
int Subcomp (const char *pathname, const int pathlen, const char *pathsub, const int sublen)
 

Detailed Description

Definition at line 43 of file XrdAccCapability.hh.

Constructor & Destructor Documentation

◆ XrdAccCapability() [1/2]

XrdAccCapability::XrdAccCapability ( char * pathval,
XrdAccPrivCaps & privval )

Definition at line 43 of file XrdAccCapability.cc.

44{
45 int i;
46
47// Do common initialization
48//
49 next = 0; ctmp = 0;
50 priv.pprivs = privval.pprivs; priv.nprivs = privval.nprivs;
51 plen = strlen(pathval); pins = 0; prem = 0;
52 pkey = XrdOucHashVal2((const char *)pathval, plen);
53 path = strdup(pathval);
54
55// Now set up for @= insertions. We do this eventhough it might never be used
56//
57 for (i = 0; i < plen; i++)
58 if (path[i] == '@' && path[i+1] == '=')
59 {pins = i; prem = plen - i - 2; break;}
60}
unsigned long XrdOucHashVal2(const char *KeyVal, int KeyLen)
XrdAccPrivs nprivs
XrdAccPrivs pprivs

References XrdAccPrivCaps::nprivs, XrdAccPrivCaps::pprivs, and XrdOucHashVal2().

+ Here is the call graph for this function:

◆ XrdAccCapability() [2/2]

XrdAccCapability::XrdAccCapability ( XrdAccCapability * taddr)
inline

Definition at line 81 of file XrdAccCapability.hh.

82 {next = 0; ctmp = taddr;
83 pkey = 0; path = 0; plen = 0; pins = 0; prem = 0;
84 }

◆ ~XrdAccCapability()

XrdAccCapability::~XrdAccCapability ( )

Definition at line 69 of file XrdAccCapability.cc.

70{
71 XrdAccCapability *cp, *np = next;
72
73 if (path) {free(path); path = 0;}
74
75 while(np) {cp = np; np = np->next; cp->next = 0; delete cp;}
76 next = 0;
77}

Member Function Documentation

◆ Add()

void XrdAccCapability::Add ( XrdAccCapability * newcap)
inline

Definition at line 46 of file XrdAccCapability.hh.

46{next = newcap;}

◆ Next()

XrdAccCapability * XrdAccCapability::Next ( )
inline

Definition at line 48 of file XrdAccCapability.hh.

48{return next;}

◆ Privs() [1/3]

int XrdAccCapability::Privs ( XrdAccPrivCaps & pathpriv,
const char * pathname,
const char * pathsub = 0 )
inline

Definition at line 68 of file XrdAccCapability.hh.

71 {extern unsigned long XrdOucHashVal2(const char *,int);
72 int pathlen = strlen(pathname);
73 return Privs(pathpriv, pathname, pathlen,
74 XrdOucHashVal2(pathname, pathlen), pathsub);}
int Privs(XrdAccPrivCaps &pathpriv, const char *pathname, const int pathlen, const unsigned long pathhash, const char *pathsub=0)

References Privs(), and XrdOucHashVal2().

+ Here is the call graph for this function:

◆ Privs() [2/3]

int XrdAccCapability::Privs ( XrdAccPrivCaps & pathpriv,
const char * pathname,
const int pathlen,
const char * pathsub = 0 )
inline

Definition at line 60 of file XrdAccCapability.hh.

64 {extern unsigned long XrdOucHashVal2(const char *,int);
65 return Privs(pathpriv, pathname, pathlen,
66 XrdOucHashVal2(pathname,(int)pathlen),pathsub);}

References Privs(), and XrdOucHashVal2().

+ Here is the call graph for this function:

◆ Privs() [3/3]

int XrdAccCapability::Privs ( XrdAccPrivCaps & pathpriv,
const char * pathname,
const int pathlen,
const unsigned long pathhash,
const char * pathsub = 0 )

Definition at line 82 of file XrdAccCapability.cc.

87{XrdAccCapability *cp=this;
88 const int psl = (pathsub ? strlen(pathsub) : 0);
89
90 do {if (cp->ctmp)
91 {if (cp->ctmp->Privs(pathpriv,pathname,pathlen,pathhash,pathsub))
92 return 1;
93 }
94 else if (pathlen >= cp->plen)
95 if ((!pathsub && !strncmp(pathname, cp->path, cp->plen))
96 || (pathsub && cp->Subcomp(pathname,pathlen,pathsub,psl)))
97 {pathpriv.pprivs = (XrdAccPrivs)(pathpriv.pprivs |
98 cp->priv.pprivs);
99 pathpriv.nprivs = (XrdAccPrivs)(pathpriv.nprivs |
100 cp->priv.nprivs);
101 return 1;
102 }
103 } while ((cp = cp->next));
104 return 0;
105}
XrdAccPrivs
int Subcomp(const char *pathname, const int pathlen, const char *pathsub, const int sublen)

References XrdAccPrivCaps::nprivs, XrdAccPrivCaps::pprivs, Privs(), and Subcomp().

Referenced by XrdAccAccess::Access(), Privs(), Privs(), and Privs().

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

◆ Subcomp()

int XrdAccCapability::Subcomp ( const char * pathname,
const int pathlen,
const char * pathsub,
const int sublen )

Definition at line 111 of file XrdAccCapability.cc.

113{ int ncmp;
114
115// First check if the prefix matches
116//
117 if (strncmp(pathname, path, pins)) return 0;
118
119// Now, check if the substitution appears in the source path
120//
121 if (strncmp(&pathname[pins], pathsub, sublen)) return 0;
122
123// Now check if we can match the tail
124//
125 ncmp = pins + sublen;
126 if ((pathlen - ncmp) < prem) return 0;
127
128// Return the results of matching the tail (prem should never be 0, but hey)
129//
130 if (prem) return !strncmp(&path[pins+2], &pathname[ncmp], prem);
131 return 1;
132}

Referenced by Privs().

+ Here is the caller graph for this function:

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