xrootd
XrdOfsTPC.hh
Go to the documentation of this file.
1 #ifndef __XRDOFSTPC_HH__
2 #define __XRDOFSTPC_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d O f s T P C . h h */
6 /* */
7 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <stdlib.h>
34 #include <string.h>
35 
36 #include "XrdOfs/XrdOfsTPCInfo.hh"
37 
38 class XrdAccAuthorize;
39 class XrdOfsTPCAllow;
40 class XrdOfsTPCJob;
41 class XrdOss;
42 class XrdOucEnv;
43 class XrdOucErrInfo;
44 class XrdOucPListAnchor;
45 class XrdOucTList;
46 class XrdSecEntity;
47 
48 class XrdOfsTPC
49 {
50 public:
51 
52 struct Facts
53  {const char *Key;
54  const char *Lfn;
55  const char *Pfn;
56  const char *Org;
57  const char *Dst;
58  const XrdSecEntity *Usr;
61 
62  Facts(const XrdSecEntity *vEnt, XrdOucErrInfo *vInf, XrdOucEnv *vEnv,
63  const char *vKey, const char *vLfn, const char *vPfn=0)
64  : Key(vKey), Lfn(vLfn), Pfn(vPfn), Org(0), Dst(0),
65  Usr(vEnt), eRR(vInf), Env(vEnv) {}
66  };
67 
68 static void Allow(char *vDN, char *vGN, char *vHN, char *vVO);
69 
70 static int Authorize(XrdOfsTPC **theTPC,
71  Facts &Args,
72  int isPLE=0);
73 
74 virtual void Del() {}
75 
76 struct iParm {char *Pgm;
77  char *Ckst;
78  int Dflttl;
79  int Maxttl;
80  int Logok;
81  int Strm;
82  int Xmax;
83  iParm() : Pgm(0), Ckst(0), Dflttl(-1), Maxttl(-1),
84  Logok(-1), Strm(-1), Xmax(-1) {}
85  };
86 
87 static void Init(iParm &Parms);
88 
89 static void Init(XrdAccAuthorize *accP) {fsAuth = accP;}
90 
91 static void Init(XrdOss *ossP) {OfsOss = ossP;}
92 
93 static const int reqALL = 0;
94 static const int reqDST = 1;
95 static const int reqORG = 2;
96 
97 static void Require(const char *Auth, int RType);
98 
99 static int Restrict(const char *Path);
100 
101 static int Start();
102 
103 virtual int Sync(XrdOucErrInfo *error) {return 0;}
104 
105 static int Validate (XrdOfsTPC **theTPC, Facts &Args);
106 
107  XrdOfsTPC() : Refs(1), inQ(0) {}
108 
109  XrdOfsTPC(const char *Url, const char *Org,
110  const char *Lfn, const char *Pfn, const char *Cks=0)
111  : Info(Url, Org, Lfn, Pfn, Cks), Refs(1), inQ(0) {}
112 
113 virtual ~XrdOfsTPC() {}
114 
116 
117 static char *cksType;
118 
119 protected:
120 
121 static int Fatal(Facts &Args, const char *eMsg, int eCode, int nomsg=0);
122 static int genOrg(const XrdSecEntity *client, char *Buff, int Blen);
123 static int getTTL(XrdOucEnv *Env);
124 static int Screen(Facts &Args, XrdOucTList *tP, int wasEnc=0);
125 static char *Verify(const char *Who,const char *Name,char *Buf,int Blen);
126 static const char *Yield(const char *Name,char *Buf,int Blen);
127 
129 static XrdOss *OfsOss;
130 
131 static char *XfrProg;
132 
135 
138 
139 static int dflTTL;
140 static int maxTTL;
141 static int LogOK;
142 static int nStrms;
143 static int xfrMax;
144 static int tpcOK;
145 static int encTPC;
146 
147  char Refs; // Reference count
148  char inQ; // Object in queue
149 };
150 #endif