XRootD
XrdSsiFileResource.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d S s i F i l e R e s o u r c e . c c */
4 /* */
5 /* (c) 2017 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 <cstdlib>
31 
32 #include "XrdOuc/XrdOucEnv.hh"
33 
34 #include "XrdNet/XrdNetAddrInfo.hh"
35 #include "XrdSec/XrdSecEntity.hh"
37 
38 /******************************************************************************/
39 /* I n i t */
40 /******************************************************************************/
41 
42 void XrdSsiFileResource::Init(const char *path, XrdOucEnv &envX, bool aDNS)
43 {
44  const XrdSecEntity *entP = envX.secEnv();
45  const char *rVal;
46  int n;
47 
48 // Construct the security information
49 //
50  if (entP)
51  {strncpy(mySec.prot, entP->prot, XrdSsiPROTOIDSIZE);
52  mySec.name = entP->name;
53  mySec.host = (!aDNS ? entP->host : entP->addrInfo->Name(entP->host));
54  mySec.role = entP->vorg;
55  mySec.role = entP->role;
56  mySec.grps = entP->grps;
57  mySec.endorsements = entP->endorsements;
58  mySec.creds = entP->creds;
59  mySec.credslen = entP->credslen;
60  } else mySec.tident = "ssi";
61  client = &mySec;
62 
63 // Fill out the resource name and user
64 //
65  rName = path;
66  if ((rVal = envX.Get("ssi.user"))) rUser = rVal;
67  else rUser.clear();
68 
69 // Fill out the the optional cgi info
70 //
71  if (!(rVal = envX.Get("ssi.cgi"))) rInfo.clear();
72  else {rVal = envX.Env(n);
73  if (!(rVal = strstr(rVal, "ssi.cgi="))) rInfo.clear();
74  else rInfo = rVal+8;
75  }
76 }
#define XrdSsiPROTOIDSIZE
Definition: XrdSsiEntity.hh:41
const char * Name(const char *eName=0, const char **eText=0)
char * Get(const char *varname)
Definition: XrdOucEnv.hh:69
const XrdSecEntity * secEnv() const
Definition: XrdOucEnv.hh:107
char * Env(int &envlen)
Definition: XrdOucEnv.hh:48
char * vorg
Entity's virtual organization(s)
Definition: XrdSecEntity.hh:71
int credslen
Length of the 'creds' data.
Definition: XrdSecEntity.hh:78
XrdNetAddrInfo * addrInfo
Entity's connection details.
Definition: XrdSecEntity.hh:80
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5)
Definition: XrdSecEntity.hh:67
char * creds
Raw entity credentials or cert.
Definition: XrdSecEntity.hh:77
char * grps
Entity's group name(s)
Definition: XrdSecEntity.hh:73
char * name
Entity's name.
Definition: XrdSecEntity.hh:69
char * role
Entity's role(s)
Definition: XrdSecEntity.hh:72
char * endorsements
Protocol specific endorsements.
Definition: XrdSecEntity.hh:75
char * host
Entity's host name dnr dependent.
Definition: XrdSecEntity.hh:70
const char * creds
Raw client credentials or cert.
Definition: XrdSsiEntity.hh:53
const char * host
Entity's host name or address.
Definition: XrdSsiEntity.hh:48
const char * tident
Trace identifier always preset.
Definition: XrdSsiEntity.hh:56
const char * name
Entity's name.
Definition: XrdSsiEntity.hh:47
const char * role
Entity's role.
Definition: XrdSsiEntity.hh:50
char prot[XrdSsiPROTOIDSIZE]
Protocol used.
Definition: XrdSsiEntity.hh:46
int credslen
Length of the 'creds' field.
Definition: XrdSsiEntity.hh:54
const char * endorsements
Protocol specific endorsements.
Definition: XrdSsiEntity.hh:52
const char * grps
Entity's group names.
Definition: XrdSsiEntity.hh:51
void Init(const char *path, XrdOucEnv &envP, bool aDNS)
std::string rUser
-> Name of the resource user (nil if anonymous)
XrdSsiEntity * client
-> Pointer to client identification (server-side)
std::string rInfo
-> Additional information in CGI format
std::string rName
-> Name of the resource to be used