21#include "RConfigure.h"
51#if !defined(R__WIN32) && !defined(R__MACOSX) && !defined(R__FBSD) && \
58#if defined(R__LINUX) || defined(R__FBSD) || defined(R__OBSD)
67extern "C" char *crypt(
const char *,
const char *);
77# include <openssl/bio.h>
78# include <openssl/err.h>
79# include <openssl/pem.h>
80# include <openssl/rand.h>
81# include <openssl/rsa.h>
82# include <openssl/ssl.h>
83# include <openssl/blowfish.h>
91 static BF_KEY fgBFKey;
97 "Globus",
"SSH",
"UidGid" };
142 int frnd =
open(
"/dev/urandom", O_RDONLY);
143 if (frnd < 0) frnd =
open(
"/dev/random", O_RDONLY);
146 ssize_t rs = read(frnd, (
void *) &
r,
sizeof(
int));
149 if (rs ==
sizeof(
int))
return r;
151 Printf(
"+++ERROR+++ : auth_rand: neither /dev/urandom nor /dev/random are available or readable!");
153 if (gettimeofday(&tv,0) == 0) {
155 memcpy((
void *)&
t1, (
void *)&tv.tv_sec,
sizeof(
int));
156 memcpy((
void *)&t2, (
void *)&tv.tv_usec,
sizeof(
int));
172 const char *
proto,
const char *user)
179 if (
gROOT->IsProofServ())
196 Info(
"TAuthenticate",
"Enter: local host: %s, user is: %s (proto: %s)",
205 if ((pdd = strstr(sproto,
":")) != 0) {
206 int rproto = atoi(pdd + 1);
208 if (strstr(sproto,
"root") != 0) {
225 if (strstr(sproto,
"proof") != 0) {
240 Info(
"TAuthenticate",
241 "service: %s (remote protocol: %d): fVersion: %d", sproto,
251 if (user && strlen(user) > 0) {
257 checkUser = u->
fUser;
277 Info(
"TAuthenticate",
"RSA key: default type %d",
fgRSAKey);
291 fqdnsrv.
Form(
"%s:%d",fqdn.
Data(),servtype);
297 Info(
"TAuthenticate",
298 "number of HostAuth Instantiations in memory: %d",
325 if (!strncmp(tmp.
Data(),
"up",2))
327 else if (!strncmp(tmp.
Data(),
"s",1))
329 else if (!strncmp(tmp.
Data(),
"k",1))
331 else if (!strncmp(tmp.
Data(),
"g",1))
333 else if (!strncmp(tmp.
Data(),
"h",1))
335 else if (!strncmp(tmp.
Data(),
"ug",2))
337 if (sec > -1 && sec <
kMAXSEC) {
363 Info(
"CatchTimeOut",
"%d sec timeout expired (protocol: %s)",
387 char noSupport[80] = { 0 };
388 char triedMeth[80] = { 0 };
404 alarm->
Connect(
"Timeout()",
"TAuthenticate",
this,
"CatchTimeOut()");
412 Info(
"Authenticate",
"try #: %d", ntry);
423 "trying authentication: method:%d, default details:%s",
427 if (triedMeth[0] !=
'\0')
428 (
void) strlcat(triedMeth,
" ",
sizeof(triedMeth) - 1);
469 Error(
"Authenticate",
470 "unable to get user name for UsrPwd authentication");
507 Error(
"Authenticate",
508 "no support for SRP authentication available");
510 Error(
"Authenticate",
511 "unable to get user name for SRP authentication");
536 Error(
"Authenticate",
537 "support for kerberos5 auth locally unavailable");
541 Info(
"Authenticate",
"remote daemon does not support Kerberos authentication");
542 (
void) strlcat(noSupport, noSupport[0] ==
'\0' ?
"Krb5" :
"/Krb5",
sizeof(noSupport) - 1);
560 Error(
"Authenticate",
561 "no support for Globus authentication available");
565 Info(
"Authenticate",
"remote daemon does not support Globus authentication");
566 (
void) strlcat(noSupport, noSupport[0] ==
'\0' ?
"Globus" :
"/Globus",
sizeof(noSupport) - 1);
579 Info(
"Authenticate",
"remote daemon does not support SSH authentication");
580 (
void) strlcat(noSupport, noSupport[0] ==
'\0' ?
"SSH" :
"/SSH",
sizeof(noSupport) - 1);
592 Info(
"Authenticate",
"remote daemon does not support UidGid authentication");
593 (
void) strlcat(noSupport, noSupport[0] ==
'\0' ?
"UidGid" :
"/UidGid",
sizeof(noSupport) - 1);
598 if (alarm) alarm->
Stop();
610 Int_t remloc = nmet - ntry;
612 Info(
"Authenticate",
"remloc: %d, ntry: %d, meth: %d, fSecurity: %d",
638 "negotiation not supported remotely: try next method, if any");
639 if (meth < nmet - 1) {
656 "after failed attempt: kind= %d, stat= %d", kind, stat);
663 char *answer =
new char[len];
672 "strings with accepted methods not received (%d:%d)",
675 sscanf(answer,
"%d %d %d %d %d %d", &rMth[0], &rMth[1],
676 &rMth[2], &rMth[3], &rMth[4], &rMth[5]);
677 if (
gDebug > 0 && remloc > 0)
679 "remotely allowed methods not yet tried: %s",
682 }
else if (stat == 0) {
684 "no more methods accepted remotely to be tried");
697 std::string available{};
699 for (i = 0; i < remMeth; i++) {
700 for (j = 0; j < nmet; j++) {
710 if (methfound)
break;
712 if (methfound)
break;
716 Warning(
"Authenticate",
"no match with those locally available: %s", available.c_str());
733 "method not even started: insufficient or wrong info: %s",
734 "try with next method, if any");
751 "status code -2 not expected from old daemons");
763 Info(
"Authenticate",
"got a timeout");
765 if (meth < nmet - 1) {
775 Info(
"Authenticate",
"unknown status code: %d - assume failure",st);
789 if (strlen(noSupport) > 0)
790 Info(
"Authenticate",
"attempted methods %s are not supported"
791 " by remote server version", noSupport);
793 "failure: list of attempted methods: %s", triedMeth);
817 Info(
"SetEnvironment",
818 "setting environment: fSecurity:%d, fDetails:%s",
fSecurity,
833 char pt[5] = { 0 }, ru[5] = { 0 };
840 if ((ptr = strstr(
fDetails,
"pt:")) != 0) {
841 sscanf(ptr + 3,
"%4s %8191s",
pt, usdef);
843 if (!strncasecmp(
gEnv->
GetValue(usrPromptDef,
""),
"no",2) ||
850 if ((ptr = strstr(
fDetails,
"ru:")) != 0) {
851 sscanf(ptr + 3,
"%4s %8191s", ru, usdef);
853 if (!strncasecmp(
gEnv->
GetValue(usrReUseDef,
""),
"no",2) ||
862 if ((pd = hours.
Index(
":")) > -1) {
866 hh = atoi(hours.
Data());
867 mm = atoi(minutes.
Data());
869 hh = atoi(hours.
Data());
875 if ((ptr = strstr(
fDetails,
"cd:")) != 0)
876 sscanf(ptr,
"%8191s %8191s", cd, usdef);
877 if ((ptr = strstr(
fDetails,
"cf:")) != 0)
878 sscanf(ptr,
"%8191s %8191s", cf, usdef);
879 if ((ptr = strstr(
fDetails,
"kf:")) != 0)
880 sscanf(ptr,
"%8191s %8191s", kf, usdef);
881 if ((ptr = strstr(
fDetails,
"ad:")) != 0)
882 sscanf(ptr,
"%8191s %8191s", ad, usdef);
884 Info(
"SetEnvironment",
885 "details:%s, pt:%s, ru:%s, cd:%s, cf:%s, kf:%s, ad:%s",
889 if ((ptr = strstr(
fDetails,
"us:")) != 0)
890 sscanf(ptr + 3,
"%8191s %8191s",
us, usdef);
891 if ((ptr = strstr(
fDetails,
"cp:")) != 0)
892 sscanf(ptr + 3,
"%8191s %8191s", cp, usdef);
894 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s cp:%s",
897 if ((ptr = strstr(
fDetails,
"us:")) != 0)
898 sscanf(ptr + 3,
"%8191s %8191s",
us, usdef);
899 if ((ptr = strstr(
fDetails,
"pp:")) != 0)
900 sscanf(ptr + 3,
"%8191s %8191s", pp, usdef);
902 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s pp:%s",
905 if ((ptr = strstr(
fDetails,
"us:")) != 0)
906 sscanf(ptr + 3,
"%8191s %8191s",
us, usdef);
908 Info(
"SetEnvironment",
"details:%s, pt:%s, ru:%s, us:%s",
913 if (!strncasecmp(
pt,
"yes",3) || !strncmp(
pt,
"1", 1))
919 if (!strncasecmp(ru,
"yes",3) || !strncmp(ru,
"1",1))
924 if (!strncasecmp(ru,
"no",2) || !strncmp(ru,
"0",1))
936 if (!strncmp(cp,
"no", 2) || !strncmp(cp,
"0", 1))
942 for (
const char *str : { cd, cf, kf, ad }) {
944 (
void) strlcat(usdef,
" ",
sizeof(usdef) - 1);
945 (
void) strlcat(usdef, str,
sizeof(usdef) - 1);
951 if (strlen(pp) > 0) {
955 if (strlen(
us) > 0 && strstr(
us,
"@"))
962 if (strlen(
us) > 0 && !strstr(
us,
"@"))
973 if (strlen(usdef) > 0) {
1003 Info(
"GetUserPasswd",
"Enter: User: '%s' Hash:%d SRP:%d",
1023 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
1033 Info(
"GetUserPasswd",
"In memory: User: '%s' Hash:%d",
1039 if (user ==
"" ||
passwd ==
"") {
1041 Info(
"GetUserPasswd",
"Checking .netrc family ...");
1045 Info(
"GetUserPasswd",
"From .netrc family: User: '%s' Hash:%d",
1054 Error(
"GetUserPasswd",
"user name not set");
1132 FILE *fd = fopen(net,
"r");
1134 while (fgets(
line,
sizeof(
line), fd) != 0) {
1138 int nword = sscanf(
line,
"%63s %63s %63s %63s %63s %63s",
1139 word[0], word[1], word[2], word[3], word[4], word[5]);
1142 if (srppwd && strcmp(word[0],
"secure"))
1144 if (!srppwd && strcmp(word[0],
"machine"))
1146 if (strcmp(word[2],
"login"))
1148 if (srppwd && strcmp(word[4],
"password"))
1151 strcmp(word[4],
"password") && strcmp(word[4],
"password-hash"))
1163 if (!strcmp(word[4],
"password-hash"))
1168 if (!strcmp(word[3], user.
Data())) {
1170 if (!strcmp(word[4],
"password-hash"))
1181 "file %s exists but has not 0600 permission", net);
1185 if (
first && !srppwd && !result) {
1265 if (idx < 0 || idx >
kMAXSEC-1) {
1266 ::Error(
"Authenticate::GetAuthMethod",
"idx out of bounds (%d)", idx);
1280 if (meth && meth[0]) {
1309 if (isatty(0) == 0 || isatty(1) == 0) {
1311 "not tty: cannot prompt for user, returning default");
1318 const char *usrIn = Getline(
Form(
"Name (%s:%s): ", remote, user));
1338 if (isatty(0) == 0 || isatty(1) == 0) {
1339 ::Warning(
"TAuthenticate::PromptPasswd",
1340 "not tty: cannot prompt for passwd, returning -1");
1341 static char noint[4] = {
"-1"};
1346 const char *pw = buf;
1351 gROOT->GetPluginManager()->FindHandler(
"TGPasswdDialog"))) {
1355 "could not load plugin for the password dialog box");
1365 while (
gROOT->IsInterrupted())
1369 Gl_config(
"noecho", 1);
1370 pw = Getline(prompt);
1371 Gl_config(
"noecho", 0);
1398 key = (key >= 0 && key <= 1) ? key : 0;
1415 if (key >= 0 && key <= 1)
1468 lasterr =
"(last error only; re-run with gDebug > 0 for more details)";
1472 if (
gDebug > 0 || forceprint) {
1474 ::Error(
Form(
"TAuthenticate::%s", where),
"%s %s",
1478 "unknown error code: server must be running a newer ROOT version %s",
1496 if (user && user[0])
1556 if (defaultuser && defaultuser[0])
1621 FILE *ferr = fopen(errorfile,
"r");
1627 Int_t lerr = strlen(serr);
1628 char *
pc = (
char *)memchr(serr,
'"',lerr);
1631 pc = (
char *)memchr(
pc+1,
'"',strlen(
pc+1));
1635 while (fgets(
line,
sizeof(
line),ferr)) {
1640 Info(
"SshError",
"read line: %s",
line);
1642 while (
pc < serr + lerr) {
1643 if (
pc[0] ==
'\0' ||
pc[0] ==
' ')
1647 Info(
"SshError",
"checking error: '%s'",
pc);
1673 if (
gROOT->IsProofServ()) {
1676 Info(
"SshAuth",
"SSH protocol is switched OFF by default"
1677 " for PROOF servers: use 'ProofServ.UseSSH 1'"
1678 " to enable it (see system.rootrc)");
1688 char cmdref[2][5] = {
"ssh",
"scp"};
1693 while (notfound && sshproto > -1) {
1695 strlcpy(scmd,cmdref[sshproto],5);
1704 Info(
"SshAuth",
"%s not found in $PATH", scmd);
1707 if (strcmp(
gEnv->
GetValue(
"SSH.ExecDir",
"-1"),
"-1")) {
1709 Info(
"SshAuth",
"searching user defined path ...");
1713 Info(
"SshAuth",
"%s not executable", sshExe.
Data());
1719 if (notfound) sshproto--;
1727 Info(
"SshAuth",
"%s is %s (sshproto: %d)", scmd, sshExe.
Data(), sshproto);
1750 options.
Form(
"%d none %ld %s %d", opt,
1755 Int_t retval = reuse;
1790 Info(
"SshAuth",
"received from server command info: %s", cmdinfo);
1796 while (ci.Tokenize(tkn, from,
" ")) {
1797 if (from > 0) cmdinfo[from-1] =
'\0';
1811 if (isatty(0) == 0 || isatty(1) == 0) {
1812 noPrompt =
TString(
"-o 'PasswordAuthentication no' ");
1813 noPrompt +=
TString(
"-o 'StrictHostKeyChecking no' ");
1815 Info(
"SshAuth",
"using noprompt options: %s", noPrompt.
Data());
1827 if (sshproto == 0) {
1829 fileErr =
"rootsshtmp_";
1833 fileErr =
"rootsshtmp_";
1837 fileErr.
Append(
".error");
1839 sshcmd.
Form(
"%s -x -l %s %s", sshExe.
Data(), user.
Data(), noPrompt.
Data());
1847 while (ssh_rc && again && ntry--) {
1852 Info(
"SshAuth",
"%d: sleeping: rc: %d, again:%d, ntry: %d",
1867 TString fileLoc =
"rootsshtmp_";
1871 fileLoc =
"rootsshtmp_";
1878 if (chmod(fileLoc, 0600) == -1) {
1879 Info(
"SshAuth",
"fchmod error: %d", errno);
1881 }
else if ((floc = fopen(fileLoc,
"w"))) {
1885 fprintf(floc,
"k: %d\n",
fRSAKey+1);
1893 fprintf(floc,
"k: -1\n");
1900 sshcmd.
Form(
"%s -p %s", sshExe.
Data(), noPrompt.
Data());
1914 while (ssh_rc && again && ntry--) {
1919 Info(
"SshAuth",
"%d: sleeping: rc: %d, again:%d, ntry: %d",
1941 Info(
"SshAuth",
"%d: system return code: %d (%d)",
1944 if (ssh_rc && sshproto == 0) {
1969 newsock->
Send(
"failure notification");
1972 char cd1[1024], pipe[1024], dum[1024];
1974 sscanf(cmdinfo,
"%1023s %d %1023s %1023s", cd1, &id3, pipe, dum);
1982 if (newsock->
Recv(retval, kind) >= 0) {
1983 char *buf =
new char[retval+1];
1984 if (newsock->
Recv(buf, retval+1, kind) >= 0) {
1985 if (strncmp(buf,
"OK",2)) {
1987 Info(
"SshAuth",
">> nothing listening on port %s %s",buf,
1988 "(supposed to be associated to sshd)");
1989 Info(
"SshAuth",
">> contact the daemon administrator at %s",
1994 Info(
"SshAuth",
">> something listening on the port"
1995 " supposed to be associated to sshd.");
1996 Info(
"SshAuth",
">> You have probably mistyped your"
1997 " password. Or you tried to hack the"
1999 Info(
"SshAuth",
">> If the problem persists you may"
2000 " consider contacting the daemon");
2016 }
else if (ssh_rc && sshproto > 0) {
2019 Info(
"SshAuth",
"error communicating failure");
2026 Info(
"SshAuth",
"error communicating success");
2034 Info(
"SshAuth",
"got message %d, flag: %d", kind, retval);
2042 if (reuse == 1 && sshproto == 0) {
2047 "problems recvn RSA key flag: got message %d, flag: %d",
2062 Info(
"SshAuth",
"got message %d, flag: %d", kind, retval);
2067 "problems recvn (user,offset) length (%d:%d bytes:%d)", kind,
2073 reclen = (retval+1 > 256) ? 256 : retval+1;
2074 if ((nrec =
fSocket->
Recv(answer, reclen, kind)) < 0)
2077 Warning(
"SshAuth",
"username and offset not received (%d:%d)", kind,
2083 sscanf(answer,
"%127s %d", lUser, &offset);
2085 Info(
"SshAuth",
"received from server: user: %s, offset: %d", lUser,
2090 if (reuse == 1 && offset > -1) {
2092 Warning(
"SshAuth",
"problems secure-receiving token -"
2093 " may result in corrupted token");
2098 Info(
"SshAuth",
"received from server: token: '%s' ", token);
2109 if (token)
delete [] token;
2115 Info(
"SshAuth",
"received from server: kind: %d, retval: %d", kind,
2173 if (!strcmp(href,
"*"))
2182 if (rename.
Index(href,&len) != -1 || strstr(href,
"-"))
2187 if (strstr(href,
"*"))
2199 ::Info(
"TAuthenticate::CheckHost",
"checking host IP: %s", theHost.
Data());
2210 if (pos > 0 && pos != (
Ssiz_t)(theHost.
Length()-strlen(href)))
2226 Info(
"RfioAuth",
"enter ... username %s", username.
Data());
2233 username = pw->
fUser;
2237 if (pw->
fUid != 0) {
2250 Info(
"RfioAuth",
"sending ... %s", sstr.
Data());
2255 Info(
"RfioAuth",
"sent ... %d bytes (expected > %d)",
ns,
2263 Info(
"RfioAuth",
"after kROOTD_RFIO: kind= %d, stat= %d", kind,
2285 "%s@%s does not accept connections from %s%s",
2293 "%s@%s does not accept %s authentication from %s@%s",
2304 Warning(
"RfioAuth",
"UidGid login as \"root\" not allowed");
2321 Info(
"ClearAuth",
"enter: user: %s (passwd hashed?: %d)",
2333 Info(
"ClearAuth",
"ru:%d pt:%d cp:%d ns:%d rk:%d",
2362 options.
Form(
"%d %ld %s %ld %s", opt,
2384 Info(
"ClearAuth",
"anonymous user");
2393 char ctag[11] = {0};
2394 if (anon == 0 && cryptopt == 1) {
2401 "problems recvn RSA key flag: got message %d, flag: %d",
2407 Info(
"ClearAuth",
"get key request ...");
2421 Warning(
"ClearAuth",
"problems secure-receiving salt -"
2422 " may result in corrupted salt");
2423 Warning(
"ClearAuth",
"switch off reuse for this session");
2431 while (ltmp && tmpsalt[ltmp-1] !=
'#') ltmp--;
2433 if (tmpsalt[ltmp-1] ==
'#' &&
2434 tmpsalt[ltmp-10] ==
'#') {
2435 strlcpy(ctag,&tmpsalt[ltmp-10],11);
2454 Info(
"ClearAuth",
"got salt: '%s' (len: %d)", salt.
Data(), slen);
2457 Info(
"ClearAuth",
"Salt not required");
2460 Warning(
"ClearAuth",
"problems secure-receiving rndmtag -"
2461 " may result in corrupted rndmtag");
2464 strlcpy(ctag, tmptag, 11);
2490 if (localFQDN ==
"") {
2498 "automatically generated anonymous passwd: %s",
2504 if (prompt == 1 || pashash.
Length() == 0) {
2513 Error(
"ClearAuth",
"password not set");
2518 if (needsalt && !pwdhash) {
2546 if (anon == 0 && cryptopt == 1) {
2558 Warning(
"ClearAuth",
"problems secure-sending pass hash"
2559 " - may result in authentication failure");
2566 for (
int i = 0; i <
passwd.Length(); i++) {
2580 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
2592 "problems recvn (user,offset) length (%d:%d bytes:%d)",
2597 int reclen = (stat+1 > 256) ? 256 : stat+1;
2598 if ((nrec =
fSocket->
Recv(answer, reclen, kind)) < 0)
2602 "username and offset not received (%d:%d)", kind,
2608 sscanf(answer,
"%127s %d", lUser, &offset);
2611 "received from server: user: %s, offset: %d (%s)", lUser,
2618 if (reuse == 1 && offset > -1) {
2620 if (cryptopt == 1) {
2623 "problems secure-receiving token -"
2624 " may result in corrupted token");
2629 token =
new char[tlen];
2635 Warning(
"ClearAuth",
"token not received (%d:%d)", kind,
2638 for (
int i = 0; i < (int) strlen(token); i++) {
2639 token[i] = ~token[i];
2644 Info(
"ClearAuth",
"received from server: token: '%s' ",
2706 "%s@%s does not accept connections from %s@%s",
2713 "%s@%s does not accept %s authentication from %s@%s",
2730 Error(
"ClearAuth",
"password not set");
2732 if (
fUser ==
"anonymous" ||
fUser ==
"rootd") {
2733 if (!
passwd.Contains(
"@")) {
2735 "please use passwd of form: user@host.do.main");
2746 for (
int i = 0; i <
passwd.Length(); i++) {
2759 Info(
"ClearAuth",
"after kROOTD_PASS: kind= %d, stat= %d", kind,
2788 ::Info(
"TAuthenticate::GetHostAuth",
"enter ... %s ... %s", host, user);
2794 char *
ps = (
char *)strstr(host,
":");
2796 srvtyp = atoi(
ps+1);
2800 if (strncmp(host,
"default",7) && !hostFQDN.
Contains(
"*")) {
2812 if (!strncasecmp(opt,
"P",1)) {
2820 while ((ai = (
THostAuth *) (*next)())) {
2822 ai->
Print(
"Authenticate::GetHostAuth");
2825 if (!(serverOK = (ai->
GetServer() == -1) ||
2830 if (!strcmp(ai->
GetHost(),
"default") && serverOK && notFound)
2840 if (hostFQDN == ai->
GetHost() &&
2862 ::Info(
"TAuthenticate::HasHostAuth",
"enter ... %s ... %s", host, user);
2868 char *
ps = (
char *)strstr(host,
":");
2870 srvtyp = atoi(
ps+1);
2873 if (strncmp(host,
"default",7) && !hostFQDN.
Contains(
"*")) {
2880 if (!strncasecmp(opt,
"P",1)) {
2885 while ((ai = (
THostAuth *) (*next)())) {
2887 if (hostFQDN == ai->
GetHost() &&
2909 ::Info(
"TAuthenticate::FileExpand",
"enter ... '%s' ... 0x%lx", fexp, (
Long_t)ftmp);
2911 fin = fopen(fexp,
"r");
2915 while (fgets(
line,
sizeof(
line), fin) != 0) {
2919 if (
line[strlen(
line) - 1] ==
'\n')
2922 ::Info(
"TAuthenticate::FileExpand",
"read line ... '%s'",
line);
2923 int nw = sscanf(
line,
"%19s %8191s", cinc, fileinc);
2926 if (strcmp(cinc,
"include") != 0) {
2928 fprintf(ftmp,
"%s\n",
line);
2935 sscanf(ln.
Data(),
"%19s %8191s", cinc, fileinc);
2938 if (fileinc[0] ==
'$') {
2955 if (fileinc[0] ==
'~') {
2959 char *ffull =
new char[flen];
2969 "file specified by 'include' cannot be open or read (%s)",
2984 const char copt[2][5] = {
"no",
"yes" };
2987 ::Info(
"TAuthenticate::GetDefaultDetails",
2988 "enter ... %d ...pt:%d ... '%s'", sec, opt, usr);
2990 if (opt < 0 || opt > 1)
2995 if (!usr[0] || !strncmp(usr,
"*",1))
3004 if (!usr[0] || !strncmp(usr,
"*",1))
3012 if (!usr[0] || !strncmp(usr,
"*",1))
3027 if (!usr[0] || !strncmp(usr,
"*",1))
3035 if (!usr[0] || !strncmp(usr,
"*",1))
3041 ::Info(
"TAuthenticate::GetDefaultDetails",
"returning ... %s", temp);
3051 if (!strncasecmp(opt,
"P",1))
3080 " +--------------------------- BEGIN --------------------------------+");
3085 " + List fgProofAuthInfo has %4d members +",
3090 " +------------------------------------------------------------------+");
3098 " + List fgAuthInfo has %4d members +",
3103 " +------------------------------------------------------------------+");
3112 " +---------------------------- END ---------------------------------+");
3128 Info(
"AuthExists",
"%d: enter: msg: %d options: '%s'",
3129 method,*message, options);
3141 (*checksecctx)(username,secctx) == 1)
3154 (*checksecctx)(username,secctx) == 1) {
3171 "found valid TSecContext: offset: %d token: '%s'",
3172 offset, token.
Data());
3183 Int_t reuse = *rflag;
3184 if (reuse == 1 && offset > -1) {
3193 Int_t stat = 1, kind;
3198 Warning(
"AuthExists",
"protocol error: expecting %d got %d"
3204 Info(
"AuthExists",
"offset OK");
3208 Info(
"AuthExists",
"key type: %d", rsaKey);
3224 Warning(
"AuthExists",
"problems secure-sending token %s",
3225 "- may trigger problems in proofing Id ");
3230 for (
int i = 0; i < token.
Length(); i++) {
3231 char inv = ~token(i);
3239 Info(
"AuthExists",
"offset not OK - rerun authentication");
3250 Info(
"AuthExists",
"%d: after msg %d: kind= %d, stat= %d",
3251 method,*message, kind, stat);
3264 Error(
"AuthExists",
"%s@%s does not accept connections from %s@%s",
3270 "%s@%s does not accept %s authentication from %s@%s",
3288 Info(
"AuthExists",
"valid authentication exists");
3290 Info(
"AuthExists",
"valid authentication exists: offset changed");
3292 Info(
"AuthExists",
"remote access authorized by /etc/hosts.equiv");
3294 Info(
"AuthExists",
"no authentication required remotely");
3324 const char *randdev =
"/dev/urandom";
3327 if ((fd =
open(randdev, O_RDONLY)) != -1) {
3329 ::Info(
"InitRandom",
"taking seed from %s", randdev);
3330 if (read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
3331 ::Warning(
"InitRandom",
"could not read seed from %s", randdev);
3335 ::Info(
"InitRandom",
"%s not available: using time()", randdev);
3350 Info(
"GenRSAKeys",
"enter");
3354 Info(
"GenRSAKeys",
"Keys prviously generated - return");
3376 Info(
"GenRSAKeys",
"SSL: Generate Blowfish key");
3385 OpenSSL_add_all_ciphers();
3391 nbits = (nbits >= 128) ? nbits : 128;
3394 nbits = (nbits <= 15912) ? nbits : 15912;
3397 Int_t klen = nbits / 8 ;
3401 RAND_seed(rbuf,strlen(rbuf));
3410 BF_set_key(&fgBFKey, klen, (
const unsigned char *)rbuf);
3419 Int_t l_n = 0, l_d = 0;
3426 Int_t nAttempts = 0;
3432 if (
gDebug > 2 && nAttempts > 1) {
3433 Info(
"GenRSAKeys",
"retry no. %d",nAttempts);
3446 Info(
"GenRSAKeys",
"equal primes: regenerate (%d times)",nPrimes);
3454 Info(
"GenRSAKeys",
"local: p1: '%s' ", buf);
3456 Info(
"GenRSAKeys",
"local: p2: '%s' ", buf);
3461 if (
gDebug > 2 && nAttempts > 1)
3462 Info(
"GenRSAKeys",
" genrsa: unable to generate keys (%d)",
3469 l_n = strlen(buf_n);
3472 l_e = strlen(buf_e);
3475 l_d = strlen(buf_d);
3479 Info(
"GenRSAKeys",
"local: n: '%s' length: %d", buf_n, l_n);
3480 Info(
"GenRSAKeys",
"local: e: '%s' length: %d", buf_e, l_e);
3481 Info(
"GenRSAKeys",
"local: d: '%s' length: %d", buf_d, l_d);
3493 strlcpy(
test, tdum, lTes+1);
3497 Info(
"GenRSAKeys",
"local: test string: '%s' ",
test);
3500 strlcpy(buf,
test, lTes+1);
3506 "local: length of crypted string: %d bytes", lout);
3512 Info(
"GenRSAKeys",
"local: after private/public : '%s' ", buf);
3514 if (strncmp(
test, buf, lTes))
3518 strlcpy(buf,
test, lTes+1);
3523 Info(
"GenRSAKeys",
"local: length of crypted string: %d bytes ",
3530 Info(
"GenRSAKeys",
"local: after public/private : '%s' ", buf);
3532 if (strncmp(
test, buf, lTes))
3549 Info(
"GenRSAKeys",
"local: generated keys are:");
3550 Info(
"GenRSAKeys",
"local: n: '%s' length: %d", buf_n, l_n);
3551 Info(
"GenRSAKeys",
"local: e: '%s' length: %d", buf_e, l_e);
3552 Info(
"GenRSAKeys",
"local: d: '%s' length: %d", buf_d, l_d);
3593 unsigned int iimx[4][4] = {
3594 {0x0, 0xffffff08, 0xafffffff, 0x2ffffffe},
3595 {0x0, 0x3ff0000, 0x7fffffe, 0x7fffffe},
3596 {0x0, 0x3ff0000, 0x7e, 0x7e},
3597 {0x0, 0x3ffc000, 0x7fffffe, 0x7fffffe}
3600 const char *cOpt[4] = {
"Any",
"LetNum",
"Hex",
"Crypt" };
3603 if (opt < 0 || opt > 2) {
3606 Info(
"GetRandString",
"unknown option: %d : assume 0", opt);
3609 Info(
"GetRandString",
"enter ... len: %d %s", len, cOpt[opt]);
3612 char *buf =
new char[len + 1];
3622 for (
m = 7;
m < 32;
m += 7) {
3623 i = 0x7F & (frnd >>
m);
3626 if ((iimx[opt][j] & (1 <<
l))) {
3638 Info(
"GetRandString",
"got '%s' ", buf);
3650 Int_t key,
const char *str)
3656 ::Info(
"TAuthenticate::SecureSend",
"local: enter ... (enc: %d)", enc);
3658 Int_t slen = strlen(str) + 1;
3663 strlcpy(buftmp, str, slen+1);
3673 }
else if (key == 1) {
3678 ttmp = ((ttmp + 8)/8) * 8;
3679 unsigned char iv[8];
3680 memset((
void *)&iv[0],0,8);
3681 BF_cbc_encrypt((
const unsigned char *)str, (
unsigned char *)buftmp,
3682 strlen(str), &fgBFKey, iv, BF_ENCRYPT);
3685 ::Info(
"TAuthenticate::SecureSend",
"not compiled with SSL support:"
3686 " you should not have got here!");
3690 ::Info(
"TAuthenticate::SecureSend",
"unknown key type (%d)",key);
3697 nsen = sock->
SendRaw(buftmp, ttmp);
3699 ::Info(
"TAuthenticate::SecureSend",
3700 "local: sent %d bytes (expected: %d)", nsen,ttmp);
3722 if (sock->
Recv(buflen, 20, kind) < 0)
3724 Int_t len = atoi(buflen);
3726 ::Info(
"TAuthenticate::SecureRecv",
"got len '%s' %d (msg kind: %d)",
3731 if (!strncmp(buflen,
"-1", 2))
3735 if ((nrec = sock->
RecvRaw(buftmp, len)) < 0)
3746 const size_t strSize = strlen(buftmp) + 1;
3747 *str =
new char[strSize];
3748 strlcpy(*str, buftmp, strSize);
3750 }
else if (key == 1) {
3752 unsigned char iv[8];
3753 memset((
void *)&iv[0],0,8);
3754 *str =
new char[nrec + 1];
3755 BF_cbc_encrypt((
const unsigned char *)buftmp, (
unsigned char *)(*str),
3756 nrec, &fgBFKey, iv, BF_DECRYPT);
3757 (*str)[nrec] =
'\0';
3760 ::Info(
"TAuthenticate::SecureRecv",
"not compiled with SSL support:"
3761 " you should not have got here!");
3765 ::Info(
"TAuthenticate::SecureRecv",
"unknown key type (%d)",key);
3778 R__rsa_NUMBER &rsa_d,
char **rsassl)
3784 ::Info(
"TAuthenticate::DecodeRSAPublic",
3785 "enter: string length: %ld bytes", (
Long_t)strlen(rsaPubExport));
3788 Int_t klen = strlen(rsaPubExport);
3790 ::Info(
"TAuthenticate::DecodeRSAPublic",
3791 "key too long (%d): truncate to %d",klen,
kMAXPATHLEN);
3794 memcpy(str, rsaPubExport, klen);
3803 while (str[k] == 32) k++;
3805 if (str[k] ==
'#') {
3810 char *pd1 = strstr(str,
"#");
3811 char *pd2 = pd1 ? strstr(pd1 + 1,
"#") : (
char *)0;
3812 char *pd3 = pd2 ? strstr(pd2 + 1,
"#") : (
char *)0;
3813 if (pd1 && pd2 && pd3) {
3815 int l1 = (int) (pd2 - pd1 - 1);
3816 char *rsa_n_exp =
new char[l1 + 1];
3817 strlcpy(rsa_n_exp, pd1 + 1, l1+1);
3819 ::Info(
"TAuthenticate::DecodeRSAPublic",
3820 "got %ld bytes for rsa_n_exp", (
Long_t)strlen(rsa_n_exp));
3822 int l2 = (int) (pd3 - pd2 - 1);
3823 char *rsa_d_exp =
new char[l2 + 1];
3824 strlcpy(rsa_d_exp, pd2 + 1, 13);
3826 ::Info(
"TAuthenticate::DecodeRSAPublic",
3827 "got %ld bytes for rsa_d_exp", (
Long_t)strlen(rsa_d_exp));
3836 ::Info(
"TAuthenticate::DecodeRSAPublic",
"bad format for input string");
3845 BIO *bpub = BIO_new(BIO_s_mem());
3848 BIO_write(bpub,(
void *)str,strlen(str));
3851 if (!(rsatmp = PEM_read_bio_RSAPublicKey(bpub, 0, 0, 0))) {
3853 ::Info(
"TAuthenticate::DecodeRSAPublic",
3854 "unable to read pub key from bio");
3857 *rsassl = (
char *)rsatmp;
3859 ::Info(
"TAuthenticate::DecodeRSAPublic",
3860 "no space allocated for output variable");
3867 ::Info(
"TAuthenticate::DecodeRSAPublic",
"not compiled with SSL support:"
3868 " you should not have got here!");
3883 ::Info(
"TAuthenticate::SetRSAPublic",
3884 "enter: string length %ld bytes", (
Long_t)strlen(rsaPubExport));
3894 while (rsaPubExport[k0] == 32) k0++;
3903 if (rsaPubExport[k0] ==
'#' && rsaPubExport[k2] ==
'#') {
3904 char *p0 = (
char *)&rsaPubExport[k0];
3905 char *
p2 = (
char *)&rsaPubExport[k2];
3906 char *
p1 = strchr(p0+1,
'#');
3907 if (
p1 > p0 &&
p1 <
p2) {
3913 while (
c <
p1 && ((*c < 58 && *c > 47) || (*c < 91 && *c > 64)))
3917 while (
c <
p2 && ((*c < 58 && *c > 47) || (*c < 91 && *c > 64)))
3926 ::Info(
"TAuthenticate::SetRSAPublic",
" Key type: %d",rsakey);
3930 R__rsa_NUMBER rsa_n, rsa_d;
3941 BF_set_key(&fgBFKey, klen, (
const unsigned char *)rsaPubExport);
3944 ::Info(
"TAuthenticate::SetRSAPublic",
3945 "not compiled with SSL support:"
3946 " you should not have got here!");
3966 ::Info(
"TAuthenticate::SendRSAPublicKey",
3967 "received key from server %ld bytes", (
Long_t)strlen(serverPubKey));
3970 R__rsa_NUMBER rsa_n, rsa_d;
3976 RSA_free((RSA *)tmprsa);
3979 RSA *RSASSLServer = (RSA *)tmprsa;
3987 char buflen[20] = {0};
3994 }
else if (key == 1) {
3996 Int_t lcmax = RSA_size(RSASSLServer) - 11;
4002 if ((ttmp = RSA_public_encrypt(lc,
4004 (
unsigned char *)&buftmp[ke],
4005 RSASSLServer,RSA_PKCS1_PADDING)) < 0) {
4008 ::Info(
"TAuthenticate::SendRSAPublicKey",
"SSL: error: '%s' ",errstr);
4018 ::Info(
"TAuthenticate::SendRSAPublicKey",
"not compiled with SSL support:"
4019 " you should not have got here!");
4024 ::Info(
"TAuthenticate::SendRSAPublicKey",
"unknown key type (%d)",key);
4027 RSA_free(RSASSLServer);
4038 ::Info(
"TAuthenticate::SendRSAPublicKey",
4039 "local: sent %d bytes (expected: %d)", nsen,ttmp);
4042 RSA_free(RSASSLServer);
4063 if (authrc &&
gDebug > 2)
4064 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking file: %s", authrc);
4066 if (authrc &&
gDebug > 1)
4067 ::Info(
"TAuthenticate::ReadRootAuthrc",
4068 "file %s cannot be read (errno: %d)", authrc, errno);
4072 ::Info(
"TAuthenticate::ReadRootAuthrc",
"Checking system file: %s", authrc);
4075 ::Info(
"TAuthenticate::ReadRootAuthrc",
4076 "file %s cannot be read (errno: %d)", authrc, errno);
4086 stat(tRootAuthrc, &si);
4089 ::Info(
"TAuthenticate::ReadRootAuthrc",
4090 "file %s already read", authrc);
4106 TString filetmp =
"rootauthrc";
4109 ::Info(
"TAuthenticate::ReadRootAuthrc",
"got tmp file: %s open at 0x%lx",
4122 fd = fopen(authrc,
"r");
4125 ::Info(
"TAuthenticate::ReadRootAuthrc",
4126 "file %s cannot be open (errno: %d)", authrc, errno);
4137 while (fgets(
line,
sizeof(
line), fd) != 0) {
4144 if (
line[strlen(
line) - 1] ==
'\n')
4152 const size_t tmpSize = strlen(
line) + 1;
4153 char *tmp =
new char[tmpSize];
4155 ::Error(
"TAuthenticate::ReadRootAuthrc",
4156 "could not allocate temporary buffer");
4160 strlcpy(tmp,
line, tmpSize);
4161 char *nxt = strtok(tmp,
" ");
4163 if (!strcmp(nxt,
"proofserv") || cont) {
4173 proofserv +=
TString((
const char *)ph);
4194 if (server ==
"0" || server.
BeginsWith(
"sock"))
4196 else if (server ==
"1" || server.
BeginsWith(
"root"))
4198 else if (server ==
"2" || server.
BeginsWith(
"proof"))
4205 nxt = strtok(0,
" ");
4206 if (!strncmp(nxt,
"user",4)) {
4207 nxt = strtok(0,
" ");
4208 if (strncmp(nxt,
"list",4) && strncmp(nxt,
"method",6)) {
4210 nxt = strtok(0,
" ");
4215 TIter next(&tmpAuthInfo);
4225 tmpAuthInfo.
Add(ha);
4228 if (!strncmp(nxt,
"list",4)) {
4231 char *mth = strtok(0,
" ");
4234 if (strlen(mth) > 1) {
4237 if (met == -1 &&
gDebug > 2)
4238 ::Info(
"TAuthenticate::ReadRootAuthrc",
4239 "unrecognized method (%s): ", mth);
4243 if (met > -1 && met <
kMAXSEC)
4245 mth = strtok(0,
" ");
4250 }
else if (!strncmp(nxt,
"method",6)) {
4253 char *mth = strtok(0,
" ");
4255 if (strlen(mth) > 1) {
4258 if (met == -1 &&
gDebug > 2)
4259 ::Info(
"TAuthenticate::ReadRootAuthrc",
4260 "unrecognized method (%s): ", mth);
4264 if (met > -1 && met <
kMAXSEC) {
4265 const char *det = 0;
4266 nxt = strtok(0,
" ");
4268 det = (
const char *)strstr(
line,nxt);
4277 if (tmp)
delete [] tmp;
4295 TList tmpproofauthinfo;
4296 if (proofserv.
Length() > 0) {
4297 char *tmps =
new char[proofserv.
Length()+1];
4298 strlcpy(tmps,proofserv.
Data(),proofserv.
Length()+1);
4299 char *nxt = strtok(tmps,
" ");
4301 TString tmp((
const char *)nxt);
4305 if ((pdd = tmp.
Index(
":")) == -1) {
4316 if ((pdd = tmp.
Index(
":")) == -1) {
4328 while (tmp.
Length() > 0) {
4330 if ((pdd = tmp.
Index(
":")) > -1)
4335 if (met == -1 &&
gDebug > 2)
4336 ::Info(
"TAuthenticate::ReadRootAuthrc",
4337 "unrecognized method (%s): ",meth.
Data());
4338 }
else if (meth.
Length() == 1) {
4339 met = atoi(meth.
Data());
4340 if (met > -1 && met <
kMAXSEC)
4363 tmpproofauthinfo.
Add(ha);
4365 nxt = strtok(0,
" ");
4385 const char sshid[3][20] = {
"/.ssh/identity",
"/.ssh/id_dsa",
"/.ssh/id_rsa" };
4386 const char netrc[2][20] = {
"/.netrc",
"/.rootnetrc" };
4396 "not properly logged on (getpwuid unable to find relevant info)!");
4404 for (; i < 2; i++) {
4410 out.
Form(
"pt:0 ru:1 us:%s",user.
Data());
4416 out.
Form(
"pt:0 ru:1 us:%s",user.
Data());
4424 out.
Form(
"pt:0 ru:0 us:%s",user.
Data());
4433 if (lApp != 0 && lApp->
Argc() > 9) {
4434 if (
gROOT->IsProofServ()) {
4441 struct shmid_ds shm_ds;
4442 if (shmctl(ShmId, IPC_STAT, &shm_ds) == 0)
4456 out.
Form(
"pt=0 ru:0 cd:%s cf:%s kf:%s ad:%s",
4467 for (; i < 3; i++) {
4473 out.
Form(
"pt:0 ru:1 us:%s",user.
Data());
4478 out.
Form(
"pt:0 ru:0 us:%s",user.
Data());
4483 if (strlen(out) > 0)
4485 "meth: %d ... is available: details: %s", cSec, out.
Data());
4488 "meth: %d ... is NOT available", cSec);
4506 if (!strcmp(user,ctx->
GetUser()) &&
4507 strncmp(
"AFS", ctx->
GetID(), 3))
4537 while ((hanew = (
THostAuth *)nxnew())) {
4559 while ((hanew = (
THostAuth *)nxnew())) {
4623 Info(
"ProofAuthSetup",
"Buffer not found: nothing to do");
4637 *mess >> user >>
passwd >> pwhash >> srppwd >> rsakey;
4655 Info(
"ProofAuthSetup",
"List of THostAuth not found");
4676 fromProofAI =
kTRUE;
4687 if (!master || fromProofAI) {
4751 if (remoteOffSet > -1 && (upwd || srp))
4755 if ((
gEnv->
GetValue(
"Proofd.SendSRPPwd",0)) && (remoteOffSet > -1))
4758 if (srp && pwdctx) {
4759 if (strcmp(pwdctx->
GetPasswd(),
"") && remoteOffSet > -1)
4764 if ((upwd && pwdctx) || (srp && sndsrp)) {
4775 mess << user <<
passwd << pwhash << srppwd << keytyp;
4781 char *mbuf = mess.
Buffer();
4786 ::Info(
"ProofAuthSetup",
"sending %d bytes", messb64.
Length());
4789 if (remoteOffSet > -1) {
4791 ::Error(
"ProofAuthSetup",
"problems secure-sending message buffer");
4799 ::Error(
"ProofAuthSetup",
"plain: problems sending message length");
4803 ::Error(
"ProofAuthSetup",
"problems sending message buffer");
4839 Error(
"SendHostAuth",
"invalid input: socket undefined");
4854 Info(
"SendHostAuth",
"sent %d bytes (%s)",
ns,buf.
Data());
4861 Info(
"SendHostAuth",
"sent %d bytes for closing",
ns);
4875 Error(
"RecvHostAuth",
"invalid input: socket undefined");
4890 Error(
"RecvHostAuth",
"received: kind: %d (%d bytes)", kind, nr);
4894 Info(
"RecvHostAuth",
"received %d bytes (%s)",nr,buf);
4896 while (strcmp(buf,
"END")) {
4916 fromProofAI =
kTRUE;
4927 if (!master || fromProofAI) {
4966 Info(
"RecvHostAuth",
"Error: received: kind: %d (%d bytes)", kind, nr);
4970 Info(
"RecvHostAuth",
"received %d bytes (%s)",nr,buf);
5005 if (remoteOffSet > -1 && (upwd || srp))
5009 if ((
gEnv->
GetValue(
"Proofd.SendSRPPwd",0)) && (remoteOffSet > -1))
5012 if (srp && pwdctx) {
5013 if (strcmp(pwdctx->
GetPasswd(),
"") && remoteOffSet > -1)
5018 if ((upwd && pwdctx) || (srp && sndsrp)) {
5022 Error(
"OldAuthSetup",
"failed to send offset in RSA key");
5033 if (remoteOffSet > -1)
5034 Warning(
"OldAuthSetup",
"problems secure-sending pass hash %s",
5035 "- may result in failures");
5038 for (
int i = 0; i <
passwd.Length(); i++) {
5044 if (sock->
Send(mess) < 0) {
5045 Error(
"OldAuthSetup",
"failed to send inverted password");
5055 Error(
"OldAuthSetup",
"failed to send no offset notification in RSA key");
5062 mess << user << pwhash << srppwd << ord << conf;
5064 if (sock->
Send(mess) < 0) {
5065 Error(
"OldAuthSetup",
"failed to send ordinal and config info");
5069 if (proofdProto > 6) {
5075 Error(
"OldAuthSetup",
"failed to send HostAuth info");
5094 if (sock->
Recv(retval, kind) != 2*
sizeof(
Int_t)) {
5096 Info(
"OldProofServAuthSetup",
5097 "socket has been closed due to protocol mismatch - Exiting");
5114 if ((fKey = fopen(keyfile.
Data(),
"r"))) {
5115 Int_t klen = fread((
void *)pubkey,1,
sizeof(pubkey),fKey);
5117 Error(
"OldProofServAuthSetup",
5118 "failed to read public key from '%s'", keyfile.
Data());
5127 Error(
"OldProofServAuthSetup",
"failed to open '%s'", keyfile.
Data());
5136 Error(
"OldProofServAuthSetup",
"failed to receive password");
5142 }
else if (retval == -1) {
5146 if ((sock->
Recv(mess) <= 0) || !mess) {
5147 Error(
"OldProofServAuthSetup",
"failed to receive inverted password");
5163 if ((sock->
Recv(mess) <= 0) || !mess) {
5164 Error(
"OldProofServAuthSetup",
"failed to receive ordinal and config info");
5172 (*mess) >> user >> pwhash >> srppwd >> conf;
5175 (*mess) >> user >> pwhash >> srppwd >> ord >> conf;
5180 (*mess) >> user >> pwhash >> srppwd >> iord;
5184 (*mess) >> user >> pwhash >> srppwd >> ord >> conf;
5206 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[]
static double p1(double t, double a, double b)
static double p2(double t, double a, double b, double c)
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 OldSlaveAuthSetup(TSocket *sock, Bool_t master, TString ord, TString conf)
Setup of authetication in PROOF run after successful opening of the socket.
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...
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
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,...)
void Error(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
char * Form(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
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
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)
UidGid client authentication code.
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.
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 GlobusAuth_t fgGlobusAuthHook
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.
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 TString fgKrb5Principal
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.
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 Krb5Auth_t fgKrb5AuthHook
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...
Int_t SshError(const char *errfile)
SSH error parsing: returns 0 : no error or fatal 1 : should retry (eg 'connection closed by remote ho...
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.
virtual TObject * ReadObject(const TClass *cl)
Read object from I/O buffer.
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE)
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 globus, cleanup local stuff If ...
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.
Int_t Atoi() const
Return integer value of string.
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
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & ReplaceAll(const TString &s1, const TString &s2)
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
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_t GetEffectiveGid()
Returns the effective group id.
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 UserGroup_t * GetGroupInfo(Int_t gid)
Returns all group info in the UserGroup_t structure.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
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=0)
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 void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
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.
static constexpr double us
static constexpr double nm
static constexpr double s
static constexpr double pc
static constexpr double mm
static constexpr double ps
static constexpr double ns
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)