Loading...
Searching...
No Matches
XrdOfsTPCAuth Class Reference

`#include <XrdOfsTPCAuth.hh>`

Inheritance diagram for XrdOfsTPCAuth:
Collaboration diagram for XrdOfsTPCAuth:

## Public Member Functions

| XrdOfsTPCAuth (int vTTL)
| ~XrdOfsTPCAuth ()
int | Add (Facts &Args)
void | Del ()
int | Expired ()
int | Expired (const char *Dst, int cnt=1)

## Static Public Member Functions

static int | Get (Facts &Args, XrdOfsTPCAuth **theTPC)
static int | RunTTL (int Init)

## Detailed Description

Definition at line 39 of file XrdOfsTPCAuth.hh.

## Constructor & Destructor Documentation

## XrdOfsTPCAuth()

XrdOfsTPCAuth::XrdOfsTPCAuth | ( | int | vTTL | ) |

inline

Definition at line 55 of file XrdOfsTPCAuth.hh.

: expT(vTTL+time(0)) {}

Referenced by Add(), Del(), Get(), and RunTTL().

Here is the caller graph for this function:

## ~XrdOfsTPCAuth()

XrdOfsTPCAuth::~XrdOfsTPCAuth | ( |  | ) |

inline

Definition at line 57 of file XrdOfsTPCAuth.hh.

{}

## Member Function Documentation

## Add()

int XrdOfsTPCAuth::Add | ( | XrdOfsTPC::Facts & | Args | ) |

Definition at line 77 of file XrdOfsTPCAuth.cc.

{
XrdOfsTPCAuth *aP;
const char *eMsg;
char Buff[512];
// Generate the origin information
//
if (!genOrg(Args.Usr, Buff, sizeof(Buff))) return Fatal(Args, Buff, EINVAL);
Args.Org = Buff;
// Check if there is a matching authorization in the queue. If this is for a
// pending authorization, indicated that we now have one. Otherwise, consider
// this a potential security breach and cancel both autorizations.
//
authMutex.Lock();
if ((aP = Find(Args)))
{if (aP->Info.cbP)
{aP->expT = expT;
aP->Next = authQ; authQ = aP;
aP->Info.Reply(SFS_OK, 0, "", &authMutex);
return 1;
} else {
authMutex.UnLock();
return Fatal(Args, "duplicate athorization", EPROTO);
}
}
// Set the copy authorization information
//
if ((eMsg = Info.Set(Args.Key, Buff, Args.Lfn, Args.Dst)))
{
authMutex.UnLock();
return Fatal(Args, eMsg, EINVAL);
}
// Add this to queue
//
Next = authQ; authQ = this; inQ = 1;
// All done
//
authMutex.UnLock();
return 1;
}
eMsg
#define eMsg(x)
Definition XrdSecsssAdmin.cc:53
SFS_OK
#define SFS_OK
Definition XrdSfsInterface.hh:108
XrdOfsTPCAuth::XrdOfsTPCAuth
XrdOfsTPCAuth(int vTTL)
Definition XrdOfsTPCAuth.hh:55
XrdOfsTPC::Fatal
static int Fatal(Facts &Args, const char *eMsg, int eCode, int nomsg=0)
Definition XrdOfsTPC.cc:334
XrdOfsTPC::Info
XrdOfsTPCInfo Info
Definition XrdOfsTPC.hh:109
XrdOfsTPC::inQ
char inQ
Definition XrdOfsTPC.hh:130
XrdOfsTPC::genOrg
static int genOrg(const XrdSecEntity *client, char *Buff, int Blen)
Definition XrdOfsTPC.cc:359
XrdOfsTPC::Facts::Usr
const XrdSecEntity * Usr
Definition XrdOfsTPC.hh:57
XrdOfsTPC::Facts::Key
const char * Key
Definition XrdOfsTPC.hh:52
XrdOfsTPC::Facts::Org
const char * Org
Definition XrdOfsTPC.hh:55
XrdOfsTPC::Facts::Lfn
const char * Lfn
Definition XrdOfsTPC.hh:53
XrdOfsTPC::Facts::Dst
const char * Dst
Definition XrdOfsTPC.hh:56

References XrdOfsTPCAuth(), XrdOfsTPC::Facts::Dst, eMsg, XrdOfsTPC::Fatal(), XrdOfsTPC::genOrg(), XrdOfsTPC::Info, XrdOfsTPC::inQ, XrdOfsTPC::Facts::Key, XrdOfsTPC::Facts::Lfn, XrdOfsTPC::Facts::Org, SFS_OK, and XrdOfsTPC::Facts::Usr.

Referenced by XrdOfsTPC::Authorize().

Here is the call graph for this function:
Here is the caller graph for this function:

## Del()

void XrdOfsTPCAuth::Del | ( |  | ) |

virtual

Reimplemented from XrdOfsTPC.

Definition at line 127 of file XrdOfsTPCAuth.cc.

{
XrdOfsTPCAuth *pP;
// Remove from queue if we are still in the queue
//
authMutex.Lock();
if (inQ)
{if (this == authQ) authQ = Next;
else {pP = authQ;
while(pP && pP->Next != this) pP = pP->Next;
if (pP) pP->Next = Next;
}
inQ = 0;
}
// Delete the element if possible
//
if (Refs <= 1) delete this;
else Refs--;
authMutex.UnLock();
}
XrdOfsTPC::Refs
char Refs
Definition XrdOfsTPC.hh:129

References XrdOfsTPCAuth(), XrdOfsTPC::inQ, and XrdOfsTPC::Refs.

Referenced by XrdOfsTPC::Authorize().

Here is the call graph for this function:
Here is the caller graph for this function:

## Expired() [1/2]

int XrdOfsTPCAuth::Expired | ( |  | ) |

inline

Definition at line 47 of file XrdOfsTPCAuth.hh.

{return (time(0) >= expT);}

Referenced by XrdOfsTPC::Authorize(), and RunTTL().

Here is the caller graph for this function:

## Expired() [2/2]

int XrdOfsTPCAuth::Expired | ( | const char * | Dst,
|  | int | cnt = 1 )

Definition at line 154 of file XrdOfsTPCAuth.cc.

{
char Buff[1024];
// If there is a callback, tell the client they are no longer wanted
//
if (Info.cbP) Info.Reply(SFS_ERROR, EACCES, "tpc authorization expired");
// Log this event
//
snprintf(Buff, sizeof(Buff), "tpc grant by %s expired for", Info.Org);
Buff[sizeof(Buff)-1] = 0;
OfsEroute.Emsg("TPC", Dst, Buff, Info.Lfn);
// Count stats and return
//
if (cnt) OfsStats.Add(OfsStats.Data.numTPCexpr);
return 0;
}
OfsEroute
XrdSysError OfsEroute(0)
OfsStats
XrdOfsStats OfsStats
Definition XrdOfs.cc:113
SFS_ERROR
#define SFS_ERROR
Definition XrdSfsInterface.hh:109
XrdOfsStats::Data
struct XrdOfsStats::StatsData Data
XrdOfsStats::Add
void Add(int &Cntr)
Definition XrdOfsStats.hh:62
XrdOfsStats::StatsData::numTPCexpr
int numTPCexpr
Definition XrdOfsStats.hh:57
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95

References XrdOfsTPC::Info, OfsEroute, OfsStats, and SFS_ERROR.

## Get()

int XrdOfsTPCAuth::Get | ( | XrdOfsTPC::Facts & | Args,
|  | XrdOfsTPCAuth ** | theTPC )

static

Definition at line 204 of file XrdOfsTPCAuth.cc.

{
XrdSysMutexHelper authMon(&authMutex);
XrdOfsTPCAuth *aP;
const char *eMsg;
// Check if there is a matching authorization in the queue. If this is for a
// pending authorization, then consider this a potential security breach and
// cancel both requests. Otherwise, indicate that authorization is present.
//
if ((aP = Find(Args)))
{if (aP->Info.cbP)
{aP->Info.Reply(SFS_ERROR, EPROTO, "duplicate tpc auth request");
return Fatal(Args, "duplicate tpc auth request", EPROTO);
} else {
aP->Refs++;
*theTPC = aP;
return SFS_OK;
}
}
// Add this request as a pending authorization to the queue
//
if (!(aP = new XrdOfsTPCAuth(Cfg.maxTTL)))
return Fatal(Args, "insufficient memory", ENOMEM);
// Set the copy authorization information
//
if ((eMsg = aP->Info.Set(Args.Key, Args.Org, Args.Lfn, Args.Dst)))
{delete aP;
return Fatal(Args, eMsg, EINVAL);
}
// Create a callback
//
if (aP->Info.SetCB(Args.eRR)) {delete aP; return SFS_ERROR;}
// Add it to the queue
//
aP->Next = authQ; authQ = aP;
// Return result
//
*theTPC = aP;
aP->Refs = 0;
aP->Info.Engage();
return SFS_STARTED;
}
SFS_STARTED
#define SFS_STARTED
Definition XrdSfsInterface.hh:111
XrdOfsTPCParms::Cfg
XrdOfsTPCConfig Cfg
Definition XrdOfsTPC.cc:85
XrdOfsTPCConfig::maxTTL
int maxTTL
Definition XrdOfsTPCConfig.hh:43
XrdOfsTPC::Facts::eRR
XrdOucErrInfo * eRR
Definition XrdOfsTPC.hh:58

References XrdOfsTPCAuth(), XrdOfsTPCParms::Cfg, XrdOfsTPC::Facts::Dst, eMsg, XrdOfsTPC::Facts::eRR, XrdOfsTPC::Fatal(), XrdOfsTPC::Facts::Key, XrdOfsTPC::Facts::Lfn, XrdOfsTPC::Facts::Org, SFS_ERROR, SFS_OK, and SFS_STARTED.

Referenced by XrdOfsTPC::Authorize().

Here is the call graph for this function:
Here is the caller graph for this function:

## RunTTL()

int XrdOfsTPCAuth::RunTTL | ( | int | Init | ) |

static

Definition at line 257 of file XrdOfsTPCAuth.cc.

{
XrdOfsTPCAuth *cP, *pP, *nP;
time_t eNow;
int eWait, eDiff, numExp;
// Start the expiration thread
//
if (Init)
{pthread_t tid;
int rc;
if ((rc = XrdSysThread::Run(&tid,XrdOfsTPCAuthttl,0,0,"TPC ttl runner")))
OfsEroute.Emsg("TPC", rc, "create tpc ttl runner thread");
return (rc ? 0 : 1);
}
// Find all expired entries and remove them
//
do{authMutex.Lock();
cP = authQ; pP = 0;
eNow = time(0); eWait = Cfg.maxTTL; numExp = 0;
while(cP)
{if (eNow < cP->expT)
{eDiff = cP->expT - eNow;
if (eDiff < eWait) eWait = eDiff;
pP = cP; cP = cP->Next;
}
else {if (pP) pP->Next = cP->Next;
else authQ = cP->Next;
cP->Expired("localhost", 0); numExp++;
nP = cP->Next;
if (cP->Refs < 1) delete cP;
cP = nP;
}
}
authMutex.UnLock();
// Add number of expirations to statistics
//
if (numExp)
{OfsStats.sdMutex.Lock();
OfsStats.Data.numTPCexpr += numExp;
OfsStats.sdMutex.UnLock();
}
// Wait as long as possible for a recan
//
XrdSysTimer::Snooze(eWait);
} while(1);
}
XrdOfsTPCAuthttl
void * XrdOfsTPCAuthttl(void *pp)
Definition XrdOfsTPCAuth.cc:67
XrdOfsStats::sdMutex
XrdSysMutex sdMutex
Definition XrdOfsStats.hh:60
XrdOfsTPCAuth::Expired
int Expired()
Definition XrdOfsTPCAuth.hh:47
XrdOfsTPC::Init
static void Init()
Definition XrdOfsTPC.cc:414
XrdSysMutex::Lock
void Lock()
Definition XrdSysPthread.hh:222
XrdSysMutex::UnLock
void UnLock()
Definition XrdSysPthread.hh:224
XrdSysThread::Run
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
Definition XrdSysPthread.cc:307
XrdSysTimer::Snooze
static void Snooze(int seconds)
Definition XrdSysTimer.cc:168

References XrdOfsTPCAuth(), XrdOfsTPCParms::Cfg, Expired(), XrdOfsTPC::Init(), OfsEroute, OfsStats, XrdSysThread::Run(), XrdSysTimer::Snooze(), and XrdOfsTPCAuthttl().

Referenced by XrdOfsTPC::Start(), and XrdOfsTPCAuthttl().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- XrdOfsTPCAuth.hh
- XrdOfsTPCAuth.cc