19#ifndef __XRD_CL_UTILS_HH__
20#define __XRD_CL_UTILS_HH__
55 template<
class Container>
57 const std::string &input,
58 const std::string &delimiter )
73 const std::string &name,
80 const std::string &name,
81 const std::string &defaultVal );
112 const std::string &hostId,
113 std::vector<XrdNetAddr> &addresses );
129 const std::string &checkSumType,
136 const std::string &checkSumType,
137 const std::string &path );
148 uint16_t timeout = 0 );
157 uint16_t timeout = 0 );
162 static std::string
FQDNToCC(
const std::string &fqdn );
168 const std::string &path );
174 const std::string &file );
180 const std::string &dir );
185 static void Trim( std::string &str );
198 static std::string
Char2Hex( uint8_t *array, uint16_t size );
204 const std::string &checksum );
240 if( !st.
IsOK() )
return st;
242 qryResult.
Get( tmp );
258 if( !st.IsOK() )
return false;
272 if( !st.IsOK() )
return false;
285 const uint32_t maxcs,
331 class ScopedFsUidSetter
337 ScopedFsUidSetter(uid_t fsuid, gid_t fsgid,
const std::string &streamName)
338 : pFsUid(fsuid), pFsGid(fsgid), pStreamName(streamName)
348 pPrevFsUid = setfsuid(pFsUid);
350 if(setfsuid(pFsUid) != pFsUid) {
360 pPrevFsGid = setfsgid(pFsGid);
362 if(setfsgid(pFsGid) != pFsGid) {
372 ~ScopedFsUidSetter() {
373 Log *log = DefaultEnv::GetLog();
375 if(pPrevFsUid >= 0) {
376 int retcode = setfsuid(pPrevFsUid);
377 log->Dump(XRootDTransportMsg,
"[%s] Restored fsuid from %d to %d", pStreamName.c_str(), retcode, pPrevFsUid);
380 if(pPrevFsGid >= 0) {
381 int retcode = setfsgid(pPrevFsGid);
382 log->Dump(XRootDTransportMsg,
"[%s] Restored fsgid from %d to %d", pStreamName.c_str(), retcode, pPrevFsGid);
394 const std::string &pStreamName;
#define kXR_PROTXATTVERSION
Definition XProtocol.hh:71
#define kXR_PROTPGRWVERSION
Definition XProtocol.hh:73
#define close(a)
Definition XrdPosix.hh:43
Definition XrdClAnyObject.hh:33
void Get(Type &object)
Retrieve the object being held.
Definition XrdClAnyObject.hh:78
static PostMaster * GetPostMaster()
Get default post master.
Handle diagnostics.
Definition XrdClLog.hh:101
The message representation used throughout the system.
Definition XrdClMessage.hh:30
A key-value pair map storing both keys and values as strings.
Definition XrdClPropertyList.hh:41
Smart descriptor - closes the descriptor on destruction.
Definition XrdClUtils.hh:293
int pDescriptor
Definition XrdClUtils.hh:324
~ScopedDescriptor()
Destructor.
Definition XrdClUtils.hh:303
ScopedDescriptor(int descriptor)
Constructor.
Definition XrdClUtils.hh:298
int GetDescriptor()
Get the descriptor.
Definition XrdClUtils.hh:318
int Release()
Release the descriptor being held.
Definition XrdClUtils.hh:308
URL representation.
Definition XrdClURL.hh:31
Random utilities.
Definition XrdClUtils.hh:50
static XRootDStatus CheckTPCLite(const std::string &server, uint16_t timeout=0)
static void Trim(std::string &str)
Trim a string.
static std::string Char2Hex(uint8_t *array, uint16_t size)
Print a char array as hex.
static uint64_t GetElapsedMicroSecs(timeval start, timeval end)
Get the elapsed microseconds between two timevals.
static Status GetDirectoryEntries(std::vector< std::string > &entries, const std::string &path)
Get directory entries.
static void SplitChunks(std::vector< ChunkList > &listsvec, const ChunkList &chunks, const uint32_t maxcs, const size_t maxc)
static std::string FQDNToCC(const std::string &fqdn)
Convert the fully qualified host name to country code.
static std::string NormalizeChecksum(const std::string &name, const std::string &checksum)
Normalize checksum.
static std::vector< std::string > GetSupportedCheckSums(const XrdCl::URL &url)
Get supported checksum types for given URL.
static int GetIntParameter(const URL &url, const std::string &name, int defaultVal)
Get a parameter either from the environment or URL.
static Status GetHostAddresses(std::vector< XrdNetAddr > &addresses, const URL &url, AddressType type)
Resolve IP addresses.
static void LogHostAddresses(Log *log, uint64_t type, const std::string &hostId, std::vector< XrdNetAddr > &addresses)
Log all the addresses on the list.
static bool CheckEC(const Message *req, const URL &url)
Check if this client can support given EC redirect.
static XRootDStatus GetRemoteCheckSum(std::string &checkSum, const std::string &checkSumType, const URL &url)
Get a checksum from a remote xrootd server.
static void LogPropertyList(Log *log, uint64_t topic, const char *format, const PropertyList &list)
Log property list.
static Status ProcessConfigDir(std::map< std::string, std::string > &config, const std::string &dir)
Process a config directory and return key-value pairs.
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition XrdClUtils.hh:56
static XRootDStatus CheckTPC(const std::string &server, uint16_t timeout=0)
Check if peer supports tpc.
static AddressType String2AddressType(const std::string &addressType)
Interpret a string as address type, default to IPAll.
static XRootDStatus GetLocalCheckSum(std::string &checkSum, const std::string &checkSumType, const std::string &path)
Get a checksum from local file.
static bool HasXAttr(const XrdCl::URL &url)
Definition XrdClUtils.hh:253
static Status ProcessConfig(std::map< std::string, std::string > &config, const std::string &file)
Process a config file and return key-value pairs.
static std::string BytesToString(uint64_t bytes)
Convert bytes to a human readable string.
static std::string InferChecksumType(const XrdCl::URL &source, const XrdCl::URL &destination, bool zip=false)
static std::string GetStringParameter(const URL &url, const std::string &name, const std::string &defaultVal)
Get a parameter either from the environment or URL.
static std::string TimeToString(time_t timestamp)
Convert timestamp to a string.
AddressType
Address type.
Definition XrdClUtils.hh:87
@ IPAll
Definition XrdClUtils.hh:89
@ IPv6
Definition XrdClUtils.hh:90
@ IPv4
Definition XrdClUtils.hh:91
@ IPAuto
Definition XrdClUtils.hh:88
@ IPv4Mapped6
Definition XrdClUtils.hh:92
static XrdCl::XRootDStatus GetProtocolVersion(const XrdCl::URL url, int &protver)
Definition XrdClUtils.hh:235
static bool HasPgRW(const XrdCl::URL &url)
Definition XrdClUtils.hh:267
Request status.
Definition XrdClXRootDResponses.hh:219
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition XrdOucTUtils.hh:49
Definition XrdClAction.hh:34
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition XrdClXRootDResponses.hh:1055
Procedure execution status.
Definition XrdClStatus.hh:115
bool IsOK() const
We're fine.
Definition XrdClStatus.hh:124
static const uint16_t ProtocolVersion
returns the protocol version
Definition XrdClPostMasterInterfaces.hh:291