20#include "RConfigure.h"
52#if !defined(R__WIN32) && !defined(R__MACOSX) && !defined(R__FBSD) && \
59#if defined(R__LINUX) || defined(R__FBSD) || defined(R__OBSD)
68extern "C" char *
crypt(
const char *,
const char *);
73# include <openssl/bio.h>
74# include <openssl/err.h>
75# include <openssl/pem.h>
76# include <openssl/rand.h>
77# include <openssl/rsa.h>
78# include <openssl/ssl.h>
79# include <openssl/blowfish.h>
95 "Unsupported",
"Unsupported",
"Unsupported" };
145 if (
rs ==
sizeof(
int))
return r;
147 Printf(
"+++ERROR+++ : auth_rand: neither /dev/urandom nor /dev/random are available or readable!");
151 memcpy((
void *)&
t1, (
void *)&
tv.tv_sec,
sizeof(
int));
152 memcpy((
void *)&
t2, (
void *)&
tv.tv_usec,
sizeof(
int));
187 Info(
"TAuthenticate",
"Enter: local host: %s, user is: %s (proto: %s)",
217 Info(
"TAuthenticate",
218 "service: %s (remote protocol: %d): fVersion: %d",
sproto,
228 if (user &&
strlen(user) > 0) {
253 Info(
"TAuthenticate",
"RSA key: default type %d",
fgRSAKey);
273 Info(
"TAuthenticate",
274 "number of HostAuth Instantiations in memory: %d",
298 tmp.ReplaceAll(
"root",4,
"",0);
299 tmp.ReplaceAll(
"sock",4,
"",0);
338 Info(
"CatchTimeOut",
"%d sec timeout expired (protocol: %s)",
339 fgAuthTO, fgAuthMeth[fSecurity].Data());
343 fSocket->Close(
"force");
370 Info(
"Authenticate",
"enter: fUser: %s", fUser.Data());
377 alarm->SetInterruptSyscalls();
379 alarm->Connect(
"Timeout()",
"TAuthenticate",
this,
"CatchTimeOut()");
387 Info(
"Authenticate",
"try #: %d",
ntry);
395 fDetails = fHostAuth->GetDetails((
Int_t) fSecurity);
398 "trying authentication: method:%d, default details:%s",
399 fSecurity, fDetails.Data());
413 if (fgAuthTO > 0 &&
alarm) {
418 if (fSecurity == kClear) {
423 user = fgDefaultUser;
428 char *
u = PromptUser(fRemote);
442 Error(
"Authenticate",
443 "unable to get user name for UsrPwd authentication");
452 st = (fTimeOut > 0) ? -3 :
st;
463 Info(
"Authenticate",
"remloc: %d, ntry: %d, meth: %d, fSecurity: %d",
471 fHostAuth->CountSuccess((
Int_t)fSecurity);
473 fSecContext->Print();
474 if (fSecContext->IsActive())
475 fSecContext->AddForCleanup(fSocket->GetPort(),
476 fSocket->GetRemoteProtocol(),fSocket->GetServType());
483 fHostAuth->CountFailure((
Int_t)fSecurity);
489 "negotiation not supported remotely: try next method, if any");
501 if (fSocket->Recv(stat, kind) < 0) {
507 "after failed attempt: kind= %d, stat= %d", kind, stat);
524 "strings with accepted methods not received (%d:%d)",
531 "remotely allowed methods not yet tried: %s",
534 }
else if (stat == 0) {
536 "no more methods accepted remotely to be tried");
551 for (i = 0; i <
remMeth; i++) {
553 if (fHostAuth->GetMethod(
j) ==
rMth[i] &&
tMth[
j] == 0) {
560 available +=
" " + std::to_string(fHostAuth->GetMethod(
j));
568 Warning(
"Authenticate",
"no match with those locally available: %s",
available.c_str());
582 fHostAuth->CountFailure((
Int_t)fSecurity);
585 "method not even started: insufficient or wrong info: %s",
586 "try with next method, if any");
587 fHostAuth->RemoveMethod(fSecurity);
599 fHostAuth->CountFailure((
Int_t)fSecurity);
603 "status code -2 not expected from old daemons");
613 fHostAuth->CountFailure((
Int_t)fSecurity);
615 Info(
"Authenticate",
"got a timeout");
616 fHostAuth->SetLast(fSecurity);
625 fHostAuth->CountFailure((
Int_t)fSecurity);
627 Info(
"Authenticate",
"unknown status code: %d - assume failure",
st);
642 Info(
"Authenticate",
"attempted methods %s are not supported"
645 "failure: list of attempted methods: %s",
triedMeth);
646 AuthError(
"Authenticate",-1);
669 Info(
"SetEnvironment",
670 "setting environment: fSecurity:%d, fDetails:%s", fSecurity,
674 fgDefaultUser = fgUser;
679 if (fDetails !=
"") {
681 char pt[5] = { 0 },
ru[5] = { 0 };
687 if ((ptr =
strstr(fDetails,
"pt:")) != 0) {
697 if ((ptr =
strstr(fDetails,
"ru:")) != 0) {
709 if ((
pd =
hours.Index(
":")) > -1) {
721 if (fSecurity == kClear) {
722 if ((ptr =
strstr(fDetails,
"us:")) != 0)
724 if ((ptr =
strstr(fDetails,
"cp:")) != 0)
727 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s cp:%s",
728 fDetails.Data(),
pt,
ru, us,
cp);
730 if ((ptr =
strstr(fDetails,
"us:")) != 0)
733 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s",
734 fDetails.Data(),
pt,
ru, us);
739 fgPromptUser =
kTRUE;
743 fgExpDate.Set(fgExpDate.Convert() +
hh*3600 + mm*60);
746 if (fSecurity == kClear) {
747 fgUsrPwdCrypt =
kTRUE;
761 fgDefaultUser =
usdef;
764 fgDefaultUser = fgUser;
768 fgDefaultUser =
u->fUser;
772 if (fgDefaultUser ==
"anonymous" || fgDefaultUser ==
"rootd" ||
773 fgUser !=
"" || fUser !=
"") {
779 Info(
"SetEnvironment",
"usdef:%s", fgDefaultUser.Data());
789 Error(
"GetUserPasswd",
"SRP no longer supported by ROOT");
794 Info(
"GetUserPasswd",
"Enter: User: '%s' Hash:%d SRP:%d",
798 if (user ==
"" && fgUser !=
"")
801 if (fgUser !=
"" && user == fgUser) {
802 if (
passwd ==
"" && fgPasswd !=
"") {
809 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
819 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
825 if (user ==
"" ||
passwd ==
"") {
827 Info(
"GetUserPasswd",
"Checking .netrc family ...");
831 Info(
"GetUserPasswd",
"From .netrc family: User: '%s' Hash:%d",
836 char *
p = PromptUser(fRemote);
840 Error(
"GetUserPasswd",
"user name not set");
886 Error(
"CheckNetrc",
"SRP no longer supported by ROOT");
937 href.ReplaceAll(
"*",
".*");
961 "file %s exists but has not 0600 permission",
net);
1011 return fgDefaultUser;
1019 ::Error(
"Krb5Auth",
"Kerberos5 is no longer supported by ROOT");
1036 return fgPromptUser;
1047 ::Error(
"Authenticate::GetAuthMethod",
"idx out of bounds (%d)", idx);
1050 return fgAuthMeth[idx];
1082 if (fgDefaultUser !=
"")
1083 user = fgDefaultUser;
1092 "not tty: cannot prompt for user, returning default");
1102 usr.Remove(
usr.Length() - 1);
1120 ::Warning(
"TAuthenticate::PromptPasswd",
1121 "not tty: cannot prompt for passwd, returning -1");
1122 static char noint[4] = {
"-1"};
1127 const char *
pw = buf;
1131 if ((fgPasswdDialog =
1132 gROOT->GetPluginManager()->FindHandler(
"TGPasswdDialog"))) {
1133 if (fgPasswdDialog->LoadPlugin() == -1) {
1136 "could not load plugin for the password dialog box");
1140 if (fgPasswdDialog && (fgPasswdDialog != (
TPluginHandler *)(-1))) {
1143 fgPasswdDialog->ExecPlugin(3,
prompt, buf, 128);
1146 while (
gROOT->IsInterrupted())
1158 if (
spw.EndsWith(
"\n"))
1159 spw.Remove(
spw.Length() - 1);
1179 key = (key >= 0 && key <= 1) ? key : 0;
1180 return fgRSAPubExport[key].keys;
1196 if (key >= 0 && key <= 1)
1216 fgAuthInfo =
new TList;
1236 lasterr =
"(last error only; re-run with gDebug > 0 for more details)";
1245 ::Error(
Form(
"TAuthenticate::%s",
where),
1246 "unknown error code: server must be running a newer ROOT version %s",
1264 if (user && user[0])
1295 ::Error(
"SetGlobalSRPPwd",
"SRP no longer supported by ROOT");
1311 if (fgDefaultUser !=
"")
1323 fgAuthTO = (to <= 0) ? -1 : to;
1347 fgSecAuthHook = func;
1356 ::Error(
"Krb5Auth",
"Kerberos5 is no longer supported by ROOT");
1365 ::Error(
"GlobusAuth",
"Globus is no longer supported by ROOT");
1373 ::Error(
"SshAuth",
"SSH is no longer supported by ROOT");
1382 ::Error(
"GetSshUser",
"SSH is no longer supported by ROOT");
1429 ::Info(
"TAuthenticate::CheckHost",
"checking host IP: %s",
theHost.Data());
1452 ::Error(
"RfioAuth",
"RfioAuth is no longer supported by ROOT");
1466 Info(
"ClearAuth",
"enter: user: %s (passwd hashed?: %d)",
1476 fgPromptUser, fgAuthReUse, fgUsrPwdCrypt) + user;
1478 Info(
"ClearAuth",
"ru:%d pt:%d cp:%d ns:%d rk:%d",
1479 fgAuthReUse,fgPromptUser,fgUsrPwdCrypt,
needsalt,fgRSAKey);
1507 options.
Form(
"%d %ld %s %ld %s", opt,
1529 Info(
"ClearAuth",
"anonymous user");
1538 char ctag[11] = {0};
1546 "problems recvn RSA key flag: got message %d, flag: %d",
1552 Info(
"ClearAuth",
"get key request ...");
1558 if (SendRSAPublicKey(fSocket,fRSAKey) < 0)
1565 if ((
slen = SecureRecv(fSocket, 1, fRSAKey, &
tmpsalt)) == -1) {
1566 Warning(
"ClearAuth",
"problems secure-receiving salt -"
1567 " may result in corrupted salt");
1568 Warning(
"ClearAuth",
"switch off reuse for this session");
1599 Info(
"ClearAuth",
"got salt: '%s' (len: %d)",
salt.Data(),
slen);
1602 Info(
"ClearAuth",
"Salt not required");
1604 if (SecureRecv(fSocket, 1, fRSAKey, &
tmptag) == -1) {
1605 Warning(
"ClearAuth",
"problems secure-receiving rndmtag -"
1606 " may result in corrupted rndmtag");
1621 if (fgPasswd.Contains(
"@")) {
1643 "automatically generated anonymous passwd: %s",
1653 xp.Form(
"%s@%s password: ", user.
Data(),fRemote.Data());
1654 char *pwd = PromptPasswd(
xp);
1658 Error(
"ClearAuth",
"password not set");
1700 if (SecureSend(fSocket, 1, fRSAKey,
pashash.Data()) == -1) {
1701 Warning(
"ClearAuth",
"problems secure-sending pass hash"
1702 " - may result in authentication failure");
1709 for (
int i = 0; i <
passwd.Length(); i++) {
1720 if ((
nrec = fSocket->Recv(stat, kind)) < 0 )
1723 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
1728 AuthError(
"ClearAuth", stat);
1735 "problems recvn (user,offset) length (%d:%d bytes:%d)",
1740 int reclen = (stat+1 > 256) ? 256 : stat+1;
1745 "username and offset not received (%d:%d)", kind,
1754 "received from server: user: %s, offset: %d (%s)",
lUser,
1764 if (SecureRecv(fSocket, 1, fRSAKey, &token) == -1) {
1766 "problems secure-receiving token -"
1767 " may result in corrupted token");
1772 token =
new char[
tlen];
1773 if (fSocket->Recv(token,
tlen, kind) < 0) {
1778 Warning(
"ClearAuth",
"token not received (%d:%d)", kind,
1781 for (
int i = 0; i < (
int)
strlen(token); i++) {
1787 Info(
"ClearAuth",
"received from server: token: '%s' ",
1792 fSecContext = fHostAuth->CreateSecContext((
const char *)
lUser, fRemote,
1793 kClear,
offset, fDetails, (
const char *)token,
1794 fgExpDate, (
void *)
pwdctx, fRSAKey);
1801 if (fSocket->Recv(stat, kind) < 0)
1808 AuthError(
"ClearAuth", stat);
1821 if (fSocket->Recv(stat, kind) < 0)
1828 fHostAuth->CreateSecContext(user,fRemote,kClear,-1,fDetails,0);
1834 if (fProtocol.Contains(
"root"))
1839 "%s@%s does not accept connections from %s@%s",
1840 server.Data(),fRemote.Data(),
1846 "%s@%s does not accept %s authentication from %s@%s",
1847 server.Data(),fRemote.Data(),
1851 AuthError(
"ClearAuth", stat);
1858 xp.Form(
"%s@%s password: ", user.
Data(),fRemote.Data());
1859 char *
p = PromptPasswd(
xp);
1863 Error(
"ClearAuth",
"password not set");
1865 if (fUser ==
"anonymous" || fUser ==
"rootd") {
1866 if (!
passwd.Contains(
"@")) {
1868 "please use passwd of form: user@host.do.main");
1879 for (
int i = 0; i <
passwd.Length(); i++) {
1889 if (fSocket->Recv(stat, kind) < 0)
1892 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
1897 fHostAuth->CreateSecContext(user,fRemote,kClear,-1,fDetails,0);
1901 AuthError(
"ClearAuth", stat);
1920 ::Info(
"TAuthenticate::GetHostAuth",
"enter ... %s ... %s", host, user);
1926 char *ps = (
char *)
strstr(host,
":");
1950 ai->Print(
"Authenticate::GetHostAuth");
1989 ::Info(
"TAuthenticate::HasHostAuth",
"enter ... %s ... %s", host, user);
1995 char *ps = (
char *)
strstr(host,
":");
2032 ::Info(
"TAuthenticate::FileExpand",
"enter ... '%s' ... 0x%zx",
fexp, (
size_t)
ftmp);
2045 ::Info(
"TAuthenticate::FileExpand",
"read line ... '%s'",
line);
2056 ln.ReplaceAll(
"\"",1,
"",0);
2057 ln.ReplaceAll(
"'",1,
"",0);
2064 if (
edir.Contains(
"/")) {
2092 "file specified by 'include' cannot be open or read (%s)",
2107 const char copt[2][5] = {
"no",
"yes" };
2110 ::Info(
"TAuthenticate::GetDefaultDetails",
2111 "enter ... %d ...pt:%d ... '%s'",
sec, opt,
usr);
2127 ::Info(
"TAuthenticate::GetDefaultDetails",
"returning ... %s", temp);
2137 GetAuthInfo()->Remove(
ha);
2161 ::Info(
"::Print",
" +--------------------------- BEGIN --------------------------------+");
2162 ::Info(
"::Print",
" + +");
2163 ::Info(
"::Print",
" + List fgAuthInfo has %4d members +",
2164 GetAuthInfo()->GetSize());
2165 ::Info(
"::Print",
" + +");
2166 ::Info(
"::Print",
" +------------------------------------------------------------------+");
2167 TIter next(GetAuthInfo());
2171 ai->PrintEstablished();
2173 ::Info(
"::Print",
" +---------------------------- END ---------------------------------+");
2189 Info(
"AuthExists",
"%d: enter: msg: %d options: '%s'",
2190 method,*message, options);
2196 TIter next(fHostAuth->Established());
2200 if (fRemote ==
secctx->GetHost()) {
2213 if (fRemote ==
secctx->GetHost()) {
2229 token =
secctx->GetToken();
2232 "found valid TSecContext: offset: %d token: '%s'",
2238 sstr.Form(
"%d %d %s", fgProcessID,
offset, options);
2241 if (fSocket->Send(
sstr, *message) < 0)
2253 Int_t stat = 1, kind;
2255 if (fSocket->Recv(stat, kind) < 0)
2258 Warning(
"AuthExists",
"protocol error: expecting %d got %d"
2264 Info(
"AuthExists",
"offset OK");
2283 if (SecureSend(fSocket, 1,
rsaKey, token) == -1) {
2284 Warning(
"AuthExists",
"problems secure-sending token %s",
2285 "- may trigger problems in proofing Id ");
2290 for (
int i = 0; i < token.
Length(); i++) {
2299 Info(
"AuthExists",
"offset not OK - rerun authentication");
2307 if (fSocket->Recv(stat, kind) < 0)
2310 Info(
"AuthExists",
"%d: after msg %d: kind= %d, stat= %d",
2311 method,*message, kind, stat);
2322 Error(
"AuthExists",
"%s@%s does not accept connections from %s@%s",
2328 "%s@%s does not accept %s authentication from %s@%s",
2329 server.Data(),fRemote.Data(), fgAuthMeth[
method].Data(),
2332 AuthError(
"AuthExists", stat);
2343 fHostAuth->CreateSecContext(fUser,fRemote,
method,-stat,fDetails,0);
2346 Info(
"AuthExists",
"valid authentication exists");
2348 Info(
"AuthExists",
"valid authentication exists: offset changed");
2350 Info(
"AuthExists",
"remote access authorized by /etc/hosts.equiv");
2352 Info(
"AuthExists",
"no authentication required remotely");
2367 fHostAuth->Established()->Add(
secctx);
2382 const char *
randdev =
"/dev/urandom";
2388 if (read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
2393 ::Info(
"InitRandom",
"%s not available: using time()",
randdev);
2408 Info(
"GenRSAKeys",
"enter");
2410 if (fgRSAInit == 1) {
2412 Info(
"GenRSAKeys",
"Keys prviously generated - return");
2431 if (fgRSAKey == 1) {
2434 Info(
"GenRSAKeys",
"SSL: Generate Blowfish key");
2458 char *
rbuf = GetRandString(0,
klen);
2462 fgRSAPubExport[1].len =
klen;
2463 fgRSAPubExport[1].keys =
rbuf;
2465 Info(
"GenRSAKeys",
"SSL: BF key length: %d", fgRSAPubExport[1].
len);
2504 Info(
"GenRSAKeys",
"equal primes: regenerate (%d times)",
nPrimes);
2512 Info(
"GenRSAKeys",
"local: p1: '%s' ", buf);
2514 Info(
"GenRSAKeys",
"local: p2: '%s' ", buf);
2520 Info(
"GenRSAKeys",
" genrsa: unable to generate keys (%d)",
2537 Info(
"GenRSAKeys",
"local: n: '%s' length: %d",
buf_n,
l_n);
2538 Info(
"GenRSAKeys",
"local: e: '%s' length: %d",
buf_e,
l_e);
2539 Info(
"GenRSAKeys",
"local: d: '%s' length: %d",
buf_d,
l_d);
2550 char *
tdum = GetRandString(0,
lTes - 1);
2555 Info(
"GenRSAKeys",
"local: test string: '%s' ",
test);
2564 "local: length of crypted string: %d bytes",
lout);
2570 Info(
"GenRSAKeys",
"local: after private/public : '%s' ", buf);
2581 Info(
"GenRSAKeys",
"local: length of crypted string: %d bytes ",
2588 Info(
"GenRSAKeys",
"local: after public/private : '%s' ", buf);
2607 Info(
"GenRSAKeys",
"local: generated keys are:");
2608 Info(
"GenRSAKeys",
"local: n: '%s' length: %d",
buf_n,
l_n);
2609 Info(
"GenRSAKeys",
"local: e: '%s' length: %d",
buf_e,
l_e);
2610 Info(
"GenRSAKeys",
"local: d: '%s' length: %d",
buf_d,
l_d);
2614 if (fgRSAPubExport[0].keys) {
2615 delete [] fgRSAPubExport[0].keys;
2616 fgRSAPubExport[0].len = 0;
2618 fgRSAPubExport[0].len =
l_n +
l_d + 4;
2619 fgRSAPubExport[0].keys =
new char[fgRSAPubExport[0].len];
2621 fgRSAPubExport[0].keys[0] =
'#';
2623 fgRSAPubExport[0].keys[
l_n + 1] =
'#';
2625 fgRSAPubExport[0].keys[
l_n +
l_d + 2] =
'#';
2626 fgRSAPubExport[0].keys[
l_n +
l_d + 3] = 0;
2629 Info(
"GenRSAKeys",
"local: export pub: '%s'", fgRSAPubExport[0].keys);
2632 Info(
"GenRSAKeys",
"local: export pub length: %d bytes", fgRSAPubExport[0].
len);
2651 unsigned int iimx[4][4] = {
2652 {0x0, 0xffffff08, 0xafffffff, 0x2ffffffe},
2653 {0x0, 0x3ff0000, 0x7fffffe, 0x7fffffe},
2654 {0x0, 0x3ff0000, 0x7e, 0x7e},
2655 {0x0, 0x3ffc000, 0x7fffffe, 0x7fffffe}
2658 const char *
cOpt[4] = {
"Any",
"LetNum",
"Hex",
"Crypt" };
2664 Info(
"GetRandString",
"unknown option: %d : assume 0", opt);
2667 Info(
"GetRandString",
"enter ... len: %d %s",
len,
cOpt[opt]);
2670 char *buf =
new char[
len + 1];
2680 for (
m = 7;
m < 32;
m += 7) {
2681 i = 0x7F & (
frnd >>
m);
2684 if ((
iimx[opt][
j] & (1 <<
l))) {
2696 Info(
"GetRandString",
"got '%s' ", buf);
2713 ::Info(
"TAuthenticate::SecureSend",
"local: enter ... (enc: %d)",
enc);
2730 }
else if (key == 1) {
2736 unsigned char iv[8];
2742 ::Info(
"TAuthenticate::SecureSend",
"not compiled with SSL support:"
2743 " you should not have got here!");
2747 ::Info(
"TAuthenticate::SecureSend",
"unknown key type (%d)",key);
2756 ::Info(
"TAuthenticate::SecureSend",
2757 "local: sent %d bytes (expected: %d)",
nsen,
ttmp);
2779 if (sock->
Recv(buflen, 20, kind) < 0)
2783 ::Info(
"TAuthenticate::SecureRecv",
"got len '%s' %d (msg kind: %d)",
2806 if (*str ==
nullptr) {
2808 ::Info(
"TAuthenticate::SecureRecv",
"Memory allocation error size (%ld)", (
long)
strSize);
2813 }
else if (key == 1) {
2815 unsigned char iv[8];
2817 *str =
new char[
nrec + 1];
2820 (*str)[
nrec] =
'\0';
2823 ::Info(
"TAuthenticate::SecureRecv",
"not compiled with SSL support:"
2824 " you should not have got here!");
2828 ::Info(
"TAuthenticate::SecureRecv",
"unknown key type (%d)",key);
2847 ::Info(
"TAuthenticate::DecodeRSAPublic",
2853 ::Info(
"TAuthenticate::DecodeRSAPublic",
2866 while (str[k] == 32) k++;
2868 if (str[k] ==
'#') {
2882 ::Info(
"TAuthenticate::DecodeRSAPublic",
2889 ::Info(
"TAuthenticate::DecodeRSAPublic",
2899 ::Info(
"TAuthenticate::DecodeRSAPublic",
"bad format for input string");
2916 ::Info(
"TAuthenticate::DecodeRSAPublic",
2917 "unable to read pub key from bio");
2922 ::Info(
"TAuthenticate::DecodeRSAPublic",
2923 "no space allocated for output variable");
2930 ::Info(
"TAuthenticate::DecodeRSAPublic",
"not compiled with SSL support:"
2931 " you should not have got here!");
2946 ::Info(
"TAuthenticate::SetRSAPublic",
2989 ::Info(
"TAuthenticate::SetRSAPublic",
" Key type: %d",
rsakey);
3007 ::Info(
"TAuthenticate::SetRSAPublic",
3008 "not compiled with SSL support:"
3009 " you should not have got here!");
3029 ::Info(
"TAuthenticate::SendRSAPublicKey",
3050 char buflen[20] = {0};
3057 }
else if (key == 1) {
3066 (
unsigned char *)&fgRSAPubExport[key].keys[
kk],
3071 ::Info(
"TAuthenticate::SendRSAPublicKey",
"SSL: error: '%s' ",
errstr);
3081 ::Info(
"TAuthenticate::SendRSAPublicKey",
"not compiled with SSL support:"
3082 " you should not have got here!");
3087 ::Info(
"TAuthenticate::SendRSAPublicKey",
"unknown key type (%d)",key);
3101 ::Info(
"TAuthenticate::SendRSAPublicKey",
3102 "local: sent %d bytes (expected: %d)",
nsen,
ttmp);
3122 if (fgReadHomeAuthrc) {
3128 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking file: %s",
tRootAuthrc.Data());
3131 ::Info(
"TAuthenticate::ReadRootAuthrc",
3136 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking system file: %s",
tRootAuthrc.Data());
3139 ::Info(
"TAuthenticate::ReadRootAuthrc",
3149 if ((
UInt_t)
si.st_mtime < fgLastAuthrc.Convert()) {
3151 ::Info(
"TAuthenticate::ReadRootAuthrc",
3169 ::Info(
"TAuthenticate::ReadRootAuthrc",
"got tmp file: %s open at 0x%zx",
3185 ::Info(
"TAuthenticate::ReadRootAuthrc",
3212 ::Error(
"TAuthenticate::ReadRootAuthrc",
3213 "could not allocate temporary buffer");
3253 if (host ==
ha->GetHost() && user ==
ha->GetUser() &&
3271 met = GetAuthMethodIdx(
mth);
3273 ::Info(
"TAuthenticate::ReadRootAuthrc",
3274 "unrecognized method (%s): ",
mth);
3292 met = GetAuthMethodIdx(
mth);
3294 ::Info(
"TAuthenticate::ReadRootAuthrc",
3295 "unrecognized method (%s): ",
mth);
3300 const char *
det = 0;
3305 if (
ha->HasMethod(
met))
3360 if (!
ha->IsActive()) {
3370 if (
hanew->NumMethods()) {
3379 hanew->DeActivate();
3386 hanew->DeActivate();
3392 if (!
hanew->IsActive()) {
3411 TIter next(
ha->Established());
3415 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 *)