Loading...
Searching...
No Matches
XrdSecLoadSecurity.cc File Reference
`#include <iostream>`
`#include "XrdVersion.hh"`
`#include "XProtocol/XProtocol.hh"`
`#include "XrdOuc/XrdOucPinLoader.hh"`
`#include "XrdSec/XrdSecLoadSecurity.hh"`
`#include "XrdSec/XrdSecProtector.hh"`
`#include "XrdSys/XrdSysError.hh"`
`#include "XrdSys/XrdSysPlatform.hh"`
`#include "XrdSys/XrdSysPthread.hh"`
Include dependency graph for XrdSecLoadSecurity.cc:

Go to the source code of this file.

## Namespaces

namespace | XrdSecProtection

## Functions

int | XrdSecGetProtection (XrdSecProtect *&protP, XrdSecProtocol &aprot, ServerResponseBody_Protocol &resp, unsigned int resplen)
XrdSecProtector * | XrdSecLoadProtection (XrdSysError &erP)
XrdSecGetProt_t | XrdSecLoadSecFactory (char *eBuff, int eBlen, const char *seclib)
XrdSecService * | XrdSecLoadSecService (XrdSysError *eDest, const char *cfn, const char *seclib, XrdSecGetProt_t *getP, XrdSecProtector **proP)

## Variables

int | XrdSecProtection::protRC = 0
XrdSecProtector * | XrdSecProtection::theProtector = 0

## Function Documentation

## XrdSecGetProtection()

int XrdSecGetProtection | ( | XrdSecProtect *& | protP,
|  | XrdSecProtocol & | aprot,
|  | ServerResponseBody_Protocol & | resp,
|  | unsigned int | resplen )

Obtain an instance of a security protection object based on the kXR_protocol response. This is only used client-side.

Parameters

  protP | Place where the protection object point is placed.
  aprot | Uses the authentication protocol to protect requests. It must be supplied and must be he protocol the client used for authentication. Hence, authentication must occur first.
  resp | Reference to the response body returned by kXR_protocol.
  resplen | Length of the response body.

Returns
  >0 pointer to the protect object placed in protP.
  =0 No protection is needed, protP set to zero.
  <0 An error occurred getting the protection object the return value is -errno and protP has been set to zero.

Definition at line 206 of file XrdSecLoadSecurity.cc.

{
static const unsigned int hdrLen = sizeof(ServerResponseReqs_Protocol) - 2;
static const unsigned int minLen = kXR_ShortProtRespLen + hdrLen;
XrdSecProtector *pObj;
unsigned int vLen;
int rc;
// First validate the response before passing it to anyone
//
protP = 0;
if (resplen <= kXR_ShortProtRespLen) return 0;
if (resplen < minLen) return -EINVAL;
vLen = static_cast<unsigned int>(resp.secreq.secvsz)
* sizeof(ServerResponseSVec_Protocol);
if (vLen + minLen > resplen) return -EINVAL;
// Our first step is to see if any protection is required
//
if (vLen == 0 && resp.secreq.seclvl == kXR_secNone) return 0;
// The next step is to see if we have a protector object. If we do not then
// we need to load the library that provides such objects. This needs to be
// MT-safe as it may be called at any time by any thread.
//
protMutex.Lock();
if (!(pObj = XrdSecProtection::theProtector))
{if (!XrdSecProtection::protRC)
{char eBuff[2048];
if ((XrdSecProtection::protRC = Load(eBuff, sizeof(eBuff), 0)))
std::cerr <<"SecLoad: " <<eBuff <<'\n' <<std::flush;
else
pObj = XrdSecProtection::theProtector;
}
if ((rc = XrdSecProtection::protRC))
{protMutex.UnLock();
return -rc;
}
}
protMutex.UnLock();
// Return new protection object
//
protP = pObj->New4Client(aprot, resp.secreq, resplen-kXR_ShortProtRespLen);
return (protP ? 1 : 0);
}
kXR_ShortProtRespLen
#define kXR_ShortProtRespLen
Definition XProtocol.hh:1200
kXR_secNone
#define kXR_secNone
Definition XProtocol.hh:1131
ServerResponseReqs_Protocol::secvsz
kXR_char secvsz
Definition XProtocol.hh:1113
ServerResponseReqs_Protocol::seclvl
kXR_char seclvl
Definition XProtocol.hh:1112
ServerResponseBody_Protocol::secreq
ServerResponseReqs_Protocol secreq
Definition XProtocol.hh:1194
ServerResponseReqs_Protocol
Definition XProtocol.hh:1107
ServerResponseSVec_Protocol
Definition XProtocol.hh:1102
XrdSecProtector
Definition XrdSecProtector.hh:73
XrdSecProtector::New4Client
virtual XrdSecProtect * New4Client(XrdSecProtocol &aprot, const ServerResponseReqs_Protocol &inReqs, unsigned int reqLen)
Definition XrdSecProtector.cc:202
XrdSecProtection::theProtector
XrdSecProtector * theProtector
Definition XrdSecLoadSecurity.cc:56
XrdSecProtection::protRC
int protRC
Definition XrdSecLoadSecurity.cc:57

References kXR_secNone, kXR_ShortProtRespLen, XrdSecProtector::New4Client(), XrdSecProtection::protRC, ServerResponseReqs_Protocol::seclvl, ServerResponseBody_Protocol::secreq, ServerResponseReqs_Protocol::secvsz, and XrdSecProtection::theProtector.

Here is the call graph for this function:

## XrdSecLoadProtection()

XrdSecProtector * XrdSecLoadProtection | ( | XrdSysError & | erP | ) |

Definition at line 262 of file XrdSecLoadSecurity.cc.

{
// Load the protection object. This is done in the main thread do no mutex
//
XrdSecProtection::protRC = Load(0, 0, 0, &erP);
// All done, return result
//
return (XrdSecProtection::protRC ? 0 : XrdSecProtection::theProtector);
}

References XrdSecProtection::protRC, and XrdSecProtection::theProtector.

Referenced by XrdSecServer::Configure().

Here is the caller graph for this function:

## XrdSecLoadSecFactory()

XrdSecGetProt_t XrdSecLoadSecFactory | ( | char * | eBuff,
|  | int | eBlen,
|  | const char * | seclib = 0 )

This include file defines utility functions that load the security framework plugin specialized for server-side or client-side use. These functions are public and remain ABI stable!

Load the Security Protocol Factory (used client-side)

Parameters

  eBuff | Pointer to a buffer tat is to receive any messages. Upon failure it will contain an eror message. Upon success it will contain an informational message that describes the version that was loaded.
  eBlen | The length of the eBuff, it should be at least 1K to avoid message truncation as the message may have a path.
  seclib | Pointer to the shared library path that contains the framework implementation. If a nill pointer is passed, then the default library is used.

Returns
  !0 Pointer to the to XrdSegGetProtocol() function is returned. returned in getP if it is not nil.
  =0 The security frmaework could not be loaded. The error message describing the problem is in eBuff.

Definition at line 176 of file XrdSecLoadSecurity.cc.

{
XrdSecGetProt_t getP;
int rc;
// Load required plugin nd obtain pointers
//
rc = Load(eBuff, eBlen, 0, seclib, &getP);
if (!rc) return getP;
// Issue correct error message, if any
//
if (!seclib) seclib = "default";
if (rc < 0)
snprintf(eBuff, eBlen,
"Unable to create security framework via %s; invalid path.",
seclib);
else if (!(*eBuff))
snprintf(eBuff, eBlen,
"Unable to create security framework via %s", seclib);
return 0;
}
XrdSecGetProt_t
XrdSecProtocol *(* XrdSecGetProt_t)(const char *hostname, XrdNetAddrInfo &endPoint, XrdSecParameters &sectoken, XrdOucErrInfo *einfo)
Typedef to simplify the encoding of methods returning XrdSecProtocol.
Definition XrdSecInterface.hh:483

## XrdSecLoadSecService()

XrdSecService * XrdSecLoadSecService | ( | XrdSysError * | eDest,
|  | const char * | cfn,
|  | const char * | seclib,
|  | XrdSecGetProt_t * | getP,
|  | XrdSecProtector ** | proP )

Definition at line 278 of file XrdSecLoadSecurity.cc.

{
XrdSecService *CIA;
// Load required plugin nd obtain pointers
//
if (Load(0, 0, cfn, seclib, getP, &CIA, eDest)) return 0;
// Set the protectorobject. Note that the securityservice will load it if
// is needed and we will havecaptured its pointer. This sort of a hack but
// we can't change the SecService object as it is a public interface.
//
if (proP) *proP = XrdSecProtection::theProtector;
return CIA;
}
eDest
static XrdSysError eDest(0,"crypto_")
XrdSecService
Definition XrdSecInterface.hh:554

References eDest, and XrdSecProtection::theProtector.

Referenced by XrdCmsSecurity::Configure().

Here is the caller graph for this function: