XRootD
Loading...
Searching...
No Matches
XrdSecEntity.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d S e c E n t i t y . h h */
4/* */
5/* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* Produced by Andrew Hanushevsky for Stanford University under contract */
7/* DE-AC02-76-SFO0515 with the Department of Energy */
8/* */
9/* This file is part of the XRootD software suite. */
10/* */
11/* XRootD is free software: you can redistribute it and/or modify it under */
12/* the terms of the GNU Lesser General Public License as published by the */
13/* Free Software Foundation, either version 3 of the License, or (at your */
14/* option) any later version. */
15/* */
16/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19/* License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24/* */
25/* The copyright holder's institutional names and contributor's names may not */
26/* be used to endorse or promote products derived from this software without */
27/* specific prior written permission of the institution or contributor. */
28/******************************************************************************/
29
30#include <cstring>
31
34#include "XrdSys/XrdSysError.hh"
35
36/******************************************************************************/
37/* C o n s t r u c t o r */
38/******************************************************************************/
39
41{
42 Init(spName);
43}
44
45/******************************************************************************/
46/* D e s t r u c t o r */
47/******************************************************************************/
48
50{
51 delete eaAPI->entXtra;
52}
53
54/******************************************************************************/
55/* D i s p l a y */
56/******************************************************************************/
57
59{
60 class AttrCB : public XrdSecEntityAttrCB
61 {public:
62 XrdSecEntityAttrCB::Action Attr(const char *key, const char *val)
63 {mDest.Say(Tid, " Attr ",key," = '", val, "'");
65 }
66 AttrCB(XrdSysError &erp, const char *tid) : mDest(erp), Tid(tid) {}
67 ~AttrCB() {}
68
69 XrdSysError &mDest;
70 const char *Tid;
71 } displayAttr(mDest, tident);
72
73 char theprot[XrdSecPROTOIDSIZE+1];
74
75// Avoid vulgarities of old gcc compilers that didn't implemented full C++11
76//
77 typedef long long int LLint;
78 typedef long long unsigned int ULint;
79
80// Make sure the protocol is poperly set
81//
82 memcpy(theprot, prot, XrdSecPROTOIDSIZE);
83 theprot[XrdSecPROTOIDSIZE] = 0;
84
85// Display this object
86//
87 mDest.Say(tident, " Protocol '", theprot, "'");
88 mDest.Say(tident, " Name '", (name ? name : ""), "'");
89 mDest.Say(tident, " Host '", (host ? host : ""), "'");
90 mDest.Say(tident, " Vorg '", (vorg ? vorg : ""), "'");
91 mDest.Say(tident, " Role '", (role ? role : ""), "'");
92 mDest.Say(tident, " Grps '", (grps ? grps : ""), "'");
93 mDest.Say(tident, " Caps '", (caps ? caps : ""), "'");
94 mDest.Say(tident, " Pidn '", (pident ? pident : ""), "'");
95
96 mDest.Say(tident, " Crlen ", std::to_string((LLint)credslen).c_str());
97 mDest.Say(tident, " ueid ", std::to_string((ULint)ueid).c_str());
98 mDest.Say(tident, " uid ", std::to_string((ULint)uid).c_str());
99 mDest.Say(tident, " gid ", std::to_string((ULint)gid).c_str());
100
101// Display it's attributes, if any
102//
103 eaAPI->List(displayAttr);
104}
105
106/******************************************************************************/
107/* I n i t */
108/******************************************************************************/
109
110void XrdSecEntity::Init(const char *spV)
111{
112 memset( prot, 0, sizeof(prot) );
113 memset( prox, 0, sizeof(prox) );
114 if (spV) strncpy(prot, spV, sizeof(prot)-1);
115
116 name = 0;
117 host = 0;
118 vorg = 0;
119 role = 0;
120 grps = 0;
121 caps = 0;
122 endorsements = 0;
123 moninfo = 0;
124 creds = 0;
125 credslen = 0;
126 ueid = 0;
127 addrInfo = 0;
128 tident = 0;
129 pident = 0;
130 sessvar = 0;
131 uid = 0;
132 gid = 0;
133 secMon = 0;
134 memset(future, 0, sizeof(future));
135}
136
137/******************************************************************************/
138/* R e s e t */
139/******************************************************************************/
140
141void XrdSecEntity::Reset(const char *spV)
142{
143 Init(spV);
144 eaAPI->entXtra->Reset();
145}
#define tident
#define XrdSecPROTOIDSIZE
@ Next
Proceed to the next key-value pair.
char * vorg
Entity's virtual organization(s)
const char * pident
Trace identifier (originator)
int credslen
Length of the 'creds' data.
char prox[XrdSecPROTOIDSIZE]
Auth extractor used (e.g. xrdvoms)
XrdNetAddrInfo * addrInfo
Entity's connection details.
XrdSecEntityAttr * eaAPI
non-const API to attributes
const char * tident
Trace identifier always preset.
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5)
char * caps
Entity's capabilities.
char * creds
Raw entity credentials or cert.
XrdSecMonitor * secMon
If !0 security monitoring enabled.
gid_t gid
Unix gid or 0 if none.
char * grps
Entity's group name(s)
void Reset(const char *spV=0)
XrdSecEntity(const char *spName=0)
uid_t uid
Unix uid or 0 if none.
void * future[2]
Reserved for future expansion.
char * name
Entity's name.
unsigned int ueid
Unique ID of entity instance.
char * role
Entity's role(s)
char * endorsements
Protocol specific endorsements.
void Display(XrdSysError &mDest)
char * moninfo
Information for monitoring.
char * host
Entity's host name dnr dependent.
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)