XRootD
Loading...
Searching...
No Matches
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 <cstring>
34
#include <ctime>
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
long
long
Flags
;
// Future!
56
time_t
Crt
;
57
time_t
Exp
;
58
int
Opts
;
59
int
Len
;
60
char
Val
[
maxKLen
];
// Key strings are 1024 bits or less
61
char
Name
[
NameSZ
];
// Key names are null terminated
62
char
User
[
UserSZ
];
// Usr names are null terminated
63
char
Grup
[
GrupSZ
];
// Grp names are null terminated
64
}
Data
;
65
66
static
const
int
allUSR
= 1;
67
static
const
int
anyUSR
= 2;
68
static
const
int
anyGRP
= 4;
69
static
const
int
usrGRP
= 8;
70
static
const
int
noIPCK
=16;
71
72
void
NUG
(
ktEnt
*ktP) {strcpy(
Data
.
Name
, ktP->
Data
.
Name
);
73
strcpy(
Data
.
User
, ktP->
Data
.
User
);
74
strcpy(
Data
.
Grup
, ktP->
Data
.
Grup
);
75
}
76
void
Set
(
ktEnt
&rhs) {
Data
.
ID
=rhs.
Data
.
ID
;
Data
.
Len
= rhs.
Data
.
Len
;
77
memcpy(
Data
.
Val
, rhs.
Data
.
Val
,
Data
.
Len
);
78
Data
.
Crt
=rhs.
Data
.
Crt
;
Data
.
Exp
=rhs.
Data
.
Exp
;
79
}
80
ktEnt
*
Next
;
81
82
ktEnt
() :
Next
(0) {
Data
.
ID
= -1;
Data
.
Flags
= 0;
Data
.
Opts
= 0;
83
*
Data
.
Val
=
'\0'
; *
Data
.
Name
=
'\0'
;
84
*
Data
.
User
=
'\0'
; *
Data
.
Grup
=
'\0'
;
85
}
86
~ktEnt
() {}
87
};
88
89
void
addKey
(ktEnt &ktNew);
90
91
int
delKey
(ktEnt &ktDel);
92
93
static
94
char
*
genFN
();
95
96
static
97
void
genKey
(
char
*Buff,
int
blen);
98
99
int
getKey
(ktEnt &ktEql,
bool
andKeyID=
false
);
100
101
ktEnt
*
keyList
() {
return
ktList;}
102
103
void
Refresh
();
104
105
time_t
RefrTime
() {
return
ktRefT;}
106
107
int
Rewrite
(
int
Keep,
int
&numKeys,
int
&numTot,
int
&numExp);
108
109
int
Same
(
const
char
*path) {
return
(ktPath && !strcmp(ktPath, path));}
110
111
void
setPath
(
const
char
*
Path
)
112
{
if
(ktPath) free(ktPath); ktPath = strdup(
Path
);}
113
114
enum
xMode
{
isAdmin
= 0,
isClient
,
isServer
};
115
116
XrdSecsssKT
(
XrdOucErrInfo
*,
const
char
*,
xMode
,
int
refr=60*60);
117
~XrdSecsssKT
();
118
119
private
:
120
int
eMsg
(
const
char
*epn,
int
rc,
const
char
*txt1,
121
const
char
*txt2=0,
const
char
*txt3=0,
const
char
*txt4=0);
122
ktEnt *getKeyTab(
XrdOucErrInfo
*eInfo, time_t Mtime, mode_t Amode);
123
mode_t fileMode(
const
char
*
Path
);
124
int
isKey(ktEnt &ktRef, ktEnt *ktP,
int
Full=1);
125
void
keyB2X(ktEnt *theKT,
char
*buff);
126
void
keyX2B(ktEnt *theKT,
char
*xKey);
127
ktEnt *ktDecode0(
XrdOucStream
&kTab,
XrdOucErrInfo
*eInfo);
128
129
XrdSysMutex
myMutex;
130
char
*ktPath;
131
ktEnt *ktList;
132
time_t ktMtime;
133
xMode
ktMode;
134
time_t ktRefT;
135
int
kthiID;
136
pthread_t ktRefID;
137
static
int
randFD;
138
};
139
#endif
Path
XrdOucString Path
Definition
XrdSecpwdSrvAdmin.cc:160
eMsg
#define eMsg(x)
Definition
XrdSecsssAdmin.cc:53
XrdSysPthread.hh
XrdOucErrInfo
Definition
XrdOucErrInfo.hh:101
XrdOucStream
Definition
XrdOucStream.hh:47
XrdSecsssKT::ktEnt
Definition
XrdSecsssKT.hh:45
XrdSecsssKT::ktEnt::ktData::User
char User[UserSZ]
Definition
XrdSecsssKT.hh:62
XrdSecsssKT::ktEnt::anyUSR
static const int anyUSR
Definition
XrdSecsssKT.hh:67
XrdSecsssKT::ktEnt::UserSZ
static const int UserSZ
Definition
XrdSecsssKT.hh:50
XrdSecsssKT::ktEnt::Data
struct XrdSecsssKT::ktEnt::ktData Data
XrdSecsssKT::ktEnt::noIPCK
static const int noIPCK
Definition
XrdSecsssKT.hh:70
XrdSecsssKT::ktEnt::ktData::Flags
long long Flags
Definition
XrdSecsssKT.hh:55
XrdSecsssKT::ktEnt::NUG
void NUG(ktEnt *ktP)
Definition
XrdSecsssKT.hh:72
XrdSecsssKT::ktEnt::ktData::Exp
time_t Exp
Definition
XrdSecsssKT.hh:57
XrdSecsssKT::ktEnt::ktData::Opts
int Opts
Definition
XrdSecsssKT.hh:58
XrdSecsssKT::ktEnt::anyGRP
static const int anyGRP
Definition
XrdSecsssKT.hh:68
XrdSecsssKT::ktEnt::GrupSZ
static const int GrupSZ
Definition
XrdSecsssKT.hh:51
XrdSecsssKT::ktEnt::Set
void Set(ktEnt &rhs)
Definition
XrdSecsssKT.hh:76
XrdSecsssKT::ktEnt::ktEnt
ktEnt()
Definition
XrdSecsssKT.hh:82
XrdSecsssKT::ktEnt::maxKLen
static const int maxKLen
Definition
XrdSecsssKT.hh:48
XrdSecsssKT::ktEnt::allUSR
static const int allUSR
Definition
XrdSecsssKT.hh:66
XrdSecsssKT::ktEnt::ktData::Val
char Val[maxKLen]
Definition
XrdSecsssKT.hh:60
XrdSecsssKT::ktEnt::usrGRP
static const int usrGRP
Definition
XrdSecsssKT.hh:69
XrdSecsssKT::ktEnt::NameSZ
static const int NameSZ
Definition
XrdSecsssKT.hh:49
XrdSecsssKT::ktEnt::ktData::Name
char Name[NameSZ]
Definition
XrdSecsssKT.hh:61
XrdSecsssKT::ktEnt::ktData::ID
long long ID
Definition
XrdSecsssKT.hh:54
XrdSecsssKT::ktEnt::ktData::Crt
time_t Crt
Definition
XrdSecsssKT.hh:56
XrdSecsssKT::ktEnt::Next
ktEnt * Next
Definition
XrdSecsssKT.hh:80
XrdSecsssKT::ktEnt::ktData::Len
int Len
Definition
XrdSecsssKT.hh:59
XrdSecsssKT::ktEnt::ktData::Grup
char Grup[GrupSZ]
Definition
XrdSecsssKT.hh:63
XrdSecsssKT::ktEnt::~ktEnt
~ktEnt()
Definition
XrdSecsssKT.hh:86
XrdSecsssKT::ktEnt::ktData
Definition
XrdSecsssKT.hh:54
XrdSecsssKT
Definition
XrdSecsssKT.hh:41
XrdSecsssKT::~XrdSecsssKT
~XrdSecsssKT()
Definition
XrdSecsssKT.cc:130
XrdSecsssKT::Same
int Same(const char *path)
Definition
XrdSecsssKT.hh:109
XrdSecsssKT::setPath
void setPath(const char *Path)
Definition
XrdSecsssKT.hh:111
XrdSecsssKT::delKey
int delKey(ktEnt &ktDel)
Definition
XrdSecsssKT.cc:185
XrdSecsssKT::Rewrite
int Rewrite(int Keep, int &numKeys, int &numTot, int &numExp)
Definition
XrdSecsssKT.cc:339
XrdSecsssKT::genFN
static char * genFN()
Definition
XrdSecsssKT.cc:249
XrdSecsssKT::Refresh
void Refresh()
Definition
XrdSecsssKT.cc:311
XrdSecsssKT::getKey
int getKey(ktEnt &ktEql, bool andKeyID=false)
Definition
XrdSecsssKT.cc:207
XrdSecsssKT::keyList
ktEnt * keyList()
Definition
XrdSecsssKT.hh:101
XrdSecsssKT::RefrTime
time_t RefrTime()
Definition
XrdSecsssKT.hh:105
XrdSecsssKT::xMode
xMode
Definition
XrdSecsssKT.hh:114
XrdSecsssKT::isClient
@ isClient
Definition
XrdSecsssKT.hh:114
XrdSecsssKT::isServer
@ isServer
Definition
XrdSecsssKT.hh:114
XrdSecsssKT::isAdmin
@ isAdmin
Definition
XrdSecsssKT.hh:114
XrdSecsssKT::genKey
static void genKey(char *Buff, int blen)
Definition
XrdSecsssKT.cc:268
XrdSecsssKT::addKey
void addKey(ktEnt &ktNew)
Definition
XrdSecsssKT.cc:158
XrdSysMutex
Definition
XrdSysPthread.hh:165
XrdSecsss
XrdSecsssKT.hh
Generated by
1.9.8