Skip to content

Commit

Permalink
[All] Realign request codes for new functionality and remove the old …
Browse files Browse the repository at this point in the history
…stuff.
  • Loading branch information
abh3 committed Oct 18, 2019
1 parent c9622fd commit 96c04cc
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 107 deletions.
11 changes: 5 additions & 6 deletions src/XProtocol/XProtocol.cc
Expand Up @@ -101,14 +101,13 @@ const char *errNames[kXR_ERRFENCE-kXR_ArgInvalid] =

const char *reqNames[kXR_REQFENCE-kXR_auth] =
{"auth", "query", "chmod", "close",
"dirlist", "getfile", "protocol", "login",
"dirlist", "gpfile", "protocol", "login",
"mkdir", "mv", "open", "ping",
"putfile", "read", "rm", "rmdir",
"chkpoint", "read", "rm", "rmdir",
"sync", "stat", "set", "write",
"admin", "prepare", "statx", "endsess",
"bind", "readv", "verifyw", "locate",
"truncate", "sigver", "decrypt", "writev",
"fattr"
"fattr", "prepare", "statx", "endsess",
"bind", "readv", "pgwrite", "locate",
"truncate", "sigver", "pgread", "writev"
};

// Following value is used to determine if the error or request code is
Expand Down
33 changes: 14 additions & 19 deletions src/XProtocol/XProtocol.hh
Expand Up @@ -122,39 +122,38 @@ enum XReqErrorType {
//______________________________________________
//
enum XRequestTypes {
kXR_auth = 3000,
kXR_auth = 3000,
kXR_query, // 3001
kXR_chmod, // 3002
kXR_close, // 3003
kXR_dirlist, // 3004
kXR_getfile, // 3005
kXR_gpfile, // 3005 was kXR_getfile
kXR_protocol,// 3006
kXR_login, // 3007
kXR_mkdir, // 3008
kXR_mv, // 3009
kXR_open, // 3010
kXR_ping, // 3011
kXR_putfile, // 3012
kXR_chkpoint,// 3012 was kXR_putfile
kXR_read, // 3013
kXR_rm, // 3014
kXR_rmdir, // 3015
kXR_sync, // 3016
kXR_stat, // 3017
kXR_set, // 3018
kXR_write, // 3019
kXR_admin, // 3020
kXR_fattr, // 3020 was kXR_admin
kXR_prepare, // 3021
kXR_statx, // 3022
kXR_endsess, // 3023
kXR_bind, // 3024
kXR_readv, // 3025
kXR_verifyw, // 3026
kXR_pgwrite, // 3026 was kXR_verifyw
kXR_locate, // 3027
kXR_truncate,// 3028
kXR_sigver, // 3029
kXR_decrypt, // 3030
kXR_pgread, // 3030 was kXR_decrypt
kXR_writev, // 3031
kXR_fattr, // 3032
kXR_REQFENCE // Always last valid request code +1
};

Expand Down Expand Up @@ -202,7 +201,8 @@ enum XLoginVersion {
kXR_ver001 = 1, // Generally implemented 2005 protocol
kXR_ver002 = 2, // Same as 1 but adds asyncresp recognition
kXR_ver003 = 3, // The 2011-2012 rewritten client
kXR_ver004 = 4 // The 2016 sign-capable client
kXR_ver004 = 4, // The 2016 sign-capable client
kXR_ver005 = 5 // The 2019 TLS-capable client
};

enum XStatRequestOption {
Expand Down Expand Up @@ -265,11 +265,6 @@ enum XVerifyType {
kXR_crc32 = 1
};

enum XLogonType {
kXR_useruser = 0,
kXR_useradmin = 1
};

enum XPrepRequestOption {
kXR_cancel = 1,
kXR_notify = 2,
Expand All @@ -283,14 +278,13 @@ enum XPrepRequestOption {
kXR_evict = 0x0001 // optionsX: file no longer useful
};

// Version used for kXR_decrypt and kXR_sigver and is set in
// Set in SigverRequest::version, DecryptRequest::version and
// Version used for kXR_sigver and is set in SigverRequest::version,
// ServerResponseReqs_Protocol::secver
#define kXR_secver_0 0

// Flags for kXR_decrypt and kXR_sigver
// Flags for kXR_sigver
enum XSecFlags {
kXR_nodata = 1 // Request payload was not hashed or encrypted
kXR_nodata = 1 // Request payload was not hashed
};

// Cryptography used for kXR_sigver SigverRequest::crypto
Expand Down Expand Up @@ -347,7 +341,8 @@ enum XActionCode {
kXR_asyncav, // 5005
kXR_asynunav, // 5006
kXR_asyncgo, // 5007
kXR_asynresp // 5008
kXR_asynresp, // 5008
kXR_asyninfo // 5009
};

//_______________________________________________
Expand Down Expand Up @@ -523,7 +518,7 @@ struct ClientLoginRequest {
kXR_char reserved;
kXR_char ability; // See XLoginAbility enum flags
kXR_char capver[1]; // See XLoginCapVer enum flags
kXR_char role[1];
kXR_char reserved2;
kXR_int32 dlen;
};
struct ClientMkdirRequest {
Expand Down
1 change: 0 additions & 1 deletion src/XrdCl/XrdClXRootDTransport.cc
Expand Up @@ -1690,7 +1690,6 @@ namespace XrdCl
loginReq->requestid = kXR_login;
loginReq->pid = ::getpid();
loginReq->capver[0] = kXR_asyncap | kXR_ver004;
loginReq->role[0] = kXR_useruser;
loginReq->dlen = cgiLen;
loginReq->ability = kXR_fullurl | kXR_readrdok | kXR_lclfile;

Expand Down
2 changes: 1 addition & 1 deletion src/XrdCms/XrdCmsAdmin.cc
Expand Up @@ -567,7 +567,7 @@ int XrdCmsAdmin::Con2Ads(const char *pname)
(kXR_unt16)htons(kXR_login),
(kXR_int32)htonl(getpid()),
{'c', 'm', 's', 'd', 0, 0, 0, 0},
0, 0, {0}, {0}, 0};
0, 0, {0}, 0, 0};
struct {kXR_int32 siHS[4];} hsRsp;
XrdNetSocket adsSocket;
int ecode, snum;
Expand Down
8 changes: 4 additions & 4 deletions src/XrdOuc/XrdOucBackTrace.cc
Expand Up @@ -89,28 +89,28 @@ XrdInfo *CvtReq(const char *name, int rnum)
{"chmod", kXR_chmod, 1<< 2},
{"close", kXR_close, 1<< 3},
{"dirlist", kXR_dirlist, 1<< 4},
{"getfile", kXR_getfile, 1<< 5},
{"gpfile", kXR_gpfile, 1<< 5},
{"protocol", kXR_protocol,1<< 6},
{"login", kXR_login, 1<< 7},
{"mkdir", kXR_mkdir, 1<< 8},
{"mv", kXR_mv, 1<< 9},
{"open", kXR_open, 1<<10},
{"ping", kXR_ping, 1<<11},
{"putfile", kXR_putfile, 1<<12},
{"chkpoint", kXR_chkpoint,1<<12},
{"read", kXR_read, 1<<13},
{"rm", kXR_rm, 1<<14},
{"rmdir", kXR_rmdir, 1<<15},
{"sync", kXR_sync, 1<<16},
{"stat", kXR_stat, 1<<17},
{"set", kXR_set, 1<<18},
{"write", kXR_write, 1<<19},
{"admin", kXR_admin, 1<<20},
{"fattr", kXR_fattr, 1<<20},
{"prepare", kXR_prepare, 1<<21},
{"statx", kXR_statx, 1<<22},
{"endess", kXR_endsess, 1<<23},
{"bind", kXR_bind, 1<<24},
{"readv", kXR_readv, 1<<25},
{"verifyw", kXR_verifyw, 1<<26},
{"pgwrite", kXR_pgwrite, 1<<26},
{"locate", kXR_locate, 1<<27},
{"truncate", kXR_truncate,1<<28}
};
Expand Down
11 changes: 5 additions & 6 deletions src/XrdSec/XrdSecProtect.cc
Expand Up @@ -106,25 +106,25 @@ namespace

XrdSecVec secTable(0,
// Compatible Standard Intense Pedantic
kXR_admin, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_auth, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore,
kXR_bind, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
kXR_chmod, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_chkpoint, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_close, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
kXR_decrypt, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore,
kXR_dirlist, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_endsess, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
kXR_fattr, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_getfile, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_gpfile, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_locate, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_login, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore,
kXR_mkdir, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_mv, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_open, kXR_signLikely, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_pgread, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
kXR_pgwrite, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
kXR_ping, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore,
kXR_prepare, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_protocol, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore,
kXR_putfile, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_query, kXR_signIgnore, kXR_signIgnore, kXR_signLikely, kXR_signNeeded,
kXR_read, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_readv, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
Expand All @@ -136,7 +136,6 @@ kXR_stat, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_statx, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_sync, kXR_signIgnore, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded,
kXR_truncate, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded, kXR_signNeeded,
kXR_verifyw, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
kXR_write, kXR_signIgnore, kXR_signIgnore, kXR_signNeeded, kXR_signNeeded,
0);
}
Expand Down Expand Up @@ -260,7 +259,7 @@ int XrdSecProtect::Secure(SecurityRequest *&newreq,
{kXR_unt16 reqid = htons(thereq.header.requestid);
paysize = ntohl(thereq.header.dlen);
if (!payload) payload = ((char *)&thereq) + sizeof(ClientRequest);
if (reqid == kXR_write || reqid == kXR_verifyw) n = (secVerData ? 3 : 2);
if (reqid == kXR_write || reqid == kXR_pgwrite) n = (secVerData ? 3 : 2);
else n = 3;
} else n = 2;

Expand Down
12 changes: 5 additions & 7 deletions src/XrdSec/XrdSecProtect.hh
Expand Up @@ -87,9 +87,8 @@ virtual void Delete() {delete this;}
//! Modify the above to your particuar needs but gaurd the call!
//!
//! @param newreq A reference to a pointer where the new request, if needed,
//! will be placed. The new request will consist of a either a
//! kXR_sigver or kXR_decrypt request followed by hash if the
//! request is kXR_sigver. The request buffer must be freed
//! will be placed. The new request will consist of a kXR_sigver
//! request followed by hash. The request buffer must be freed
//! using free() when it is no longer needed.
//! @param thereq Reference to the client request header/body that needs to
//! be secured. The request must be in network byte order.
Expand All @@ -110,10 +109,9 @@ virtual int Secure(SecurityRequest *&newreq,
//------------------------------------------------------------------------------
//! Verify that a request was properly secured.
//!
//! @param secreq A reference to the security request (kxr_sigver or
//! kXR_decrypt) followed by whatever data was sent (normally
//! an encrypted verification hash for kXR_sigver). All but
//! the request code must be in network byte order.
//! @param secreq A reference to the kXR_sigver request followed by whatever
//! data was sent (normally an encrypted verification hash).
//! All but the request code must be in network byte order.
//! @param thereq Reference to the client request header/body that needs to
//! be verified. The request must be in network byte order.
//! @aparam thedata The request data whose length resides in theReq.dlen.
Expand Down
2 changes: 1 addition & 1 deletion src/XrdXrootd/XrdXrootdAdmin.cc
Expand Up @@ -383,7 +383,7 @@ int XrdXrootdAdmin::do_Lsd()
if ((xp = lp->getProtocol())
&& (pp = dynamic_cast<XrdXrootdProtocol *>(xp)))
{cver = int(pp->CapVer);
ctyp = (pp->Status & XRD_ADMINUSER ? 'a' : 'u');
ctyp = 'u';
conn = static_cast<long long>(lp->timeCon());
mm = monit;
if (pp->Monitor.Files()) *mm++ = 'f';
Expand Down
7 changes: 2 additions & 5 deletions src/XrdXrootd/XrdXrootdProtocol.cc
Expand Up @@ -490,8 +490,7 @@ int XrdXrootdProtocol::Process2()
//
switch(Request.header.requestid)
{case kXR_open: return do_Open();
case kXR_getfile: return do_Getfile();
case kXR_putfile: return do_Putfile();
case kXR_gpfile: return do_gpFile();
default: break;
}

Expand All @@ -502,9 +501,7 @@ int XrdXrootdProtocol::Process2()
// Now process whatever we have
//
switch(Request.header.requestid)
{case kXR_admin: if (Status & XRD_ADMINUSER) return do_Admin();
else break;
case kXR_chmod: return do_Chmod();
{case kXR_chmod: return do_Chmod();
case kXR_dirlist: return do_Dirlist();
case kXR_fattr: return do_FAttr();
case kXR_locate: return do_Locate();
Expand Down
5 changes: 1 addition & 4 deletions src/XrdXrootd/XrdXrootdProtocol.hh
Expand Up @@ -53,7 +53,6 @@

#define XRD_LOGGEDIN 1
#define XRD_NEED_AUTH 2
#define XRD_ADMINUSER 4
#define XRD_BOUNDPATH 8

#ifndef __GNUC__
Expand Down Expand Up @@ -135,7 +134,6 @@ enum RD_func {RD_chmod = 0, RD_chksum, RD_dirlist, RD_locate, RD_mkdir,
RD_stat, RD_trunc, RD_ovld,
RD_open1, RD_open2, RD_open3, RD_open4, RD_Num};

int do_Admin();
int do_Auth();
int do_Bind();
int do_Chmod();
Expand All @@ -146,7 +144,7 @@ enum RD_func {RD_chmod = 0, RD_chksum, RD_dirlist, RD_locate, RD_mkdir,
int do_DirStat(XrdSfsDirectory *dp, char *pbuff, char *opaque);
int do_Endsess();
int do_FAttr();
int do_Getfile();
int do_gpFile();
int do_Login();
int do_Locate();
int do_Mkdir();
Expand All @@ -157,7 +155,6 @@ enum RD_func {RD_chmod = 0, RD_chksum, RD_dirlist, RD_locate, RD_mkdir,
int do_Ping();
int do_Prepare(bool isQuery=false);
int do_Protocol();
int do_Putfile();
int do_Qconf();
int do_Qfh();
int do_Qopaque(short);
Expand Down

0 comments on commit 96c04cc

Please sign in to comment.