21#include "RConfigure.h"
53#if !defined(R__WIN32) && !defined(R__MACOSX) && !defined(R__FBSD) && \
60#if defined(R__LINUX) || defined(R__FBSD) || defined(R__OBSD)
69extern "C" char *crypt(
const char *,
const char *);
74# include <openssl/bio.h>
75# include <openssl/err.h>
76# include <openssl/pem.h>
77# include <openssl/rand.h>
78# include <openssl/rsa.h>
79# include <openssl/ssl.h>
80# include <openssl/blowfish.h>
88 static BF_KEY fgBFKey;
94 "Unsupported",
"Unsupported",
"Unsupported" };
135 int frnd = open(
"/dev/urandom", O_RDONLY);
136 if (frnd < 0) frnd = open(
"/dev/random", O_RDONLY);
139 ssize_t rs = read(frnd, (
void *) &
r,
sizeof(
int));
142 if (rs ==
sizeof(
int))
return r;
144 Printf(
"+++ERROR+++ : auth_rand: neither /dev/urandom nor /dev/random are available or readable!");
146 if (gettimeofday(&tv,0) == 0) {
148 memcpy((
void *)&
t1, (
void *)&tv.tv_sec,
sizeof(
int));
149 memcpy((
void *)&t2, (
void *)&tv.tv_usec,
sizeof(
int));
165 const char *
proto,
const char *user)
172 if (
gROOT->IsProofServ())
189 Info(
"TAuthenticate",
"Enter: local host: %s, user is: %s (proto: %s)",
198 if ((pdd = strstr(sproto,
":")) != 0) {
199 int rproto = atoi(pdd + 1);
201 if (strstr(sproto,
"root") != 0) {
218 if (strstr(sproto,
"proof") != 0) {
233 Info(
"TAuthenticate",
234 "service: %s (remote protocol: %d): fVersion: %d", sproto,
244 if (user && strlen(user) > 0) {
250 checkUser = u->
fUser;
269 Info(
"TAuthenticate",
"RSA key: default type %d",
fgRSAKey);
283 fqdnsrv.
Form(
"%s:%d",fqdn.
Data(),servtype);
289 Info(
"TAuthenticate",
290 "number of HostAuth Instantiations in memory: %d",
317 if (!strncmp(tmp.
Data(),
"up",2))
319 else if (!strncmp(tmp.
Data(),
"s",1))
321 else if (!strncmp(tmp.
Data(),
"k",1))
323 else if (!strncmp(tmp.
Data(),
"g",1))
325 else if (!strncmp(tmp.
Data(),
"h",1))
327 else if (!strncmp(tmp.
Data(),
"ug",2))
329 if (sec > -1 && sec <
kMAXSEC) {
355 Info(
"CatchTimeOut",
"%d sec timeout expired (protocol: %s)",
379 char noSupport[80] = { 0 };
380 char triedMeth[80] = { 0 };
396 alarm->
Connect(
"Timeout()",
"TAuthenticate",
this,
"CatchTimeOut()");
404 Info(
"Authenticate",
"try #: %d", ntry);
415 "trying authentication: method:%d, default details:%s",
419 if (triedMeth[0] !=
'\0')
420 (
void) strlcat(triedMeth,
" ",
sizeof(triedMeth) - 1);
461 Error(
"Authenticate",
462 "unable to get user name for UsrPwd authentication");
468 if (alarm) alarm->
Stop();
480 Int_t remloc = nmet - ntry;
482 Info(
"Authenticate",
"remloc: %d, ntry: %d, meth: %d, fSecurity: %d",
508 "negotiation not supported remotely: try next method, if any");
509 if (meth < nmet - 1) {
526 "after failed attempt: kind= %d, stat= %d", kind, stat);
533 char *answer =
new char[len];
543 "strings with accepted methods not received (%d:%d)",
546 sscanf(answer,
"%d %d %d %d %d %d", &rMth[0], &rMth[1],
547 &rMth[2], &rMth[3], &rMth[4], &rMth[5]);
548 if (
gDebug > 0 && remloc > 0)
550 "remotely allowed methods not yet tried: %s",
553 }
else if (stat == 0) {
555 "no more methods accepted remotely to be tried");
568 std::string available{};
570 for (i = 0; i < remMeth; i++) {
571 for (j = 0; j < nmet; j++) {
581 if (methfound)
break;
583 if (methfound)
break;
587 Warning(
"Authenticate",
"no match with those locally available: %s", available.c_str());
604 "method not even started: insufficient or wrong info: %s",
605 "try with next method, if any");
622 "status code -2 not expected from old daemons");
634 Info(
"Authenticate",
"got a timeout");
636 if (meth < nmet - 1) {
646 Info(
"Authenticate",
"unknown status code: %d - assume failure",st);
660 if (strlen(noSupport) > 0)
661 Info(
"Authenticate",
"attempted methods %s are not supported"
662 " by remote server version", noSupport);
664 "failure: list of attempted methods: %s", triedMeth);
688 Info(
"SetEnvironment",
689 "setting environment: fSecurity:%d, fDetails:%s",
fSecurity,
700 char pt[5] = { 0 }, ru[5] = { 0 };
701 Int_t hh = 0, mm = 0;
706 if ((ptr = strstr(
fDetails,
"pt:")) != 0) {
707 sscanf(ptr + 3,
"%4s %8191s",
pt, usdef);
709 if (!strncasecmp(
gEnv->
GetValue(usrPromptDef,
""),
"no",2) ||
716 if ((ptr = strstr(
fDetails,
"ru:")) != 0) {
717 sscanf(ptr + 3,
"%4s %8191s", ru, usdef);
719 if (!strncasecmp(
gEnv->
GetValue(usrReUseDef,
""),
"no",2) ||
728 if ((pd = hours.
Index(
":")) > -1) {
732 hh = atoi(hours.
Data());
733 mm = atoi(minutes.
Data());
735 hh = atoi(hours.
Data());
741 if ((ptr = strstr(
fDetails,
"us:")) != 0)
742 sscanf(ptr + 3,
"%8191s %8191s", us, usdef);
743 if ((ptr = strstr(
fDetails,
"cp:")) != 0)
744 sscanf(ptr + 3,
"%8191s %8191s", cp, usdef);
746 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s cp:%s",
749 if ((ptr = strstr(
fDetails,
"us:")) != 0)
750 sscanf(ptr + 3,
"%8191s %8191s", us, usdef);
752 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s",
757 if (!strncasecmp(
pt,
"yes",3) || !strncmp(
pt,
"1", 1))
761 if (!
gROOT->IsProofServ()) {
763 if (!strncasecmp(ru,
"no",2) || !strncmp(ru,
"0",1))
774 if (!strncmp(cp,
"no", 2) || !strncmp(cp,
"0", 1))
786 if (strlen(usdef) > 0) {
816 Error(
"GetUserPasswd",
"SRP no longer supported by ROOT");
821 Info(
"GetUserPasswd",
"Enter: User: '%s' Hash:%d SRP:%d",
825 if (user ==
"" &&
fgUser !=
"")
836 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
846 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
852 if (user ==
"" ||
passwd ==
"") {
854 Info(
"GetUserPasswd",
"Checking .netrc family ...");
858 Info(
"GetUserPasswd",
"From .netrc family: User: '%s' Hash:%d",
867 Error(
"GetUserPasswd",
"user name not set");
914 Error(
"CheckNetrc",
"SRP no longer supported by ROOT");
939 bool mode0600 =
true;
944 FILE *fd = fopen(net,
"r");
946 while (fgets(
line,
sizeof(
line), fd) != 0) {
950 int nword = sscanf(
line,
"%63s %63s %63s %63s %63s %63s",
951 word[0], word[1], word[2], word[3], word[4], word[5]);
954 if (strcmp(word[0],
"machine"))
956 if (strcmp(word[2],
"login"))
958 if (strcmp(word[4],
"password") && strcmp(word[4],
"password-hash"))
970 if (!strcmp(word[4],
"password-hash"))
975 if (!strcmp(word[3], user.
Data())) {
977 if (!strcmp(word[4],
"password-hash"))
988 "file %s exists but has not 0600 permission", net);
992 if (
first && !result) {
1046 ::Error(
"Krb5Auth",
"Kerberos5 is no longer supported by ROOT");
1073 if (idx < 0 || idx >
kMAXSEC-1) {
1074 ::Error(
"Authenticate::GetAuthMethod",
"idx out of bounds (%d)", idx);
1088 if (meth && meth[0]) {
1117 if (isatty(0) == 0 || isatty(1) == 0) {
1119 "not tty: cannot prompt for user, returning default");
1126 const char *usrIn = Getline(
Form(
"Name (%s:%s): ", remote, user));
1146 if (isatty(0) == 0 || isatty(1) == 0) {
1147 ::Warning(
"TAuthenticate::PromptPasswd",
1148 "not tty: cannot prompt for passwd, returning -1");
1149 static char noint[4] = {
"-1"};
1154 const char *pw = buf;
1159 gROOT->GetPluginManager()->FindHandler(
"TGPasswdDialog"))) {
1163 "could not load plugin for the password dialog box");
1173 while (
gROOT->IsInterrupted())
1177 Gl_config(
"noecho", 1);
1178 pw = Getline(prompt);
1179 Gl_config(
"noecho", 0);
1206 key = (key >= 0 && key <= 1) ? key : 0;
1223 if (key >= 0 && key <= 1)
1276 lasterr =
"(last error only; re-run with gDebug > 0 for more details)";
1280 if (
gDebug > 0 || forceprint) {
1282 ::Error(
Form(
"TAuthenticate::%s", where),
"%s %s",
1285 ::Error(
Form(
"TAuthenticate::%s", where),
1286 "unknown error code: server must be running a newer ROOT version %s",
1304 if (user && user[0])
1335 ::Error(
"SetGlobalSRPPwd",
"SRP no longer supported by ROOT");
1364 if (defaultuser && defaultuser[0])
1406 ::Error(
"Krb5Auth",
"Kerberos5 is no longer supported by ROOT");
1415 ::Error(
"GlobusAuth",
"Globus is no longer supported by ROOT");
1423 ::Error(
"SshAuth",
"SSH is no longer supported by ROOT");
1432 ::Error(
"GetSshUser",
"SSH is no longer supported by ROOT");
1453 if (!strcmp(href,
"*"))
1462 if (rename.
Index(href,&len) != -1 || strstr(href,
"-"))
1467 if (strstr(href,
"*"))
1479 ::Info(
"TAuthenticate::CheckHost",
"checking host IP: %s", theHost.
Data());
1490 if (pos > 0 && pos != (
Ssiz_t)(theHost.
Length()-strlen(href)))
1502 ::Error(
"RfioAuth",
"RfioAuth is no longer supported by ROOT");
1516 Info(
"ClearAuth",
"enter: user: %s (passwd hashed?: %d)",
1528 Info(
"ClearAuth",
"ru:%d pt:%d cp:%d ns:%d rk:%d",
1557 options.
Form(
"%d %ld %s %ld %s", opt,
1579 Info(
"ClearAuth",
"anonymous user");
1588 char ctag[11] = {0};
1589 if (anon == 0 && cryptopt == 1) {
1596 "problems recvn RSA key flag: got message %d, flag: %d",
1602 Info(
"ClearAuth",
"get key request ...");
1616 Warning(
"ClearAuth",
"problems secure-receiving salt -"
1617 " may result in corrupted salt");
1618 Warning(
"ClearAuth",
"switch off reuse for this session");
1626 while (ltmp && tmpsalt[ltmp-1] !=
'#') ltmp--;
1628 if (tmpsalt[ltmp-1] ==
'#' &&
1629 tmpsalt[ltmp-10] ==
'#') {
1630 strlcpy(ctag,&tmpsalt[ltmp-10],11);
1649 Info(
"ClearAuth",
"got salt: '%s' (len: %d)", salt.
Data(), slen);
1652 Info(
"ClearAuth",
"Salt not required");
1655 Warning(
"ClearAuth",
"problems secure-receiving rndmtag -"
1656 " may result in corrupted rndmtag");
1659 strlcpy(ctag, tmptag, 11);
1685 if (localFQDN ==
"") {
1693 "automatically generated anonymous passwd: %s",
1699 if (prompt == 1 || pashash.
Length() == 0) {
1708 Error(
"ClearAuth",
"password not set");
1713 if (needsalt && !pwdhash) {
1739 if (anon == 0 && cryptopt == 1) {
1751 Warning(
"ClearAuth",
"problems secure-sending pass hash"
1752 " - may result in authentication failure");
1759 for (
int i = 0; i <
passwd.Length(); i++) {
1773 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
1785 "problems recvn (user,offset) length (%d:%d bytes:%d)",
1790 int reclen = (stat+1 > 256) ? 256 : stat+1;
1791 if ((nrec =
fSocket->
Recv(answer, reclen, kind)) < 0)
1795 "username and offset not received (%d:%d)", kind,
1801 sscanf(answer,
"%127s %d", lUser, &offset);
1804 "received from server: user: %s, offset: %d (%s)", lUser,
1811 if (reuse == 1 && offset > -1) {
1813 if (cryptopt == 1) {
1816 "problems secure-receiving token -"
1817 " may result in corrupted token");
1822 token =
new char[tlen];
1828 Warning(
"ClearAuth",
"token not received (%d:%d)", kind,
1831 for (
int i = 0; i < (
int) strlen(token); i++) {
1832 token[i] = ~token[i];
1837 Info(
"ClearAuth",
"received from server: token: '%s' ",
1899 "%s@%s does not accept connections from %s@%s",
1906 "%s@%s does not accept %s authentication from %s@%s",
1923 Error(
"ClearAuth",
"password not set");
1925 if (
fUser ==
"anonymous" ||
fUser ==
"rootd") {
1926 if (!
passwd.Contains(
"@")) {
1928 "please use passwd of form: user@host.do.main");
1939 for (
int i = 0; i <
passwd.Length(); i++) {
1952 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
1981 ::Info(
"TAuthenticate::GetHostAuth",
"enter ... %s ... %s", host, user);
1987 char *ps = (
char *)strstr(host,
":");
1989 srvtyp = atoi(ps+1);
1993 if (strncmp(host,
"default",7) && !hostFQDN.
Contains(
"*")) {
2005 if (!strncasecmp(opt,
"P",1)) {
2013 while ((ai = (
THostAuth *) (*next)())) {
2015 ai->
Print(
"Authenticate::GetHostAuth");
2018 if (!(serverOK = (ai->
GetServer() == -1) ||
2023 if (!strcmp(ai->
GetHost(),
"default") && serverOK && notFound)
2033 if (hostFQDN == ai->
GetHost() &&
2055 ::Info(
"TAuthenticate::HasHostAuth",
"enter ... %s ... %s", host, user);
2061 char *ps = (
char *)strstr(host,
":");
2063 srvtyp = atoi(ps+1);
2066 if (strncmp(host,
"default",7) && !hostFQDN.
Contains(
"*")) {
2073 if (!strncasecmp(opt,
"P",1)) {
2078 while ((ai = (
THostAuth *) (*next)())) {
2080 if (hostFQDN == ai->
GetHost() &&
2102 ::Info(
"TAuthenticate::FileExpand",
"enter ... '%s' ... 0x%lx", fexp, (
Long_t)ftmp);
2104 fin = fopen(fexp,
"r");
2108 while (fgets(
line,
sizeof(
line), fin) != 0) {
2112 if (
line[strlen(
line) - 1] ==
'\n')
2115 ::Info(
"TAuthenticate::FileExpand",
"read line ... '%s'",
line);
2116 int nw = sscanf(
line,
"%19s %8191s", cinc, fileinc);
2119 if (strcmp(cinc,
"include") != 0) {
2121 fprintf(ftmp,
"%s\n",
line);
2128 sscanf(ln.
Data(),
"%19s %8191s", cinc, fileinc);
2131 if (fileinc[0] ==
'$') {
2148 if (fileinc[0] ==
'~') {
2152 char *ffull =
new char[flen];
2162 "file specified by 'include' cannot be open or read (%s)",
2177 const char copt[2][5] = {
"no",
"yes" };
2180 ::Info(
"TAuthenticate::GetDefaultDetails",
2181 "enter ... %d ...pt:%d ... '%s'", sec, opt, usr);
2183 if (opt < 0 || opt > 1)
2188 if (!usr[0] || !strncmp(usr,
"*",1))
2197 ::Info(
"TAuthenticate::GetDefaultDetails",
"returning ... %s", temp);
2207 if (!strncasecmp(opt,
"P",1))
2236 " +--------------------------- BEGIN --------------------------------+");
2241 " + List fgProofAuthInfo has %4d members +",
2246 " +------------------------------------------------------------------+");
2254 " + List fgAuthInfo has %4d members +",
2259 " +------------------------------------------------------------------+");
2268 " +---------------------------- END ---------------------------------+");
2284 Info(
"AuthExists",
"%d: enter: msg: %d options: '%s'",
2285 method,*message, options);
2297 (*checksecctx)(username,secctx) == 1)
2310 (*checksecctx)(username,secctx) == 1) {
2327 "found valid TSecContext: offset: %d token: '%s'",
2328 offset, token.
Data());
2339 Int_t reuse = *rflag;
2340 if (reuse == 1 && offset > -1) {
2349 Int_t stat = 1, kind;
2354 Warning(
"AuthExists",
"protocol error: expecting %d got %d"
2360 Info(
"AuthExists",
"offset OK");
2364 Info(
"AuthExists",
"key type: %d", rsaKey);
2380 Warning(
"AuthExists",
"problems secure-sending token %s",
2381 "- may trigger problems in proofing Id ");
2386 for (
int i = 0; i < token.
Length(); i++) {
2387 char inv = ~token(i);
2395 Info(
"AuthExists",
"offset not OK - rerun authentication");
2406 Info(
"AuthExists",
"%d: after msg %d: kind= %d, stat= %d",
2407 method,*message, kind, stat);
2420 Error(
"AuthExists",
"%s@%s does not accept connections from %s@%s",
2426 "%s@%s does not accept %s authentication from %s@%s",
2444 Info(
"AuthExists",
"valid authentication exists");
2446 Info(
"AuthExists",
"valid authentication exists: offset changed");
2448 Info(
"AuthExists",
"remote access authorized by /etc/hosts.equiv");
2450 Info(
"AuthExists",
"no authentication required remotely");
2480 const char *randdev =
"/dev/urandom";
2483 if ((fd = open(randdev, O_RDONLY)) != -1) {
2485 ::Info(
"InitRandom",
"taking seed from %s", randdev);
2486 if (read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
2487 ::Warning(
"InitRandom",
"could not read seed from %s", randdev);
2491 ::Info(
"InitRandom",
"%s not available: using time()", randdev);
2506 Info(
"GenRSAKeys",
"enter");
2510 Info(
"GenRSAKeys",
"Keys prviously generated - return");
2532 Info(
"GenRSAKeys",
"SSL: Generate Blowfish key");
2541 OpenSSL_add_all_ciphers();
2547 nbits = (nbits >= 128) ? nbits : 128;
2550 nbits = (nbits <= 15912) ? nbits : 15912;
2553 Int_t klen = nbits / 8 ;
2557 RAND_seed(rbuf,strlen(rbuf));
2566 BF_set_key(&fgBFKey, klen, (
const unsigned char *)rbuf);
2575 Int_t l_n = 0, l_d = 0;
2582 Int_t nAttempts = 0;
2588 if (
gDebug > 2 && nAttempts > 1) {
2589 Info(
"GenRSAKeys",
"retry no. %d",nAttempts);
2602 Info(
"GenRSAKeys",
"equal primes: regenerate (%d times)",nPrimes);
2610 Info(
"GenRSAKeys",
"local: p1: '%s' ", buf);
2612 Info(
"GenRSAKeys",
"local: p2: '%s' ", buf);
2617 if (
gDebug > 2 && nAttempts > 1)
2618 Info(
"GenRSAKeys",
" genrsa: unable to generate keys (%d)",
2625 l_n = strlen(buf_n);
2628 l_e = strlen(buf_e);
2631 l_d = strlen(buf_d);
2635 Info(
"GenRSAKeys",
"local: n: '%s' length: %d", buf_n, l_n);
2636 Info(
"GenRSAKeys",
"local: e: '%s' length: %d", buf_e, l_e);
2637 Info(
"GenRSAKeys",
"local: d: '%s' length: %d", buf_d, l_d);
2649 strlcpy(
test, tdum, lTes+1);
2653 Info(
"GenRSAKeys",
"local: test string: '%s' ",
test);
2656 strlcpy(buf,
test, lTes+1);
2662 "local: length of crypted string: %d bytes", lout);
2668 Info(
"GenRSAKeys",
"local: after private/public : '%s' ", buf);
2670 if (strncmp(
test, buf, lTes))
2674 strlcpy(buf,
test, lTes+1);
2679 Info(
"GenRSAKeys",
"local: length of crypted string: %d bytes ",
2686 Info(
"GenRSAKeys",
"local: after public/private : '%s' ", buf);
2688 if (strncmp(
test, buf, lTes))
2705 Info(
"GenRSAKeys",
"local: generated keys are:");
2706 Info(
"GenRSAKeys",
"local: n: '%s' length: %d", buf_n, l_n);
2707 Info(
"GenRSAKeys",
"local: e: '%s' length: %d", buf_e, l_e);
2708 Info(
"GenRSAKeys",
"local: d: '%s' length: %d", buf_d, l_d);
2749 unsigned int iimx[4][4] = {
2750 {0x0, 0xffffff08, 0xafffffff, 0x2ffffffe},
2751 {0x0, 0x3ff0000, 0x7fffffe, 0x7fffffe},
2752 {0x0, 0x3ff0000, 0x7e, 0x7e},
2753 {0x0, 0x3ffc000, 0x7fffffe, 0x7fffffe}
2756 const char *cOpt[4] = {
"Any",
"LetNum",
"Hex",
"Crypt" };
2759 if (opt < 0 || opt > 2) {
2762 Info(
"GetRandString",
"unknown option: %d : assume 0", opt);
2765 Info(
"GetRandString",
"enter ... len: %d %s", len, cOpt[opt]);
2768 char *buf =
new char[len + 1];
2778 for (
m = 7;
m < 32;
m += 7) {
2779 i = 0x7F & (frnd >>
m);
2782 if ((iimx[opt][j] & (1 <<
l))) {
2794 Info(
"GetRandString",
"got '%s' ", buf);
2806 Int_t key,
const char *str)
2812 ::Info(
"TAuthenticate::SecureSend",
"local: enter ... (enc: %d)", enc);
2814 Int_t slen = strlen(str) + 1;
2819 strlcpy(buftmp, str, slen+1);
2829 }
else if (key == 1) {
2834 ttmp = ((ttmp + 8)/8) * 8;
2835 unsigned char iv[8];
2836 memset((
void *)&iv[0],0,8);
2837 BF_cbc_encrypt((
const unsigned char *)str, (
unsigned char *)buftmp,
2838 strlen(str), &fgBFKey, iv, BF_ENCRYPT);
2841 ::Info(
"TAuthenticate::SecureSend",
"not compiled with SSL support:"
2842 " you should not have got here!");
2846 ::Info(
"TAuthenticate::SecureSend",
"unknown key type (%d)",key);
2853 nsen = sock->
SendRaw(buftmp, ttmp);
2855 ::Info(
"TAuthenticate::SecureSend",
2856 "local: sent %d bytes (expected: %d)", nsen,ttmp);
2878 if (sock->
Recv(buflen, 20, kind) < 0)
2880 Int_t len = atoi(buflen);
2882 ::Info(
"TAuthenticate::SecureRecv",
"got len '%s' %d (msg kind: %d)",
2887 if (!strncmp(buflen,
"-1", 2))
2891 if ((nrec = sock->
RecvRaw(buftmp, len)) < 0)
2902 const size_t strSize = strlen(buftmp) + 1;
2903 *str =
new char[strSize];
2904 strlcpy(*str, buftmp, strSize);
2906 }
else if (key == 1) {
2908 unsigned char iv[8];
2909 memset((
void *)&iv[0],0,8);
2910 *str =
new char[nrec + 1];
2911 BF_cbc_encrypt((
const unsigned char *)buftmp, (
unsigned char *)(*str),
2912 nrec, &fgBFKey, iv, BF_DECRYPT);
2913 (*str)[nrec] =
'\0';
2916 ::Info(
"TAuthenticate::SecureRecv",
"not compiled with SSL support:"
2917 " you should not have got here!");
2921 ::Info(
"TAuthenticate::SecureRecv",
"unknown key type (%d)",key);
2934 R__rsa_NUMBER &rsa_d,
char **rsassl)
2940 ::Info(
"TAuthenticate::DecodeRSAPublic",
2941 "enter: string length: %ld bytes", (
Long_t)strlen(rsaPubExport));
2944 Int_t klen = strlen(rsaPubExport);
2946 ::Info(
"TAuthenticate::DecodeRSAPublic",
2947 "key too long (%d): truncate to %d",klen,
kMAXPATHLEN);
2950 memcpy(str, rsaPubExport, klen);
2959 while (str[k] == 32) k++;
2961 if (str[k] ==
'#') {
2966 char *pd1 = strstr(str,
"#");
2967 char *pd2 = pd1 ? strstr(pd1 + 1,
"#") : (
char *)0;
2968 char *pd3 = pd2 ? strstr(pd2 + 1,
"#") : (
char *)0;
2969 if (pd1 && pd2 && pd3) {
2971 int l1 = (
int) (pd2 - pd1 - 1);
2972 char *rsa_n_exp =
new char[l1 + 1];
2973 strlcpy(rsa_n_exp, pd1 + 1, l1+1);
2975 ::Info(
"TAuthenticate::DecodeRSAPublic",
2976 "got %ld bytes for rsa_n_exp", (
Long_t)strlen(rsa_n_exp));
2978 int l2 = (
int) (pd3 - pd2 - 1);
2979 char *rsa_d_exp =
new char[l2 + 1];
2980 strlcpy(rsa_d_exp, pd2 + 1, 13);
2982 ::Info(
"TAuthenticate::DecodeRSAPublic",
2983 "got %ld bytes for rsa_d_exp", (
Long_t)strlen(rsa_d_exp));
2992 ::Info(
"TAuthenticate::DecodeRSAPublic",
"bad format for input string");
3001 BIO *bpub = BIO_new(BIO_s_mem());
3004 BIO_write(bpub,(
void *)str,strlen(str));
3007 if (!(rsatmp = PEM_read_bio_RSAPublicKey(bpub, 0, 0, 0))) {
3009 ::Info(
"TAuthenticate::DecodeRSAPublic",
3010 "unable to read pub key from bio");
3013 *rsassl = (
char *)rsatmp;
3015 ::Info(
"TAuthenticate::DecodeRSAPublic",
3016 "no space allocated for output variable");
3023 ::Info(
"TAuthenticate::DecodeRSAPublic",
"not compiled with SSL support:"
3024 " you should not have got here!");
3039 ::Info(
"TAuthenticate::SetRSAPublic",
3040 "enter: string length %ld bytes", (
Long_t)strlen(rsaPubExport));
3050 while (rsaPubExport[k0] == 32) k0++;
3059 if (rsaPubExport[k0] ==
'#' && rsaPubExport[k2] ==
'#') {
3060 char *p0 = (
char *)&rsaPubExport[k0];
3061 char *p2 = (
char *)&rsaPubExport[k2];
3062 char *p1 = strchr(p0+1,
'#');
3063 if (p1 > p0 && p1 < p2) {
3069 while (
c < p1 && ((*c < 58 && *c > 47) || (*c < 91 && *c > 64)))
3073 while (
c < p2 && ((*c < 58 && *c > 47) || (*c < 91 && *c > 64)))
3082 ::Info(
"TAuthenticate::SetRSAPublic",
" Key type: %d",rsakey);
3086 R__rsa_NUMBER rsa_n, rsa_d;
3097 BF_set_key(&fgBFKey, klen, (
const unsigned char *)rsaPubExport);
3100 ::Info(
"TAuthenticate::SetRSAPublic",
3101 "not compiled with SSL support:"
3102 " you should not have got here!");
3122 ::Info(
"TAuthenticate::SendRSAPublicKey",
3123 "received key from server %ld bytes", (
Long_t)strlen(serverPubKey));
3126 R__rsa_NUMBER rsa_n, rsa_d;
3132 RSA_free((RSA *)tmprsa);
3135 RSA *RSASSLServer = (RSA *)tmprsa;
3143 char buflen[20] = {0};
3150 }
else if (key == 1) {
3152 Int_t lcmax = RSA_size(RSASSLServer) - 11;
3157 Int_t lc = (ns > lcmax) ? lcmax : ns ;
3158 if ((ttmp = RSA_public_encrypt(lc,
3160 (
unsigned char *)&buftmp[ke],
3161 RSASSLServer,RSA_PKCS1_PADDING)) < 0) {
3164 ::Info(
"TAuthenticate::SendRSAPublicKey",
"SSL: error: '%s' ",errstr);
3174 ::Info(
"TAuthenticate::SendRSAPublicKey",
"not compiled with SSL support:"
3175 " you should not have got here!");
3180 ::Info(
"TAuthenticate::SendRSAPublicKey",
"unknown key type (%d)",key);
3183 RSA_free(RSASSLServer);
3194 ::Info(
"TAuthenticate::SendRSAPublicKey",
3195 "local: sent %d bytes (expected: %d)", nsen,ttmp);
3198 RSA_free(RSASSLServer);
3219 if (authrc &&
gDebug > 2)
3220 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking file: %s", authrc);
3222 if (authrc &&
gDebug > 1)
3223 ::Info(
"TAuthenticate::ReadRootAuthrc",
3224 "file %s cannot be read (errno: %d)", authrc, errno);
3228 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking system file: %s", authrc);
3231 ::Info(
"TAuthenticate::ReadRootAuthrc",
3232 "file %s cannot be read (errno: %d)", authrc, errno);
3242 stat(tRootAuthrc, &si);
3245 ::Info(
"TAuthenticate::ReadRootAuthrc",
3246 "file %s already read", authrc);
3262 TString filetmp =
"rootauthrc";
3265 ::Info(
"TAuthenticate::ReadRootAuthrc",
"got tmp file: %s open at 0x%lx",
3278 fd = fopen(authrc,
"r");
3281 ::Info(
"TAuthenticate::ReadRootAuthrc",
3282 "file %s cannot be open (errno: %d)", authrc, errno);
3293 while (fgets(
line,
sizeof(
line), fd) != 0) {
3300 if (
line[strlen(
line) - 1] ==
'\n')
3308 const size_t tmpSize = strlen(
line) + 1;
3309 char *tmp =
new char[tmpSize];
3311 ::Error(
"TAuthenticate::ReadRootAuthrc",
3312 "could not allocate temporary buffer");
3316 strlcpy(tmp,
line, tmpSize);
3317 char *nxt = strtok(tmp,
" ");
3319 if (!strcmp(nxt,
"proofserv") || cont) {
3329 proofserv +=
TString((
const char *)ph);
3350 if (server ==
"0" || server.
BeginsWith(
"sock"))
3352 else if (server ==
"1" || server.
BeginsWith(
"root"))
3354 else if (server ==
"2" || server.
BeginsWith(
"proof"))
3361 nxt = strtok(0,
" ");
3362 if (!strncmp(nxt,
"user",4)) {
3363 nxt = strtok(0,
" ");
3364 if (strncmp(nxt,
"list",4) && strncmp(nxt,
"method",6)) {
3366 nxt = strtok(0,
" ");
3371 TIter next(&tmpAuthInfo);
3381 tmpAuthInfo.
Add(ha);
3384 if (!strncmp(nxt,
"list",4)) {
3387 char *mth = strtok(0,
" ");
3390 if (strlen(mth) > 1) {
3393 if (met == -1 &&
gDebug > 2)
3394 ::Info(
"TAuthenticate::ReadRootAuthrc",
3395 "unrecognized method (%s): ", mth);
3399 if (met > -1 && met <
kMAXSEC)
3401 mth = strtok(0,
" ");
3406 }
else if (!strncmp(nxt,
"method",6)) {
3409 char *mth = strtok(0,
" ");
3411 if (strlen(mth) > 1) {
3414 if (met == -1 &&
gDebug > 2)
3415 ::Info(
"TAuthenticate::ReadRootAuthrc",
3416 "unrecognized method (%s): ", mth);
3420 if (met > -1 && met <
kMAXSEC) {
3421 const char *det = 0;
3422 nxt = strtok(0,
" ");
3424 det = (
const char *)strstr(
line,nxt);
3433 if (tmp)
delete [] tmp;
3451 TList tmpproofauthinfo;
3452 if (proofserv.
Length() > 0) {
3453 char *tmps =
new char[proofserv.
Length()+1];
3454 strlcpy(tmps,proofserv.
Data(),proofserv.
Length()+1);
3455 char *nxt = strtok(tmps,
" ");
3457 TString tmp((
const char *)nxt);
3461 if ((pdd = tmp.
Index(
":")) == -1) {
3472 if ((pdd = tmp.
Index(
":")) == -1) {
3484 while (tmp.
Length() > 0) {
3486 if ((pdd = tmp.
Index(
":")) > -1)
3491 if (met == -1 &&
gDebug > 2)
3492 ::Info(
"TAuthenticate::ReadRootAuthrc",
3493 "unrecognized method (%s): ",meth.
Data());
3494 }
else if (meth.
Length() == 1) {
3495 met = atoi(meth.
Data());
3496 if (met > -1 && met <
kMAXSEC)
3519 tmpproofauthinfo.
Add(ha);
3521 nxt = strtok(0,
" ");
3541 const char netrc[2][20] = {
"/.netrc",
"/.rootnetrc" };
3551 "not properly logged on (getpwuid unable to find relevant info)!");
3559 for (; i < 2; i++) {
3565 out.
Form(
"pt:0 ru:1 us:%s",user.
Data());
3569 if (strlen(out) > 0)
3571 "meth: %d ... is available: details: %s", cSec, out.
Data());
3573 ::Info(
"CheckProofAuth",
3574 "meth: %d ... is NOT available", cSec);
3592 if (!strcmp(user,ctx->
GetUser()) &&
3593 strncmp(
"AFS", ctx->
GetID(), 3))
3623 while ((hanew = (
THostAuth *)nxnew())) {
3645 while ((hanew = (
THostAuth *)nxnew())) {
3709 Info(
"ProofAuthSetup",
"Buffer not found: nothing to do");
3723 *mess >> user >>
passwd >> pwhash >> srppwd >> rsakey;
3740 Info(
"ProofAuthSetup",
"List of THostAuth not found");
3761 fromProofAI =
kTRUE;
3772 if (!master || fromProofAI) {
3834 if (remoteOffSet > -1 && upwd)
3837 if (upwd && pwdctx) {
3846 mess << user <<
passwd << pwhash << srppwd << keytyp;
3852 char *mbuf = mess.
Buffer();
3857 ::Info(
"ProofAuthSetup",
"sending %d bytes", messb64.
Length());
3860 if (remoteOffSet > -1) {
3862 ::Error(
"ProofAuthSetup",
"problems secure-sending message buffer");
3870 ::Error(
"ProofAuthSetup",
"plain: problems sending message length");
3874 ::Error(
"ProofAuthSetup",
"problems sending message buffer");
3907 Int_t retval = 0, ns = 0;
3910 Error(
"SendHostAuth",
"invalid input: socket undefined");
3925 Info(
"SendHostAuth",
"sent %d bytes (%s)",ns,buf.
Data());
3932 Info(
"SendHostAuth",
"sent %d bytes for closing",ns);
3946 Error(
"RecvHostAuth",
"invalid input: socket undefined");
3961 Error(
"RecvHostAuth",
"received: kind: %d (%d bytes)", kind, nr);
3965 Info(
"RecvHostAuth",
"received %d bytes (%s)",nr,buf);
3967 while (strcmp(buf,
"END")) {
3987 fromProofAI =
kTRUE;
3998 if (!master || fromProofAI) {
4037 Info(
"RecvHostAuth",
"Error: received: kind: %d (%d bytes)", kind, nr);
4041 Info(
"RecvHostAuth",
"received %d bytes (%s)",nr,buf);
4074 if (remoteOffSet > -1 && upwd)
4077 if (upwd && pwdctx) {
4081 Error(
"OldAuthSetup",
"failed to send offset in RSA key");
4092 if (remoteOffSet > -1)
4093 Warning(
"OldAuthSetup",
"problems secure-sending pass hash %s",
4094 "- may result in failures");
4097 for (
int i = 0; i <
passwd.Length(); i++) {
4103 if (sock->
Send(mess) < 0) {
4104 Error(
"OldAuthSetup",
"failed to send inverted password");
4114 Error(
"OldAuthSetup",
"failed to send no offset notification in RSA key");
4121 mess << user << pwhash << srppwd << ord << conf;
4123 if (sock->
Send(mess) < 0) {
4124 Error(
"OldAuthSetup",
"failed to send ordinal and config info");
4128 if (proofdProto > 6) {
4134 Error(
"OldAuthSetup",
"failed to send HostAuth info");
4153 if (sock->
Recv(retval, kind) != 2*
sizeof(
Int_t)) {
4155 Info(
"OldProofServAuthSetup",
4156 "socket has been closed due to protocol mismatch - Exiting");
4173 if ((fKey = fopen(keyfile.
Data(),
"r"))) {
4174 Int_t klen = fread((
void *)pubkey,1,
sizeof(pubkey),fKey);
4176 Error(
"OldProofServAuthSetup",
4177 "failed to read public key from '%s'", keyfile.
Data());
4186 Error(
"OldProofServAuthSetup",
"failed to open '%s'", keyfile.
Data());
4195 Error(
"OldProofServAuthSetup",
"failed to receive password");
4201 }
else if (retval == -1) {
4205 if ((sock->
Recv(mess) <= 0) || !mess) {
4206 Error(
"OldProofServAuthSetup",
"failed to receive inverted password");
4222 if ((sock->
Recv(mess) <= 0) || !mess) {
4223 Error(
"OldProofServAuthSetup",
"failed to receive ordinal and config info");
4231 (*mess) >> user >> pwhash >> srppwd >> conf;
4234 (*mess) >> user >> pwhash >> srppwd >> ord >> conf;
4239 (*mess) >> user >> pwhash >> srppwd >> iord;
4243 (*mess) >> user >> pwhash >> srppwd >> ord >> conf;
4264 Error(
"OldProofServAuthSetup",
"failed to receive HostAuth info");
const Int_t kAUTH_SSALT_MSK
const Int_t kAUTH_CRYPT_MSK
const Int_t kAUTH_REUSE_MSK
const Int_t kAUTH_RSATY_MSK
R__EXTERN const char * gRootdErrStr[]
TVirtualMutex * gAuthenticateMutex
static Int_t SendHostAuth(TSocket *s)
Sends the list of the relevant THostAuth objects to the master or to the active slaves,...
Int_t OldProofServAuthSetup(TSocket *sock, Bool_t master, Int_t protocol, TString &user, TString &ord, TString &conf)
Authentication related setup in TProofServ run after successful startup.
Int_t StdCheckSecCtx(const char *, TRootSecContext *)
Standard version of CheckSecCtx to be passed to TAuthenticate::AuthExists Check if User is matches th...
Int_t OldSlaveAuthSetup(TSocket *sock, Bool_t, TString ord, TString conf)
Setup of authetication in PROOF run after successful opening of the socket.
static Int_t RecvHostAuth(TSocket *s, Option_t *opt)
Receive from client/master directives for authentications, create related THostAuth and add them to t...
R__rsa_KEY_export R__fgRSAPubExport[2]
static int auth_rand()
rand() implementation using /udev/random or /dev/random, if available
R__EXTERN TVirtualMutex * gAuthenticateMutex
Int_t(* Krb5Auth_t)(TAuthenticate *auth, TString &user, TString &det, Int_t version)
Int_t(* SecureAuth_t)(TAuthenticate *auth, const char *user, const char *passwd, const char *remote, TString &det, Int_t version)
Int_t(* GlobusAuth_t)(TAuthenticate *auth, TString &user, TString &det)
Int_t(* CheckSecCtx_t)(const char *subj, TRootSecContext *ctx)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
typedef void((*Func_t)())
Bool_t R_ISREG(Int_t mode)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD2(mutex)
#define SSL_load_error_strings
static void RemoveHostAuth(THostAuth *ha, Option_t *opt="")
Remove THostAuth instance from the list.
static Int_t SetRSAPublic(const char *rsapubexport, Int_t klen)
Store RSA public keys from export string rsaPubExport.
static TPluginHandler * fgPasswdDialog
static void SetGlobalSRPPwd(Bool_t srppwd)
Set global SRP passwd flag to be used for authentication to rootd or proofd.
static Bool_t fgPromptUser
TRootSecContext * fSecContext
static void FileExpand(const char *fin, FILE *ftmp)
Expands include directives found in fexp files The expanded, temporary file, is pointed to by 'ftmp' ...
static const char * GetGlobalUser()
Static method returning the global user.
static void SetGlobalUser(const char *user)
Set global user name to be used for authentication to rootd or proofd.
static void SetPromptUser(Bool_t promptuser)
Set global PromptUser flag.
Int_t RfioAuth(TString &user)
RFIO authentication (no longer supported)
static void Show(Option_t *opt="S")
Print info about the authentication sector.
const char * GetSshUser(TString user) const
Method returning the user to be used for the ssh login (no longer supported)
static const char * GetDefaultUser()
Static method returning the default user information.
static Bool_t GetPromptUser()
Static method returning the prompt user settings.
static Int_t SecureRecv(TSocket *Socket, Int_t dec, Int_t KeyType, char **Out)
Receive str from sock and decode it using key indicated by key type Return number of received bytes o...
static const char * GetKrb5Principal()
Static method returning the principal to be used to init Krb5 tickets.
THostAuth * GetHostAuth() const
static void SetAuthReUse(Bool_t authreuse)
Set global AuthReUse flag.
static R__rsa_KEY_export * fgRSAPubExport
char * GetRandString(Int_t Opt, Int_t Len)
Allocates and fills a 0 terminated buffer of length len+1 with len random characters.
static TList * GetProofAuthInfo()
Static method returning the list with authentication directives to be sent to proof.
Int_t SshAuth(TString &user)
SSH client authentication code (no longer supported)
static char * PromptPasswd(const char *prompt="Password: ")
Static method to prompt for the user's passwd to be used for authentication to rootd or proofd.
static void SetDefaultUser(const char *defaultuser)
Set default user name.
static void SetGlobalPwHash(Bool_t pwhash)
Set global passwd hash flag to be used for authentication to rootd or proofd.
static void SetGlobalExpDate(TDatime expdate)
Set default expiring date for new validity contexts.
static Int_t GetRSAInit()
Static method returning the RSA initialization flag.
static void SetSecureAuthHook(SecureAuth_t func)
Set secure authorization function.
static Int_t GetClientProtocol()
Static method returning supported client protocol.
static Int_t ReadRootAuthrc()
Read authentication directives from $ROOTAUTHRC, $HOME/.rootauthrc or <Root_etc_dir>/system....
static Bool_t fgReadHomeAuthrc
static Int_t SecureSend(TSocket *Socket, Int_t enc, Int_t KeyType, const char *In)
Encode null terminated str using the session private key indicated by enc and sends it over the netwo...
Int_t GenRSAKeys()
Generate a valid pair of private/public RSA keys to protect for authentication token exchange.
Bool_t CheckNetrc(TString &user, TString &passwd)
Try to get user name and passwd from the ~/.rootnetrc or ~/.netrc files.
static const char * GetRSAPubExport(Int_t key=0)
Static method returning the RSA public keys.
static Int_t DecodeRSAPublic(const char *rsapubexport, R__rsa_NUMBER &n, R__rsa_NUMBER &d, char **rsassl=0)
Store RSA public keys from export string rsaPubExport.
static void SetReadHomeAuthrc(Bool_t readhomeauthrc)
Set flag controlling the reading of $HOME/.rootauthrc.
static void InitRandom()
Initialize random machine using seed from /dev/urandom (or current time if /dev/urandom not available...
static TList * fgProofAuthInfo
static R__rsa_KEY fgRSAPubKey
static Bool_t fgAuthReUse
static Bool_t GetGlobalPwHash()
Static method returning the global password hash flag.
static void SetKrb5AuthHook(Krb5Auth_t func)
Set kerberos5 authorization function.
static void SetGlobusAuthHook(GlobusAuth_t func)
Set Globus authorization function.
static void SetRSAInit(Int_t init=1)
Static method setting RSA initialization flag.
static void SetGlobalPasswd(const char *passwd)
Set global passwd to be used for authentication to rootd or proofd.
void SetEnvironment()
Set default authentication environment.
static Int_t SendRSAPublicKey(TSocket *Socket, Int_t key=0)
Receives server RSA Public key Sends local RSA public key encoded.
static Bool_t CheckProofAuth(Int_t cSec, TString &det)
Check if the authentication method can be attempted for the client.
static TDatime fgLastAuthrc
static TList * fgAuthInfo
static TString fgAuthMeth[kMAXSEC]
void CatchTimeOut()
Called in connection with a timer timeout.
Bool_t GetUserPasswd(TString &user, TString &passwd, Bool_t &pwhash, Bool_t srppwd)
Try to get user name and passwd from several sources.
Bool_t Authenticate()
Authenticate to remote rootd or proofd server.
static R__rsa_KEY fgRSAPriKey
static TString fgRootAuthrc
Int_t AuthExists(TString User, Int_t method, const char *Options, Int_t *Message, Int_t *Rflag, CheckSecCtx_t funcheck)
Check if we have a valid established sec context in memory Retrieves relevant info and negotiates wit...
static TList * GetAuthInfo()
Static method returning the list with authentication details.
static GlobusAuth_t GetGlobusAuthHook()
Static method returning the globus authorization hook (no longer supported)
Int_t ProofAuthSetup()
Authentication related stuff setup in TProofServ.
Int_t ClearAuth(TString &user, TString &passwd, Bool_t &pwhash)
UsrPwd client authentication code.
static void AuthError(const char *where, Int_t error)
Print error string depending on error code.
static char * GetDefaultDetails(Int_t method, Int_t opt, const char *user)
Determine default authentication details for method 'sec' and user 'usr'.
static void MergeHostAuthList(TList *Std, TList *New, Option_t *Opt="")
Tool for updating fgAuthInfo or fgProofAuthInfo 'nin' contains list of last input information through...
static TString fgDefaultUser
static Int_t GetAuthMethodIdx(const char *meth)
Static method returning the method index (which can be used to find the method in GetAuthMethod()).
static void SetTimeOut(Int_t to)
Set timeout (active if > 0)
static Bool_t fgUsrPwdCrypt
TAuthenticate(TSocket *sock, const char *remote, const char *proto, const char *user="")
Create authentication object.
static void RemoveSecContext(TRootSecContext *ctx)
Tool for removing SecContext ctx from THostAuth listed in fgAuthInfo or fgProofAuthInfo.
static TDatime GetGlobalExpDate()
Static method returning default expiring date for new validity contexts.
static Bool_t GetGlobalSRPPwd()
Static method returning the global SRP password flag.
static SecureAuth_t fgSecAuthHook
static char * PromptUser(const char *remote)
Static method to prompt for the user name to be used for authentication to rootd or proofd.
static Bool_t CheckHost(const char *Host, const char *host)
Check if 'host' matches 'href': this means either equal or "containing" it, even with wild cards * in...
static void SetDefaultRSAKeyType(Int_t key)
Static method setting the default type of RSA key.
static const char * GetAuthMethod(Int_t idx)
Static method returning the method corresponding to idx.
static Bool_t GetAuthReUse()
Static method returning the authentication reuse settings.
static THostAuth * HasHostAuth(const char *host, const char *user, Option_t *opt="R")
Checks if a THostAuth with exact match for {host,user} exists in the fgAuthInfo list If opt = "P" use...
static TString Decode(const char *data)
Decode a base64 string date into a generic TString.
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
void Set()
Set Date/Time to current time as reported by the system.
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
const char * GetUser() const
const char * GetHost() const
TRootSecContext * CreateSecContext(const char *user, const char *host, Int_t meth, Int_t offset, const char *details, const char *token, TDatime expdate=kROOTTZERO, void *ctx=0, Int_t key=-1)
Create a Security context and add it to local list Return pointer to it to be stored in TAuthenticate...
void SetUser(const char *user)
void SetDetails(Int_t level, const char *details)
Set authentication details for specified level.
void SetHost(const char *host)
void SetFirst(Int_t level)
Set 'method' to be the first used (if in the list ...).
virtual void Print(Option_t *option="") const
Print object content.
void SetServer(Int_t server)
void ReOrder(Int_t nmet, Int_t *fmet)
Reorder nmet methods according fmet[nmet].
void RemoveMethod(Int_t level)
Remove method 'meth' from the list, if there ...
void AddMethod(Int_t level, const char *details=0)
Add method to the list.
void CountFailure(Int_t level)
Count failures for 'method'.
Int_t GetMethod(Int_t idx) const
void AsString(TString &out) const
Return a static string with all info in a serialized form.
Bool_t HasMethod(Int_t level, Int_t *pos=0)
Return kTRUE if method 'level' is in the list.
TList * Established() const
void AddFirst(Int_t level, const char *details=0)
Add new method in first position If already in the list, set as first method 'level' with authenticat...
void Update(THostAuth *ha)
Update info with the one in ha Remaining methods, if any, get lower priority.
const char * GetDetails(Int_t level)
Return authentication details for specified level or "" if the specified level does not exist for thi...
void SetLast(Int_t level)
Set 'method' to be the last used (if in the list ...).
void PrintEstablished() const
Print info about established authentication vis-a-vis of this Host.
void CountSuccess(Int_t level)
Count successes for 'method'.
This class represents an Internet Protocol (IP) address.
const char * GetHostName() const
const char * GetHostAddress() const
Returns the IP address string "%d.%d.%d.%d".
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Long_t ExecPlugin(int nargs, const T &... params)
Int_t LoadPlugin()
Load the plugin library for this handler.
const char * GetPasswd() const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
static RSA_encode_t RSA_encode()
static RSA_genprim_t RSA_genprim()
static RSA_assign_t RSA_assign()
static RSA_cmp_t RSA_cmp()
static RSA_decode_t RSA_decode()
static RSA_genrsa_t RSA_genrsa()
static RSA_num_sput_t RSA_num_sput()
static RSA_num_sget_t RSA_num_sget()
Regular expression class.
Ssiz_t Index(const TString &str, Ssiz_t *len, Ssiz_t start=0) const
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match...
void DeActivate(Option_t *opt="CR")
Set OffSet to -1 and expiring Date to default Remove from the list If Opt contains "C" or "c",...
void Print(Option_t *option="F") const
If opt is "F" (default) print object content.
Bool_t IsActive() const
Check remote OffSet and expiring Date.
const char * GetID() const
void SetID(const char *id)
const char * GetHost() const
const char * GetToken() const
void AddForCleanup(Int_t port, Int_t proto, Int_t type)
Create a new TSecContextCleanup Internally is added to the list.
virtual void Print(Option_t *option="F") const
If opt is "F" (default) print object content.
Bool_t IsA(const char *methodname)
Checks if this security context is for method named 'methname' Case sensitive.
void * GetContext() const
const char * GetUser() const
void SetOffSet(Int_t offset)
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
static Int_t GetClientProtocol()
Static method returning supported client protocol.
Int_t GetRemoteProtocol() const
virtual void Close(Option_t *opt="")
Close the socket.
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
TSecContext * GetSecContext() const
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Int_t GetServType() const
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual int GetPid()
Get process id.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual FILE * TempFileName(TString &base, const char *dir=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
virtual void DispatchOneEvent(Bool_t pendingOnly=kFALSE)
Dispatch a single event.
virtual const char * HostName()
Return the system's host name.
virtual Int_t GetEffectiveUid()
Returns the effective user id.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Handles synchronous and a-synchronous timer events.
virtual void Start(Long_t milliSec=-1, Bool_t singleShot=kFALSE)
Starts the timer with a milliSec timeout.
void SetInterruptSyscalls(Bool_t set=kTRUE)
When the argument is true the a-synchronous timer (SIGALRM) signal handler is set so that interrupted...
This class implements a mutex interface.
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)