Skip to content

Commit

Permalink
Merge branch 'master' into xrdssi
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Jun 4, 2016
2 parents 505e816 + 50dd214 commit 5e7ce39
Show file tree
Hide file tree
Showing 34 changed files with 1,218 additions and 721 deletions.
2 changes: 2 additions & 0 deletions docs/PreReleaseNotes.txt
Expand Up @@ -14,7 +14,9 @@ Prerelease Notes
* [Authentication/sss] Fix dynamic id incompatability introduced in 4.0.

+ **Minor bug fixes**
* [Server] Make sure lockfile time is updated in deprecated runmodeold.
* [Server] Fixes #344 - squash path before checking for static redirect.
* [Server] Free Entity before replacing it from the cache (memleak).

+ **Miscellaneous**
* [Apps] Add xrdacctest to the tools set to test access control databases.
12 changes: 12 additions & 0 deletions src/XrdApps.cmake
Expand Up @@ -60,6 +60,18 @@ target_link_libraries(
pthread
${EXTRA_LIBS} )

#-------------------------------------------------------------------------------
# xrdacctest
#-------------------------------------------------------------------------------
add_executable(
xrdacctest
XrdApps/XrdAccTest.cc )

target_link_libraries(
xrdacctest
XrdServer
XrdUtils )

#-------------------------------------------------------------------------------
# xrdmapc
#-------------------------------------------------------------------------------
Expand Down
20 changes: 12 additions & 8 deletions src/XrdAcc/XrdAccTest.cc → src/XrdApps/XrdAccTest.cc
Expand Up @@ -52,6 +52,8 @@
#include <sys/param.h>
#include <sys/socket.h>

#include "XrdVersion.hh"

#include "XrdAcc/XrdAccAuthorize.hh"
#include "XrdAcc/XrdAccConfig.hh"
#include "XrdAcc/XrdAccGroups.hh"
Expand Down Expand Up @@ -106,12 +108,14 @@ int opcnt = sizeof(optab)/sizeof(optab[0]);

int main(int argc, char **argv)
{
extern XrdAccAuthorize *XrdAccDefaultAuthorizeObject(XrdSysLogger *lp,
const char *cfn,
const char *parm);
static XrdVERSIONINFODEF(myVer, XrdAccTest, XrdVNUMBER, XrdVERSION);
extern XrdAccAuthorize *XrdAccDefaultAuthorizeObject(XrdSysLogger *lp,
const char *cfn,
const char *parm,
XrdVersionInfo &myVer);
void Usage(const char *);
char *p2l(XrdAccPrivs priv, char *buff, int blen);
int rc = 0, argnum, DebugON = 0;
int rc = 0, argnum;
char c, *argval[32];
int DoIt(int argnum, int argc, char **argv);
XrdOucStream Command;
Expand All @@ -124,14 +128,13 @@ char *ConfigFN = (char *)"./acc.cf";
{ switch(c)
{
case 'c': ConfigFN = optarg; break;
case 'd': DebugON = 1; break;
default: Usage("Invalid option.");
}
}

// Obtain the authorization object
//
if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0)))
if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0, myVer)))
{cerr << "testaccess: Initialization failed." <<endl;
exit(2);
}
Expand Down Expand Up @@ -259,7 +262,8 @@ char *PrivsConvert(XrdAccPrivCaps &ctab, char *buff, int blen)
/******************************************************************************/

void Usage(const char *msg)
{if (msg) cerr <<"testaccess: " <<msg <<endl;
cerr << "testaccess [-c cfn] [-d] [user host op path [path [. . .]]]" <<endl;
{if (msg) cerr <<"xrdacctest: " <<msg <<endl;
cerr << "Usage: xrdacctest [-c cfn] [<user> <host> {d|i|k|l|n|r|w} "
"<path> [<path> [...]]]" <<endl;
exit(1);
}
3 changes: 2 additions & 1 deletion src/XrdCl/CMakeLists.txt
Expand Up @@ -62,7 +62,8 @@ add_library(
XrdClCopyJob.hh
XrdClFileSystemUtils.cc XrdClFileSystemUtils.hh
XrdClTPFallBackCopyJob.cc XrdClTPFallBackCopyJob.hh
XrdClMetalinkCopyJob.cc XrdClMetalinkCopyJob.hh
XrdClMetalinkRedirector.cc XrdClMetalinkRedirector.hh
XrdClRedirectorRegistry.cc XrdClRedirectorRegistry.hh
)

target_link_libraries(
Expand Down
13 changes: 12 additions & 1 deletion src/XrdCl/XrdClChannel.cc
Expand Up @@ -29,6 +29,7 @@
#include "XrdCl/XrdClConstants.hh"
#include "XrdCl/XrdClLog.hh"
#include "XrdCl/XrdClUglyHacks.hh"
#include "XrdCl/XrdClRedirectorRegistry.hh"

#include <ctime>

Expand Down Expand Up @@ -279,10 +280,20 @@ namespace XrdCl
Status Channel::Send( Message *msg,
OutgoingMsgHandler *handler,
bool stateful,
time_t expires )
time_t expires,
VirtualRedirector *redirector )

{
PathID path = pTransport->Multiplex( msg, pChannelData );

if( redirector )
{
XRootDStatus st = redirector->Redirect( msg, pStreams[path.down] );
if( st.IsOK() )
handler->OnStatusReady( msg, Status() );
return st;
}

return pStreams[path.up]->Send( msg, handler, stateful, expires );
}

Expand Down
5 changes: 3 additions & 2 deletions src/XrdCl/XrdClChannel.hh
Expand Up @@ -37,6 +37,7 @@ namespace XrdCl
{
class Stream;
class JobManager;
class VirtualRedirector;

//----------------------------------------------------------------------------
//! A communication channel between the client and the server
Expand Down Expand Up @@ -101,8 +102,8 @@ namespace XrdCl
Status Send( Message *msg,
OutgoingMsgHandler *handler,
bool stateful,
time_t expires );

time_t expires,
VirtualRedirector *redirector = 0 );

//------------------------------------------------------------------------
//! Synchronously receive a message - blocks until a message matching
Expand Down
48 changes: 36 additions & 12 deletions src/XrdCl/XrdClClassicCopyJob.cc
Expand Up @@ -32,6 +32,7 @@
#include "XrdCl/XrdClCheckSumManager.hh"
#include "XrdCks/XrdCksCalc.hh"
#include "XrdCl/XrdClUglyHacks.hh"
#include "XrdCl/XrdClRedirectorRegistry.hh"

#include <memory>
#include <iostream>
Expand Down Expand Up @@ -548,10 +549,11 @@ namespace
//------------------------------------------------------------------------
XRootDSource( const XrdCl::URL *url,
uint32_t chunkSize,
uint8_t parallelChunks ):
uint8_t parallelChunks,
bool virtRedirector ):
pUrl( url ), pFile( new XrdCl::File() ), pSize( -1 ),
pCurrentOffset( 0 ), pChunkSize( chunkSize ),
pParallel( parallelChunks )
pParallel( parallelChunks ), pVirtRedirector( virtRedirector )
{
}

Expand Down Expand Up @@ -579,7 +581,7 @@ namespace
DefaultEnv::GetEnv()->GetString( "ReadRecovery", value );
pFile->SetProperty( "ReadRecovery", value );

XRootDStatus st = pFile->Open( pUrl->GetURL(), OpenFlags::Read );
XRootDStatus st = pFile->Open( pUrl->GetURL(), OpenFlags::Read, Access::None, 0, pVirtRedirector );
if( !st.IsOK() )
return st;

Expand Down Expand Up @@ -691,9 +693,18 @@ namespace
virtual XrdCl::XRootDStatus GetCheckSum( std::string &checkSum,
std::string &checkSumType )
{
if( pVirtRedirector )
{
XrdCl::RedirectorRegistry &registry = XrdCl::RedirectorRegistry::Instance();
XrdCl::VirtualRedirector *redirector = registry.Get( *pUrl );
checkSum = redirector->GetCheckSum( checkSumType );
if( !checkSum.empty() ) return XrdCl::XRootDStatus();
}

std::string dataServer; pFile->GetProperty( "DataServer", dataServer );
std::string lastUrl; pFile->GetProperty( "LastURL", lastUrl );
return XrdCl::Utils::GetRemoteCheckSum( checkSum, checkSumType,
dataServer, pUrl->GetPath() );
dataServer, XrdCl::URL( lastUrl ).GetPath() );
}

private:
Expand Down Expand Up @@ -735,6 +746,7 @@ namespace
uint32_t pChunkSize;
uint8_t pParallel;
std::queue<ChunkHandler *> pChunks;
bool pVirtRedirector;
};

//----------------------------------------------------------------------------
Expand All @@ -747,9 +759,10 @@ namespace
//! Constructor
//------------------------------------------------------------------------
XRootDSourceDynamic( const XrdCl::URL *url,
uint32_t chunkSize ):
uint32_t chunkSize,
bool virtRedirector ):
pUrl( url ), pFile( new XrdCl::File() ), pCurrentOffset( 0 ),
pChunkSize( chunkSize ), pDone( false )
pChunkSize( chunkSize ), pDone( false ), pVirtRedirector( virtRedirector )
{
}

Expand All @@ -776,7 +789,7 @@ namespace
DefaultEnv::GetEnv()->GetString( "ReadRecovery", value );
pFile->SetProperty( "ReadRecovery", value );

XRootDStatus st = pFile->Open( pUrl->GetURL(), OpenFlags::Read );
XRootDStatus st = pFile->Open( pUrl->GetURL(), OpenFlags::Read, Access::None, 0, pVirtRedirector );
if( !st.IsOK() )
return st;

Expand Down Expand Up @@ -852,9 +865,18 @@ namespace
virtual XrdCl::XRootDStatus GetCheckSum( std::string &checkSum,
std::string &checkSumType )
{
if( pVirtRedirector )
{
XrdCl::RedirectorRegistry &registry = XrdCl::RedirectorRegistry::Instance();
XrdCl::VirtualRedirector *redirector = registry.Get( *pUrl );
checkSum = redirector->GetCheckSum( checkSumType );
if( !checkSum.empty() ) return XrdCl::XRootDStatus();
}

std::string dataServer; pFile->GetProperty( "DataServer", dataServer );
return XrdCl::Utils::GetRemoteCheckSum( checkSum, checkSumType,
dataServer, pUrl->GetPath() );
std::string lastUrl; pFile->GetProperty( "LastURL", lastUrl );
return XrdCl::Utils::GetRemoteCheckSum( checkSum, checkSumType, dataServer,
XrdCl::URL( lastUrl ).GetPath() );
}

private:
Expand All @@ -865,6 +887,7 @@ namespace
int64_t pCurrentOffset;
uint32_t pChunkSize;
bool pDone;
bool pVirtRedirector;
};

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1401,7 +1424,7 @@ namespace XrdCl
std::string checkSumPreset;
uint16_t parallelChunks;
uint32_t chunkSize;
bool posc, force, coerce, makeDir, dynamicSource;
bool posc, force, coerce, makeDir, dynamicSource, virtRedirector = false;

pProperties->Get( "checkSumMode", checkSumMode );
pProperties->Get( "checkSumType", checkSumType );
Expand All @@ -1413,6 +1436,7 @@ namespace XrdCl
pProperties->Get( "coerce", coerce );
pProperties->Get( "makeDir", makeDir );
pProperties->Get( "dynamicSource", dynamicSource );
pProperties->Get( "metalink", virtRedirector );

//--------------------------------------------------------------------------
// Initialize the source and the destination
Expand All @@ -1425,9 +1449,9 @@ namespace XrdCl
else
{
if( dynamicSource )
src.reset( new XRootDSourceDynamic( &GetSource(), chunkSize ) );
src.reset( new XRootDSourceDynamic( &GetSource(), chunkSize, virtRedirector ) );
else
src.reset( new XRootDSource( &GetSource(), chunkSize, parallelChunks ) );
src.reset( new XRootDSource( &GetSource(), chunkSize, parallelChunks, virtRedirector ) );
}

XRootDStatus st = src->Initialize();
Expand Down
30 changes: 27 additions & 3 deletions src/XrdCl/XrdClCopy.cc
Expand Up @@ -30,6 +30,7 @@
#include "XrdCl/XrdClLog.hh"
#include "XrdCl/XrdClFileSystem.hh"
#include "XrdCl/XrdClUtils.hh"
#include "XrdCl/XrdClRedirectorRegistry.hh"
#include "XrdSys/XrdSysPthread.hh"

#include <iostream>
Expand Down Expand Up @@ -738,14 +739,38 @@ int main( int argc, char **argv )
sourceFile->Path, FileType2String( sourceFile->Protocol ),
dest.c_str() );

//--------------------------------------------------------------------------
// Create a virtual redirector if it is a metalink file
//--------------------------------------------------------------------------
if( metalink )
{
RedirectorRegistry &registry = RedirectorRegistry::Instance();
XRootDStatus st = registry.Register( source );
if( !st.IsOK() )
{
std::cerr << "RedirectorRegistry::Register " << source << " -> " << dest << ": ";
std::cerr << st.ToStr() << std::endl;
resultVect.push_back( results );
sourceFile = sourceFile->Next;
continue;
}
}

//--------------------------------------------------------------------------
// Set up the job
//--------------------------------------------------------------------------
std::string target = dest;
if( targetIsDir )
if( targetIsDir)
{
target = dest + "/";
target += (sourceFile->Path+sourceFile->Doff);
// if it is a metalink we don't want to use the metalink name
if( metalink )
{
XrdCl::RedirectorRegistry &registry = XrdCl::RedirectorRegistry::Instance();
VirtualRedirector *redirector = registry.Get( source );
target += redirector->GetTargetName();
}
else target += (sourceFile->Path+sourceFile->Doff);
}

AppendCGI( target, config.dstOpq );
Expand All @@ -768,7 +793,6 @@ int main( int argc, char **argv )
XRootDStatus st = process.AddJob( properties, results );
if( !st.IsOK() )
{
delete results;
std::cerr << "AddJob " << source << " -> " << target << ": ";
std::cerr << st.ToStr() << std::endl;
}
Expand Down
20 changes: 0 additions & 20 deletions src/XrdCl/XrdClCopyProcess.cc
Expand Up @@ -31,7 +31,6 @@
#include "XrdCl/XrdClFileSystem.hh"
#include "XrdCl/XrdClMonitor.hh"
#include "XrdCl/XrdClCopyJob.hh"
#include "XrdClMetalinkCopyJob.hh"
#include "XrdCl/XrdClUtils.hh"
#include "XrdCl/XrdClJobManager.hh"
#include "XrdCl/XrdClUglyHacks.hh"
Expand Down Expand Up @@ -258,25 +257,6 @@ namespace XrdCl
if( !source.IsValid() )
return XRootDStatus( stError, errInvalidArgs, 0, "invalid source" );

bool metalink = false;
props.Get( "metalink", metalink );

if( metalink && !source.IsMetalink())
{
log->Debug( UtilityMsg, "CopyProcess (job #%d): metalink transfer requested, but no metalink found.",
i );
CleanUpJobs();
XRootDStatus st = XRootDStatus( stError, errInvalidArgs );
res->Set( "status", st );
return st;
}

if( metalink && source.IsMetalink() )
{
pJobs.push_back( new MetalinkCopyJob( i+1, &props, res ) );
continue;
}

props.Get( "target", tmp );
URL target = tmp;
if( !target.IsValid() )
Expand Down

0 comments on commit 5e7ce39

Please sign in to comment.