xrootd
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>
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 anyUSR = 2;
67static const int anyGRP = 4;
68static const int usrGRP = 8;
69static const int noIPCK =16;
70
71 void NUG(ktEnt *ktP) {strcpy(Data.Name, ktP->Data.Name);
72 strcpy(Data.User, ktP->Data.User);
73 strcpy(Data.Grup, ktP->Data.Grup);
74 }
75 void Set(ktEnt &rhs) {Data.ID=rhs.Data.ID; Data.Len = rhs.Data.Len;
76 memcpy(Data.Val, rhs.Data.Val, Data.Len);
77 Data.Crt=rhs.Data.Crt; Data.Exp=rhs.Data.Exp;
78 }
80
81 ktEnt() : Next(0) { Data.ID = -1; Data.Flags= 0; Data.Opts = 0;
82 *Data.Val = '\0'; *Data.Name = '\0';
83 *Data.User= '\0'; *Data.Grup = '\0';
84 }
85 ~ktEnt() {}
86};
87
88void addKey(ktEnt &ktNew);
89
90int delKey(ktEnt &ktDel);
91
92static
93char *genFN();
94
95static
96void genKey(char *Buff, int blen);
97
98int getKey(ktEnt &ktEql);
99
100ktEnt *keyList() {return ktList;}
101
102void Refresh();
103
104time_t RefrTime() {return ktRefT;}
105
106int Rewrite(int Keep, int &numKeys, int &numTot, int &numExp);
107
108int Same(const char *path) {return (ktPath && !strcmp(ktPath, path));}
109
110void setPath(const char *Path)
111 {if (ktPath) free(ktPath); ktPath = strdup(Path);}
112
114
115 XrdSecsssKT(XrdOucErrInfo *, const char *, xMode, int refr=60*60);
117
118private:
119int eMsg(const char *epn, int rc, const char *txt1,
120 const char *txt2=0, const char *txt3=0, const char *txt4=0);
121ktEnt *getKeyTab(XrdOucErrInfo *eInfo, time_t Mtime, mode_t Amode);
122mode_t fileMode(const char *Path);
123int isKey(ktEnt &ktRef, ktEnt *ktP, int Full=1);
124void keyB2X(ktEnt *theKT, char *buff);
125void keyX2B(ktEnt *theKT, char *xKey);
127
129char *ktPath;
131time_t ktMtime;
133time_t ktRefT;
135pthread_t ktRefID;
136static int randFD;
137};
138#endif
Definition: XrdOucErrInfo.hh:100
Definition: XrdOucStream.hh:46
Definition: XrdSecsssKT.hh:45
static const int anyUSR
Definition: XrdSecsssKT.hh:66
static const int UserSZ
Definition: XrdSecsssKT.hh:50
struct XrdSecsssKT::ktEnt::ktData Data
static const int noIPCK
Definition: XrdSecsssKT.hh:69
void NUG(ktEnt *ktP)
Definition: XrdSecsssKT.hh:71
static const int anyGRP
Definition: XrdSecsssKT.hh:67
static const int GrupSZ
Definition: XrdSecsssKT.hh:51
void Set(ktEnt &rhs)
Definition: XrdSecsssKT.hh:75
ktEnt()
Definition: XrdSecsssKT.hh:81
static const int maxKLen
Definition: XrdSecsssKT.hh:48
static const int usrGRP
Definition: XrdSecsssKT.hh:68
static const int NameSZ
Definition: XrdSecsssKT.hh:49
ktEnt * Next
Definition: XrdSecsssKT.hh:79
~ktEnt()
Definition: XrdSecsssKT.hh:85
Definition: XrdSecsssKT.hh:41
char * ktPath
Definition: XrdSecsssKT.hh:129
void keyB2X(ktEnt *theKT, char *buff)
int Same(const char *path)
Definition: XrdSecsssKT.hh:108
int getKey(ktEnt &ktEql)
void setPath(const char *Path)
Definition: XrdSecsssKT.hh:110
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()
time_t ktRefT
Definition: XrdSecsssKT.hh:133
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:134
ktEnt * keyList()
Definition: XrdSecsssKT.hh:100
ktEnt * ktList
Definition: XrdSecsssKT.hh:130
XrdSysMutex myMutex
Definition: XrdSecsssKT.hh:128
time_t RefrTime()
Definition: XrdSecsssKT.hh:104
int isKey(ktEnt &ktRef, ktEnt *ktP, int Full=1)
xMode
Definition: XrdSecsssKT.hh:113
@ isClient
Definition: XrdSecsssKT.hh:113
@ isServer
Definition: XrdSecsssKT.hh:113
@ isAdmin
Definition: XrdSecsssKT.hh:113
pthread_t ktRefID
Definition: XrdSecsssKT.hh:135
time_t ktMtime
Definition: XrdSecsssKT.hh:131
static int randFD
Definition: XrdSecsssKT.hh:136
xMode ktMode
Definition: XrdSecsssKT.hh:132
void addKey(ktEnt &ktNew)
ktEnt * ktDecode0(XrdOucStream &kTab, XrdOucErrInfo *eInfo)
XrdSecsssKT(XrdOucErrInfo *, const char *, xMode, int refr=60 *60)
Definition: XrdSysPthread.hh:166
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