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>
36
37class XrdOucErrInfo;
38class XrdOucStream;
39
41{
42public:
43
44class ktEnt
45{
46public:
47
48static const int maxKLen = 128;
49static const int NameSZ = 192;
50static const int UserSZ = 128;
51static const int GrupSZ = 64;
52
53struct 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
65
66static const int allUSR = 1;
67static const int anyUSR = 2;
68static const int anyGRP = 4;
69static const int usrGRP = 8;
70static 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 }
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
89void addKey(ktEnt &ktNew);
90
91int delKey(ktEnt &ktDel);
92
93static
94char *genFN();
95
96static
97void genKey(char *Buff, int blen);
98
99int getKey(ktEnt &ktEql, bool andKeyID=false);
100
101ktEnt *keyList() {return ktList;}
102
103void Refresh();
104
105time_t RefrTime() {return ktRefT;}
106
107int Rewrite(int Keep, int &numKeys, int &numTot, int &numExp);
108
109int Same(const char *path) {return (ktPath && !strcmp(ktPath, path));}
110
111void setPath(const char *Path)
112 {if (ktPath) free(ktPath); ktPath = strdup(Path);}
113
115
116 XrdSecsssKT(XrdOucErrInfo *, const char *, xMode, int refr=60*60);
118
119private:
120int eMsg(const char *epn, int rc, const char *txt1,
121 const char *txt2=0, const char *txt3=0, const char *txt4=0);
122ktEnt *getKeyTab(XrdOucErrInfo *eInfo, time_t Mtime, mode_t Amode);
123mode_t fileMode(const char *Path);
124int isKey(ktEnt &ktRef, ktEnt *ktP, int Full=1);
125void keyB2X(ktEnt *theKT, char *buff);
126void keyX2B(ktEnt *theKT, char *xKey);
128
130char *ktPath;
132time_t ktMtime;
134time_t ktRefT;
136pthread_t ktRefID;
137static int randFD;
138};
139#endif
Definition XrdOucErrInfo.hh:101
Definition XrdOucStream.hh:47
Definition XrdSecsssKT.hh:45
static const int anyUSR
Definition XrdSecsssKT.hh:67
static const int UserSZ
Definition XrdSecsssKT.hh:50
struct XrdSecsssKT::ktEnt::ktData Data
static const int noIPCK
Definition XrdSecsssKT.hh:70
void NUG(ktEnt *ktP)
Definition XrdSecsssKT.hh:72
static const int anyGRP
Definition XrdSecsssKT.hh:68
static const int GrupSZ
Definition XrdSecsssKT.hh:51
void Set(ktEnt &rhs)
Definition XrdSecsssKT.hh:76
ktEnt()
Definition XrdSecsssKT.hh:82
static const int maxKLen
Definition XrdSecsssKT.hh:48
static const int allUSR
Definition XrdSecsssKT.hh:66
static const int usrGRP
Definition XrdSecsssKT.hh:69
static const int NameSZ
Definition XrdSecsssKT.hh:49
ktEnt * Next
Definition XrdSecsssKT.hh:80
~ktEnt()
Definition XrdSecsssKT.hh:86
Definition XrdSecsssKT.hh:41
char * ktPath
Definition XrdSecsssKT.hh:130
void keyB2X(ktEnt *theKT, char *buff)
int Same(const char *path)
Definition XrdSecsssKT.hh:109
void setPath(const char *Path)
Definition XrdSecsssKT.hh:111
int delKey(ktEnt &ktDel)
mode_t fileMode(const char *Path)
int Rewrite(int Keep, int &numKeys, int &numTot, int &numExp)
ktEnt * getKeyTab(XrdOucErrInfo *eInfo, time_t Mtime, mode_t Amode)
void Refresh()
int getKey(ktEnt &ktEql, bool andKeyID=false)
time_t ktRefT
Definition XrdSecsssKT.hh:134
void keyX2B(ktEnt *theKT, char *xKey)
int eMsg(const char *epn, int rc, const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0)
static void genKey(char *Buff, int blen)
static char * genFN()
int kthiID
Definition XrdSecsssKT.hh:135
ktEnt * keyList()
Definition XrdSecsssKT.hh:101
ktEnt * ktList
Definition XrdSecsssKT.hh:131
XrdSysMutex myMutex
Definition XrdSecsssKT.hh:129
time_t RefrTime()
Definition XrdSecsssKT.hh:105
int isKey(ktEnt &ktRef, ktEnt *ktP, int Full=1)
xMode
Definition XrdSecsssKT.hh:114
@ isClient
Definition XrdSecsssKT.hh:114
@ isServer
Definition XrdSecsssKT.hh:114
@ isAdmin
Definition XrdSecsssKT.hh:114
pthread_t ktRefID
Definition XrdSecsssKT.hh:136
time_t ktMtime
Definition XrdSecsssKT.hh:132
static int randFD
Definition XrdSecsssKT.hh:137
xMode ktMode
Definition XrdSecsssKT.hh:133
void addKey(ktEnt &ktNew)
ktEnt * ktDecode0(XrdOucStream &kTab, XrdOucErrInfo *eInfo)
XrdSecsssKT(XrdOucErrInfo *, const char *, xMode, int refr=60 *60)
Definition XrdSysPthread.hh:165
Definition XrdSecsssKT.hh:54
char User[UserSZ]
Definition XrdSecsssKT.hh:62
long long Flags
Definition XrdSecsssKT.hh:55
time_t Exp
Definition XrdSecsssKT.hh:57
int Opts
Definition XrdSecsssKT.hh:58
char Val[maxKLen]
Definition XrdSecsssKT.hh:60
char Name[NameSZ]
Definition XrdSecsssKT.hh:61
long long ID
Definition XrdSecsssKT.hh:54
time_t Crt
Definition XrdSecsssKT.hh:56
int Len
Definition XrdSecsssKT.hh:59
char Grup[GrupSZ]
Definition XrdSecsssKT.hh:63