Loading...
Searching...
No Matches
XrdDigConfig Class Reference

`#include <XrdDigConfig.hh>`

Collaboration diagram for XrdDigConfig:

## Public Types

enum | pType { isAny = 0 , isDir , isFile }

## Public Member Functions

| XrdDigConfig ()
| ~XrdDigConfig ()
bool | Configure (const char *cFN, const char *parms)
int | GenAccess (const XrdSecEntity *client, const char *aList[], int aMax)
char * | GenPath (int &rc, const XrdSecEntity *client, const char *opname, const char *lfn, pType lfnType=isAny)
void | GetLocResp (XrdOucErrInfo &eInfo, bool nameok)

## Static Public Member Functions

static void | StatRoot (struct stat *sP)

## Detailed Description

Definition at line 38 of file XrdDigConfig.hh.

## Member Enumeration Documentation

## pType

enum XrdDigConfig::pType

Enumerator
isAny |
isDir |
isFile |

Definition at line 45 of file XrdDigConfig.hh.

{isAny = 0, isDir, isFile};
XrdDigConfig::isFile
@ isFile
Definition XrdDigConfig.hh:45
XrdDigConfig::isDir
@ isDir
Definition XrdDigConfig.hh:45
XrdDigConfig::isAny
@ isAny
Definition XrdDigConfig.hh:45

## Constructor & Destructor Documentation

## XrdDigConfig()

XrdDigConfig::XrdDigConfig | ( |  | ) |

inline

Definition at line 59 of file XrdDigConfig.hh.

: fnTmplt(0), logAcc(true), logRej(true) {}

## ~XrdDigConfig()

XrdDigConfig::~XrdDigConfig | ( |  | ) |

inline

Definition at line 60 of file XrdDigConfig.hh.

{}

## Member Function Documentation

## Configure()

bool XrdDigConfig::Configure | ( | const char * | cFN,
|  | const char * | parms )

Definition at line 97 of file XrdDigConfig.cc.

{
/*
Function: Establish default values using configuration parameters.
Input: None.
Output: true upon success or false otherwise.
*/
char buff[4096], *afile, *var;
XrdOucTokenizer cParms(buff);
struct stat Stat;
int n;
bool isOK = true;
// Get the adminpath (this better succeed).
//
if (!(var = getenv("XRDADMINPATH")) || (n = strlen(var)) >= MAXPATHLEN)
{eDest->Emsg("Config", "Unable to deterine adminpath!");
return false;
}
// Create a template for file remapping
//
strcpy(buff, var);
if (buff[n-1] != '/') {buff[n] = '/'; n++;}
strcpy(buff+n, ".xrd/=/%s");
fnTmplt = strdup(buff);
// Make sure that conf/etc no longer exists as a previous start may have
// exported something that we no longer wish to export.
//
if (snprintf(buff, sizeof(buff), fnTmplt, "conf/etc") < (int)sizeof(buff))
Empty(buff);
// Pake sure there are parameters here
//
if(!parms || !*parms)
{eDest->Emsg("Config", "DigFS parameters not specified.");
return false;
}
// Copy the parms as they will be altered and attach it to the tokenizer
//
n = strlen(parms);
if (n >= (int)sizeof(buff))
{eDest->Emsg("Config", "DigFS parm string is too long.");
return false;
}
strcpy(buff, parms);
// First token is the authfile
//
cParms.GetLine();
if (!(afile = cParms.GetToken()) || !afile[0])
{eDest->Emsg("Config", "DigFS authfile not specified.");
return false;
}
// If we have a config file, process it now
//
if (cFN && *cFN) isOK = ConfigProc(cFN);
// Config authorization. The config may have failed but we want to generate
// all of the rror messages in one go.
//
if (!Auth.Configure(afile)) isOK = false;
// Setup locate response
//
SetLocResp();
// Get a valid stat structure for the root directory
//
stat("/", &rootStat);
// Validate base entries
//
for (n = 0; n < pNum; n++)
{sprintf(buff, fnTmplt, pTab[n].pfx);
pTab[n].isOK = stat(buff, &Stat) == 0;
}
// All done
//
return isOK;
}
Stat
struct stat Stat
Definition XrdCks.cc:49
eDest
static XrdSysError eDest(0,"crypto_")
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdDigAuth::Configure
bool Configure(const char *aFN)
Definition XrdDigAuth.cc:163
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
XrdDig::Auth
XrdDigAuth Auth
Definition XrdDigAuth.cc:63

References XrdDig::Auth, eDest, XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), Stat, and stat.

Here is the call graph for this function:

## GenAccess()

int XrdDigConfig::GenAccess | ( | const XrdSecEntity * | client,
|  | const char * | aList[],
|  | int | aMax )

Definition at line 189 of file XrdDigConfig.cc.

{
bool aOK[XrdDigAuthEnt::aNum], hasAcc = false;
int i, n = 0;
// Validate aMax
//
if (aMax < 1) return -1;
// Get access right for this client
//
Auth.Authorize(client, XrdDigAuthEnt::aNum, aOK);
// Return entries that are allowed
//
for (i = (int)sizeof(aOK)-1; i >= 0 && n < aMax; i--)
{hasAcc |= aOK[i];
if (aOK[i] && pTab[i].isOK) aList[n++] = pTab[i].pfx;
}
// Return permission denied if no access allowed
//
if (!hasAcc) return -1;
// Return something if we had an error setting up as empty dirs cause problems.
//
if (!n) {aList[0] = "."; n = 1;}
return n;
}
XrdDigAuthEnt::aNum
@ aNum
Definition XrdDigAuth.hh:53
XrdDigAuth::Authorize
bool Authorize(const XrdSecEntity *client, XrdDigAuthEnt::aType aType, bool aVec[XrdDigAuthEnt::aNum]=0)
Definition XrdDigAuth.cc:89

References XrdDigAuthEnt::aNum, and XrdDig::Auth.

## GenPath()

char * XrdDigConfig::GenPath | ( | int & | rc,
|  | const XrdSecEntity * | client,
|  | const char * | opname,
|  | const char * | lfn,
|  | XrdDigConfig::pType | lfnType = isAny )

Definition at line 226 of file XrdDigConfig.cc.

{
char path[2048];
int i, n;
// First we better have a client object
//
if (!client) {rc = EPERM; return 0;}
// Translate the fname to the right file type
//
for (i = 0; i < pNum; i++)
{if (!strncmp(pTab[i].pfx, fname, pTab[i].pfxlen)
&& (*(fname+pTab[i].pfxlen) == '/' || !*(fname+pTab[i].pfxlen))) break;
}
// Make sure we found a valid entry
//
if (i >= pNum || !pTab[i].isOK) {rc = ENOENT; return 0;}
// Authorize this access
//
if (!Auth.Authorize(client, pTab[i].aType))
{if (lfnType == isFile && logRej) Audit(client, "denied", opname, fname);
rc = EACCES;
return 0;
}
// If the entry is being suffixed and it's proc, make sure we are not trying
// to gain access to something outside of the proc directory tree
//
if (pTab[i].aType == XrdDigAuthEnt::aProc && (rc = ValProc(fname)))
{if (logRej && rc == EPERM) Audit(client, "denied", opname, fname);
return 0;
}
// Log this access if so wanted
//
if (lfnType == isFile && logAcc) Audit(client, "allowed", opname, fname);
// Construct the name to be returned
//
i = (lfnType == isDir ? 1 : 0);
n = snprintf(path, sizeof(path), fnTmplt, fname);
if (n >= (int)sizeof(path)-1) {rc = ENAMETOOLONG; return 0;}
// Attach a trailing slash if there is none if this is a directory
//
if (lfnType == isDir && path[n-1] != '/') {path[n] = '/'; path[n+1] = 0;}
// Return the composite name
//
rc = 0;
return strdup(path);
}
XrdDigAuthEnt::aProc
@ aProc
Definition XrdDigAuth.hh:53

References XrdDigAuthEnt::aProc, XrdDig::Auth, isDir, and isFile.

## GetLocResp()

void XrdDigConfig::GetLocResp | ( | XrdOucErrInfo & | eInfo,
|  | bool | nameok )

Definition at line 290 of file XrdDigConfig.cc.

{
// Return desired value
//
if (nameok)
eInfo.setErrInfo(locRlenHP, locRespHP);
else if (eInfo.getUCap() & XrdOucEI::uIPv4)
eInfo.setErrInfo(locRlenV4, locRespV4);
else eInfo.setErrInfo(locRlenV6, locRespV6);
}
XrdOucErrInfo::setErrInfo
int setErrInfo(int code, const char *emsg)
Definition XrdOucErrInfo.hh:147
XrdOucErrInfo::getUCap
int getUCap()
Definition XrdOucErrInfo.hh:389
XrdOucEI::uIPv4
static const int uIPv4
ucap: Supports read redirects
Definition XrdOucErrInfo.hh:64

References XrdOucErrInfo::getUCap(), XrdOucErrInfo::setErrInfo(), and XrdOucEI::uIPv4.

Here is the call graph for this function:

## StatRoot()

void XrdDigConfig::StatRoot | ( | struct stat * | sP | ) |

static

Definition at line 306 of file XrdDigConfig.cc.

{
memcpy(sP, &rootStat, sizeof(struct stat));
}

References stat.

Referenced by XrdDigFS::stat().

Here is the caller graph for this function:

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

- XrdDigConfig.hh
- XrdDigConfig.cc