#include <XrdCmsBlackList.hh>
Definition at line 41 of file XrdCmsBlackList.hh.
◆ XrdCmsBlackList()
XrdCmsBlackList::XrdCmsBlackList |
( |
| ) |
|
|
inline |
Constructor and Destructor.
Definition at line 91 of file XrdCmsBlackList.hh.
91 :
XrdJob(
"Black List Check") {}
XrdJob(const char *desc="")
◆ ~XrdCmsBlackList()
XrdCmsBlackList::~XrdCmsBlackList |
( |
| ) |
|
|
inline |
◆ DoIt()
void XrdCmsBlackList::DoIt |
( |
| ) |
|
|
virtual |
Time driven method for checking black list file.
Implements XrdJob.
Definition at line 295 of file XrdCmsBlackList.cc.
298 XrdOucTList **blOldRedr = 0, **blNewRedr = 0, *blNewReal = 0, *tP = 0, *nP;
299 int rc, blOldRcnt = 0, blNewRcnt;
300 bool doUpdt =
false, doPrt =
false;
307 if (GetBL(blNewReal, blNewRedr, blNewRcnt))
322 {
if (doPrt)
Say.
Say(
"Config ", tP->text,
" removed from blacklist.");
323 nP = tP->next;
delete tP; tP = nP;
329 {
for (
int i = 0; i < blOldRcnt; i++)
delete blOldRedr[i];
int stat(const char *path, struct stat *buf)
virtual void BlackList(XrdOucTList *blP)
void Ring()
This method gets called at midnight.
void Schedule(XrdJob *jp)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
XrdCmsBlackList BlackList
XrdCmsCluster * blCluster
References XrdCms::BlackList, XrdCmsCluster::BlackList(), XrdCms::blChk, XrdCms::blCluster, XrdCms::blFN, XrdCms::blMN, XrdCms::blMutex, XrdCms::blRcnt, XrdCms::blReal, XrdCms::blRedr, XrdCms::blSched, XrdCms::blTime, XrdCms::isWList, XrdSysMutex::Lock(), XrdCms::MidNightTask::Ring(), XrdCms::Say, XrdSysError::Say(), XrdScheduler::Schedule(), Stat, stat(), and XrdSysMutex::UnLock().
◆ Init()
Initialize the black list
- Parameters
-
sP | Pointer to the scheduler object. |
cP | Pointer to the cluster object. |
blfn | The path to the black list file or null. |
chkt | Seconds between checks for blacklist changes. If the value is negative, the blacklist is treated as a whitelist. |
Definition at line 467 of file XrdCmsBlackList.cc.
480 if (chkt < 0) {
isWList =
true; chkt = -chkt;}
484 if (blfn)
blFN = strdup(blfn);
485 else if (!(cfn = getenv(
"XRDCONFIGFN")))
return;
486 else {
char pBuff[2048], *Slash;
488 if (!(Slash = rindex(pBuff,
'/')))
return;
489 strcpy(Slash+1, (
isWList ?
"cms.whitelist" :
"cms.blacklist"));
490 blFN = strdup(pBuff);
XrdSysLogger * logger(XrdSysLogger *lp=0)
void AtMidnight(Task *mnTask)
References XrdSysLogger::AtMidnight(), XrdCms::BlackList, XrdCms::blChk, XrdCms::blCluster, XrdCms::blFN, XrdCms::blMN, XrdCms::blRcnt, XrdCms::blReal, XrdCms::blRedr, XrdCms::blSched, XrdCms::blTime, XrdCms::isWList, XrdSysError::logger(), XrdCms::MidNightTask::Ring(), XrdCms::Say, XrdScheduler::Schedule(), Stat, and stat().
◆ Present()
int XrdCmsBlackList::Present |
( |
const char * |
hName, |
|
|
XrdOucTList * |
bList = 0 , |
|
|
char * |
rbuff = 0 , |
|
|
int |
rblen = 0 |
|
) |
| |
|
static |
Check if host is in the black list and how it should be managed.
- Parameters
-
hName | Pointer to the host name or address. |
bList | Optional pointer to a private black list. |
rbuff | Pointer to the buffer to contain the redirect response. If nil, the host is not redirected. |
rblen | The size of rbuff. If zero or insufficiently large the host is not redirected. |
- Returns
- < -1 Host is in the black list and would be redirected; but either rbuff was nil or the buffer was too small. The abs(returned value) is the size the buffer should have been.
-
= -1 Host is in the black list and should not be redirected.
-
= 0 Host not in the black list.
-
> 0 Host is in the black list and should be redirected. The return value is the size of the redirect response placed in the supplied buffer.
Definition at line 515 of file XrdCmsBlackList.cc.
524 if (!hName || !
blSched)
return 0;
528 if (bList) doUnLk =
false;
543 hLen = strlen(hName);
545 {Hdr.
info = bList->dval;
547 {
if (!strcmp(hName, bList->
text))
break;}
548 else if (hLen >= Hdr.
v.totLen)
550 || !strncmp(bList->
text, hName, Hdr.
v.pfxLen))
552 || !strncmp(bList->
text+Hdr.
v.pfxLen+1,
553 hName + (hLen - Hdr.
v.sfxLen),
554 Hdr.
v.sfxLen))
break;
566 {retval = rP->sval[1];
567 if (!rBuff || retval > rBLen) retval = -retval;
568 else {memcpy(rBuff, &(rP->sval[2]),
sizeof(
short));
569 memcpy(rBuff+
sizeof(
short), rP->
text, rP->sval[0]);
573 }
else retval = (
isWList ? -1 : 0);
References XrdCms::blMutex, XrdCms::blReal, XrdCms::blRedr, XrdCms::blSched, BL_Info::exact, BL_Info::info, XrdCms::isWList, XrdSysMutex::Lock(), XrdOucTList::next, BL_Info::redir, BL_Info::rmask, XrdOucTList::text, XrdSysMutex::UnLock(), and BL_Info::v.
Referenced by XrdCmsLogin::Admit(), and XrdCmsCluster::BlackList().
The documentation for this class was generated from the following files: