Loading...
Searching...
No Matches
XrdOfsTPC Class Reference

`#include <XrdOfsTPC.hh>`

Inheritance diagram for XrdOfsTPC:
Collaboration diagram for XrdOfsTPC:

## Classes

struct | Facts

## Public Member Functions

| XrdOfsTPC ()
| XrdOfsTPC (const char *Url, const char *Org, const char *Lfn, const char *Pfn, const char *Cks=0, const char *Spr=0, const char *Tpr=0)
virtual | ~XrdOfsTPC ()
virtual void | Del ()
virtual int | Sync (XrdOucErrInfo *error)

## Static Public Member Functions

static const char * | AddAuth (const char *auth, const char *avar)
static void | Allow (char *vDN, char *vGN, char *vHN, char *vVO)
static int | Authorize (XrdOfsTPC **theTPC, Facts &Args, int isPLE=0)
static const char * | credPath ()
static void | Init ()
static void | Init (XrdAccAuthorize *accP)
static void | Require (const char *Auth, int RType)
static int | Restrict (const char *Path)
static int | Start ()
static int | Validate (XrdOfsTPC **theTPC, Facts &Args)

## Public Attributes

XrdOfsTPCInfo | Info

## Static Public Attributes

static const int | reqALL = 0
static const int | reqDST = 1
static const int | reqORG = 2

## Static Protected Member Functions

static int | Death (Facts &Args, const char *eMsg, int eCode, int nomsg=0)
static int | Fatal (Facts &Args, const char *eMsg, int eCode, int nomsg=0)
static int | genOrg (const XrdSecEntity *client, char *Buff, int Blen)
static int | getTTL (XrdOucEnv *Env)
static int | Screen (Facts &Args, XrdOucTList *tP, int wasEnc=0)
static char * | Verify (const char *Who, const char *Name, char *Buf, int Blen)

## Protected Attributes

char | inQ
char | Refs

## Static Protected Attributes

static XrdOfsTPCAllow * | ALList = 0
static XrdOucTList * | AuthDst = 0
static XrdOucTList * | AuthOrg = 0
static char * | cPath = 0
static XrdAccAuthorize * | fsAuth = 0
static XrdOucPListAnchor * | RPList

## Detailed Description

Definition at line 47 of file XrdOfsTPC.hh.

## Constructor & Destructor Documentation

## XrdOfsTPC() [1/2]

XrdOfsTPC::XrdOfsTPC | ( |  | ) |

inline

Definition at line 99 of file XrdOfsTPC.hh.

: Refs(1), inQ(0) {}
XrdOfsTPC::Refs
char Refs
Definition XrdOfsTPC.hh:129
XrdOfsTPC::inQ
char inQ
Definition XrdOfsTPC.hh:130

References inQ, and Refs.

Referenced by XrdOfsTPCJob::XrdOfsTPCJob(), Authorize(), and Validate().

Here is the caller graph for this function:

## XrdOfsTPC() [2/2]

XrdOfsTPC::XrdOfsTPC | ( | const char * | Url,
|  | const char * | Org,
|  | const char * | Lfn,
|  | const char * | Pfn,
|  | const char * | Cks = 0,
|  | const char * | Spr = 0,
|  | const char * | Tpr = 0 )

inline

Definition at line 101 of file XrdOfsTPC.hh.

: Info(Url, Org, Lfn, Pfn, Cks, Spr, Tpr),
Refs(1), inQ(0) {}
XrdOfsTPC::Info
XrdOfsTPCInfo Info
Definition XrdOfsTPC.hh:109

References Info, inQ, and Refs.

## ~XrdOfsTPC()

virtual XrdOfsTPC::~XrdOfsTPC | ( |  | ) |

inline virtual

Definition at line 107 of file XrdOfsTPC.hh.

{}

## Member Function Documentation

## AddAuth()

const char * XrdOfsTPC::AddAuth | ( | const char * | auth,
|  | const char * | avar )

static

Definition at line 164 of file XrdOfsTPC.cc.

{
bool aOpt, aGSI;
// Check if credentials are optional
//
if (*auth != '?') aOpt = false;
else {aOpt = true;
auth++;
}
aGSI = strcmp("gsi", auth) == 0;
// Verify that the authname is not too long
//
if (strlen(auth) >= XrdSecPROTOIDSIZE) return "Invalid auth";
// Check if auth is already in the table
//
for (int i = 0; i < fcNum; i++)
if (!strcmp(auth, fcAuth[i].aProt))
{if (fcAuth[i].aVar) free(fcAuth[i].aVar);
fcAuth[i].aVar = strdup(avar);
fcAuth[i].aOpt = aOpt;
fcAuth[i].aGSI = aGSI;
return 0;
}
// Check if we have room to add an auth
//
if (fcNum >= fcMax) return "Too many fcred auths";
// Add an auth
//
strcpy(fcAuth[fcNum].aProt, auth);
fcAuth[fcNum].aVar = strdup(avar);
fcAuth[fcNum].aOpt = aOpt;
fcAuth[fcNum].aGSI = aGSI;
fcNum++;
return 0;
}
XrdSecPROTOIDSIZE
#define XrdSecPROTOIDSIZE
Definition XrdSecEntity.hh:47
XrdOfsTPCParms::fcMax
static const int fcMax
Definition XrdOfsTPC.cc:70
XrdOfsTPCParms::fcTb::aGSI
bool aGSI
Definition XrdOfsTPC.cc:75
XrdOfsTPCParms::fcTb::aOpt
bool aOpt
Definition XrdOfsTPC.cc:74
XrdOfsTPCParms::fcNum
int fcNum
Definition XrdOfsTPC.cc:80
XrdOfsTPCParms::fcAuth
struct XrdOfsTPCParms::fcTb fcAuth[fcMax]
XrdOfsTPCParms::fcTb::aVar
char * aVar
Definition XrdOfsTPC.cc:72

References XrdOfsTPCParms::fcAuth, XrdOfsTPCParms::fcMax, XrdOfsTPCParms::fcNum, and XrdSecPROTOIDSIZE.

## Allow()

void XrdOfsTPC::Allow | ( | char * | vDN,
|  | char * | vGN,
|  | char * | vHN,
|  | char * | vVO )

static

Definition at line 209 of file XrdOfsTPC.cc.

{
// Add the entry
//
ALList = new XrdOfsTPCAllow(vDN, vGN, vHN, vVO, ALList);
}
XrdOfsTPC::ALList
static XrdOfsTPCAllow * ALList
Definition XrdOfsTPC.hh:126

References ALList.

## Authorize()

int XrdOfsTPC::Authorize | ( | XrdOfsTPC ** | theTPC,
|  | XrdOfsTPC::Facts & | Args,
|  | int | isPLE = 0 )

static

Definition at line 221 of file XrdOfsTPC.cc.

{
XrdOfsTPCAuth *myTPC;
const char *dstHost;
int rc, NoGo = 0;
// Determine if we can handle any TPC requests
//
if (!tpcOK || !Args.Usr)
return Fatal(Args, "tpc not supported", ENOTSUP);
// If we are restricting paths, make sure this meets the restriction
//
if (RPList && !(RPList->Find(Args.Lfn)))
return Fatal(Args, "tpc not allowed for path", EACCES);
// The origin and the destination in the arguments
//
Args.Org = Args.Env->Get(XrdOucTPC::tpcOrg);
Args.Dst = Args.Env->Get(XrdOucTPC::tpcDst);
// Determine if this is the origin or the destination.
// Origin: dst and key required but org may not be specified
// Dest: org and key required but dst may not be specified
//
if (Args.Dst && !Args.Org)
{if (fsAuth && !fsAuth->Access(Args.Usr, Args.Lfn, AOP_Read, Args.Env))
return Fatal(Args, "permission denied", EACCES);
if (AuthOrg && !Screen(Args, AuthOrg, isPLE)) return SFS_ERROR;
if (!(myTPC = new XrdOfsTPCAuth(getTTL(Args.Env))))
return Fatal(Args, "insufficient memory", ENOMEM);
if (!(myTPC->Add(Args))) {delete myTPC; return SFS_ERROR;}
*pTPC = (XrdOfsTPC *)myTPC;
return SFS_OK;
}
else if (!Args.Org || Args.Dst)
return Fatal(Args, "conflicting tpc cgi", EINVAL);
// If we need to enforce authentication, do so now
//
if (AuthDst && !Screen(Args, AuthDst, isPLE)) return SFS_ERROR;
// Avoid nodnr manglement of the host name, we always will need one. If we have
// see if we should restrict the destinations and if so, do it.
//
if (!(dstHost = Args.Usr->addrInfo->Name())) NoGo = 1;
else if (ALList)
{XrdOfsTPCAllow *aP = ALList;
while(aP && !aP->Match(Args.Usr, dstHost)) aP = aP->Next;
if (!aP) NoGo = 1;
}
// Check if this destination is actually authorized
//
if (NoGo)
{OfsEroute.Emsg("TPC", Args.eRR->getErrUser(),
"denied tpc access to", Args.Lfn);
OfsStats.Add(OfsStats.Data.numTPCdeny);
return Fatal(Args, "dest not authorized for tpc" ,EACCES, 1);
}
// This is the destination trying to open a source file. We must make sure
// that the origin has authorized this action for this destination.
//
Args.Dst = dstHost;
if ((rc = XrdOfsTPCAuth::Get(Args, &myTPC))) return rc;
// Check if entry already expired
//
if (myTPC->Expired())
{myTPC->Expired(Args.Usr->tident);
myTPC->Del();
return Fatal(Args, "authorization expired", EACCES, 1);
}
// Log the grant if so wanted
//
if (Cfg.LogOK)
{char Buff[1024];
snprintf(Buff, sizeof(Buff), "%s granted tpc access by %s to",
Args.Usr->tident, Args.Org);
Buff[sizeof(Buff)-1] = 0;
OfsEroute.Emsg("TPC", Buff, Args.Lfn);
}
// All done
//
OfsStats.Add(OfsStats.Data.numTPCgrant);
*pTPC = (XrdOfsTPC *)myTPC;
return SFS_OK;
}
AOP_Read
@ AOP_Read
open() r/o, prepare()
Definition XrdAccAuthorize.hh:49
OfsEroute
XrdSysError OfsEroute(0)
OfsStats
XrdOfsStats OfsStats
Definition XrdOfs.cc:113
SFS_ERROR
#define SFS_ERROR
Definition XrdSfsInterface.hh:109
SFS_OK
#define SFS_OK
Definition XrdSfsInterface.hh:108
XrdNetAddrInfo::Name
const char * Name(const char *eName=0, const char **eText=0)
Definition XrdNetAddrInfo.cc:309
XrdOfsStats::Data
struct XrdOfsStats::StatsData Data
XrdOfsStats::StatsData::numTPCdeny
int numTPCdeny
Definition XrdOfsStats.hh:55
XrdOfsStats::Add
void Add(int &Cntr)
Definition XrdOfsStats.hh:62
XrdOfsStats::StatsData::numTPCgrant
int numTPCgrant
Definition XrdOfsStats.hh:54
XrdOfsTPCAllow::Next
XrdOfsTPCAllow * Next
Definition XrdOfsTPC.cc:101
XrdOfsTPCAllow::Match
int Match(const XrdSecEntity *Who, const char *Host)
Definition XrdOfsTPC.cc:122
XrdOfsTPCAuth::Del
void Del()
Definition XrdOfsTPCAuth.cc:127
XrdOfsTPCAuth::Get
static int Get(Facts &Args, XrdOfsTPCAuth **theTPC)
Definition XrdOfsTPCAuth.cc:204
XrdOfsTPCAuth::Add
int Add(Facts &Args)
Definition XrdOfsTPCAuth.cc:77
XrdOfsTPCAuth::Expired
int Expired()
Definition XrdOfsTPCAuth.hh:47
XrdOfsTPC::AuthOrg
static XrdOucTList * AuthOrg
Definition XrdOfsTPC.hh:123
XrdOfsTPC::XrdOfsTPC
XrdOfsTPC()
Definition XrdOfsTPC.hh:99
XrdOfsTPC::getTTL
static int getTTL(XrdOucEnv *Env)
Definition XrdOfsTPC.cc:396
XrdOfsTPC::fsAuth
static XrdAccAuthorize * fsAuth
Definition XrdOfsTPC.hh:120
XrdOfsTPC::Fatal
static int Fatal(Facts &Args, const char *eMsg, int eCode, int nomsg=0)
Definition XrdOfsTPC.cc:334
XrdOfsTPC::AuthDst
static XrdOucTList * AuthDst
Definition XrdOfsTPC.hh:122
XrdOfsTPC::Screen
static int Screen(Facts &Args, XrdOucTList *tP, int wasEnc=0)
Definition XrdOfsTPC.cc:497
XrdOfsTPC::RPList
static XrdOucPListAnchor * RPList
Definition XrdOfsTPC.hh:127
XrdOucEnv::Get
char * Get(const char *varname)
Definition XrdOucEnv.hh:69
XrdOucErrInfo::getErrUser
const char * getErrUser()
Definition XrdOucErrInfo.hh:297
XrdOucTPC::tpcDst
static const char * tpcDst
Definition XrdOucTPC.hh:57
XrdOucTPC::tpcOrg
static const char * tpcOrg
Definition XrdOucTPC.hh:60
XrdSecEntity::addrInfo
XrdNetAddrInfo * addrInfo
Entity's connection details.
Definition XrdSecEntity.hh:80
XrdSecEntity::tident
const char * tident
Trace identifier always preset.
Definition XrdSecEntity.hh:81
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
XrdOfsTPCParms::tpcOK
bool tpcOK
Definition XrdOfsTPC.cc:81
XrdOfsTPCParms::Cfg
XrdOfsTPCConfig Cfg
Definition XrdOfsTPC.cc:85
XrdOfsTPCConfig::LogOK
bool LogOK
Definition XrdOfsTPCConfig.hh:49
XrdOfsTPC::Facts::Usr
const XrdSecEntity * Usr
Definition XrdOfsTPC.hh:57
XrdOfsTPC::Facts::Env
XrdOucEnv * Env
Definition XrdOfsTPC.hh:59
XrdOfsTPC::Facts::Org
const char * Org
Definition XrdOfsTPC.hh:55
XrdOfsTPC::Facts::Lfn
const char * Lfn
Definition XrdOfsTPC.hh:53
XrdOfsTPC::Facts::eRR
XrdOucErrInfo * eRR
Definition XrdOfsTPC.hh:58
XrdOfsTPC::Facts::Dst
const char * Dst
Definition XrdOfsTPC.hh:56

References XrdOfsTPC(), XrdOfsTPCAuth::Add(), XrdSecEntity::addrInfo, ALList, AOP_Read, AuthDst, AuthOrg, XrdOfsTPCParms::Cfg, XrdOfsTPCAuth::Del(), XrdOfsTPC::Facts::Dst, XrdOfsTPC::Facts::Env, XrdOfsTPC::Facts::eRR, XrdOfsTPCAuth::Expired(), Fatal(), fsAuth, XrdOfsTPCAuth::Get(), XrdOucEnv::Get(), XrdOucErrInfo::getErrUser(), getTTL(), XrdOfsTPC::Facts::Lfn, XrdOfsTPCAllow::Match(), XrdNetAddrInfo::Name(), XrdOfsTPCAllow::Next, OfsEroute, OfsStats, XrdOfsTPC::Facts::Org, RPList, Screen(), SFS_ERROR, SFS_OK, XrdSecEntity::tident, XrdOucTPC::tpcDst, XrdOfsTPCParms::tpcOK, XrdOucTPC::tpcOrg, and XrdOfsTPC::Facts::Usr.

Referenced by XrdOfsFile::open().

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

## credPath()

const char * XrdOfsTPC::credPath | ( |  | ) |

inline static

Definition at line 77 of file XrdOfsTPC.hh.

{return cPath;}
XrdOfsTPC::cPath
static char * cPath
Definition XrdOfsTPC.hh:124

References cPath.

## Death()

int XrdOfsTPC::Death | ( | XrdOfsTPC::Facts & | Args,
|  | const char * | eMsg,
|  | int | eCode,
|  | int | nomsg = 0 )

static protected

Definition at line 319 of file XrdOfsTPC.cc.

{
// If automatc removal is wanted, remove the file.
//
if (Cfg.autoRM && Args.Pfn) XrdOfsOss->Unlink(Args.Lfn);
// Return error information
//
return Fatal(Args, eMsg, eCode, nomsg);
}
XrdOfsOss
XrdOss * XrdOfsOss
Definition XrdOfs.cc:163
eMsg
#define eMsg(x)
Definition XrdSecsssAdmin.cc:53
XrdOss::Unlink
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
XrdOfsTPCConfig::autoRM
bool autoRM
Definition XrdOfsTPCConfig.hh:51
XrdOfsTPC::Facts::Pfn
const char * Pfn
Definition XrdOfsTPC.hh:54

References XrdOfsTPCParms::Cfg, eMsg, Fatal(), XrdOfsTPC::Facts::Lfn, XrdOfsTPC::Facts::Pfn, and XrdOfsOss.

Referenced by Validate().

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

## Del()

virtual void XrdOfsTPC::Del | ( |  | ) |

inline virtual

Reimplemented in XrdOfsTPCAuth, and XrdOfsTPCJob.

Definition at line 79 of file XrdOfsTPC.hh.

{}

## Fatal()

int XrdOfsTPC::Fatal | ( | XrdOfsTPC::Facts & | Args,
|  | const char * | eMsg,
|  | int | eCode,
|  | int | nomsg = 0 )

static protected

Definition at line 334 of file XrdOfsTPC.cc.

{
char Buff[2048];
// Format the error message
//
snprintf(Buff, sizeof(Buff), "Unable to open %s; %s", Args.Lfn, eMsg);
// Print it out if debugging is enabled
//
#ifndef NODEBUG
if (!nomsg) OfsEroute.Emsg("TPC", Args.eRR->getErrUser(), Buff);
#endif
// Place the error message in the error object and return
//
Args.eRR->setErrInfo(eCode, Buff);
OfsStats.Add(OfsStats.Data.numTPCerrs);
return SFS_ERROR;
}
XrdOfsStats::StatsData::numTPCerrs
int numTPCerrs
Definition XrdOfsStats.hh:56
XrdOucErrInfo::setErrInfo
int setErrInfo(int code, const char *emsg)
Definition XrdOucErrInfo.hh:147

References eMsg, XrdOfsTPC::Facts::eRR, XrdOucErrInfo::getErrUser(), XrdOfsTPC::Facts::Lfn, OfsEroute, OfsStats, XrdOucErrInfo::setErrInfo(), and SFS_ERROR.

Referenced by XrdOfsTPCAuth::Add(), Authorize(), Death(), XrdOfsTPCAuth::Get(), and Screen().

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

## genOrg()

int XrdOfsTPC::genOrg | ( | const XrdSecEntity * | client,
|  | char * | Buff,
|  | int | Blen )

static protected

Definition at line 359 of file XrdOfsTPC.cc.

{
const char *Colon, *cOrg = client->tident;
char *Name;
int n;
// Extract out the login name and pid
//
if (!(Colon = index(cOrg, ':'))) return 0;
n = (Colon - cOrg);
// Expand out client's full name
//
if (!(Name = Verify("origin", client->host, Buff, Blen))) return 0;
// Make sure this all fits
//
if (((n + 1) + int(strlen(Name))) >= Blen)
{strncpy(Buff, "origin ID too long", Blen);
Buff[Blen-1] = 0;
free(Name);
return 0;
}
// Construct the origin information
//
strncpy(Buff, cOrg, n);
Buff += n; *Buff++ = '@';
strcpy(Buff, Name);
free(Name);
return 1;
}
XrdOfsTPC::Verify
static char * Verify(const char *Who, const char *Name, char *Buf, int Blen)
Definition XrdOfsTPC.cc:683
XrdSecEntity::host
char * host
Entity's host name dnr dependent.
Definition XrdSecEntity.hh:70

References XrdSecEntity::host, XrdSecEntity::tident, and Verify().

Referenced by XrdOfsTPCAuth::Add(), and Validate().

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

## getTTL()

int XrdOfsTPC::getTTL | ( | XrdOucEnv * | Env | ) |

static protected

Definition at line 396 of file XrdOfsTPC.cc.

{
const char *vTTL = Env->Get(XrdOucTPC::tpcTtl);
if (vTTL)
{char *ePtr;
int n;
n = strtol(vTTL, &ePtr, 10);
if (n < 0 || *ePtr) return Cfg.dflTTL;
return (n > Cfg.maxTTL ? Cfg.maxTTL : n);
}
return Cfg.dflTTL;
}
XrdOucTPC::tpcTtl
static const char * tpcTtl
Definition XrdOucTPC.hh:67
XrdOfsTPCConfig::dflTTL
int dflTTL
Definition XrdOfsTPCConfig.hh:44
XrdOfsTPCConfig::maxTTL
int maxTTL
Definition XrdOfsTPCConfig.hh:43

References XrdOfsTPCParms::Cfg, XrdOucEnv::Get(), and XrdOucTPC::tpcTtl.

Referenced by Authorize().

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

## Init() [1/2]

void XrdOfsTPC::Init | ( |  | ) |

static

Definition at line 414 of file XrdOfsTPC.cc.

{
std::string aStr;
// Create credential forwarding template, if cred path specified. It is
// gauranteed to end with a slash (it better be).
//
if (Cfg.cPath && Cfg.fCreds) cPath = Cfg.cPath;
else cPath = 0;
// Check for streams option
//
if (Cfg.tcpSTRM > 15) Cfg.tcpSTRM = 15;
if (Cfg.tcpSMax > 15) Cfg.tcpSMax = 15;
// Record all delegated auths
//
for (int i = 0; i < fcNum; i++)
{aStr += ' '; aStr += fcAuth[i].aProt;}
// Export the delegated auths
//
if (aStr.length())
XrdOucEnv::Export("XRDTPCDLG", strdup(aStr.c_str()+1));
}
XrdOucEnv::Export
static int Export(const char *Var, const char *Val)
Definition XrdOucEnv.cc:170
XrdOfsTPCParms::fcTb::aProt
char aProt[XrdSecPROTOIDSIZE]
Definition XrdOfsTPC.cc:73
XrdOfsTPCConfig::tcpSTRM
int tcpSTRM
Definition XrdOfsTPCConfig.hh:45
XrdOfsTPCConfig::cPath
char * cPath
Definition XrdOfsTPCConfig.hh:41
XrdOfsTPCConfig::fCreds
bool fCreds
Definition XrdOfsTPCConfig.hh:53
XrdOfsTPCConfig::tcpSMax
int tcpSMax
Definition XrdOfsTPCConfig.hh:46

References XrdOfsTPCParms::Cfg, cPath, XrdOucEnv::Export(), XrdOfsTPCParms::fcAuth, and XrdOfsTPCParms::fcNum.

Referenced by XrdOfs::Configure(), and XrdOfsTPCAuth::RunTTL().

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

## Init() [2/2]

void XrdOfsTPC::Init | ( | XrdAccAuthorize * | accP | ) |

inline static

Definition at line 83 of file XrdOfsTPC.hh.

{fsAuth = accP;}

References fsAuth.

## Require()

void XrdOfsTPC::Require | ( | const char * | Auth,
|  | int | RType )

static

Definition at line 445 of file XrdOfsTPC.cc.

{
int n = strlen(Auth), doEnc = (Auth[n-1] == '+');
if (!rType || rType == reqDST)
{AuthDst = new XrdOucTList(Auth, doEnc, AuthDst);
if (doEnc) AuthDst->text[n-1] = 0;
}
if (!rType || rType == reqORG)
{AuthOrg = new XrdOucTList(Auth, doEnc, AuthOrg);
if (doEnc) AuthOrg->text[n-1] = 0;
}
encTPC |= doEnc;
}
XrdOfsTPC::reqDST
static const int reqDST
Definition XrdOfsTPC.hh:86
XrdOfsTPC::reqORG
static const int reqORG
Definition XrdOfsTPC.hh:87
XrdDig::Auth
XrdDigAuth Auth
Definition XrdDigAuth.cc:63
XrdOfsTPCParms::encTPC
bool encTPC
Definition XrdOfsTPC.cc:82

References AuthDst, AuthOrg, XrdOfsTPCParms::encTPC, reqDST, and reqORG.

## Restrict()

int XrdOfsTPC::Restrict | ( | const char * | Path | ) |

static

Definition at line 465 of file XrdOfsTPC.cc.

{
XrdOucPList *plp;
char pBuff[MAXPATHLEN];
int n = strlen(Path);
if (n >= MAXPATHLEN)
{OfsEroute.Emsg("Config", "tpc restrict path too long");
return 0;
}
if (Path[n-1] != '/')
{strcpy(pBuff, Path);
pBuff[n++] = '/'; pBuff[n] = 0;
Path = pBuff;
}
if (!RPList) RPList = new XrdOucPListAnchor;
if (!(plp = RPList->Match(pBuff)))
{plp = new XrdOucPList(pBuff);
RPList->Insert(plp);
}
return 1;
}
Path
XrdOucString Path
Definition XrdSecpwdSrvAdmin.cc:160

References OfsEroute, Path, and RPList.

## Screen()

int XrdOfsTPC::Screen | ( | XrdOfsTPC::Facts & | Args,
|  | XrdOucTList * | tP,
|  | int | wasEnc = 0 )

static protected

Definition at line 497 of file XrdOfsTPC.cc.

{
const char *aProt = Args.Usr->prot;
while(tP)
{if (!strcmp(tP->text, aProt))
{if (tP->val && wasEnc) return 1;
Fatal(Args, "unencrypted tpc disallowed", EACCES);
break;
}
tP = tP->next;
}
if (!tP) Fatal(Args, "improper tpc authentication", EACCES);
OfsStats.Add(OfsStats.Data.numTPCdeny);
return 0;
}
XrdOucTList::next
XrdOucTList * next
Definition XrdOucTList.hh:45
XrdOucTList::text
char * text
Definition XrdOucTList.hh:46
XrdSecEntity::prot
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5).
Definition XrdSecEntity.hh:67

References Fatal(), XrdOucTList::next, OfsStats, XrdSecEntity::prot, XrdOucTList::text, and XrdOfsTPC::Facts::Usr.

Referenced by Authorize().

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

## Start()

int XrdOfsTPC::Start | ( |  | ) |

static

Definition at line 520 of file XrdOfsTPC.cc.

{
// If there is a path restriction list then setup it up
//
if (RPList) RPList->Default(1);
// If there is no copy program then we use the default one
//
if (!Cfg.XfrProg) Cfg.XfrProg = strdup("xrdcp --server");
// Allocate copy program objects
//
if (!XrdOfsTPCProg::Init()) return 0;
// Start the expiration thread
//
if (!XrdOfsTPCAuth::RunTTL(1)) return 0;
// All done
//
XrdOucEnv::Export("XRDTPC", (encTPC ? "+1" : "1"));
tpcOK = true;
return 1;
}
XrdOfsTPCAuth::RunTTL
static int RunTTL(int Init)
Definition XrdOfsTPCAuth.cc:257
XrdOfsTPCProg::Init
static int Init()
Definition XrdOfsTPCProg.cc:167
XrdOfsTPCConfig::XfrProg
char * XfrProg
Definition XrdOfsTPCConfig.hh:39

References XrdOfsTPCParms::Cfg, XrdOfsTPCParms::encTPC, XrdOucEnv::Export(), XrdOfsTPCProg::Init(), RPList, XrdOfsTPCAuth::RunTTL(), and XrdOfsTPCParms::tpcOK.

Here is the call graph for this function:

## Sync()

virtual int XrdOfsTPC::Sync | ( | XrdOucErrInfo * | error | ) |

inline virtual

Reimplemented in XrdOfsTPCJob.

Definition at line 95 of file XrdOfsTPC.hh.

{return 0;}

## Validate()

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

static

Definition at line 550 of file XrdOfsTPC.cc.

{
XrdOfsTPCJob *myTPC;
const char *tpcLfn = Args.Env->Get(XrdOucTPC::tpcLfn);
const char *tpcSrc = Args.Env->Get(XrdOucTPC::tpcSrc);
const char *tpcCks = Args.Env->Get(XrdOucTPC::tpcCks);
const char *tpcSgi = Args.Env->Get(XrdOucTPC::tpcSgi);
const char *tpcStr = Args.Env->Get(XrdOucTPC::tpcStr);
const char *tpcSpr = Args.Env->Get(XrdOucTPC::tpcSpr);
const char *tpcTpr = Args.Env->Get(XrdOucTPC::tpcTpr);
const char *theCGI, *enVar = 0;
char Buff[512], myURL[4096], sVal = 0;
int n, doRN = 0, myURLen = sizeof(myURL);
short lfnLoc[2];
// Determine if we can handle any TPC requests
//
if (!tpcOK || !Args.Usr) return Death(Args, "tpc not supported", ENOTSUP);
// If we will be forwarding credentials, then verify that we have some
//
for (int i = 0; i < fcNum; i++)
{if (!strcmp(Args.Usr->prot, fcAuth[i].aProt))
{if (Args.Usr->creds == 0 || Args.Usr->credslen < 1
|| (fcAuth[i].aGSI && !strstr(Args.Usr->creds, gsiPKH)))
{if (!fcAuth[i].aOpt)
return Death(Args,"no delegated credentials for tpc",EACCES);
} else enVar = fcAuth[i].aVar;
const char *tpcDlg = Args.Env->Get(XrdOucTPC::tpcDlg);
if (tpcDlg) tpcSrc = tpcDlg;
break;
}
}
// This is a request by a writer to get data from another party. Make sure
// the source has been specified.
//
if (!tpcSrc) return Death(Args, "tpc source not specified", EINVAL);
if (!Args.Pfn) return Death(Args, "tpc pfn not specified", EINVAL);
// If the lfn, if present, it must be absolute.
//
if (!tpcLfn) tpcLfn = Args.Lfn;
else if (Cfg.noids && *tpcLfn != '/')
return Death(Args,"source lfn not absolute",EINVAL);
else doRN = (strcmp(Args.Lfn, tpcLfn) != 0);
// Validate number of streams and adjust accordingly
//
if (tpcStr)
{char *eP;
long nStrm = strtol(tpcStr, &eP, 10);
if (nStrm < 0 || *eP)
return Death(Args, "tpc streams value is invalid", EINVAL);
if (nStrm > Cfg.tcpSMax) nStrm = Cfg.tcpSMax;
sVal = static_cast<char>(nStrm);
} else sVal = static_cast<char>(Cfg.tcpSTRM);
// Generate the origin id
//
if (!enVar && !genOrg(Args.Usr, Buff, sizeof(Buff)))
return Death(Args, Buff, EINVAL);
// Construct the source url (it may be very big)
//
const char *xProt = (!tpcSpr || strcmp("xroots",tpcSpr) ? "xroot" : tpcSpr);
n = snprintf(myURL, myURLen, "%s://%s/%s?", xProt, tpcSrc, tpcLfn);
char *cgiP = myURL+n;
int cgiL = myURLen-n;
if (cgiL < 3) return Death(Args, "url too long", EINVAL);
// Set lfn location in the URL but only if we need to do a rename
//
if (doRN) {lfnLoc[1] = strlen(tpcLfn); lfnLoc[0] = n - lfnLoc[1];}
else lfnLoc[1] = lfnLoc[0] = 0;
// Copy user specified CGI into the source URL (omit tpc tokens)
//
if (tpcSgi)
{if ((int)strlen(tpcSgi) >= cgiL)
return Death(Args, "url too long", EINVAL);
n = XrdOucTPC::copyCGI(tpcSgi, cgiP, cgiL);
cgiP += n;
cgiL -= n;
}
// Insert tpc tokens unless this is a delegated tpc which needs no tokens
//
if (!enVar)
{if (cgiL < 3) return Death(Args, "url too long", EINVAL);
*cgiP++ = '&'; cgiL--; *cgiP = 0;
theCGI = XrdOucTPC::cgiD2Src(Args.Key, Buff, cgiP, cgiL);
if (*theCGI == '!') return Death(Args, theCGI+1, EINVAL);
}
// Create a pseudo tpc object that will contain the information we need to
// actually peform this copy.
//
if (!(myTPC = new XrdOfsTPCJob(myURL, Args.Usr->tident,
Args.Lfn, Args.Pfn, tpcCks, lfnLoc,
tpcSpr, tpcTpr)))
return Death(Args, "insufficient memory", ENOMEM);
// Set credentials for the job if we need to
//
if (enVar && Args.Usr->credslen > 0)
myTPC->Info.SetCreds(enVar, Args.Usr->creds, Args.Usr->credslen);
// Setup reproxing if this is required
//
if (Cfg.rPath)
{int inst = rpInst++;
char rpBuff[1024];
snprintf(rpBuff, sizeof(rpBuff), Cfg.rPath, inst);
myTPC->Info.SetRPath(rpBuff);
Args.Env->Put("tpc.reproxy", rpBuff);
}
// Set number of streams to use
//
if (sVal > 0) myTPC->Info.SetStreams(sVal);
// All done
//
myTPC->Info.isDest();
*theTPC = (XrdOfsTPC *)myTPC;
return SFS_OK;
}
XrdOfsTPCInfo::SetRPath
void SetRPath(const char *rpath)
Definition XrdOfsTPCInfo.hh:69
XrdOfsTPCInfo::isDest
void isDest()
Definition XrdOfsTPCInfo.hh:49
XrdOfsTPCInfo::SetStreams
void SetStreams(char sval)
Definition XrdOfsTPCInfo.hh:74
XrdOfsTPCInfo::SetCreds
void SetCreds(const char *evar, const char *creds, int crdsz)
Definition XrdOfsTPCInfo.hh:62
XrdOfsTPC::Death
static int Death(Facts &Args, const char *eMsg, int eCode, int nomsg=0)
Definition XrdOfsTPC.cc:319
XrdOfsTPC::genOrg
static int genOrg(const XrdSecEntity *client, char *Buff, int Blen)
Definition XrdOfsTPC.cc:359
XrdOucEnv::Put
void Put(const char *varname, const char *value)
Definition XrdOucEnv.hh:85
XrdOucTPC::tpcSpr
static const char * tpcSpr
Definition XrdOucTPC.hh:63
XrdOucTPC::tpcTpr
static const char * tpcTpr
Definition XrdOucTPC.hh:66
XrdOucTPC::tpcLfn
static const char * tpcLfn
Definition XrdOucTPC.hh:59
XrdOucTPC::copyCGI
static int copyCGI(const char *cgi, char *Buff, int Blen)
Definition XrdOucTPC.cc:233
XrdOucTPC::tpcDlg
static const char * tpcDlg
Definition XrdOucTPC.hh:56
XrdOucTPC::tpcSrc
static const char * tpcSrc
Definition XrdOucTPC.hh:64
XrdOucTPC::cgiD2Src
static const char * cgiD2Src(const char *cKey, const char *cOrg, char *Buff, int Blen)
Definition XrdOucTPC.cc:168
XrdOucTPC::tpcSgi
static const char * tpcSgi
Definition XrdOucTPC.hh:62
XrdOucTPC::tpcCks
static const char * tpcCks
Definition XrdOucTPC.hh:55
XrdOucTPC::tpcStr
static const char * tpcStr
Definition XrdOucTPC.hh:65
XrdSecEntity::credslen
int credslen
Length of the 'creds' data.
Definition XrdSecEntity.hh:78
XrdSecEntity::creds
char * creds
Raw entity credentials or cert.
Definition XrdSecEntity.hh:77
XrdOfsTPCParms::gsiPKH
const char * gsiPKH
Definition XrdOfsTPC.cc:78
XrdOfsTPCConfig::rPath
char * rPath
Definition XrdOfsTPCConfig.hh:42
XrdOfsTPCConfig::noids
bool noids
Definition XrdOfsTPCConfig.hh:52
XrdOfsTPC::Facts::Key
const char * Key
Definition XrdOfsTPC.hh:52

References XrdOfsTPC(), XrdOfsTPCParms::Cfg, XrdOucTPC::cgiD2Src(), XrdOucTPC::copyCGI(), XrdSecEntity::creds, XrdSecEntity::credslen, Death(), XrdOfsTPC::Facts::Env, XrdOfsTPCParms::fcAuth, XrdOfsTPCParms::fcNum, genOrg(), XrdOucEnv::Get(), XrdOfsTPCParms::gsiPKH, Info, XrdOfsTPCInfo::isDest(), XrdOfsTPC::Facts::Key, XrdOfsTPC::Facts::Lfn, XrdOfsTPC::Facts::Pfn, XrdSecEntity::prot, XrdOucEnv::Put(), XrdOfsTPCInfo::SetCreds(), XrdOfsTPCInfo::SetRPath(), XrdOfsTPCInfo::SetStreams(), SFS_OK, XrdSecEntity::tident, XrdOucTPC::tpcCks, XrdOucTPC::tpcDlg, XrdOucTPC::tpcLfn, XrdOfsTPCParms::tpcOK, XrdOucTPC::tpcSgi, XrdOucTPC::tpcSpr, XrdOucTPC::tpcSrc, XrdOucTPC::tpcStr, XrdOucTPC::tpcTpr, and XrdOfsTPC::Facts::Usr.

Referenced by XrdOfsFile::open().

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

## Verify()

char * XrdOfsTPC::Verify | ( | const char * | Who,
|  | const char * | Name,
|  | char * | Buf,
|  | int | Blen )

static protected

Definition at line 683 of file XrdOfsTPC.cc.

{
XrdNetAddr vAddr;
const char *etext, *Host;
// Obtain full host name and return it if successful
//
if (!(etext = vAddr.Set(Name,0)) && (Host = vAddr.Name(0, &etext)))
return strdup(Host);
// Generate error
//
snprintf(Buf, Blen, "unable to verify %s %s (%s)", Who, Name, etext);
Buf[Blen-1] = 0;
return 0;
}
XrdNetAddr::Set
const char * Set(const char *hSpec, int pNum=PortInSpec)
Definition XrdNetAddr.cc:216

References XrdNetAddrInfo::Name(), and XrdNetAddr::Set().

Referenced by genOrg().

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

## Member Data Documentation

## ALList

XrdOfsTPCAllow * XrdOfsTPC::ALList = 0

static protected

Definition at line 126 of file XrdOfsTPC.hh.

Referenced by Allow(), and Authorize().

## AuthDst

XrdOucTList * XrdOfsTPC::AuthDst = 0

static protected

Definition at line 122 of file XrdOfsTPC.hh.

Referenced by Authorize(), and Require().

## AuthOrg

XrdOucTList * XrdOfsTPC::AuthOrg = 0

static protected

Definition at line 123 of file XrdOfsTPC.hh.

Referenced by Authorize(), and Require().

## cPath

char * XrdOfsTPC::cPath = 0

static protected

Definition at line 124 of file XrdOfsTPC.hh.

Referenced by credPath(), and Init().

## fsAuth

XrdAccAuthorize * XrdOfsTPC::fsAuth = 0

static protected

Definition at line 120 of file XrdOfsTPC.hh.

Referenced by Authorize(), and Init().

## Info

XrdOfsTPCInfo XrdOfsTPC::Info

Definition at line 109 of file XrdOfsTPC.hh.

Referenced by XrdOfsTPC(), XrdOfsTPCAuth::Add(), XrdOfsTPCJob::Del(), XrdOfsTPCJob::Done(), XrdOfsTPCAuth::Expired(), XrdOfsTPCJob::Sync(), and Validate().

## inQ

char XrdOfsTPC::inQ

protected

Definition at line 130 of file XrdOfsTPC.hh.

Referenced by XrdOfsTPC(), XrdOfsTPC(), XrdOfsTPCAuth::Add(), XrdOfsTPCAuth::Del(), XrdOfsTPCJob::Del(), XrdOfsTPCJob::Done(), and XrdOfsTPCJob::Sync().

## Refs

char XrdOfsTPC::Refs

protected

Definition at line 129 of file XrdOfsTPC.hh.

Referenced by XrdOfsTPC(), XrdOfsTPC(), XrdOfsTPCAuth::Del(), XrdOfsTPCJob::Del(), XrdOfsTPCJob::Done(), and XrdOfsTPCJob::Sync().

## reqALL

const int XrdOfsTPC::reqALL = 0

static

Definition at line 85 of file XrdOfsTPC.hh.

## reqDST

const int XrdOfsTPC::reqDST = 1

static

Definition at line 86 of file XrdOfsTPC.hh.

Referenced by Require().

## reqORG

const int XrdOfsTPC::reqORG = 2

static

Definition at line 87 of file XrdOfsTPC.hh.

Referenced by Require().

## RPList

XrdOucPListAnchor * XrdOfsTPC::RPList

static protected

Definition at line 127 of file XrdOfsTPC.hh.

Referenced by Authorize(), Restrict(), and Start().

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

- XrdOfsTPC.hh
- XrdOfsTPC.cc