XRootD
Loading...
Searching...
No Matches
XrdPssUrlInfo Class Reference

#include <XrdPssUrlInfo.hh>

+ Collaboration diagram for XrdPssUrlInfo:

Public Member Functions

 XrdPssUrlInfo (XrdOucEnv *envP, const char *path, const char *xtra="", bool addusrcgi=true, bool addident=true)
 
 ~XrdPssUrlInfo ()
 
bool addCGI (const char *prot, char *buff, int blen)
 
bool Extend (const char *cgi, int cgiln)
 
const char * getID ()
 
bool hasCGI ()
 
void setID (const char *tid=0)
 
void setID (XrdOucSid *sP)
 
const char * thePath ()
 
const char * Tident ()
 

Static Public Member Functions

static void setMapID (bool onoff)
 

Detailed Description

Definition at line 37 of file XrdPssUrlInfo.hh.

Constructor & Destructor Documentation

◆ XrdPssUrlInfo()

XrdPssUrlInfo::XrdPssUrlInfo ( XrdOucEnv * envP,
const char * path,
const char * xtra = "",
bool addusrcgi = true,
bool addident = true )

Definition at line 109 of file XrdPssUrlInfo.cc.

111 : Path(path), CgiUsr(""), CgiUsz(0), CgiSsz(0), sidP(0),
112 eIDvalid(false)
113{
114 const char *amp1= "", *amp2 = "";
115
116// Preset for no id in the url
117//
118 *theID = 0;
119 tident = 0;
120
121// If there is an environment point, get user's cgi and set the tident from it
122//
123 if (envP)
124 {if (addusrcgi && !(CgiUsr = envP->Env(CgiUsz))) CgiUsr = "";
125 const XrdSecEntity *secP = envP->secEnv();
126 if (secP)
127 {entityID = secP->ueid;
128 eIDvalid = true;
129 tident = secP->tident;
130 }
131 }
132
133// Make sure we have a tident
134//
135 if (!tident) tident = "unk.0:0@host";
136
137// Generate additional cgi information as needed
138//
139 if (*xtra && *xtra != '&') amp2 = "&";
140 if (CgiUsz) amp1 = "&";
141
142 if (addident)
143 {CgiSsz = snprintf(CgiSfx, sizeof(CgiSfx),
144 "%spss.tid=%s%s%s", amp1, tident, amp2, xtra);
145 } else {
146 if (*xtra) CgiSsz = snprintf(CgiSfx, sizeof(CgiSfx), "%s%s", amp1, xtra);
147 else *CgiSfx = 0;
148 }
149}
char * Env(int &envlen)
Definition XrdOucEnv.hh:48
const XrdSecEntity * secEnv() const
Definition XrdOucEnv.hh:107
const char * tident
Trace identifier always preset.
unsigned int ueid
Unique ID of entity instance.
XrdOucEnv * envP
Definition XrdPss.cc:109

References XrdOucEnv::Env(), XrdOucEnv::secEnv(), XrdSecEntity::tident, and XrdSecEntity::ueid.

+ Here is the call graph for this function:

◆ ~XrdPssUrlInfo()

XrdPssUrlInfo::~XrdPssUrlInfo ( )
inline

Definition at line 66 of file XrdPssUrlInfo.hh.

66{if (*theID == 'p' && sidP) sidP->Release(&idVal);}
bool Release(theSid *sidP)
Definition XrdOucSid.cc:115

References XrdOucSid::Release().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCGI()

bool XrdPssUrlInfo::addCGI ( const char * prot,
char * buff,
int blen )

Definition at line 155 of file XrdPssUrlInfo.cc.

156{
157 bool forXrd = XrdPssUtils::is4Xrootd(prot);
158
159// Short circuit all of this if there is no cgi
160//
161 if (!CgiUsz && (!CgiSsz || forXrd))
162 {*buff = 0;
163 return true;
164 }
165
166// Make sure that we can fit whatever CGI we have into the buffer. Include the
167// implicit question mark and ending null byte.
168//
169 int n = CgiUsz + (forXrd ? CgiSsz : 0) + 1;
170 if (n >= blen) return false;
171 *buff++ = '?'; blen--;
172
173// If the protocol is headed to an xroot server then we need to remove any
174// offending CGI elements from the user CGI. Otherwise, we can use the CGI
175// that was specified by the client.
176//
177 if (CgiUsz)
178 {if (forXrd) n = copyCGI(CgiUsr, buff, blen);
179 else {n = CgiUsz;
180 strcpy(buff, CgiUsr);
181 }
182 buff += n; blen -= n;
183 }
184
185// If this is destined to an xroot server, add any extended CGI.
186//
187 if (forXrd && CgiSsz)
188 {if (CgiSsz >= blen) return false;
189 strcpy(buff, CgiSfx);
190 } else *buff = 0;
191
192// All done
193//
194//std::cerr <<"Final URL: '" <<prot <<"' " <<strlen(prot) <<'\n' <<std::flush;
195 return true;
196}
static bool is4Xrootd(const char *pname)

References XrdPssUtils::is4Xrootd().

Referenced by XrdPssSys::P2OUT(), and XrdPssSys::P2URL().

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

◆ Extend()

bool XrdPssUrlInfo::Extend ( const char * cgi,
int cgiln )

Definition at line 202 of file XrdPssUrlInfo.cc.

203{
204 const char *amp = (*cgi == '&' ? "" : "&");
205 int blen = sizeof(CgiSfx) - CgiSsz;
206
207 if (blen <= cgiln) return false;
208 int n = snprintf(&CgiSfx[CgiSsz], blen, "%s%s", amp, cgi);
209 if (n >= blen) return false;
210 CgiSsz += n;
211 return true;
212}

◆ getID()

const char * XrdPssUrlInfo::getID ( )
inline

Definition at line 45 of file XrdPssUrlInfo.hh.

45{return theID;}

Referenced by XrdPssSys::P2OUT(), and XrdPssSys::P2URL().

+ Here is the caller graph for this function:

◆ hasCGI()

bool XrdPssUrlInfo::hasCGI ( )
inline

Definition at line 47 of file XrdPssUrlInfo.hh.

47{return CgiSsz || CgiUsz;}

Referenced by XrdPssSys::P2URL().

+ Here is the caller graph for this function:

◆ setID() [1/2]

void XrdPssUrlInfo::setID ( const char * tid = 0)

Definition at line 218 of file XrdPssUrlInfo.cc.

219{
220 const char *atP, *colon;
221
222// If we are mapping id then use the entity's idenification
223//
224 if (MapID && eIDvalid)
225 {const char *fmt = (entityID & 0xf0000000 ? "%x@" : "U%x@");
226 snprintf(theID, sizeof(theID), fmt, entityID); // 8+1+nul = 10 bytes
227 return;
228 }
229
230// Use the connection file descriptor number as the id lgnid.pid:fd@host
231//
232 if (tid == 0) tid = tident;
233 if ((colon = index(tid, ':')) && (atP = index(colon+1, '@')))
234 {int n = atP - colon;
235 if (n <= (int)sizeof(theID))
236 {*theID = 'u';
237 strncpy(theID+1, colon+1, n); // Include '@'
238 theID[n+1] = 0;
239 } else *theID = 0;
240 } else *theID = 0;
241}

Referenced by XrdPssCks::Get(), XrdPssFile::Open(), XrdPssDir::Opendir(), and XrdPssSys::Stat().

+ Here is the caller graph for this function:

◆ setID() [2/2]

void XrdPssUrlInfo::setID ( XrdOucSid * sP)
inline

Definition at line 51 of file XrdPssUrlInfo.hh.

52 {if (sP != 0 && !(sP->Obtain(&idVal))) return;
53 sidP = sP;
54 snprintf(theID, sizeof(theID), "p%d@", idVal.sidS);
55 }
bool Obtain(theSid *sidP)
Definition XrdOucSid.cc:70

References XrdOucSid::Obtain(), and XrdOucSid::theSid::sidS.

+ Here is the call graph for this function:

◆ setMapID()

static void XrdPssUrlInfo::setMapID ( bool onoff)
inlinestatic

Definition at line 57 of file XrdPssUrlInfo.hh.

57{MapID = onoff;}

Referenced by XrdPssSys::ConfigMapID().

+ Here is the caller graph for this function:

◆ thePath()

const char * XrdPssUrlInfo::thePath ( )
inline

Definition at line 59 of file XrdPssUrlInfo.hh.

59{return Path;}

Referenced by XrdPssSys::P2OUT(), and XrdPssSys::P2URL().

+ Here is the caller graph for this function:

◆ Tident()

const char * XrdPssUrlInfo::Tident ( )
inline

Definition at line 61 of file XrdPssUrlInfo.hh.

61{return tident;}

Referenced by XrdPssCks::Get(), XrdPssSys::Mkdir(), XrdPssFile::Open(), XrdPssDir::Opendir(), XrdPssSys::Remdir(), XrdPssSys::Rename(), XrdPssSys::Stat(), XrdPssSys::Truncate(), and XrdPssSys::Unlink().

+ Here is the caller graph for this function:

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