xrootd
Loading...
Searching...
No Matches
XrdAccCapability.hh
Go to the documentation of this file.
1#ifndef __ACC_CAPABILITY__
2#define __ACC_CAPABILITY__
3/******************************************************************************/
4/* */
5/* X r d A c c C a p a b i l i t y . h h */
6/* */
7/* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include <cstdlib>
34#include <cstring>
35#include <strings.h>
36
37#include "XrdAcc/XrdAccPrivs.hh"
38
39/******************************************************************************/
40/* X r d A c c C a p a b i l i t y */
41/******************************************************************************/
42
44{
45public:
46void Add(XrdAccCapability *newcap) {next = newcap;}
47
49
50// Privs() searches the associated capability for a prefix matching path. If one
51// is found, the privileges are or'd into the passed XrdAccPrivCaps struct and
52// a 1 is returned. Otherwise, 0 is returned and XrdAccPrivCaps is unchanged.
53//
54int Privs( XrdAccPrivCaps &pathpriv,
55 const char *pathname,
56 const int pathlen,
57 const unsigned long pathhash,
58 const char *pathsub=0);
59
60int Privs( XrdAccPrivCaps &pathpriv,
61 const char *pathname,
62 const int pathlen,
63 const char *pathsub=0)
64 {extern unsigned long XrdOucHashVal2(const char *,int);
65 return Privs(pathpriv, pathname, pathlen,
66 XrdOucHashVal2(pathname,(int)pathlen),pathsub);}
67
68int Privs( XrdAccPrivCaps &pathpriv,
69 const char *pathname,
70 const char *pathsub=0)
71 {extern unsigned long XrdOucHashVal2(const char *,int);
72 int pathlen = strlen(pathname);
73 return Privs(pathpriv, pathname, pathlen,
74 XrdOucHashVal2(pathname, pathlen), pathsub);}
75
76int Subcomp(const char *pathname, const int pathlen,
77 const char *pathsub, const int sublen);
78
79 XrdAccCapability(char *pathval, XrdAccPrivCaps &privval);
80
82 {next = 0; ctmp = taddr;
83 pkey = 0; path = 0; plen = 0; pins = 0; prem = 0;
84 }
85
87private:
88XrdAccCapability *next; // -> Next capability
89XrdAccCapability *ctmp; // -> Capability template
90
91/*----------- The below fields are valid when template is zero -----------*/
92
94unsigned long pkey;
95char *path;
96int plen;
97int pins; // index of @=
98int prem; // remaining length after @=
99};
100
101/******************************************************************************/
102/* X r d A c c C a p N a m e */
103/******************************************************************************/
104
106{
107public:
108void Add(XrdAccCapName *cnp) {next = cnp;}
109
110XrdAccCapability *Find(const char *name);
111
113 {next = 0; CapName = strdup(name); CNlen = strlen(name);
114 C_List = cap;
115 }
117private:
122};
123#endif
Definition XrdAccCapability.hh:106
void Add(XrdAccCapName *cnp)
Definition XrdAccCapability.hh:108
XrdAccCapability * Find(const char *name)
XrdAccCapName * next
Definition XrdAccCapability.hh:118
int CNlen
Definition XrdAccCapability.hh:120
XrdAccCapName(char *name, XrdAccCapability *cap)
Definition XrdAccCapability.hh:112
char * CapName
Definition XrdAccCapability.hh:119
XrdAccCapability * C_List
Definition XrdAccCapability.hh:121
Definition XrdAccCapability.hh:44
XrdAccCapability * next
Definition XrdAccCapability.hh:88
int plen
Definition XrdAccCapability.hh:96
int prem
Definition XrdAccCapability.hh:98
unsigned long pkey
Definition XrdAccCapability.hh:94
XrdAccPrivCaps priv
Definition XrdAccCapability.hh:93
int Subcomp(const char *pathname, const int pathlen, const char *pathsub, const int sublen)
XrdAccCapability(char *pathval, XrdAccPrivCaps &privval)
void Add(XrdAccCapability *newcap)
Definition XrdAccCapability.hh:46
XrdAccCapability(XrdAccCapability *taddr)
Definition XrdAccCapability.hh:81
XrdAccCapability * Next()
Definition XrdAccCapability.hh:48
int Privs(XrdAccPrivCaps &pathpriv, const char *pathname, const char *pathsub=0)
Definition XrdAccCapability.hh:68
int pins
Definition XrdAccCapability.hh:97
char * path
Definition XrdAccCapability.hh:95
XrdAccCapability * ctmp
Definition XrdAccCapability.hh:89
int Privs(XrdAccPrivCaps &pathpriv, const char *pathname, const int pathlen, const char *pathsub=0)
Definition XrdAccCapability.hh:60
int Privs(XrdAccPrivCaps &pathpriv, const char *pathname, const int pathlen, const unsigned long pathhash, const char *pathsub=0)
Definition XrdAccPrivs.hh:77