Loading...
Searching...
No Matches
XrdSutAux.hh File Reference
`#include "XrdSys/XrdSysHeaders.hh"`
`#include "XProtocol/XPtypes.hh"`
Include dependency graph for XrdSutAux.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes

class | XrdSutFileLocker

## Macros

#define | sutTRACE_ALL 0x0007
#define | sutTRACE_Debug 0x0002
#define | sutTRACE_Dump 0x0004
#define | sutTRACE_Notify 0x0001
#define | XrdSutMAXBUCKS 10
#define | XrdSutMAXBUF 4096
#define | XrdSutMAXINT64LEN 25
#define | XrdSutMAXPPT 512
#define | XrdSutPRINTLEN 100

## Enumerations

enum

kXRSBucketTypes {
kXRS_none = 0 ,
kXRS_inactive = 1 ,
kXRS_cryptomod = 3000 ,
kXRS_main ,
kXRS_srv_seal ,
kXRS_clnt_seal ,
kXRS_puk ,
kXRS_cipher ,
kXRS_rtag ,
kXRS_signed_rtag ,
kXRS_user ,
kXRS_host ,
kXRS_creds ,
kXRS_message ,
kXRS_srvID ,
kXRS_sessionID ,
kXRS_version ,
kXRS_status ,
kXRS_localstatus ,
kXRS_othercreds ,
kXRS_cache_idx ,
kXRS_clnt_opts ,
kXRS_error_code ,
kXRS_timestamp ,
kXRS_x509 ,
kXRS_issuer_hash ,
kXRS_x509_req ,
kXRS_cipher_alg ,
kXRS_md_alg ,
kXRS_afsinfo ,
kXRS_reserved
}

## Functions

bool | XrdSutAskConfirm (const char *msg1, bool defact, const char *msg2=0)
const char * | XrdSutBuckStr (int kbck)
int | XrdSutExpand (XrdOucString &path)
int | XrdSutFromHex (const char *in, char *out, int &lout)
int | XrdSutGetLine (XrdOucString &line, const char *prompt=0)
int | XrdSutGetPass (const char *prompt, XrdOucString &passwd)
const char * | XrdSutHome ()
volatile void * | XrdSutMemSet (volatile void *dst, int c, int len)
int | XrdSutMkdir (const char *dir, unsigned int mode=0777, const char *opt="-p")
int | XrdSutParseTime (const char *tstr, int opt=0)
int | XrdSutResolve (XrdOucString &path, const char *ho, const char *vo, const char *gr, const char *us)
void | XrdSutSetTrace (kXR_int32 trace)
int | XrdSutTimeString (int t, char *st, int opt=0)
int | XrdSutToHex (const char *in, int lin, char *out)

## Macro Definition Documentation

## sutTRACE_ALL

#define sutTRACE_ALL 0x0007

Definition at line 97 of file XrdSutAux.hh.

Referenced by XrdSutSetTrace().

## sutTRACE_Debug

#define sutTRACE_Debug 0x0002

Definition at line 99 of file XrdSutAux.hh.

Referenced by XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), main(), and XrdSutSetTrace().

## sutTRACE_Dump

#define sutTRACE_Dump 0x0004

Definition at line 98 of file XrdSutAux.hh.

Referenced by XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), and XrdSutSetTrace().

## sutTRACE_Notify

#define sutTRACE_Notify 0x0001

Definition at line 100 of file XrdSutAux.hh.

Referenced by XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), and XrdSutSetTrace().

## XrdSutMAXBUCKS

#define XrdSutMAXBUCKS 10

Definition at line 50 of file XrdSutAux.hh.

## XrdSutMAXBUF

#define XrdSutMAXBUF 4096

Definition at line 48 of file XrdSutAux.hh.

Referenced by XrdCryptoBasic::AsHexString(), and XrdSutGetLine().

## XrdSutMAXINT64LEN

#define XrdSutMAXINT64LEN 25

Definition at line 51 of file XrdSutAux.hh.

## XrdSutMAXPPT

#define XrdSutMAXPPT 512

Definition at line 49 of file XrdSutAux.hh.

## XrdSutPRINTLEN

#define XrdSutPRINTLEN 100

Definition at line 52 of file XrdSutAux.hh.

Referenced by XrdSutBucket::Dump().

## Enumeration Type Documentation

## kXRSBucketTypes

enum kXRSBucketTypes

Enumerator
kXRS_none |
kXRS_inactive |
kXRS_cryptomod |
kXRS_main |
kXRS_srv_seal |
kXRS_clnt_seal |
kXRS_puk |
kXRS_cipher |
kXRS_rtag |
kXRS_signed_rtag |
kXRS_user |
kXRS_host |
kXRS_creds |
kXRS_message |
kXRS_srvID |
kXRS_sessionID |
kXRS_version |
kXRS_status |
kXRS_localstatus |
kXRS_othercreds |
kXRS_cache_idx |
kXRS_clnt_opts |
kXRS_error_code |
kXRS_timestamp |
kXRS_x509 |
kXRS_issuer_hash |
kXRS_x509_req |
kXRS_cipher_alg |
kXRS_md_alg |
kXRS_afsinfo |
kXRS_reserved |

Definition at line 54 of file XrdSutAux.hh.

{
kXRS_none = 0, // end-of-vector
kXRS_inactive = 1, // inactive (dropped at serialization)
kXRS_cryptomod = 3000, // 3000 Name of crypto module to use
kXRS_main, // 3001 Main buffer
kXRS_srv_seal, // 3002 Server secrets sent back as they are
kXRS_clnt_seal, // 3003 Client secrets sent back as they are
kXRS_puk, // 3004 Public Key
kXRS_cipher, // 3005 Cipher
kXRS_rtag, // 3006 Random Tag
kXRS_signed_rtag, // 3007 Random Tag signed by the client
kXRS_user, // 3008 User name
kXRS_host, // 3009 Remote Host name
kXRS_creds, // 3010 Credentials (password, ...)
kXRS_message, // 3011 Message (null-terminated string)
kXRS_srvID, // 3012 Server unique ID
kXRS_sessionID, // 3013 Handshake session ID
kXRS_version, // 3014 Package version
kXRS_status, // 3015 Status code
kXRS_localstatus, // 3016 Status code(s) saved in sealed buffer
kXRS_othercreds, // 3017 Alternative creds (e.g. other crypto)
kXRS_cache_idx, // 3018 Cache entry index
kXRS_clnt_opts, // 3019 Client options, if any
kXRS_error_code, // 3020 Error code
kXRS_timestamp, // 3021 Time stamp
kXRS_x509, // 3022 X509 certificate
kXRS_issuer_hash, // 3023 Issuer hash
kXRS_x509_req, // 3024 X509 certificate request
kXRS_cipher_alg, // 3025 Cipher algorithm (list)
kXRS_md_alg, // 3026 MD algorithm (list)
kXRS_afsinfo, // 3027 AFS information
kXRS_reserved // Reserved
};
kXRS_issuer_hash
@ kXRS_issuer_hash
Definition XrdSutAux.hh:80
kXRS_user
@ kXRS_user
Definition XrdSutAux.hh:65
kXRS_clnt_seal
@ kXRS_clnt_seal
Definition XrdSutAux.hh:60
kXRS_signed_rtag
@ kXRS_signed_rtag
Definition XrdSutAux.hh:64
kXRS_error_code
@ kXRS_error_code
Definition XrdSutAux.hh:77
kXRS_host
@ kXRS_host
Definition XrdSutAux.hh:66
kXRS_afsinfo
@ kXRS_afsinfo
Definition XrdSutAux.hh:84
kXRS_cipher_alg
@ kXRS_cipher_alg
Definition XrdSutAux.hh:82
kXRS_rtag
@ kXRS_rtag
Definition XrdSutAux.hh:63
kXRS_version
@ kXRS_version
Definition XrdSutAux.hh:71
kXRS_message
@ kXRS_message
Definition XrdSutAux.hh:68
kXRS_x509
@ kXRS_x509
Definition XrdSutAux.hh:79
kXRS_puk
@ kXRS_puk
Definition XrdSutAux.hh:61
kXRS_cache_idx
@ kXRS_cache_idx
Definition XrdSutAux.hh:75
kXRS_cipher
@ kXRS_cipher
Definition XrdSutAux.hh:62
kXRS_inactive
@ kXRS_inactive
Definition XrdSutAux.hh:56
kXRS_localstatus
@ kXRS_localstatus
Definition XrdSutAux.hh:73
kXRS_timestamp
@ kXRS_timestamp
Definition XrdSutAux.hh:78
kXRS_srv_seal
@ kXRS_srv_seal
Definition XrdSutAux.hh:59
kXRS_none
@ kXRS_none
Definition XrdSutAux.hh:55
kXRS_sessionID
@ kXRS_sessionID
Definition XrdSutAux.hh:70
kXRS_status
@ kXRS_status
Definition XrdSutAux.hh:72
kXRS_main
@ kXRS_main
Definition XrdSutAux.hh:58
kXRS_srvID
@ kXRS_srvID
Definition XrdSutAux.hh:69
kXRS_x509_req
@ kXRS_x509_req
Definition XrdSutAux.hh:81
kXRS_reserved
@ kXRS_reserved
Definition XrdSutAux.hh:85
kXRS_creds
@ kXRS_creds
Definition XrdSutAux.hh:67
kXRS_md_alg
@ kXRS_md_alg
Definition XrdSutAux.hh:83
kXRS_cryptomod
@ kXRS_cryptomod
Definition XrdSutAux.hh:57
kXRS_othercreds
@ kXRS_othercreds
Definition XrdSutAux.hh:74
kXRS_clnt_opts
@ kXRS_clnt_opts
Definition XrdSutAux.hh:76

## Function Documentation

## XrdSutAskConfirm()

bool XrdSutAskConfirm | ( | const char * | msg1,
|  | bool | defact,
|  | const char * | msg2 = 0 )

Definition at line 203 of file XrdSutAux.cc.

{
// Prompt for confirmation of action
// If defined, msg1 is printed as prompt, followed by the default action
// ( [y] == do-act, for defact = true;
// [n] == do-not-act, for defact = false)
// If defined, msg2 is printed before prompting.
bool rc = defact;
if (msg2)
std::cout << msg2;
XrdOucString ask;
XrdOucString prompt = defact ? " [y]: " : " [n]: ";
if (msg1)
prompt.insert(msg1,0);
XrdSutGetLine(ask,prompt.c_str());
ask.lower(0);
if (ask.length()) {
if (defact && (ask == 'n' || ask == "no")) {
rc = 0;
} else if (!defact && (ask == 'y' || ask == "yes")) {
rc = 1;
}
}
// we are done
return rc;
}
XrdSutGetLine
int XrdSutGetLine(XrdOucString &line, const char *prompt)
Definition XrdSutAux.cc:179
XrdOucString
Definition XrdOucString.hh:252
XrdOucString::insert
void insert(const int i, int start=-1)
Definition XrdOucString.cc:691
XrdOucString::length
int length() const
Definition XrdOucString.hh:279
XrdOucString::lower
void lower(int pos, int size=0)
Definition XrdOucString.cc:886
XrdOucString::c_str
const char * c_str() const
Definition XrdOucString.hh:278

References XrdOucString::c_str(), XrdOucString::insert(), XrdOucString::length(), XrdOucString::lower(), and XrdSutGetLine().

Here is the call graph for this function:

## XrdSutBuckStr()

const char * XrdSutBuckStr | ( | int | kbck | ) |

Definition at line 121 of file XrdSutAux.cc.

{
// Return bucket string
static const char *ukn = "Unknown";
kbck = (kbck < 0) ? 0 : kbck;
kbck = (kbck > kXRS_reserved) ? 0 : kbck;
kbck = (kbck >= kXRS_cryptomod) ? (kbck - kXRS_cryptomod + 2) : kbck;
if (kbck < 0 || kbck > (kXRS_reserved - kXRS_cryptomod + 2))
return ukn;
else
return gXRSBucketTypes[kbck];
}
gXRSBucketTypes
static const char * gXRSBucketTypes[]
Definition XrdSutAux.cc:49

References gXRSBucketTypes, kXRS_cryptomod, and kXRS_reserved.

Referenced by XrdSutBuffer::XrdSutBuffer(), XrdSecProtocolgsi::Authenticate(), XrdSutBucket::Dump(), XrdSecProtocolgsi::getCredentials(), XrdSecProtocolpwd::getCredentials(), XrdSutBuffer::MarshalBucket(), and XrdSutBuffer::UnmarshalBucket().

Here is the caller graph for this function:

## XrdSutExpand()

int XrdSutExpand | ( | XrdOucString & | path | ) |

Definition at line 360 of file XrdSutAux.cc.

{
// Expand '~' or $PWD for incomplete absolute path specification
// Returns 0 in case of success, -EINVAL if path is not defined;
// -errno if failure of the pwnam functions; -ENOENT if PWD is not
// defined
EPNAME("Expand");
// Path must be defined
if (!path.length())
return -EINVAL;
// If path is absolute, do nothing
if (path[0] == '/')
return 0;
if (path[0] == '~') {
XrdOucString unam, home;
XrdOucString sdir(path);
int iu = path.find('/');
if (iu != STR_NPOS) {
if (iu > 1)
unam.assign(path, 1, iu-1);
sdir.erase(0, iu);
} else
sdir = '/';
if (unam.length() > 0) {
struct passwd *pw;
XrdSysPwd thePwd(unam.c_str(), &pw);
if (!pw) {
DEBUG("cannot pwnam information for local user "<<
((unam.length() > 0) ? unam : XrdOucString("")));
return -errno;
}
home = pw->pw_dir;
} else
home = XrdSutHome();
if (home.length() > 0) {
sdir.insert(home.c_str(),0);
path = sdir;
}
} else {
// relative path, add local dir
char *pwd = getenv("PWD");
if (pwd) {
path.insert('/',0);
path.insert(pwd,0);
path.erase("//");
} else {
DEBUG("PWD undefined ");
return -ENOENT;
}
}
return 0;
}
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
STR_NPOS
#define STR_NPOS
Definition XrdOucString.hh:250
XrdSutHome
const char * XrdSutHome()
Definition XrdSutAux.cc:459
XrdOucString::assign
void assign(const char *s, int j, int k=-1)
Definition XrdOucString.cc:511
XrdOucString::erase
int erase(int start=0, int size=0)
Definition XrdOucString.cc:827
XrdOucString::find
int find(const char c, int start=0, bool forward=1)
Definition XrdOucString.cc:260
XrdSysPwd
Definition XrdSysPwd.hh:37

References XrdOucString::assign(), XrdOucString::c_str(), DEBUG, EPNAME, XrdOucString::erase(), XrdOucString::find(), XrdOucString::insert(), XrdOucString::length(), STR_NPOS, and XrdSutHome().

Referenced by XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), ParseArguments(), and XrdSutMkdir().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSutFromHex()

int XrdSutFromHex | ( | const char * | in,
|  | char * | out,
|  | int & | lout )

Definition at line 268 of file XrdSutAux.cc.

{
// Content of the hexadecimal, null-terminated, string at in, is
// transformed into lout bytes returned in out.
// The output buffer should be allocated by the caller to contain
// at least lin/2 bytes if lin=strlen(in) is even, and lin/2+1 bytes
// if lin is odd (in this case an additional char equal 0 is appended
// to in).
// Return 0 in case of success, -1 in case of error (errno set to EINVAL if
// any of in or out are not defined).
lout = 0;
if (!in || !out) {
errno = EINVAL;
return -1;
}
int lin = strlen(in);
char st[3] = {0};
int i = 0, k = 0;
for ( ; i<lin; i += 2) {
st[0] = in[i];
st[1] = ((i+1) < lin) ? in[i+1] : 0;
unsigned int c;
sscanf(st,"%x",&c);
out[k++] = (char)(0x000000FF & c);
}
lout = k;
return 0;
}

Referenced by XrdCryptoBasic::FromHex().

Here is the caller graph for this function:

## XrdSutGetLine()

int XrdSutGetLine | ( | XrdOucString & | line,
|  | const char * | prompt = 0 )

Definition at line 179 of file XrdSutAux.cc.

{
// Get line from main input stream.
// Prompt 'prompt' if this is defined.
// Returns number of chars entered.
// NB: at most XrdSutMAXBUF-1 chars will be accepted
char bin[XrdSutMAXBUF] = {0};
// Print prompt, if requested
if (prompt)
std::cout << prompt;
// Get line
std::cin.getline(bin,XrdSutMAXBUF-1);
// Fill input
line = bin;
return line.length();
}
XrdSutMAXBUF
#define XrdSutMAXBUF
Definition XrdSutAux.hh:48

References XrdOucString::length(), and XrdSutMAXBUF.

Referenced by AskConfirm(), main(), and XrdSutAskConfirm().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSutGetPass()

int XrdSutGetPass | ( | const char * | prompt,
|  | XrdOucString & | passwd )

Definition at line 150 of file XrdSutAux.cc.

{
// Get password from command line using getpass
// *** Use only if you cannot provide a better alternative ***
// User will be prompted for 'prompt'; the entered password
// is returned in 'passwd'.
// Returns 0 if ok, -1 if any error occurs.
EPNAME("GetPass");
char *pw = getpass(prompt);
if (pw) {
// Get rid of special chars, if any
int k = 0, i = 0, len = strlen(pw);
for (; i<len ; i++)
if (pw[i] > 0x20) pw[k++] = pw[i];
pw[k] = 0;
passwd = pw;
XrdSutMemSet((void *)pw,0,len);
} else {
DEBUG("error from getpass");
return -1;
}
return 0;
}
XrdSutMemSet
volatile void * XrdSutMemSet(volatile void *dst, int c, int len)
Definition XrdSutAux.cc:140

References DEBUG, EPNAME, and XrdSutMemSet().

Referenced by AddPassword(), and AddPassword().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSutHome()

const char * XrdSutHome | ( |  | ) |

Definition at line 459 of file XrdSutAux.cc.

{
// Gets the home directory preferentially from HOME or from pwd entry
EPNAME("Home");
// Use the save value, if any
static XrdOucString homedir;
if (homedir.length() <= 0) {
// Check the HOME environment variable
if (getenv("HOME"))
homedir = getenv("HOME");
if (homedir.length() <= 0) {
struct passwd *pw;
XrdSysPwd thePwd(getuid(), &pw);
if (pw) homedir = pw->pw_dir;
}
if (homedir.length() <= 0)
DEBUG("Warning: home directory undefined! ");
}
// Done
return homedir.c_str();
}

References XrdOucString::c_str(), DEBUG, EPNAME, and XrdOucString::length().

Referenced by XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), ParseArguments(), and XrdSutExpand().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSutMemSet()

volatile void * XrdSutMemSet | ( | volatile void * | dst,
|  | int | c,
|  | int | len )

Definition at line 140 of file XrdSutAux.cc.

{
return memset((void*)dst, c, len);
}

Referenced by XrdSutGetPass().

Here is the caller graph for this function:

## XrdSutMkdir()

int XrdSutMkdir | ( | const char * | dir,
|  | unsigned int | mode = 0777,
|  | const char * | opt = "-p" )

Definition at line 487 of file XrdSutAux.cc.

{
// Make directory dir
// mode specifies permissions
// opt == "-p" : make parent directories as needed
if (!dir) {
errno = EINVAL;
return -1;
}
if (!strncmp(opt,"-p",2)) {
//
// make also parent directories, if needed
XrdOucString dd(dir);
XrdSutExpand(dd);
if (dd[dd.length()-1] != '/')
dd.append('/');
int lsl = dd.find('/',1);
while (lsl > -1) {
XrdOucString pd(dd,0,lsl-1);
struct stat st;
if (stat(pd.c_str(),&st) == -1) {
if (errno == ENOENT) {
// path does not exists: create it
if (mkdir(pd.c_str(),mode) != 0)
return -1;
} else {
return -1;
}
}
// Go to next
lsl = dd.find('/',lsl+1);
}
} else {
return mkdir(dir,mode);
}
return 0;
}
mkdir
#define mkdir(a, b)
Definition XrdPosix.hh:74
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdSutExpand
int XrdSutExpand(XrdOucString &path)
Definition XrdSutAux.cc:360

References XrdOucString::append(), XrdOucString::c_str(), XrdOucString::find(), XrdOucString::length(), mkdir, stat, and XrdSutExpand().

Referenced by XrdSecProtocolpwd::Init(), ParseArguments(), SavePasswd(), and SavePuk().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSutParseTime()

int XrdSutParseTime | ( | const char * | tstr,
|  | int | opt = 0 )

Definition at line 534 of file XrdSutAux.cc.

{
// Parse time string of the form "<val1><unit1>:<val2><unit2>:..."
// with <val> any integer and <unit> one of the following chars:
// 'y' for years
// 'd' for days
// 'h' for hours
// 'm' for minutes
// 's' for seconds
// (e.g. "34d:10h:20s")
// If opt == 1, assume a string in the form ".hh"[:<ss>[:<mm>]]"
// (e.g. "12:24:35" for 12 hours, 24 minutes and 35 secs)
// Return the corresponding number of seconds
EPNAME("ParseTime");
XrdOucString ts = tstr;
XrdOucString fr = "";
int i = 0;
int tsec = 0;
// Parse list
if (ts.length()) {
int ls = 0;
int ld = ts.find(':',1);
ld = (ld == -1) ? ts.length() - 1 : ld;
while (ld >= ls) {
fr.assign(ts, ls, ld);
fr.erase(":");
// Check this fraction
if (opt == 0) {
if (fr.length() > 1) {
// The unit must be known
char u = fr[fr.length()-1];
fr.erase(fr.length()-1);
if (u == 'y') {
tsec += atoi(fr.c_str())*31536000;
} else if (u == 'd') {
tsec += atoi(fr.c_str())*86400;
} else if (u == 'h') {
tsec += atoi(fr.c_str())*3600;
} else if (u == 'm') {
tsec += atoi(fr.c_str())*60;
} else if (u == 's') {
tsec += atoi(fr.c_str());
} else {
DEBUG("unknown unit: "<<u);
}
} else {
DEBUG("Incomplete fraction: "<<fr.c_str());
}
} else {
if (i == 0) {
tsec += atoi(fr.c_str())*3600;
} else if (i == 1) {
tsec += atoi(fr.c_str())*60;
} else if (i == 2) {
tsec += atoi(fr.c_str());
}
}
i++;
ls = ld + 1;
ld = ts.find(':',ls);
ld = (ld == -1) ? ts.length() - 1 : ld;
}
}
return tsec;
}
ts
static std::string ts()
timestamp output for logging messages
Definition XrdCephOss.cc:53

References XrdOucString::assign(), XrdOucString::c_str(), DEBUG, EPNAME, XrdOucString::erase(), XrdOucString::length(), and ts().

Referenced by main(), and XrdSecProtocolpwdInit().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSutResolve()

int XrdSutResolve | ( | XrdOucString & | path,
|  | const char * | ho,
|  | const char * | vo,
|  | const char * | gr,
|  | const char * | us )

Definition at line 419 of file XrdSutAux.cc.

{
// Resolve templates <host>, <vo>, <group>, <user> (if any)
// Returns 0 in case of success, -EINVAL if path is not defined.
// Path must be defined
if (!path.length())
return -EINVAL;
// No templates, nothing to do
if (path.find("<") == STR_NPOS)
return 0;
// Replace <host>, if defined
if (ho && strlen(ho) > 0) path.replace("<host>", ho);
// Replace <vo>, if defined
if (vo && strlen(vo) > 0) path.replace("<vo>", vo);
// Replace <group>, if defined
if (gr && strlen(gr) > 0) path.replace("<group>", gr);
// Replace <user>, if defined
if (us && strlen(us) > 0) path.replace("<user>", us);
// Replace <rtag>, if defined
if (path.find("<rtag>") != STR_NPOS) {
XrdOucString rtag;
XrdSutRndm::GetString(2,6,rtag);
path.replace("<rtag>", rtag);
}
// Done
return 0;
}
XrdOucString::replace
int replace(const char *s1, const char *s2, int from=0, int to=-1)
Definition XrdOucString.cc:733
XrdSutRndm::GetString
static int GetString(int opt, int len, XrdOucString &s)
Definition XrdSutRndm.cc:120

References XrdOucString::find(), XrdSutRndm::GetString(), XrdOucString::length(), XrdOucString::replace(), and STR_NPOS.

Here is the call graph for this function:

## XrdSutSetTrace()

void XrdSutSetTrace | ( | kXR_int32 | trace | ) |

Definition at line 93 of file XrdSutAux.cc.

{
// Set trace flags according to 'trace'
//
// Initiate error logging and tracing
eDest.logger(&Logger);
if (!sutTrace)
sutTrace = new XrdOucTrace(&eDest);
if (sutTrace) {
// Set debug mask
sutTrace->What = 0;
// Low level only
if ((trace & sutTRACE_Notify))
sutTrace->What |= sutTRACE_Notify;
// Medium level
if ((trace & sutTRACE_Debug))
sutTrace->What |= (sutTRACE_Notify | sutTRACE_Debug);
// High level
if ((trace & sutTRACE_Dump))
sutTrace->What |= sutTRACE_ALL;
}
}
Logger
static XrdSysLogger Logger
Definition XrdCryptoAux.cc:37
eDest
static XrdSysError eDest(0,"crypto_")
sutTrace
XrdOucTrace * sutTrace
Definition XrdSutAux.cc:87
sutTRACE_ALL
#define sutTRACE_ALL
Definition XrdSutAux.hh:97
sutTRACE_Notify
#define sutTRACE_Notify
Definition XrdSutAux.hh:100
sutTRACE_Debug
#define sutTRACE_Debug
Definition XrdSutAux.hh:99
sutTRACE_Dump
#define sutTRACE_Dump
Definition XrdSutAux.hh:98
XrdOucTrace
Definition XrdOucTrace.hh:36

References eDest, Logger, sutTrace, sutTRACE_ALL, sutTRACE_Debug, sutTRACE_Dump, and sutTRACE_Notify.

Referenced by XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), and main().

Here is the caller graph for this function:

## XrdSutTimeString()

int XrdSutTimeString | ( | int | t,
|  | char * | st,
|  | int | opt = 0 )

Definition at line 305 of file XrdSutAux.cc.

{
// Trasform a time in secs since 1Jan1970 in a string of the format
// 24Apr2006:09:10:23 (opt = 0, default)
// 24Apr2006-091023 (opt = 1)
// The buffer st must be supplied by the caller to contain at least 20.
// This length is returned when calling the function with t=-1
static const char month[12][4] = {"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
static short flen = strlen("24Apr2006:09:10:23");
// Check if the length is required
if (t == -1)
return (flen+1);
// Now check inputs
if (t < 0 || !st)
return -1;
// Get the breakdown
struct tm tst;
time_t ttmp = t;
if (!localtime_r(&ttmp,&tst))
return -2;
// Now fill the output
if (opt == 1) {
sprintf(st,"%2d%3s%4d-%2d%2d%2d",tst.tm_mday,month[tst.tm_mon],
1900+tst.tm_year,
tst.tm_hour,tst.tm_min,tst.tm_sec);
// Make sure is null terminated at the right point
st[flen-2] = '\0';
} else {
sprintf(st,"%2d%3s%4d:%2d:%2d:%2d",tst.tm_mday,month[tst.tm_mon],
1900+tst.tm_year,
tst.tm_hour,tst.tm_min,tst.tm_sec);
}
// Make sure there are no empty spaces
if (st[0] == 0x20) st[0] = 0x30;
int i = 10;
for (; i <= 16; i++ )
if (st[i] == 0x20) st[i] = 0x30;
// Null termination
st[flen] = 0;
// Ok
return 0;
}

Referenced by XrdSutCacheEntry::AsString(), XrdSutPFEntry::AsString(), XrdSutPFile::Browse(), XrdSutPFCache::Dump(), and SavePuk().

Here is the caller graph for this function:

## XrdSutToHex()

int XrdSutToHex | ( | const char * | in,
|  | int | lin,
|  | char * | out )

Definition at line 235 of file XrdSutAux.cc.

{
// Content of lin bytes at in are transformed into an hexadecimal,
// null-terminated, string of length 2*lin; the result is returned
// in the buffer pointed by out, which must be allocated by the caller
// to contain at least 2*lin+1 bytes.
// Return 0 in case of success, -1 in case of error (errno set to EINVAL if
// any of in or out are not defined).
if (!in || !out) {
errno = EINVAL;
return -1;
}
int lbuf = 2*lin+1;
int i = 0;
out[0] = 0;
for ( ; i < lin; i++)
{
char buff[3];
sprintf(buff, "%02x", (0xFF & in[i]));
strncat(out, buff, 3);
}
// Null termination
out[lbuf-1] = 0;
// ok
return 0;
}

Referenced by XrdCryptoBasic::AsHexString(), XrdSecProtocolpwd::Authenticate(), and main().

Here is the caller graph for this function: