Loading...
Searching...
No Matches
XrdSecsssKT.hh
Go to the documentation of this file.
#ifndef __SecsssKT__
#define __SecsssKT__
/******************************************************************************/
/* */
/* X r d S e c s s s K T . h h */
/* */
/* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
/* All Rights Reserved */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include <cstring>
#include <ctime>
#include "XrdSys/XrdSysPthread.hh"
class XrdOucErrInfo;
class XrdOucStream;
class XrdSecsssKT
{
public:
class ktEnt
{
public:
static const int maxKLen = 128;
static const int NameSZ = 192;
static const int UserSZ = 128;
static const int GrupSZ = 64;
struct ktData
{long long ID;
long long Flags; // Future!
time_t Crt;
time_t Exp;
int Opts;
int Len;
char Val[maxKLen];// Key strings are 1024 bits or less
char Name[NameSZ];// Key names are null terminated
char User[UserSZ];// Usr names are null terminated
char Grup[GrupSZ];// Grp names are null terminated
} Data;
static const int allUSR = 1;
static const int anyUSR = 2;
static const int anyGRP = 4;
static const int usrGRP = 8;
static const int noIPCK =16;
void NUG(ktEnt *ktP) {strcpy(Data.Name, ktP->Data.Name);
strcpy(Data.User, ktP->Data.User);
strcpy(Data.Grup, ktP->Data.Grup);
}
void Set(ktEnt &rhs) {Data.ID=rhs.Data.ID; Data.Len = rhs.Data.Len;
memcpy(Data.Val, rhs.Data.Val, Data.Len);
Data.Crt=rhs.Data.Crt; Data.Exp=rhs.Data.Exp;
}
ktEnt *Next;
ktEnt() : Next(0) { Data.ID = -1; Data.Flags= 0; Data.Opts = 0;
*Data.Val = '\0'; *Data.Name = '\0';
*Data.User= '\0'; *Data.Grup = '\0';
}
~ktEnt() {}
};
void addKey(ktEnt &ktNew);
int delKey(ktEnt &ktDel);
static
char *genFN();
static
void genKey(char *Buff, int blen);
int getKey(ktEnt &ktEql, bool andKeyID=false);
ktEnt *keyList() {return ktList;}
void Refresh();
time_t RefrTime() {return ktRefT;}
int Rewrite(int Keep, int &numKeys, int &numTot, int &numExp);
int Same(const char *path) {return (ktPath && !strcmp(ktPath, path));}
void setPath(const char *Path)
{if (ktPath) free(ktPath); ktPath = strdup(Path);}
enum xMode {isAdmin = 0, isClient, isServer};
XrdSecsssKT(XrdOucErrInfo *, const char *, xMode, int refr=60*60);
~XrdSecsssKT();
private:
int eMsg(const char *epn, int rc, const char *txt1,
const char *txt2=0, const char *txt3=0, const char *txt4=0);
ktEnt *getKeyTab(XrdOucErrInfo *eInfo, time_t Mtime, mode_t Amode);
mode_t fileMode(const char *Path);
int isKey(ktEnt &ktRef, ktEnt *ktP, int Full=1);
void keyB2X(ktEnt *theKT, char *buff);
void keyX2B(ktEnt *theKT, char *xKey);
ktEnt *ktDecode0(XrdOucStream &kTab, XrdOucErrInfo *eInfo);
XrdSysMutex myMutex;
char *ktPath;
ktEnt *ktList;
time_t ktMtime;
xMode ktMode;
time_t ktRefT;
int kthiID;
pthread_t ktRefID;
static int randFD;
};
#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::~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
XrdSecsssKT::XrdSecsssKT
XrdSecsssKT(XrdOucErrInfo *, const char *, xMode, int refr=60 *60)
Definition XrdSecsssKT.cc:78
XrdSysMutex
Definition XrdSysPthread.hh:165