20#include "RConfigure.h"
50#if !defined(R__WIN32) && !defined(R__MACOSX) && !defined(R__FBSD) && \
57#if defined(R__LINUX) || defined(R__FBSD) || defined(R__OBSD)
66extern "C" char *
crypt(
const char *,
const char *);
71# include <openssl/bio.h>
72# include <openssl/err.h>
73# include <openssl/pem.h>
74# include <openssl/rand.h>
75# include <openssl/rsa.h>
76# include <openssl/ssl.h>
77# include <openssl/blowfish.h>
93 "Unsupported",
"Unsupported",
"Unsupported" };
143 if (
rs ==
sizeof(
int))
return r;
145 Printf(
"+++ERROR+++ : auth_rand: neither /dev/urandom nor /dev/random are available or readable!");
149 memcpy((
void *)&
t1, (
void *)&
tv.tv_sec,
sizeof(
int));
150 memcpy((
void *)&
t2, (
void *)&
tv.tv_usec,
sizeof(
int));
185 Info(
"TAuthenticate",
"Enter: local host: %s, user is: %s (proto: %s)",
215 Info(
"TAuthenticate",
216 "service: %s (remote protocol: %d): fVersion: %d",
sproto,
226 if (user &&
strlen(user) > 0) {
251 Info(
"TAuthenticate",
"RSA key: default type %d",
fgRSAKey);
271 Info(
"TAuthenticate",
272 "number of HostAuth Instantiations in memory: %d",
296 tmp.ReplaceAll(
"root",4,
"",0);
297 tmp.ReplaceAll(
"sock",4,
"",0);
336 Info(
"CatchTimeOut",
"%d sec timeout expired (protocol: %s)",
337 fgAuthTO, fgAuthMeth[fSecurity].Data());
341 fSocket->Close(
"force");
368 Info(
"Authenticate",
"enter: fUser: %s", fUser.Data());
375 alarm->SetInterruptSyscalls();
377 alarm->Connect(
"Timeout()",
"TAuthenticate",
this,
"CatchTimeOut()");
385 Info(
"Authenticate",
"try #: %d",
ntry);
393 fDetails = fHostAuth->GetDetails((
Int_t) fSecurity);
396 "trying authentication: method:%d, default details:%s",
397 fSecurity, fDetails.Data());
411 if (fgAuthTO > 0 &&
alarm) {
416 if (fSecurity == kClear) {
421 user = fgDefaultUser;
426 char *
u = PromptUser(fRemote);
440 Error(
"Authenticate",
441 "unable to get user name for UsrPwd authentication");
450 st = (fTimeOut > 0) ? -3 :
st;
461 Info(
"Authenticate",
"remloc: %d, ntry: %d, meth: %d, fSecurity: %d",
469 fHostAuth->CountSuccess((
Int_t)fSecurity);
471 fSecContext->Print();
472 if (fSecContext->IsActive())
473 fSecContext->AddForCleanup(fSocket->GetPort(),
474 fSocket->GetRemoteProtocol(),fSocket->GetServType());
481 fHostAuth->CountFailure((
Int_t)fSecurity);
487 "negotiation not supported remotely: try next method, if any");
499 if (fSocket->Recv(stat, kind) < 0) {
505 "after failed attempt: kind= %d, stat= %d", kind, stat);
522 "strings with accepted methods not received (%d:%d)",
529 "remotely allowed methods not yet tried: %s",
532 }
else if (stat == 0) {
534 "no more methods accepted remotely to be tried");
549 for (i = 0; i <
remMeth; i++) {
551 if (fHostAuth->GetMethod(
j) ==
rMth[i] &&
tMth[
j] == 0) {
558 available +=
" " + std::to_string(fHostAuth->GetMethod(
j));
566 Warning(
"Authenticate",
"no match with those locally available: %s",
available.c_str());
580 fHostAuth->CountFailure((
Int_t)fSecurity);
583 "method not even started: insufficient or wrong info: %s",
584 "try with next method, if any");
585 fHostAuth->RemoveMethod(fSecurity);
597 fHostAuth->CountFailure((
Int_t)fSecurity);
601 "status code -2 not expected from old daemons");
611 fHostAuth->CountFailure((
Int_t)fSecurity);
613 Info(
"Authenticate",
"got a timeout");
614 fHostAuth->SetLast(fSecurity);
623 fHostAuth->CountFailure((
Int_t)fSecurity);
625 Info(
"Authenticate",
"unknown status code: %d - assume failure",
st);
640 Info(
"Authenticate",
"attempted methods %s are not supported"
643 "failure: list of attempted methods: %s",
triedMeth);
644 AuthError(
"Authenticate",-1);
667 Info(
"SetEnvironment",
668 "setting environment: fSecurity:%d, fDetails:%s", fSecurity,
672 fgDefaultUser = fgUser;
677 if (fDetails !=
"") {
679 char pt[5] = { 0 },
ru[5] = { 0 };
685 if ((ptr =
strstr(fDetails,
"pt:")) != 0) {
695 if ((ptr =
strstr(fDetails,
"ru:")) != 0) {
707 if ((
pd =
hours.Index(
":")) > -1) {
719 if (fSecurity == kClear) {
720 if ((ptr =
strstr(fDetails,
"us:")) != 0)
722 if ((ptr =
strstr(fDetails,
"cp:")) != 0)
725 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s cp:%s",
726 fDetails.Data(),
pt,
ru, us,
cp);
728 if ((ptr =
strstr(fDetails,
"us:")) != 0)
731 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s",
732 fDetails.Data(),
pt,
ru, us);
737 fgPromptUser =
kTRUE;
741 fgExpDate.Set(fgExpDate.Convert() +
hh*3600 + mm*60);
744 if (fSecurity == kClear) {
745 fgUsrPwdCrypt =
kTRUE;
759 fgDefaultUser =
usdef;
762 fgDefaultUser = fgUser;
766 fgDefaultUser =
u->fUser;
770 if (fgDefaultUser ==
"anonymous" || fgDefaultUser ==
"rootd" ||
771 fgUser !=
"" || fUser !=
"") {
777 Info(
"SetEnvironment",
"usdef:%s", fgDefaultUser.Data());
787 Error(
"GetUserPasswd",
"SRP no longer supported by ROOT");
792 Info(
"GetUserPasswd",
"Enter: User: '%s' Hash:%d SRP:%d",
796 if (user ==
"" && fgUser !=
"")
799 if (fgUser !=
"" && user == fgUser) {
800 if (
passwd ==
"" && fgPasswd !=
"") {
807 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
817 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
823 if (user ==
"" ||
passwd ==
"") {
825 Info(
"GetUserPasswd",
"Checking .netrc family ...");
829 Info(
"GetUserPasswd",
"From .netrc family: User: '%s' Hash:%d",
834 char *
p = PromptUser(fRemote);
838 Error(
"GetUserPasswd",
"user name not set");
884 Error(
"CheckNetrc",
"SRP no longer supported by ROOT");
935 href.ReplaceAll(
"*",
".*");
959 "file %s exists but has not 0600 permission",
net);
1009 return fgDefaultUser;
1017 ::Error(
"Krb5Auth",
"Kerberos5 is no longer supported by ROOT");
1034 return fgPromptUser;
1045 ::Error(
"Authenticate::GetAuthMethod",
"idx out of bounds (%d)", idx);
1048 return fgAuthMeth[idx];
1080 if (fgDefaultUser !=
"")
1081 user = fgDefaultUser;
1090 "not tty: cannot prompt for user, returning default");
1100 usr.Remove(
usr.Length() - 1);
1118 ::Warning(
"TAuthenticate::PromptPasswd",
1119 "not tty: cannot prompt for passwd, returning -1");
1120 static char noint[4] = {
"-1"};
1125 const char *
pw = buf;
1129 if ((fgPasswdDialog =
1130 gROOT->GetPluginManager()->FindHandler(
"TGPasswdDialog"))) {
1131 if (fgPasswdDialog->LoadPlugin() == -1) {
1134 "could not load plugin for the password dialog box");
1138 if (fgPasswdDialog && (fgPasswdDialog != (
TPluginHandler *)(-1))) {
1141 fgPasswdDialog->ExecPlugin(3,
prompt, buf, 128);
1144 while (
gROOT->IsInterrupted())
1156 if (
spw.EndsWith(
"\n"))
1157 spw.Remove(
spw.Length() - 1);
1177 key = (key >= 0 && key <= 1) ? key : 0;
1178 return fgRSAPubExport[key].keys;
1194 if (key >= 0 && key <= 1)
1214 fgAuthInfo =
new TList;
1234 lasterr =
"(last error only; re-run with gDebug > 0 for more details)";
1243 ::Error(
Form(
"TAuthenticate::%s",
where),
1244 "unknown error code: server must be running a newer ROOT version %s",
1262 if (user && user[0])
1293 ::Error(
"SetGlobalSRPPwd",
"SRP no longer supported by ROOT");
1309 if (fgDefaultUser !=
"")
1321 fgAuthTO = (to <= 0) ? -1 : to;
1345 fgSecAuthHook = func;
1354 ::Error(
"Krb5Auth",
"Kerberos5 is no longer supported by ROOT");
1363 ::Error(
"GlobusAuth",
"Globus is no longer supported by ROOT");
1371 ::Error(
"SshAuth",
"SSH is no longer supported by ROOT");
1380 ::Error(
"GetSshUser",
"SSH is no longer supported by ROOT");
1427 ::Info(
"TAuthenticate::CheckHost",
"checking host IP: %s",
theHost.Data());
1450 ::Error(
"RfioAuth",
"RfioAuth is no longer supported by ROOT");
1464 Info(
"ClearAuth",
"enter: user: %s (passwd hashed?: %d)",
1474 fgPromptUser, fgAuthReUse, fgUsrPwdCrypt) + user;
1476 Info(
"ClearAuth",
"ru:%d pt:%d cp:%d ns:%d rk:%d",
1477 fgAuthReUse,fgPromptUser,fgUsrPwdCrypt,
needsalt,fgRSAKey);
1505 options.
Form(
"%d %ld %s %ld %s", opt,
1527 Info(
"ClearAuth",
"anonymous user");
1536 char ctag[11] = {0};
1544 "problems recvn RSA key flag: got message %d, flag: %d",
1550 Info(
"ClearAuth",
"get key request ...");
1556 if (SendRSAPublicKey(fSocket,fRSAKey) < 0)
1563 if ((
slen = SecureRecv(fSocket, 1, fRSAKey, &
tmpsalt)) == -1) {
1564 Warning(
"ClearAuth",
"problems secure-receiving salt -"
1565 " may result in corrupted salt");
1566 Warning(
"ClearAuth",
"switch off reuse for this session");
1597 Info(
"ClearAuth",
"got salt: '%s' (len: %d)",
salt.Data(),
slen);
1600 Info(
"ClearAuth",
"Salt not required");
1602 if (SecureRecv(fSocket, 1, fRSAKey, &
tmptag) == -1) {
1603 Warning(
"ClearAuth",
"problems secure-receiving rndmtag -"
1604 " may result in corrupted rndmtag");
1619 if (fgPasswd.Contains(
"@")) {
1641 "automatically generated anonymous passwd: %s",
1651 xp.Form(
"%s@%s password: ", user.
Data(),fRemote.Data());
1652 char *pwd = PromptPasswd(
xp);
1656 Error(
"ClearAuth",
"password not set");
1698 if (SecureSend(fSocket, 1, fRSAKey,
pashash.Data()) == -1) {
1699 Warning(
"ClearAuth",
"problems secure-sending pass hash"
1700 " - may result in authentication failure");
1707 for (
int i = 0; i <
passwd.Length(); i++) {
1718 if ((
nrec = fSocket->Recv(stat, kind)) < 0 )
1721 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
1726 AuthError(
"ClearAuth", stat);
1733 "problems recvn (user,offset) length (%d:%d bytes:%d)",
1738 int reclen = (stat+1 > 256) ? 256 : stat+1;
1743 "username and offset not received (%d:%d)", kind,
1752 "received from server: user: %s, offset: %d (%s)",
lUser,
1762 if (SecureRecv(fSocket, 1, fRSAKey, &token) == -1) {
1764 "problems secure-receiving token -"
1765 " may result in corrupted token");
1770 token =
new char[
tlen];
1771 if (fSocket->Recv(token,
tlen, kind) < 0) {
1776 Warning(
"ClearAuth",
"token not received (%d:%d)", kind,
1779 for (
int i = 0; i < (
int)
strlen(token); i++) {
1785 Info(
"ClearAuth",
"received from server: token: '%s' ",
1790 fSecContext = fHostAuth->CreateSecContext((
const char *)
lUser, fRemote,
1791 kClear,
offset, fDetails, (
const char *)token,
1792 fgExpDate, (
void *)
pwdctx, fRSAKey);
1799 if (fSocket->Recv(stat, kind) < 0)
1806 AuthError(
"ClearAuth", stat);
1819 if (fSocket->Recv(stat, kind) < 0)
1826 fHostAuth->CreateSecContext(user,fRemote,kClear,-1,fDetails,0);
1832 if (fProtocol.Contains(
"root"))
1837 "%s@%s does not accept connections from %s@%s",
1838 server.Data(),fRemote.Data(),
1844 "%s@%s does not accept %s authentication from %s@%s",
1845 server.Data(),fRemote.Data(),
1849 AuthError(
"ClearAuth", stat);
1856 xp.Form(
"%s@%s password: ", user.
Data(),fRemote.Data());
1857 char *
p = PromptPasswd(
xp);
1861 Error(
"ClearAuth",
"password not set");
1863 if (fUser ==
"anonymous" || fUser ==
"rootd") {
1864 if (!
passwd.Contains(
"@")) {
1866 "please use passwd of form: user@host.do.main");
1877 for (
int i = 0; i <
passwd.Length(); i++) {
1887 if (fSocket->Recv(stat, kind) < 0)
1890 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
1895 fHostAuth->CreateSecContext(user,fRemote,kClear,-1,fDetails,0);
1899 AuthError(
"ClearAuth", stat);
1918 ::Info(
"TAuthenticate::GetHostAuth",
"enter ... %s ... %s", host, user);
1924 char *ps = (
char *)
strstr(host,
":");
1948 ai->Print(
"Authenticate::GetHostAuth");
1987 ::Info(
"TAuthenticate::HasHostAuth",
"enter ... %s ... %s", host, user);
1993 char *ps = (
char *)
strstr(host,
":");
2030 ::Info(
"TAuthenticate::FileExpand",
"enter ... '%s' ... 0x%zx",
fexp, (
size_t)
ftmp);
2043 ::Info(
"TAuthenticate::FileExpand",
"read line ... '%s'",
line);
2054 ln.ReplaceAll(
"\"",1,
"",0);
2055 ln.ReplaceAll(
"'",1,
"",0);
2062 if (
edir.Contains(
"/")) {
2090 "file specified by 'include' cannot be open or read (%s)",
2105 const char copt[2][5] = {
"no",
"yes" };
2108 ::Info(
"TAuthenticate::GetDefaultDetails",
2109 "enter ... %d ...pt:%d ... '%s'",
sec, opt,
usr);
2125 ::Info(
"TAuthenticate::GetDefaultDetails",
"returning ... %s", temp);
2135 GetAuthInfo()->Remove(
ha);
2159 ::Info(
"::Print",
" +--------------------------- BEGIN --------------------------------+");
2160 ::Info(
"::Print",
" + +");
2161 ::Info(
"::Print",
" + List fgAuthInfo has %4d members +",
2162 GetAuthInfo()->GetSize());
2163 ::Info(
"::Print",
" + +");
2164 ::Info(
"::Print",
" +------------------------------------------------------------------+");
2165 TIter next(GetAuthInfo());
2169 ai->PrintEstablished();
2171 ::Info(
"::Print",
" +---------------------------- END ---------------------------------+");
2187 Info(
"AuthExists",
"%d: enter: msg: %d options: '%s'",
2188 method,*message, options);
2194 TIter next(fHostAuth->Established());
2198 if (fRemote ==
secctx->GetHost()) {
2211 if (fRemote ==
secctx->GetHost()) {
2227 token =
secctx->GetToken();
2230 "found valid TSecContext: offset: %d token: '%s'",
2236 sstr.Form(
"%d %d %s", fgProcessID,
offset, options);
2239 if (fSocket->Send(
sstr, *message) < 0)
2251 Int_t stat = 1, kind;
2253 if (fSocket->Recv(stat, kind) < 0)
2256 Warning(
"AuthExists",
"protocol error: expecting %d got %d"
2262 Info(
"AuthExists",
"offset OK");
2281 if (SecureSend(fSocket, 1,
rsaKey, token) == -1) {
2282 Warning(
"AuthExists",
"problems secure-sending token %s",
2283 "- may trigger problems in proofing Id ");
2288 for (
int i = 0; i < token.
Length(); i++) {
2297 Info(
"AuthExists",
"offset not OK - rerun authentication");
2305 if (fSocket->Recv(stat, kind) < 0)
2308 Info(
"AuthExists",
"%d: after msg %d: kind= %d, stat= %d",
2309 method,*message, kind, stat);
2320 Error(
"AuthExists",
"%s@%s does not accept connections from %s@%s",
2326 "%s@%s does not accept %s authentication from %s@%s",
2327 server.Data(),fRemote.Data(), fgAuthMeth[
method].Data(),
2330 AuthError(
"AuthExists", stat);
2341 fHostAuth->CreateSecContext(fUser,fRemote,
method,-stat,fDetails,0);
2344 Info(
"AuthExists",
"valid authentication exists");
2346 Info(
"AuthExists",
"valid authentication exists: offset changed");
2348 Info(
"AuthExists",
"remote access authorized by /etc/hosts.equiv");
2350 Info(
"AuthExists",
"no authentication required remotely");
2365 fHostAuth->Established()->Add(
secctx);
2380 const char *
randdev =
"/dev/urandom";
2386 if (read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
2391 ::Info(
"InitRandom",
"%s not available: using time()",
randdev);
2406 Info(
"GenRSAKeys",
"enter");
2408 if (fgRSAInit == 1) {
2410 Info(
"GenRSAKeys",
"Keys prviously generated - return");
2429 if (fgRSAKey == 1) {
2432 Info(
"GenRSAKeys",
"SSL: Generate Blowfish key");
2456 char *
rbuf = GetRandString(0,
klen);
2460 fgRSAPubExport[1].len =
klen;
2461 fgRSAPubExport[1].keys =
rbuf;
2463 Info(
"GenRSAKeys",
"SSL: BF key length: %d", fgRSAPubExport[1].
len);
2502 Info(
"GenRSAKeys",
"equal primes: regenerate (%d times)",
nPrimes);
2510 Info(
"GenRSAKeys",
"local: p1: '%s' ", buf);
2512 Info(
"GenRSAKeys",
"local: p2: '%s' ", buf);
2518 Info(
"GenRSAKeys",
" genrsa: unable to generate keys (%d)",
2535 Info(
"GenRSAKeys",
"local: n: '%s' length: %d",
buf_n,
l_n);
2536 Info(
"GenRSAKeys",
"local: e: '%s' length: %d",
buf_e,
l_e);
2537 Info(
"GenRSAKeys",
"local: d: '%s' length: %d",
buf_d,
l_d);
2548 char *
tdum = GetRandString(0,
lTes - 1);
2553 Info(
"GenRSAKeys",
"local: test string: '%s' ",
test);
2562 "local: length of crypted string: %d bytes",
lout);
2568 Info(
"GenRSAKeys",
"local: after private/public : '%s' ", buf);
2579 Info(
"GenRSAKeys",
"local: length of crypted string: %d bytes ",
2586 Info(
"GenRSAKeys",
"local: after public/private : '%s' ", buf);
2605 Info(
"GenRSAKeys",
"local: generated keys are:");
2606 Info(
"GenRSAKeys",
"local: n: '%s' length: %d",
buf_n,
l_n);
2607 Info(
"GenRSAKeys",
"local: e: '%s' length: %d",
buf_e,
l_e);
2608 Info(
"GenRSAKeys",
"local: d: '%s' length: %d",
buf_d,
l_d);
2612 if (fgRSAPubExport[0].keys) {
2613 delete [] fgRSAPubExport[0].keys;
2614 fgRSAPubExport[0].len = 0;
2616 fgRSAPubExport[0].len =
l_n +
l_d + 4;
2617 fgRSAPubExport[0].keys =
new char[fgRSAPubExport[0].len];
2619 fgRSAPubExport[0].keys[0] =
'#';
2621 fgRSAPubExport[0].keys[
l_n + 1] =
'#';
2623 fgRSAPubExport[0].keys[
l_n +
l_d + 2] =
'#';
2624 fgRSAPubExport[0].keys[
l_n +
l_d + 3] = 0;
2627 Info(
"GenRSAKeys",
"local: export pub: '%s'", fgRSAPubExport[0].keys);
2630 Info(
"GenRSAKeys",
"local: export pub length: %d bytes", fgRSAPubExport[0].
len);
2649 unsigned int iimx[4][4] = {
2650 {0x0, 0xffffff08, 0xafffffff, 0x2ffffffe},
2651 {0x0, 0x3ff0000, 0x7fffffe, 0x7fffffe},
2652 {0x0, 0x3ff0000, 0x7e, 0x7e},
2653 {0x0, 0x3ffc000, 0x7fffffe, 0x7fffffe}
2656 const char *
cOpt[4] = {
"Any",
"LetNum",
"Hex",
"Crypt" };
2662 Info(
"GetRandString",
"unknown option: %d : assume 0", opt);
2665 Info(
"GetRandString",
"enter ... len: %d %s",
len,
cOpt[opt]);
2668 char *buf =
new char[
len + 1];
2678 for (
m = 7;
m < 32;
m += 7) {
2679 i = 0x7F & (
frnd >>
m);
2682 if ((
iimx[opt][
j] & (1 <<
l))) {
2694 Info(
"GetRandString",
"got '%s' ", buf);
2711 ::Info(
"TAuthenticate::SecureSend",
"local: enter ... (enc: %d)",
enc);
2728 }
else if (key == 1) {
2734 unsigned char iv[8];
2740 ::Info(
"TAuthenticate::SecureSend",
"not compiled with SSL support:"
2741 " you should not have got here!");
2745 ::Info(
"TAuthenticate::SecureSend",
"unknown key type (%d)",key);
2754 ::Info(
"TAuthenticate::SecureSend",
2755 "local: sent %d bytes (expected: %d)",
nsen,
ttmp);
2777 if (sock->
Recv(buflen, 20, kind) < 0)
2781 ::Info(
"TAuthenticate::SecureRecv",
"got len '%s' %d (msg kind: %d)",
2804 if (*str ==
nullptr) {
2806 ::Info(
"TAuthenticate::SecureRecv",
"Memory allocation error size (%ld)", (
long)
strSize);
2811 }
else if (key == 1) {
2813 unsigned char iv[8];
2815 *str =
new char[
nrec + 1];
2818 (*str)[
nrec] =
'\0';
2821 ::Info(
"TAuthenticate::SecureRecv",
"not compiled with SSL support:"
2822 " you should not have got here!");
2826 ::Info(
"TAuthenticate::SecureRecv",
"unknown key type (%d)",key);
2845 ::Info(
"TAuthenticate::DecodeRSAPublic",
2851 ::Info(
"TAuthenticate::DecodeRSAPublic",
2864 while (str[k] == 32) k++;
2866 if (str[k] ==
'#') {
2880 ::Info(
"TAuthenticate::DecodeRSAPublic",
2887 ::Info(
"TAuthenticate::DecodeRSAPublic",
2897 ::Info(
"TAuthenticate::DecodeRSAPublic",
"bad format for input string");
2914 ::Info(
"TAuthenticate::DecodeRSAPublic",
2915 "unable to read pub key from bio");
2920 ::Info(
"TAuthenticate::DecodeRSAPublic",
2921 "no space allocated for output variable");
2928 ::Info(
"TAuthenticate::DecodeRSAPublic",
"not compiled with SSL support:"
2929 " you should not have got here!");
2944 ::Info(
"TAuthenticate::SetRSAPublic",
2987 ::Info(
"TAuthenticate::SetRSAPublic",
" Key type: %d",
rsakey);
3005 ::Info(
"TAuthenticate::SetRSAPublic",
3006 "not compiled with SSL support:"
3007 " you should not have got here!");
3027 ::Info(
"TAuthenticate::SendRSAPublicKey",
3048 char buflen[20] = {0};
3055 }
else if (key == 1) {
3064 (
unsigned char *)&fgRSAPubExport[key].keys[
kk],
3069 ::Info(
"TAuthenticate::SendRSAPublicKey",
"SSL: error: '%s' ",
errstr);
3079 ::Info(
"TAuthenticate::SendRSAPublicKey",
"not compiled with SSL support:"
3080 " you should not have got here!");
3085 ::Info(
"TAuthenticate::SendRSAPublicKey",
"unknown key type (%d)",key);
3099 ::Info(
"TAuthenticate::SendRSAPublicKey",
3100 "local: sent %d bytes (expected: %d)",
nsen,
ttmp);
3120 if (fgReadHomeAuthrc) {
3126 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking file: %s",
tRootAuthrc.Data());
3129 ::Info(
"TAuthenticate::ReadRootAuthrc",
3134 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking system file: %s",
tRootAuthrc.Data());
3137 ::Info(
"TAuthenticate::ReadRootAuthrc",
3147 if ((
UInt_t)
si.st_mtime < fgLastAuthrc.Convert()) {
3149 ::Info(
"TAuthenticate::ReadRootAuthrc",
3167 ::Info(
"TAuthenticate::ReadRootAuthrc",
"got tmp file: %s open at 0x%zx",
3183 ::Info(
"TAuthenticate::ReadRootAuthrc",
3210 ::Error(
"TAuthenticate::ReadRootAuthrc",
3211 "could not allocate temporary buffer");
3251 if (host ==
ha->GetHost() && user ==
ha->GetUser() &&
3269 met = GetAuthMethodIdx(
mth);
3271 ::Info(
"TAuthenticate::ReadRootAuthrc",
3272 "unrecognized method (%s): ",
mth);
3290 met = GetAuthMethodIdx(
mth);
3292 ::Info(
"TAuthenticate::ReadRootAuthrc",
3293 "unrecognized method (%s): ",
mth);
3298 const char *
det = 0;
3303 if (
ha->HasMethod(
met))
3358 if (!
ha->IsActive()) {
3368 if (
hanew->NumMethods()) {
3377 hanew->DeActivate();
3384 hanew->DeActivate();
3390 if (!
hanew->IsActive()) {
3409 TIter next(
ha->Established());
3413 ha->Established()->Remove(ctx);
R__EXTERN const char * gRootdErrStr[]
int Int_t
Signed integer 4 bytes (int)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
const char Option_t
Option string (const char)
TVirtualMutex *& gAuthenticateMutex
static Int_t StdCheckSecCtx(const char *, ROOT::Deprecated::TRootSecContext *)
Standard version of CheckSecCtx to be passed to TAuthenticate::AuthExists Check if User is matches th...
static int auth_rand()
rand() implementation using /udev/random or /dev/random, if available
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
Bool_t R_ISREG(Int_t mode)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD2(mutex)
static const char * GetDefaultUser()
Static method returning the default user information.
static const char * GetGlobalUser()
Static method returning the global user.
static GlobusAuth_t GetGlobusAuthHook()
Static method returning the globus authorization hook (no longer supported)
static void RemoveSecContext(TRootSecContext *ctx)
Tool for removing SecContext ctx from THostAuth listed in fgAuthInfo.
void CatchTimeOut()
Called in connection with a timer timeout.
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 'nin' contains list of last input information through (re)reading of a r...
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 TDatime GetGlobalExpDate()
Static method returning default expiring date for new validity contexts.
TRootSecContext * fSecContext
static Int_t ReadRootAuthrc()
Read authentication directives from $ROOTAUTHRC, $HOME/.rootauthrc or <Root_etc_dir>/system....
char * GetRandString(Int_t Opt, Int_t Len)
Allocates and fills a 0 terminated buffer of length len+1 with len random characters.
static void SetGlobalPwHash(Bool_t pwhash)
Set global passwd hash flag to be used for authentication to rootd.
static R__rsa_KEY_export * fgRSAPubExport
static TList * fgAuthInfo
static TString fgDefaultUser
static void SetKrb5AuthHook(Krb5Auth_t func)
Set kerberos5 authorization function.
Int_t SshAuth(TString &user)
SSH client authentication code (no longer supported)
static void SetGlobalPasswd(const char *passwd)
Set global passwd to be used for authentication to rootd.
static TString fgAuthMeth[kMAXSEC]
static void SetDefaultUser(const char *defaultuser)
Set default user name.
static void RemoveHostAuth(THostAuth *ha, Option_t *opt="")
Remove THostAuth instance from the list.
static void Show(Option_t *opt="S")
Print info about the authentication sector.
static Int_t GetRSAInit()
Static method returning the RSA initialization flag.
static R__rsa_KEY fgRSAPubKey
static Int_t DecodeRSAPublic(const char *rsapubexport, R__rsa_NUMBER &n, R__rsa_NUMBER &d, char **rsassl=nullptr)
Store RSA public keys from export string rsaPubExport.
static void SetDefaultRSAKeyType(Int_t key)
Static method setting the default type of RSA key.
static TString fgRootAuthrc
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 SetGlobalExpDate(TDatime expdate)
Set default expiring date for new validity contexts.
static TPluginHandler * fgPasswdDialog
static Int_t SetRSAPublic(const char *rsapubexport, Int_t klen)
Store RSA public keys from export string rsaPubExport.
static Bool_t fgPromptUser
static TList * GetAuthInfo()
Static method returning the list with authentication details.
void SetEnvironment()
Set default authentication environment.
static void SetTimeOut(Int_t to)
Set timeout (active if > 0)
static Bool_t GetAuthReUse()
Static method returning the authentication reuse settings.
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 SecureAuth_t fgSecAuthHook
static const char * GetKrb5Principal()
Static method returning the principal to be used to init Krb5 tickets.
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...
static Bool_t GetPromptUser()
Static method returning the prompt user settings.
static void SetGlobalSRPPwd(Bool_t srppwd)
Set global SRP passwd flag to be used for authentication to rootd.
static void SetSecureAuthHook(SecureAuth_t func)
Set secure authorization function.
Bool_t Authenticate()
Authenticate to remote rootd server.
Int_t RfioAuth(TString &user)
RFIO authentication (no longer supported)
static TDatime fgLastAuthrc
static void SetAuthReUse(Bool_t authreuse)
Set global AuthReUse flag.
static Int_t GetClientProtocol()
Static method returning supported client protocol.
static char * PromptUser(const char *remote)
Static method to prompt for the user name to be used for authentication to rootd.
static Bool_t GetGlobalPwHash()
Static method returning the global password hash flag.
static void SetGlobalUser(const char *user)
Set global user name to be used for authentication to rootd.
static void SetPromptUser(Bool_t promptuser)
Set global PromptUser flag.
static char * PromptPasswd(const char *prompt="Password: ")
Static method to prompt for the user's passwd to be used for authentication to rootd.
TAuthenticate(TSocket *sock, const char *remote, const char *proto, const char *user="")
Create authentication object.
THostAuth * GetHostAuth() const
static Bool_t fgUsrPwdCrypt
Int_t GenRSAKeys()
Generate a valid pair of private/public RSA keys to protect for authentication token exchange.
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 SetRSAInit(Int_t init=1)
Static method setting RSA initialization flag.
static Bool_t fgReadHomeAuthrc
static R__rsa_KEY fgRSAPriKey
static void InitRandom()
Initialize random machine using seed from /dev/urandom (or current time if /dev/urandom not available...
static void SetGlobusAuthHook(GlobusAuth_t func)
Set Globus authorization function.
static const char * GetAuthMethod(Int_t idx)
Static method returning the method corresponding to idx.
static Bool_t fgAuthReUse
static Bool_t GetGlobalSRPPwd()
Static method returning the global SRP password flag.
Bool_t GetUserPasswd(TString &user, TString &passwd, Bool_t &pwhash, Bool_t srppwd)
Try to get user name and passwd from several sources.
const char * GetSshUser(TString user) const
Method returning the user to be used for the ssh login (no longer supported)
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 Int_t SendRSAPublicKey(TSocket *Socket, Int_t key=0)
Receives server RSA Public key Sends local RSA public key encoded.
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 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 Returns pointer ...
static const char * GetRSAPubExport(Int_t key=0)
Static method returning the RSA public keys.
Bool_t CheckNetrc(TString &user, TString &passwd)
Try to get user name and passwd from the ~/.rootnetrc or ~/.netrc files.
void SetHost(const char *host)
void AddFirst(Int_t level, const char *details=nullptr)
Add new method in first position If already in the list, set as first method 'level' with authenticat...
TList * Established() const
void SetFirst(Int_t level)
Set 'method' to be the first used (if in the list ...).
Bool_t HasMethod(Int_t level, Int_t *pos=nullptr)
Return kTRUE if method 'level' is in the list.
void SetUser(const char *user)
void SetServer(Int_t server)
const char * GetHost() const
void Print(Option_t *option="F") const override
If opt is "F" (default) print object content.
const char * GetUser() const
Bool_t IsActive() const
Check remote OffSet and expiring Date.
const char * GetID() const
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
This class represents an Internet Protocol (IP) address.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
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.
This class implements client sockets.
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
static Int_t GetClientProtocol()
Static method returning supported client protocol.
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() 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.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
virtual int GetPid()
Get process id.
virtual const char * Getenv(const char *env)
Get environment variable.
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 const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
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.
This class implements a mutex interface.
TSeqCollection * GetListOfSecContexts(const TROOT &)
Int_t(* GlobusAuth_t)(ROOT::Deprecated::TAuthenticate *auth, TString &user, TString &det)
const Int_t kAUTH_REUSE_MSK
const Int_t kAUTH_CRYPT_MSK
R__rsa_KEY_export R__fgRSAPubExport[2]
R__EXTERN TVirtualMutex * gAuthenticateMutex
const Int_t kAUTH_SSALT_MSK
const Int_t kAUTH_RSATY_MSK
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)