xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdSecsss
XrdSecsssKT.hh
Go to the documentation of this file.
1
#ifndef __SecsssKT__
2
#define __SecsssKT__
3
/******************************************************************************/
4
/* */
5
/* X r d S e c s s s K T . h h */
6
/* */
7
/* (c) 2008 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 <string.h>
34
#include <time.h>
35
#include "
XrdSys/XrdSysPthread.hh
"
36
37
class
XrdOucErrInfo
;
38
class
XrdOucStream
;
39
40
class
XrdSecsssKT
41
{
42
public
:
43
44
class
ktEnt
45
{
46
public
:
47
48
static
const
int
maxKLen
= 128;
49
static
const
int
NameSZ
= 192;
50
static
const
int
UserSZ
= 128;
51
static
const
int
GrupSZ
= 64;
52
53
struct
ktData
54
{
long
long
ID
;
55
time_t
Crt
;
56
time_t
Exp
;
57
int
Opts
;
58
int
Len
;
59
char
Val
[
maxKLen
];
// Key strings are 1024 bits or less
60
char
Name
[
NameSZ
];
// Key names are null terminated
61
char
User
[
UserSZ
];
// Usr names are null terminated
62
char
Grup
[
GrupSZ
];
// Grp names are null terminated
63
}
Data
;
64
65
static
const
int
anyUSR
= 2;
66
static
const
int
anyGRP
= 4;
67
static
const
int
usrGRP
= 8;
68
69
void
NUG
(
ktEnt
*ktP) {strcpy(
Data
.
Name
, ktP->
Data
.
Name
);
70
strcpy(
Data
.
User
, ktP->
Data
.
User
);
71
strcpy(
Data
.
Grup
, ktP->
Data
.
Grup
);
72
}
73
void
Set
(
ktEnt
&rhs) {
Data
.
ID
=rhs.
Data
.
ID
;
Data
.
Len
= rhs.
Data
.
Len
;
74
memcpy(
Data
.
Val
, rhs.
Data
.
Val
,
Data
.
Len
);
75
Data
.
Crt
=rhs.
Data
.
Crt
;
Data
.
Exp
=rhs.
Data
.
Exp
;
76
}
77
ktEnt
*
Next
;
78
79
ktEnt
() :
Next
(0) {
Data
.
ID
= -1;
Data
.
Opts
= 0;
80
*
Data
.
Val
=
'\0'
; *
Data
.
Name
=
'\0'
;
81
*
Data
.
User
=
'\0'
; *
Data
.
Grup
=
'\0'
;
82
}
83
~ktEnt
() {}
84
};
85
86
void
addKey
(ktEnt &ktNew);
87
88
int
delKey
(ktEnt &ktDel);
89
90
static
91
char
*
genFN
();
92
93
static
94
void
genKey
(
char
*Buff,
int
blen);
95
96
int
getKey
(ktEnt &ktEql);
97
98
ktEnt
*
keyList
() {
return
ktList
;}
99
100
void
Refresh
();
101
102
time_t
RefrTime
() {
return
ktRefT
;}
103
104
int
Rewrite
(
int
Keep,
int
&numKeys,
int
&numTot,
int
&numExp);
105
106
int
Same
(
const
char
*path) {
return
(
ktPath
&& !strcmp(
ktPath
, path));}
107
108
void
setPath
(
const
char
*
Path
)
109
{
if
(
ktPath
) free(
ktPath
);
ktPath
= strdup(Path);}
110
111
enum
xMode
{
isAdmin
= 0,
isClient
,
isServer
};
112
113
XrdSecsssKT
(
XrdOucErrInfo
*,
const
char
*,
xMode
,
int
refr=60*60);
114
~XrdSecsssKT
();
115
116
private
:
117
int
eMsg
(
const
char
*epn,
int
rc,
const
char
*txt1,
118
const
char
*txt2=0,
const
char
*txt3=0,
const
char
*txt4=0);
119
ktEnt *
getKeyTab
(
XrdOucErrInfo
*eInfo, time_t Mtime, mode_t Amode);
120
mode_t
fileMode
(
const
char
*
Path
);
121
int
isKey
(ktEnt &ktRef, ktEnt *ktP,
int
Full=1);
122
void
keyB2X
(ktEnt *theKT,
char
*buff);
123
void
keyX2B
(ktEnt *theKT,
char
*xKey);
124
ktEnt *
ktDecode0
(
XrdOucStream
&kTab,
XrdOucErrInfo
*eInfo);
125
126
XrdSysMutex
myMutex
;
127
char
*
ktPath
;
128
ktEnt
*
ktList
;
129
time_t
ktMtime
;
130
xMode
ktMode
;
131
time_t
ktRefT
;
132
int
kthiID
;
133
pthread_t
ktRefID
;
134
static
int
randFD
;
135
};
136
#endif
Generated by
1.8.3.1