106 int TestAuth(
int port = 1094,
char *user =
"",
char *krb5 =
"",
char *globus =
"")
117 Bool_t HaveMeth[6] = {1,0,0,0,0,1};
118 Int_t TestMeth[6] = {0,0,0,0,0,0};
119 Int_t TestReUse[6] = {3,3,3,3,3,3};
123 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
125 printf(
"+ TestAuth.C +\n");
127 printf(
"+ Test of authentication methods +\n");
131 printf(
"+ .x TestAuth.C(<port>,\"<user>\",\"<krb5_princ>\",\"<globus_det>\") +\n");
133 printf(
"+ <port> = rootd port (default 1094) +\n");
134 printf(
"+ <user> = login user name for the test +\n");
135 printf(
"+ (default from getpwuid) +\n");
136 printf(
"+ <krb5_princ> = Principal to be used for Krb5 authentication +\n");
137 printf(
"+ in the form user@THE.REA.LM +\n");
138 printf(
"+ ( default: <running_user@Default_Realm with +\n");
139 printf(
"+ Default_realm taken from /etc/krb5.conf +\n");
140 printf(
"+ or the $KRB5_CONFIG file ) +\n");
141 printf(
"+ <globus_det> = details for the globus authentication +\n");
142 printf(
"+ ( default ad:certificates cd:$HOME/.globus +\n");
143 printf(
"+ cf:usercert.pem kf:userkey.pem ) +\n");
145 printf(
"+ >>> MAKE SURE that rootd is running <<< +\n");
147 printf(
"+ See $ROOTSYS/README/README.AUTH for additional details +\n");
149 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
159 printf(
"\n >>>> 'user' not defined: please enter a valid username:\n");
160 char utmp[256] = {0};
165 printf(
">>>> no 'user' defined: return!\n");
183 HostName +
TString(
":")+ port ;
203 if (strlen(krb5) > 0) {
213 Krb5Conf =
"/etc/krb5.conf";
215 printf(
"\n >>>> Kerberos Principal undefined\n");
216 printf(
"\n >>>> unable to localize Kerberos config file to build a default\n");
217 printf(
"\n >>>> Switching off Kerberos\n");
218 printf(
"\n >>>> Run again with giving the principal as 3rd argument\n");
219 printf(
"\n >>>> or define the variable KRB5_CONFIG with the full path \n");
220 printf(
"\n >>>> to the config file (usually /etc/krb5.conf)\n");
223 if (HaveMeth[2] == 1) {
224 FILE *
fc = fopen(Krb5Conf.
Data(),
"r");
226 char line[1024], fs1[1024], fs2[1024], fs3[1024];
227 while (fgets(line,
sizeof(line), fc) != 0) {
228 int nf = sscanf(line,
"%s %s %s",fs1,fs2,fs3);
229 if (nf == 3 && !strcmp(fs1,
"default_realm")) {
234 Krb5Details =
TString(
"pt:0 ru:1 us:") + User +
TString(
"@") + Realm;
260 printf(
"\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
262 printf(
"+ Basic test parameters: +\n");
264 printf(
"+ Local User is : %s \n",User.
Data());
265 printf(
"+ Authentication Details : %s \n",Details.
Data());
267 printf(
"+ TFTP string : %s \n",TFTPPath.
Data());
269 printf(
"+ Krb5 Details : %s \n",Krb5Details.
Data());
272 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
282 printf(
"+ Testing UsrPwd ... +\n");
313 printf(
" >>>>>>>>>>>>>>>> Test of UsrPwd authentication failed \n");
317 if (TestMeth[0] == 1) {
321 if (ai->GetMethod() == 0) {
338 printf(
"+ Testing SRP ... +\n");
350 printf(
" >>>>>>>>>>>>>>>> Test of SRP authentication failed \n");
354 if (TestMeth[1] == 1) {
358 if (ai->GetMethod() == 1) {
379 printf(
"+ Testing Krb5 ... +\n");
387 printf(
" >>>>>>>>>>>>>>>> Krb5: existing THostAuth found \n");
405 t1 =
new TFTP(TFTPPathKrb5.
Data(),2);
409 printf(
" >>>>>>>>>>>>>>>> Test of Kerberos authentication failed \n");
410 if (strlen(krb5) > 0) {
411 printf(
" >>>>>>>>>>>>>>>> details used: '%s' \n",krb5);
416 if (TestMeth[2] == 1) {
420 if (ai->GetMethod() == 2) {
438 printf(
"+ Testing Globus ... +\n");
450 printf(
" >>>>>>>>>>>>>>>> Test of Globus authentication failed \n");
451 if (strlen(globus) > 0) {
452 printf(
" >>>>>>>>>>>>>>>> details used: '%s' \n",globus);
454 printf(
" >>>>>>>>>>>>>>>> using default details: \n");
455 printf(
" >>>>>>>>>>>>>>>> ad:/etc/grid-security/certificates");
456 printf(
" cd:$HOME/.globus cf:usercert.pem kf:userkey.pem\n");
461 printf(
" >>>>>>>>>>>>>>>> You are not root,");
462 printf(
" you may not have the right privileges\n");
463 printf(
" >>>>>>>>>>>>>>>> Make sure that the used details are correct! \n");
469 if (TestMeth[3] == 1) {
473 if (ai->GetMethod() == 3) {
492 printf(
"+ Testing SSH ... +\n");
504 printf(
" >>>>>>>>>>>>>>>> Test of SSH authentication failed \n");
508 if (TestMeth[4] == 1) {
512 if (ai->GetMethod() == 4) {
530 printf(
"+ Testing UidGid ... +\n");
543 printf(
" >>>>>>>>>>>>>>>> Test of UidGid authentication failed \n");
553 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
574 printf(
"\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
576 printf(
"+ Result of the tests: +\n");
578 char status[4][20] = {
"failed!",
"successful!",
"not testable",
"not tested"};
580 for( i=0; i<6; i++ ) {
581 if (HaveMeth[i] && TestMeth[i] < 2) {
583 printf(
"+ Method: %d %8s: %11s (reuse: %11s) +\n",i,
585 status[TestMeth[i]],status[TestReUse[i]]);
587 printf(
"+ Method: %d %8s: %11s +\n",i,
589 status[TestMeth[i]]);
593 for( i=0; i<6; i++ ) {
594 if (HaveMeth[i] && TestMeth[i] > 1) {
597 printf(
"+ Could not be tested: +\n");
601 printf(
"+ Method: %d %8s: %11s +\n",i,
603 status[TestMeth[i]]);
607 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * WorkingDirectory()
Return working directory.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
int TestAuth(int port=1094, char *user="", char *krb5="", char *globus="")
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
const char * Data() const
static Int_t ReadRootAuthrc()
Read authentication directives from $ROOTAUTHRC, $HOME/.rootauthrc or <Root_etc_dir>/system.rootauthrc and create related THostAuth objects.
static struct mg_connection * fc(struct mg_context *ctx)
virtual const char * Getenv(const char *env)
Get environment variable.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
TList * Established() const
void RemoveMethod(Int_t level)
Remove method 'meth' from the list, if there ...
R__EXTERN TSystem * gSystem
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
char * Form(const char *fmt,...)
void AddMethod(Int_t level, const char *details=0)
Add method to the list.
static void Show(Option_t *opt="S")
Print info about the authentication sector.
static TList * GetAuthInfo()
Static method returning the list with authentication details.
virtual const char * HostName()
Return the system's host name.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual void Add(TObject *obj)
void Update(THostAuth *ha)
Update info with the one in ha Remaining methods, if any, get lower priority.
virtual void Print(Option_t *option="") const
Print object content.
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...
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 const char * GetAuthMethod(Int_t idx)
Static method returning the method corresponding to idx.
void Reset()
Remove all methods, leaving Active status and list of associted TSceContexts unchanged.