From 96c04cc58b3a894d66ba49080f8e511a2ceaae26 Mon Sep 17 00:00:00 2001 From: Andrew Hanushevsky Date: Thu, 17 Oct 2019 23:06:29 -0700 Subject: [PATCH] [All] Realign request codes for new functionality and remove the old stuff. --- src/XProtocol/XProtocol.cc | 11 +++---- src/XProtocol/XProtocol.hh | 33 ++++++++----------- src/XrdCl/XrdClXRootDTransport.cc | 1 - src/XrdCms/XrdCmsAdmin.cc | 2 +- src/XrdOuc/XrdOucBackTrace.cc | 8 ++--- src/XrdSec/XrdSecProtect.cc | 11 +++---- src/XrdSec/XrdSecProtect.hh | 12 +++---- src/XrdXrootd/XrdXrootdAdmin.cc | 2 +- src/XrdXrootd/XrdXrootdProtocol.cc | 7 ++-- src/XrdXrootd/XrdXrootdProtocol.hh | 5 +-- src/XrdXrootd/XrdXrootdXeq.cc | 53 ++++++------------------------ src/api_test/xrdsrv.cc | 20 +++++------ 12 files changed, 58 insertions(+), 107 deletions(-) diff --git a/src/XProtocol/XProtocol.cc b/src/XProtocol/XProtocol.cc index fe28883bbfa..71f1be0a448 100644 --- a/src/XProtocol/XProtocol.cc +++ b/src/XProtocol/XProtocol.cc @@ -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 diff --git a/src/XProtocol/XProtocol.hh b/src/XProtocol/XProtocol.hh index 5744dad7148..ed978b08413 100644 --- a/src/XProtocol/XProtocol.hh +++ b/src/XProtocol/XProtocol.hh @@ -122,19 +122,19 @@ 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 @@ -142,19 +142,18 @@ enum XRequestTypes { 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 }; @@ -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 { @@ -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, @@ -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 @@ -347,7 +341,8 @@ enum XActionCode { kXR_asyncav, // 5005 kXR_asynunav, // 5006 kXR_asyncgo, // 5007 - kXR_asynresp // 5008 + kXR_asynresp, // 5008 + kXR_asyninfo // 5009 }; //_______________________________________________ @@ -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 { diff --git a/src/XrdCl/XrdClXRootDTransport.cc b/src/XrdCl/XrdClXRootDTransport.cc index e26ddeb8bed..d54e7ce7508 100644 --- a/src/XrdCl/XrdClXRootDTransport.cc +++ b/src/XrdCl/XrdClXRootDTransport.cc @@ -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; diff --git a/src/XrdCms/XrdCmsAdmin.cc b/src/XrdCms/XrdCmsAdmin.cc index a38af540600..0ed41cfea91 100644 --- a/src/XrdCms/XrdCmsAdmin.cc +++ b/src/XrdCms/XrdCmsAdmin.cc @@ -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; diff --git a/src/XrdOuc/XrdOucBackTrace.cc b/src/XrdOuc/XrdOucBackTrace.cc index e7a1e65c42c..8d3ffb0e497 100644 --- a/src/XrdOuc/XrdOucBackTrace.cc +++ b/src/XrdOuc/XrdOucBackTrace.cc @@ -89,14 +89,14 @@ 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}, @@ -104,13 +104,13 @@ XrdInfo *CvtReq(const char *name, int rnum) {"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} }; diff --git a/src/XrdSec/XrdSecProtect.cc b/src/XrdSec/XrdSecProtect.cc index 019a3951d44..f997032edc8 100644 --- a/src/XrdSec/XrdSecProtect.cc +++ b/src/XrdSec/XrdSecProtect.cc @@ -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, @@ -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); } @@ -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; diff --git a/src/XrdSec/XrdSecProtect.hh b/src/XrdSec/XrdSecProtect.hh index 4eb5c248be8..d42541dd8e6 100644 --- a/src/XrdSec/XrdSecProtect.hh +++ b/src/XrdSec/XrdSecProtect.hh @@ -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. @@ -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. diff --git a/src/XrdXrootd/XrdXrootdAdmin.cc b/src/XrdXrootd/XrdXrootdAdmin.cc index 824087075b2..6c1bdc0517d 100644 --- a/src/XrdXrootd/XrdXrootdAdmin.cc +++ b/src/XrdXrootd/XrdXrootdAdmin.cc @@ -383,7 +383,7 @@ int XrdXrootdAdmin::do_Lsd() if ((xp = lp->getProtocol()) && (pp = dynamic_cast(xp))) {cver = int(pp->CapVer); - ctyp = (pp->Status & XRD_ADMINUSER ? 'a' : 'u'); + ctyp = 'u'; conn = static_cast(lp->timeCon()); mm = monit; if (pp->Monitor.Files()) *mm++ = 'f'; diff --git a/src/XrdXrootd/XrdXrootdProtocol.cc b/src/XrdXrootd/XrdXrootdProtocol.cc index 2a8d6ff65b4..b657a82a34b 100644 --- a/src/XrdXrootd/XrdXrootdProtocol.cc +++ b/src/XrdXrootd/XrdXrootdProtocol.cc @@ -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; } @@ -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(); diff --git a/src/XrdXrootd/XrdXrootdProtocol.hh b/src/XrdXrootd/XrdXrootdProtocol.hh index 2b33f73c0d8..fcfc967de72 100644 --- a/src/XrdXrootd/XrdXrootdProtocol.hh +++ b/src/XrdXrootd/XrdXrootdProtocol.hh @@ -53,7 +53,6 @@ #define XRD_LOGGEDIN 1 #define XRD_NEED_AUTH 2 -#define XRD_ADMINUSER 4 #define XRD_BOUNDPATH 8 #ifndef __GNUC__ @@ -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(); @@ -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(); @@ -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); diff --git a/src/XrdXrootd/XrdXrootdXeq.cc b/src/XrdXrootd/XrdXrootdXeq.cc index ed4d2e62c47..71deb53b6eb 100644 --- a/src/XrdXrootd/XrdXrootdXeq.cc +++ b/src/XrdXrootd/XrdXrootdXeq.cc @@ -154,15 +154,6 @@ struct tm *tmp; static const char *startUP = getTime(); } -/******************************************************************************/ -/* d o _ A d m i n */ -/******************************************************************************/ - -int XrdXrootdProtocol::do_Admin() -{ - return Response.Send(kXR_Unsupported, "admin request is not supported"); -} - /******************************************************************************/ /* d o _ A u t h */ /******************************************************************************/ @@ -784,23 +775,24 @@ int XrdXrootdProtocol::do_Endsess() /******************************************************************************/ /******************************************************************************/ -/* d o G e t f i l e */ +/* d o _ g p F i l e */ /******************************************************************************/ -int XrdXrootdProtocol::do_Getfile() +int XrdXrootdProtocol::do_gpFile() { // int gopts, buffsz; -// Keep Statistics +// Keep Statistics (TO DO: differentiate get vs put) // SI->Bump(SI->getfCnt); +// SI->Bump(SI->putfCnt); -// Check if getfiles need to occur on a TLS connection +// Check if gpfile need to occur on a TLS connection // - if ((doTLS & Req_TLSTPC) && !Link->hasTLS() && !Link->hasBridge()) - return Response.Send(kXR_TLSRequired, "getfile requires TLS"); + if ((doTLS & Req_TLSGPFile) && !Link->hasTLS() && !Link->hasBridge()) + return Response.Send(kXR_TLSRequired, "gpfile requires TLS"); - return Response.Send(kXR_Unsupported, "getfile request is not supported"); + return Response.Send(kXR_Unsupported, "gpfile request is not supported"); } /******************************************************************************/ @@ -954,11 +946,6 @@ int XrdXrootdProtocol::do_Login() if (addrP->isPrivate()) {clientPV |= XrdOucEI::uPrip; rdType = 1;} else rdType = 0; -// Check if this is an admin login -// - if (*(Request.login.role) & (kXR_char)kXR_useradmin) - Status = XRD_ADMINUSER; - // Get the security token for this link. We will either get a token, a null // string indicating host-only authentication, or a null indicating no // authentication. We can then optimize of each case. @@ -1826,26 +1813,6 @@ int XrdXrootdProtocol::do_Protocol() return rc; } -/******************************************************************************/ -/* d o _ P u t f i l e */ -/******************************************************************************/ - -int XrdXrootdProtocol::do_Putfile() -{ -// int popts, buffsz; - -// Keep Statistics -// - SI->Bump(SI->putfCnt); - -// Check if putfiles need to occur on a TLS connection -// - if ((doTLS & Req_TLSTPC) && !Link->hasTLS() && !Link->hasBridge()) - return Response.Send(kXR_TLSRequired, "putfile requires TLS"); - - return Response.Send(kXR_Unsupported, "putfile request is not supported"); -} - /******************************************************************************/ /* d o _ Q c o n f */ /******************************************************************************/ @@ -3675,9 +3642,9 @@ bool XrdXrootdProtocol::logLogin(bool xauth) // Format the line // - sprintf(lBuff, "%s %s %s%s%slogin%s", + sprintf(lBuff, "%s %s %s%slogin%s", (clientPV & XrdOucEI::uPrip ? "pvt" : "pub"), ipName, - (Status & XRD_ADMINUSER ? "admin " : ""), tMsg, zMsg, + tMsg, zMsg, (xauth ? " as" : "")); // Document the login diff --git a/src/api_test/xrdsrv.cc b/src/api_test/xrdsrv.cc index fb12004e892..7b70e342afd 100644 --- a/src/api_test/xrdsrv.cc +++ b/src/api_test/xrdsrv.cc @@ -418,9 +418,9 @@ int HandleRequest( SocketIO &io, int iterations ) break; } - case kXR_getfile: + case kXR_gpfile: { - stdio.write( "Got kXR_getfile!" ); + stdio.write( "Got kXR_gpfile!" ); break; } @@ -463,9 +463,9 @@ int HandleRequest( SocketIO &io, int iterations ) break; } - case kXR_putfile: + case kXR_chkpoint: { - stdio.write( "Got kXR_putfile!" ); + stdio.write( "Got kXR_chkpoint!" ); break; } @@ -512,9 +512,9 @@ int HandleRequest( SocketIO &io, int iterations ) break; } - case kXR_admin: + case kXR_fattr: { - stdio.write( "Got kXR_admin!" ); + stdio.write( "Got kXR_fattr!" ); break; } @@ -549,9 +549,9 @@ int HandleRequest( SocketIO &io, int iterations ) break; } - case kXR_verifyw: + case kXR_pgwrite: { - stdio.write( "Got kXR_verifyw!" ); + stdio.write( "Got kXR_pgwrite!" ); break; } @@ -573,9 +573,9 @@ int HandleRequest( SocketIO &io, int iterations ) break; } - case kXR_decrypt: + case kXR_pgread: { - stdio.write( "Got kXR_decrypt!" ); + stdio.write( "Got kXR_pgread!" ); break; }