xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdAcc
XrdAccGroups.hh
Go to the documentation of this file.
1
#ifndef _ACC_GROUPS_H
2
#define _ACC_GROUPS_H
3
/******************************************************************************/
4
/* */
5
/* X r d A c c G r o u p s . 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 Deprtment of Energy */
11
/******************************************************************************/
12
13
// $Id$
14
15
#include <grp.h>
16
#include <limits.h>
17
18
#include "
XrdOuc/XrdOucHash.hh
"
19
#include "
XrdSys/XrdSysPthread.hh
"
20
21
/******************************************************************************/
22
/* X r d A c c G r o u p L i s t */
23
/******************************************************************************/
24
25
class
XrdAccGroupList
26
{
27
public
:
28
29
const
char
*
First
() {
return
grouptab
[0];}
30
31
const
char
*
Next
() {
if
(
grouptab
[
nextgroup
])
return
grouptab
[nextgroup++];
32
return
(
const
char
*)0;
33
}
34
35
void
Reset
() {
nextgroup
= 0;}
36
37
XrdAccGroupList
(
const
int
cnt=0,
const
char
**gtable=0)
38
{
int
j = (cnt > NGROUPS_MAX ? NGROUPS_MAX : cnt);
39
if
(cnt) memcpy((
void
*)
grouptab
, (
const
void
*)gtable,
40
(
size_t
)(j *
sizeof
(
char
*)));
41
memset((
void
*)&
grouptab
[cnt], 0,
42
(
size_t
)((NGROUPS_MAX-j+1)*
sizeof
(
char
*)));
43
nextgroup
= 0;
44
}
45
46
XrdAccGroupList
(
XrdAccGroupList
& rv)
47
{memcpy((
void
*)
grouptab
,(
const
void
*)rv.
grouptab
,
sizeof
(
grouptab
));
48
nextgroup
= 0;
49
}
50
51
~XrdAccGroupList
() {}
52
53
private
:
54
const
char
*
grouptab
[NGROUPS_MAX+1];
55
int
nextgroup
;
56
};
57
58
/******************************************************************************/
59
/* G r o u p s O p t i o n s */
60
/******************************************************************************/
61
62
enum
XrdAccGroups_Options
{
Primary_Only
= 0x0001,
63
Groups_Debug
= 0x8000,
64
No_Group_Opt
= 0x0000
65
};
66
67
/******************************************************************************/
68
/* G r o u p T y p e s */
69
/******************************************************************************/
70
71
enum
XrdAccGroupType
{
XrdAccNoGroup
= 0,
XrdAccUnixGroup
,
XrdAccNetGroup
};
72
73
/******************************************************************************/
74
/* X r d A c c G r o u p s */
75
/******************************************************************************/
76
77
class
XrdAccGroups
78
{
79
public
:
80
81
// Domain() returns whatever we have for the NIS domain.
82
//
83
const
char
*
Domain
() {
return
domain
;}
84
85
// AddName() registers a name in the static name table. This allows us to
86
// avoid copying the strings a table points to when returning a table copy.
87
// If the name was added successfully, a pointer to the name is returned.
88
// Otherwise, zero is returned.
89
//
90
char
*
AddName
(
const
XrdAccGroupType
gtype,
const
char
*name);
91
92
// FindName() looks up a name in the static name table.
93
//
94
char
*
FindName
(
const
XrdAccGroupType
gtype,
const
char
*name);
95
96
// Groups() returns all of the relevant groups that a user belongs to. A
97
// null pointer may be returned if no groups are applicable.
98
//
99
XrdAccGroupList
*
Groups
(
const
char
*user);
100
101
// NetGroups() returns all of the relevant netgroups that the user/host
102
// combination belongs to. A null pointer may be returned is no netgroups
103
// are applicable.
104
//
105
XrdAccGroupList
*
NetGroups
(
const
char
*user,
const
char
*host);
106
107
// PurgeCache() removes all entries in the various caches. It is called
108
// whenever a new set of access tables has been instantiated.
109
//
110
void
PurgeCache
();
111
112
// Use by the configuration object to set group id's that must be looked up.
113
//
114
int
Retran
(
const
gid_t gid);
115
116
// Use by the configuration object to establish the netgroup domain.
117
//
118
void
SetDomain
(
const
char
*dname) {
domain
= dname;}
119
120
// Used by the configuration object to set the cache lifetime.
121
//
122
void
SetLifetime
(
const
int
seconds) {
LifeTime
= (int)seconds;}
123
124
// Used by the configuration object to set various options
125
//
126
void
SetOptions
(
XrdAccGroups_Options
opts
) {
options
=
opts
;}
127
128
XrdAccGroups
();
129
130
~XrdAccGroups
() {}
// The group object never gets deleted!!
131
132
private
:
133
134
int
addGroup
(
const
char
*user,
const
gid_t gid,
char
*gname,
135
char
**Gtab,
int
gtabi);
136
char
*
Dotran
(
const
gid_t gid,
char
*gname);
137
138
gid_t
retrangid
[128];
// Up to 128 retranslatable gids
139
int
retrancnt
;
// Number of used entries
140
time_t
LifeTime
;
// Seconds we can keep something in the cache
141
const
char
*
domain
;
// NIS netgroup domain to use
142
143
XrdAccGroups_Options
options
;
// Various option values.
144
int
HaveGroups
;
145
int
HaveNetGroups
;
146
147
XrdSysMutex
Group_Build_Context
,
Group_Name_Context
;
148
XrdSysMutex
Group_Cache_Context
,
NetGroup_Cache_Context
;
149
150
XrdOucHash<XrdAccGroupList>
NetGroup_Cache
;
151
XrdOucHash<XrdAccGroupList>
Group_Cache
;
152
XrdOucHash<char>
Group_Names
;
153
XrdOucHash<char>
NetGroup_Names
;
154
};
155
#endif
Generated by
1.8.1.2