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
13
#include <string.h>
14
#include <time.h>
15
#include "
XrdSys/XrdSysPthread.hh
"
16
17
class
XrdOucErrInfo
;
18
class
XrdOucStream
;
19
20
class
XrdSecsssKT
21
{
22
public
:
23
24
class
ktEnt
25
{
26
public
:
27
28
static
const
int
maxKLen
= 128;
29
static
const
int
NameSZ
= 192;
30
static
const
int
UserSZ
= 128;
31
static
const
int
GrupSZ
= 64;
32
33
struct
ktData
34
{
long
long
ID
;
35
time_t
Crt
;
36
time_t
Exp
;
37
int
Opts
;
38
int
Len
;
39
char
Val
[
maxKLen
];
// Key strings are 1024 bits or less
40
char
Name
[
NameSZ
];
// Key names are null terminated
41
char
User
[
UserSZ
];
// Usr names are null terminated
42
char
Grup
[
GrupSZ
];
// Grp names are null terminated
43
}
Data
;
44
45
static
const
int
anyUSR
= 2;
46
static
const
int
anyGRP
= 4;
47
static
const
int
usrGRP
= 8;
48
49
void
NUG
(
ktEnt
*ktP) {strcpy(
Data
.
Name
, ktP->
Data
.
Name
);
50
strcpy(
Data
.
User
, ktP->
Data
.
User
);
51
strcpy(
Data
.
Grup
, ktP->
Data
.
Grup
);
52
}
53
void
Set
(
ktEnt
&rhs) {
Data
.
ID
=rhs.
Data
.
ID
;
Data
.
Len
= rhs.
Data
.
Len
;
54
memcpy(
Data
.
Val
, rhs.
Data
.
Val
,
Data
.
Len
);
55
Data
.
Crt
=rhs.
Data
.
Crt
;
Data
.
Exp
=rhs.
Data
.
Exp
;
56
}
57
ktEnt
*
Next
;
58
59
ktEnt
() :
Next
(0) {
Data
.
ID
= -1;
Data
.
Opts
= 0;
60
*
Data
.
Val
=
'\0'
; *
Data
.
Name
=
'\0'
;
61
*
Data
.
User
=
'\0'
; *
Data
.
Grup
=
'\0'
;
62
}
63
~ktEnt
() {}
64
};
65
66
void
addKey
(ktEnt &ktNew);
67
68
int
delKey
(ktEnt &ktDel);
69
70
static
71
char
*
genFN
();
72
73
static
74
void
genKey
(
char
*Buff,
int
blen);
75
76
int
getKey
(ktEnt &ktEql);
77
78
ktEnt
*
keyList
() {
return
ktList
;}
79
80
void
Refresh
();
81
82
time_t
RefrTime
() {
return
ktRefT
;}
83
84
int
Rewrite
(
int
Keep,
int
&numKeys,
int
&numTot,
int
&numExp);
85
86
int
Same
(
const
char
*path) {
return
(
ktPath
&& !strcmp(
ktPath
, path));}
87
88
void
setPath
(
const
char
*
Path
)
89
{
if
(
ktPath
) free(
ktPath
);
ktPath
= strdup(Path);}
90
91
enum
xMode
{
isAdmin
= 0,
isClient
,
isServer
};
92
93
XrdSecsssKT
(
XrdOucErrInfo
*,
const
char
*,
xMode
,
int
refr=60*60);
94
~XrdSecsssKT
();
95
96
private
:
97
int
eMsg
(
const
char
*epn,
int
rc,
const
char
*txt1,
98
const
char
*txt2=0,
const
char
*txt3=0,
const
char
*txt4=0);
99
ktEnt *
getKeyTab
(
XrdOucErrInfo
*eInfo, time_t Mtime, mode_t Amode);
100
mode_t
fileMode
(
const
char
*
Path
);
101
int
isKey
(ktEnt &ktRef, ktEnt *ktP,
int
Full=1);
102
void
keyB2X
(ktEnt *theKT,
char
*buff);
103
void
keyX2B
(ktEnt *theKT,
char
*xKey);
104
ktEnt *
ktDecode0
(
XrdOucStream
&kTab,
XrdOucErrInfo
*eInfo);
105
106
XrdSysMutex
myMutex
;
107
char
*
ktPath
;
108
ktEnt
*
ktList
;
109
time_t
ktMtime
;
110
xMode
ktMode
;
111
time_t
ktRefT
;
112
int
kthiID
;
113
pthread_t
ktRefID
;
114
static
int
randFD
;
115
};
116
#endif
Generated by
1.8.1.2