xrootd
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-AC03-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 // $Id$
14 
15 #include <stdlib.h>
16 #include <string.h>
17 #include <strings.h>
18 
19 #include "XrdAcc/XrdAccPrivs.hh"
20 
21 /******************************************************************************/
22 /* X r d A c c C a p a b i l i t y */
23 /******************************************************************************/
24 
26 {
27 public:
28 void Add(XrdAccCapability *newcap) {next = newcap;}
29 
31 
32 // Privs() searches the associated capability for a prefix matching path. If one
33 // is found, the privileges are or'd into the passed XrdAccPrivCaps struct and
34 // a 1 is returned. Otherwise, 0 is returned and XrdAccPrivCaps is unchanged.
35 //
36 int Privs( XrdAccPrivCaps &pathpriv,
37  const char *pathname,
38  const int pathlen,
39  const unsigned long pathhash,
40  const char *pathsub=0);
41 
42 int Privs( XrdAccPrivCaps &pathpriv,
43  const char *pathname,
44  const int pathlen,
45  const char *pathsub=0)
46  {extern unsigned long XrdOucHashVal2(const char *,int);
47  return Privs(pathpriv, pathname, pathlen,
48  XrdOucHashVal2(pathname,(int)pathlen),pathsub);}
49 
50 int Privs( XrdAccPrivCaps &pathpriv,
51  const char *pathname,
52  const char *pathsub=0)
53  {extern unsigned long XrdOucHashVal2(const char *,int);
54  int pathlen = strlen(pathname);
55  return Privs(pathpriv, pathname, pathlen,
56  XrdOucHashVal2(pathname, pathlen), pathsub);}
57 
58 int Subcomp(const char *pathname, const int pathlen,
59  const char *pathsub, const int sublen);
60 
61  XrdAccCapability(char *pathval, XrdAccPrivCaps &privval);
62 
64  {next = 0; ctmp = taddr;
65  pkey = 0; path = 0; plen = 0; pins = 0; prem = 0;
66  }
67 
69 private:
70 XrdAccCapability *next; // -> Next capability
71 XrdAccCapability *ctmp; // -> Capability template
72 
73 /*----------- The below fields are valid when template is zero -----------*/
74 
76 unsigned long pkey;
77 char *path;
78 int plen;
79 int pins; // index of @=
80 int prem; // remaining length after @=
81 };
82 
83 /******************************************************************************/
84 /* X r d A c c C a p N a m e */
85 /******************************************************************************/
86 
88 {
89 public:
90 void Add(XrdAccCapName *cnp) {next = cnp;}
91 
92 XrdAccCapability *Find(const char *name);
93 
94  XrdAccCapName(char *name, XrdAccCapability *cap)
95  {next = 0; CapName = strdup(name); CNlen = strlen(name);
96  C_List = cap;
97  }
99 private:
101 char *CapName;
102 int CNlen;
104 };
105 #endif