XRootD
Loading...
Searching...
No Matches
XrdAccAccess.cc File Reference
#include <cctype>
#include <cstdio>
#include <ctime>
#include <sys/param.h>
#include "XrdVersion.hh"
#include "XrdAcc/XrdAccAccess.hh"
#include "XrdAcc/XrdAccEntity.hh"
#include "XrdAcc/XrdAccCapability.hh"
#include "XrdAcc/XrdAccConfig.hh"
#include "XrdAcc/XrdAccGroups.hh"
#include "XrdNet/XrdNetAddrInfo.hh"
#include "XrdOuc/XrdOucUtils.hh"
#include "XrdSec/XrdSecEntityAttr.hh"
#include "XrdSys/XrdSysPlugin.hh"
+ Include dependency graph for XrdAccAccess.cc:

Go to the source code of this file.

Macros

#define XrdAccSWAP(x)
 

Functions

XrdAccAuthorizeXrdAccDefaultAuthorizeObject (XrdSysLogger *lp, const char *cfn, const char *parm, XrdVersionInfo &urVer)
 
unsigned long XrdOucHashVal2 (const char *KeyVal, int KeyLen)
 

Variables

XrdAccConfig XrdAccConfiguration
 

Macro Definition Documentation

◆ XrdAccSWAP

#define XrdAccSWAP (   x)
Value:
oldtab.x = Atab.x; Atab.x = newtab.x; \
newtab.x = oldtab.x; oldtab.x = 0;

Definition at line 351 of file XrdAccAccess.cc.

354{
355 struct XrdAccAccess_Tables oldtab;
356 bool hRefX = false, hRefY = false;
357
358// Determine if we need to resolve the host name early
359//
360 XrdAccAccess_ID *xlP = newtab.SXList;
361 while(xlP)
362 {if (xlP->host) {hRefX = true; break;}
363 xlP = xlP->next;
364 }
365
366// Determine if we need to resolve the hostname at all.
367//
368 if (!hRefX)
369 {if (newtab.D_List || newtab.H_Hash || newtab.N_Hash) hRefY = true;
370 else {XrdAccAccess_ID *ylP = newtab.SYList;
371 while (ylP)
372 {if (ylP->host) {hRefY = true; break;}
373 ylP = ylP->next;
374 }
375 }
376 }
377
378// Get an exclusive context to change the table pointers
379//
380 Access_Context.Lock(xs_Exclusive);
381
382// Save the old pointer while replacing it with the new pointer
383//
398 hostRefX = hRefX;
399 hostRefY = hRefY;
400
401// When we set new access tables, we should purge the group cache
402//
404
405// We can now let loose new table searchers
406//
407 Access_Context.UnLock(xs_Exclusive);
408}
409
410/******************************************************************************/
411/* T e s t */
412/******************************************************************************/
413
414int XrdAccAccess::Test(const XrdAccPrivs priv,const Access_Operation oper)
415{
416
417// Warning! This table must be in 1-to-1 correspondence with Access_Operation
418//
419 static XrdAccPrivs need[] = {XrdAccPriv_None, // 0
420 XrdAccPriv_Chmod, // 1
421 XrdAccPriv_Chown, // 2
425 XrdAccPriv_Lock, // 6
426 XrdAccPriv_Mkdir, // 7
427 XrdAccPriv_Read, // 8
429 XrdAccPriv_Rename, // 10
430 XrdAccPriv_Lookup, // 11
431 XrdAccPriv_Update, // 12
432 (XrdAccPrivs)0xffff, // 13
433 (XrdAccPrivs)0xffff // 14
434 };
435 // Note AOP_Excl* does not have a corresponding XrdAccPrivs; this is on
436 // purpose as the Excl* privilege is not modelled within the AuditDB framework.
437 if (oper < 0 || oper > AOP_LastOp) return 0;
438 return (int)(need[oper] & priv) == need[oper];
439}
440
441/******************************************************************************/
442/* X r d A c c A c c e s s _ I D : : A p p l i e s */
443/******************************************************************************/
444
446{
447
448// Check single value items in the most probable use order
449//
450 if (org && (!Entity.vorg || strcmp(org, Entity.vorg))) return false;
451 if (role && (!Entity.role || strcmp(role, Entity.role))) return false;
452 if (grp && (!Entity.grup || strcmp(grp, Entity.grup))) return false;
453 if (user && (!Entity.name || strcmp(user, Entity.name))) return false;
454
455// The check is more complicated as the host field may be a domain.
456//
457 if (host)
458 {const char *hName;
459 if (*host == '.')
460 {int eLen = strlen(Entity.host);
461 if (eLen <= hlen) return false;
462 hName = Entity.host + eLen - hlen;
463 } else hName = Entity.host;
464 if (strcmp(host, hName)) return false;
465 }
466
467// All done, this rules applies!
468//
469 return true;
470}
#define XrdAccSWAP(x)
XrdAccConfig XrdAccConfiguration
Access_Operation
The following are supported operations.
@ AOP_LastOp
XrdAccPrivs
@ XrdAccPriv_Mkdir
@ XrdAccPriv_Chown
@ XrdAccPriv_Insert
@ XrdAccPriv_Lookup
@ XrdAccPriv_Rename
@ XrdAccPriv_Update
@ XrdAccPriv_Read
@ XrdAccPriv_Lock
@ XrdAccPriv_None
@ XrdAccPriv_Delete
@ XrdAccPriv_Create
@ XrdAccPriv_Readdir
@ XrdAccPriv_Chmod
@ xs_Exclusive
int Test(const XrdAccPrivs priv, const Access_Operation oper)
XrdAccGroups GroupMaster
bool Applies(const XrdAccEntityInfo &Entity)
XrdAccAccess_ID * next
XrdOucHash< XrdAccCapability > * U_Hash
XrdOucHash< XrdAccCapability > * G_Hash
XrdAccCapName * E_List
XrdOucHash< XrdAccCapability > * N_Hash
XrdAccCapability * X_List
XrdAccAccess_ID * SXList
XrdAccCapability * Z_List
XrdOucHash< XrdAccCapability > * T_Hash
XrdOucHash< XrdAccCapability > * O_Hash
XrdAccCapName * D_List
XrdOucHash< XrdAccCapability > * H_Hash
XrdOucHash< XrdAccAccess_ID > * S_Hash
XrdOucHash< XrdAccCapability > * R_Hash
XrdAccAccess_ID * SYList
const char * vorg
const char * role
const char * name
const char * host
const char * grup

Function Documentation

◆ XrdAccDefaultAuthorizeObject()

XrdAccAuthorize * XrdAccDefaultAuthorizeObject ( XrdSysLogger lp,
const char *  cfn,
const char *  parm,
XrdVersionInfo &  urVer 
)

Definition at line 64 of file XrdAccAccess.cc.

68{
69 static XrdVERSIONINFODEF(myVer, XrdAcc, XrdVNUMBER, XrdVERSION);
70 static XrdSysError Eroute(lp, "acc_");
71
72// Verify version compatibility
73//
74 if (urVer.vNum != myVer.vNum && !XrdSysPlugin::VerCmp(urVer,myVer))
75 return 0;
76
77// Configure the authorization system
78//
79 if (XrdAccConfiguration.Configure(Eroute, cfn)) return (XrdAccAuthorize *)0;
80
81// Set error object pointer
82//
84
85// All is well, return the actual pointer to the object
86//
88}
static XrdVERSIONINFODEF(compiledVer, XrdHttpProtocolTest, XrdVNUMBER, XrdVERSION)
int Configure(XrdSysError &Eroute, const char *cfn)
XrdAccAccess * Authorization
static void setError(XrdSysError *errP)
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)

References XrdAccConfig::Authorization, XrdAccConfig::Configure(), XrdAccEntity::setError(), XrdSysPlugin::VerCmp(), XrdAccConfiguration, and XrdVERSIONINFODEF().

Referenced by main(), and XrdAccAuthorizeObject().

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

◆ XrdOucHashVal2()

unsigned long XrdOucHashVal2 ( const char *  KeyVal,
int  KeyLen 
)
extern

Definition at line 40 of file XrdOucHashVal.cc.

41{ int j;
42 unsigned long *lp, lword, hval = 0;
43 int hl = sizeof(hval);
44
45// If name is shorter than the hash length, use the name.
46//
47 if (KeyLen <= hl)
48 {memcpy(&hval, KeyVal, (size_t)KeyLen);
49 return hval;
50 }
51
52// Compute the length of the name and develop starting hash.
53//
54 hval = KeyLen;
55 j = KeyLen % hl; KeyLen /= hl;
56 if (j)
57 {memcpy(&lword, KeyVal, (size_t)hl);
58 hval ^= lword;
59 }
60 lp = (unsigned long *)&KeyVal[j];
61
62// Compute and return the full hash.
63//
64 while(KeyLen--)
65 {memcpy(&lword, lp++, (size_t)hl);
66 hval ^= lword;
67 }
68 return (hval ? hval : 1);
69}

Referenced by XrdAccCapability::XrdAccCapability(), XrdAccAccess::Access(), XrdAccCapability::Privs(), and XrdAccCapability::Privs().

+ Here is the caller graph for this function:

Variable Documentation

◆ XrdAccConfiguration

XrdAccConfig XrdAccConfiguration
extern