Loading...
Searching...
No Matches
XrdCmsLogin Class Reference

`#include <XrdCmsLogin.hh>`

Collaboration diagram for XrdCmsLogin:

## Public Member Functions

| XrdCmsLogin (char *Buff=0, int Blen=0)
| ~XrdCmsLogin ()
int | Admit (XrdLink *Link, XrdCms::CmsLoginData &Data, const char *sid, const char *envP)

## Static Public Member Functions

static int | Login (XrdLink *Link, XrdCms::CmsLoginData &Data, int timeout=-1)

## Detailed Description

Definition at line 40 of file XrdCmsLogin.hh.

## Constructor & Destructor Documentation

## XrdCmsLogin()

XrdCmsLogin::XrdCmsLogin | ( | char * | Buff = 0,
|  | int | Blen = 0 )

inline

Definition at line 49 of file XrdCmsLogin.hh.

{myBuff = Buff; myBlen = Blen;}

## ~XrdCmsLogin()

XrdCmsLogin::~XrdCmsLogin | ( |  | ) |

inline

Definition at line 51 of file XrdCmsLogin.hh.

{}

## Member Function Documentation

## Admit()

int XrdCmsLogin::Admit | ( | XrdLink * | Link,
|  | XrdCms::CmsLoginData & | Data,
|  | const char * | sid,
|  | const char * | envP )

Definition at line 56 of file XrdCmsLogin.cc.

{
CmsRRHdr myHdr;
CmsLoginData myData;
const char *eText, *Token;
int myDlen, Toksz;
// Get complete request
//
if ((eText = XrdCmsTalk::Attend(Link, myHdr, myBuff, myBlen, myDlen)))
return Emsg(Link, eText, 0);
// If we need to do authentication, do so now
//
if ((Token = XrdCmsSecurity::getToken(Toksz, Link->AddrInfo()))
&& !XrdCmsSecurity::Authenticate(Link, Token, Toksz)) return 0;
// Fiddle with the login data structures
//
Data.SID = Data.Paths = Data.ifList = Data.envCGI = 0;
memset(&myData, 0, sizeof(myData));
myData.Mode = Data.Mode;
myData.HoldTime = Data.HoldTime;
myData.Version = Data.Version = kYR_Version;
// Decode the data pointers ans grab the login data
//
if (!Parser.Parse(&Data, myBuff, myBuff+myDlen))
return Emsg(Link, "invalid login data", 0);
// Check if this node is blacklisted
//
if (!(Data.Mode & CmsLoginData::kYR_director))
{static const int rbsz = 1024;
char *rbP, rbuff[rbsz];
int rc;
rbP = (myData.Version <= Data.Version ? rbuff : 0);
rc = XrdCmsBlackList::Present(Link->Host(), 0, rbP, rbsz);
if (rc > 0) return SendErrorBL(Link, rbuff, rc);
else if (rc < 0) return SendErrorBL(Link);
}
// Fill out additional information if the client can accept it
//
if (myData.Version <= Data.Version)
{myData.SID = (kXR_char *)sid;
myData.envCGI = (kXR_char *)envP;
}
// Send off login reply
//
return (sendData(Link, myData) ? 0 : 1);
}
kXR_char
unsigned char kXR_char
Definition XPtypes.hh:65
XrdCmsBlackList::Present
static int Present(const char *hName, XrdOucTList *bList=0, char *rbuff=0, int rblen=0)
Definition XrdCmsBlackList.cc:515
XrdCmsParser::Parse
int Parse(XrdCms::CmsLoginData *Data, const char *Aps, const char *Apt)
Definition XrdCmsParser.hh:59
XrdCmsSecurity::getToken
static const char * getToken(int &size, XrdNetAddrInfo *endPoint)
Definition XrdCmsSecurity.cc:277
XrdCmsSecurity::Authenticate
static int Authenticate(XrdLink *Link, const char *Token, int tlen)
Definition XrdCmsSecurity.cc:77
XrdCmsTalk::Attend
static const char * Attend(XrdLink *Link, XrdCms::CmsRRHdr &Hdr, char *buff, int blen, int &rlen, int tmo=5000)
Definition XrdCmsTalk.cc:46
XrdLink::AddrInfo
XrdNetAddrInfo * AddrInfo()
Definition XrdLink.cc:143
XrdLink::Host
const char * Host() const
Definition XrdLink.hh:204
XrdCms::kYR_Version
static const unsigned char kYR_Version
Definition YProtocol.hh:80
XrdCms::Parser
XrdCmsParser Parser
Definition XrdCmsParser.cc:132
XrdCms::CmsLoginData::Mode
kXR_unt32 Mode
Definition YProtocol.hh:279
XrdCms::CmsLoginData::Paths
kXR_char * Paths
Definition YProtocol.hh:289
XrdCms::CmsLoginData::HoldTime
kXR_int32 HoldTime
Definition YProtocol.hh:280
XrdCms::CmsLoginData::envCGI
kXR_char * envCGI
Definition YProtocol.hh:291
XrdCms::CmsLoginData::ifList
kXR_char * ifList
Definition YProtocol.hh:290
XrdCms::CmsLoginData::kYR_director
@ kYR_director
Definition YProtocol.hh:294
XrdCms::CmsLoginData::Version
kXR_unt16 Version
Definition YProtocol.hh:278
XrdCms::CmsLoginData::SID
kXR_char * SID
Definition YProtocol.hh:288

References XrdLink::AddrInfo(), XrdCmsTalk::Attend(), XrdCmsSecurity::Authenticate(), XrdCms::CmsLoginData::envCGI, XrdCmsSecurity::getToken(), XrdCms::CmsLoginData::HoldTime, XrdLink::Host(), XrdCms::CmsLoginData::ifList, XrdCms::CmsLoginData::kYR_director, XrdCms::kYR_Version, XrdCms::CmsLoginData::Mode, XrdCms::Parser, XrdCms::CmsLoginData::Paths, XrdCmsBlackList::Present(), XrdCms::CmsLoginData::SID, and XrdCms::CmsLoginData::Version.

Here is the call graph for this function:

## Login()

int XrdCmsLogin::Login | ( | XrdLink * | Link,
|  | XrdCms::CmsLoginData & | Data,
|  | int | timeout = -1 )

static

Definition at line 125 of file XrdCmsLogin.cc.

{
CmsRRHdr LIHdr;
char WorkBuff[4096], *hList, *wP = WorkBuff;
int n, dataLen;
// We can accept permanent redirects so indicate this
//
Data.Mode |= CmsLoginData::kYR_blredir;
// Send the data and immediately clear the data structure of pointers
//
n = sendData(Link, Data);
Data.Paths = Data.SID = Data.envCGI = 0;
if (n) return kYR_EINVAL;
// Get the response.
//
if ((n = Link->RecvAll((char *)&LIHdr, sizeof(LIHdr), timeout)) < 0)
return Emsg(Link, (n == -ETIMEDOUT ? "timed out" : "rejected"));
// Receive and decode the response. We apparently have protocol version 2.
//
if ((dataLen = static_cast<int>(ntohs(LIHdr.datalen))))
{if (dataLen > (int)sizeof(WorkBuff))
return Emsg(Link, "login reply too long");
if (Link->RecvAll(WorkBuff, dataLen, timeout) < 0)
return Emsg(Link, "login receive error");
}
// Check if we are being asked to identify ourselves
//
if (LIHdr.rrCode == kYR_xauth)
{if (!XrdCmsSecurity::Identify(Link, LIHdr, WorkBuff, sizeof(WorkBuff)))
return kYR_EINVAL;
dataLen = static_cast<int>(ntohs(LIHdr.datalen));
if (dataLen > (int)sizeof(WorkBuff))
return Emsg(Link, "login reply too long");
}
// The response can also be a login redirect (i.e., a try request).
//
if (!(Data.Mode & CmsLoginData::kYR_director)
&& LIHdr.rrCode == kYR_try)
{if (!XrdOucPup::Unpack(&wP, wP+dataLen, &hList, n))
return Emsg(Link, "malformed try host data");
Data.Paths = (kXR_char *)strdup(n ? hList : "");
if (!(LIHdr.modifier & CmsTryRequest::kYR_permtop))
Data.Mode &= ~CmsLoginData::kYR_blredir;
return kYR_redirect;
}
// Process error reply
//
if (LIHdr.rrCode == kYR_error)
{unsigned int eRC;
if (dataLen < (int)sizeof(kXR_unt32)+8)
return Emsg(Link, "invalid error reply");
Emsg(Link, WorkBuff+sizeof(kXR_unt32));
memcpy(&eRC, WorkBuff, sizeof(eRC));
eRC = ntohl(eRC);
return (eRC == kYR_EPERM ? -1 : kYR_EINVAL);
}
// Process normal reply
//
if (LIHdr.rrCode != kYR_login
|| !Parser.Parse(&Data, WorkBuff, WorkBuff+dataLen))
return Emsg(Link, "invalid login response");
// Copy any strings that we are exporting
//
if (Data.SID) Data.SID = (kXR_char *)strdup((const char *)Data.SID);
if (Data.envCGI) Data.envCGI = (kXR_char *)strdup((const char *)Data.envCGI);
return 0;
}
kXR_unt32
unsigned int kXR_unt32
Definition XPtypes.hh:90
XrdCmsSecurity::Identify
static int Identify(XrdLink *Link, XrdCms::CmsRRHdr &inHdr, char *authBuff, int abLen)
Definition XrdCmsSecurity.cc:293
XrdLink::RecvAll
int RecvAll(char *buff, int blen, int timeout=-1)
Definition XrdLink.cc:312
XrdOucPup::Unpack
static int Unpack(char **buff, const char *bend, char **data, int &dlen)
Definition XrdOucPup.cc:250
XrdCms::kYR_EINVAL
@ kYR_EINVAL
Definition YProtocol.hh:153
XrdCms::kYR_EPERM
@ kYR_EPERM
Definition YProtocol.hh:151
XrdCms::kYR_redirect
@ kYR_redirect
Definition YProtocol.hh:143
XrdCms::kYR_error
@ kYR_error
Definition YProtocol.hh:142
XrdCms::kYR_xauth
@ kYR_xauth
Definition YProtocol.hh:117
XrdCms::kYR_login
@ kYR_login
Definition YProtocol.hh:90
XrdCms::kYR_try
@ kYR_try
Definition YProtocol.hh:114
XrdCms::CmsLoginData::kYR_blredir
@ kYR_blredir
Definition YProtocol.hh:300
XrdCms::CmsTryRequest::kYR_permtop
@ kYR_permtop
Definition YProtocol.hh:628

References XrdCms::CmsRRHdr::datalen, XrdCms::CmsLoginData::envCGI, XrdCmsSecurity::Identify(), XrdCms::CmsLoginData::kYR_blredir, XrdCms::CmsLoginData::kYR_director, XrdCms::kYR_EINVAL, XrdCms::kYR_EPERM, XrdCms::kYR_error, XrdCms::kYR_login, XrdCms::CmsTryRequest::kYR_permtop, XrdCms::kYR_redirect, XrdCms::kYR_try, XrdCms::kYR_xauth, XrdCms::CmsLoginData::Mode, XrdCms::CmsRRHdr::modifier, XrdCms::Parser, XrdCms::CmsLoginData::Paths, XrdLink::RecvAll(), XrdCms::CmsRRHdr::rrCode, XrdCms::CmsLoginData::SID, and XrdOucPup::Unpack().

Here is the call graph for this function:

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

- XrdCmsLogin.hh
- XrdCmsLogin.cc