12 #ifndef ROOT_XrdProofdProtocol
13 #define ROOT_XrdProofdProtocol
35 #define XPROOFD_VERSBIN 0x000003EF
36 #define XPROOFD_VERSION "0.7"
40 #include "Xrd/XrdLink.hh"
41 #include "Xrd/XrdProtocol.hh"
42 #include "XrdOuc/XrdOucString.hh"
43 #include "XrdSec/XrdSecInterface.hh"
48 class XrdProofdClient;
49 class XrdProofdManager;
50 class XrdProofdResponse;
51 class XrdProofdProofServ;
54 class XrdProofdProtocol : XrdProtocol {
57 XrdProofdProtocol(XrdProtocol_Config *pi = 0);
58 virtual ~XrdProofdProtocol() {}
61 XrdProtocol *Match(XrdLink *lp);
62 int Process(XrdLink *lp);
63 void Recycle(XrdLink *lp,
int x,
const char *y);
64 int Stats(
char *buff,
int blen,
int do_sync);
66 static int Configure(
char *parms, XrdProtocol_Config *pi);
69 int GetData(
const char *dtype,
char *buff,
int blen);
70 static XrdBuffer *GetBuff(
int quantum, XrdBuffer *argp = 0);
71 static void ReleaseBuff(XrdBuffer *argp);
72 static int MaxBuffsz() {
return fgMaxBuffsz; }
75 inline kXR_int32 CID()
const {
return fCID; }
76 inline XrdProofdClient *Client()
const {
return fPClient; }
77 inline const char *GroupIn()
const {
return fGroupIn.c_str(); }
78 inline const char *UserIn()
const {
return fUserIn.c_str(); }
79 inline int ConnType()
const {
return fConnType; }
80 inline const char *TraceID()
const {
return fTraceID.c_str(); }
81 inline bool Internal() {
return (fConnType == kXPD_Internal) ? 1 : 0; }
82 inline bool IsCtrlC() { XrdSysMutexHelper mhp(fCtrlcMutex);
83 bool rc = fIsCtrlC; fIsCtrlC = 0;
return rc; }
84 inline int Pid()
const {
return fPid; }
85 inline void ResetCtrlC() { XrdSysMutexHelper mhp(fCtrlcMutex); fIsCtrlC = 0; }
86 inline char Status()
const {
return fStatus; }
87 inline short int ProofProtocol()
const {
return fProofProtocol; }
88 inline bool SuperUser()
const {
return fSuperUser; }
90 XrdProofdResponse *Response(kXR_unt16 rid);
91 inline XPClientRequest *Request()
const {
return (XPClientRequest *)&fRequest; }
92 inline XrdBuffer *Argp()
const {
return fArgp; }
93 inline XrdLink *Link()
const {
return fLink; }
94 inline XrdSecProtocol *AuthProt()
const {
return fAuthProt; }
97 inline void SetAdminPath(
const char *p) { XrdSysMutexHelper mhp(fMutex); fAdminPath = p; }
98 inline void SetAuthEntity(XrdSecEntity *se = 0) { fSecEntity.tident = fLink->ID;
99 fSecClient = (se) ? se : &fSecEntity; }
100 inline void SetAuthProt(XrdSecProtocol *p) { fAuthProt = p; }
101 inline void SetClient(XrdProofdClient *c) { fPClient = c; }
102 inline void SetClntCapVer(
unsigned char c) { fClntCapVer = c; }
103 inline void SetCID(kXR_int32 cid) { fCID = cid; }
104 inline void SetConnType(
int ct) { fConnType = ct; }
105 inline void SetGroupIn(
const char *gin) { fGroupIn = gin; }
106 inline void SetTraceID() {
if (fLink) XPDFORM(fTraceID,
"%s: ", fLink->ID); }
107 inline void SetPid(
int pid) { fPid = pid; }
108 inline void SetProofProtocol(
short int pp) { fProofProtocol = pp; }
109 inline void SetStatus(
char s) { fStatus = s; }
110 inline void SetSuperUser(
bool su = 1) { fSuperUser = su; }
111 inline void SetUserIn(
const char *uin) { fUserIn = uin; }
113 static XrdProofdManager *Mgr() {
return fgMgr; }
114 static int EUidAtStartup() {
return fgEUidAtStartup; }
118 XrdProofdResponse *GetNewResponse(kXR_unt16 rid);
123 int SendData(XrdProofdProofServ *xps, kXR_int32 sid = -1, XrdSrvBuffer **buf = 0,
bool sb = 0);
124 int SendDataN(XrdProofdProofServ *xps, XrdSrvBuffer **buf = 0,
bool sb = 0);
127 void TouchAdminPath();
141 unsigned char fClntCapVer;
142 short int fProofProtocol;
146 XrdOucString fUserIn;
147 XrdOucString fGroupIn;
148 XrdProofdClient *fPClient;
149 XrdOucString fAdminPath;
151 XrdOucString fTraceID;
153 XrdSecEntity *fSecClient;
154 XrdSecProtocol *fAuthProt;
155 XrdSecEntity fSecEntity;
161 XrdSysRecMutex fMutex;
162 XrdSysRecMutex fCtrlcMutex;
170 XPClientRequest fRequest;
171 std::vector<XrdProofdResponse *> fResponses;
176 static bool fgConfigDone;
178 static XpdObjectQ fgProtStack;
179 static XrdBuffManager *fgBPool;
180 static int fgMaxBuffsz;
181 static XrdSysRecMutex fgBMutex;
183 static XrdSysError fgEDest;
184 static XrdSysLogger *fgLogger;
186 static int fgEUidAtStartup;
190 static int fgReadWait;
191 static XrdProofdManager *fgMgr;
193 static void PostSession(
int on,
const char *u,
const char *g,
194 XrdProofdProofServ *xps);
197 #define XPD_SETRESP(p, x) \
199 memcpy((void *)&rid, (const void *)&(p->Request()->header.streamid[0]), 2); \
200 XrdProofdResponse *response = p->Response(rid); \
202 TRACEP(p, XERR, x << ": could not get Response instance for requid:"<< rid); \
206 #define XPD_SETRESPV(p, x) \
208 memcpy((void *)&rid, (const void *)&(p->Request()->header.streamid[0]), 2); \
209 XrdProofdResponse *response = p->Response(rid); \
211 TRACEP(p, XERR, x << ": could not get Response instance for requid:"<< rid); \
215 #define XPD_CLNT_VERSION_OK(p,v) (v < 0 || (p && p->ProofProtocol() >= v))