71 int TestAuth(
int port = 1094,
char *user =
"")
79 Int_t lDebug = gEnv->GetValue(
"Root.Debug",0);
82 Bool_t HaveMeth[6] = {1,0,0,0,0,1};
83 Int_t TestMeth[6] = {0,0,0,0,0,0};
84 Int_t TestReUse[6] = {3,3,3,3,3,3};
88 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
90 printf(
"+ TestAuth.C +\n");
92 printf(
"+ Test of authentication methods +\n");
94 printf(
"+ Syntax: +\n");
96 printf(
"+ .x TestAuth.C(<port>,\"<user>\") +\n");
98 printf(
"+ <port> = rootd port (default 1094) +\n");
99 printf(
"+ <user> = login user name for the test +\n");
100 printf(
"+ (default from getpwuid) +\n");
102 printf(
"+ >>> MAKE SURE that rootd is running <<< +\n");
104 printf(
"+ See $ROOTSYS/README/README.AUTH for additional details +\n");
106 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
114 UserGroup_t *u = gSystem->GetUserInfo();
116 printf(
"\n >>>> 'user' not defined: please enter a valid username:\n");
117 char utmp[256] = {0};
122 printf(
">>>> no 'user' defined: return!\n");
132 TString Host =
"localhost";
133 TString HostName = gSystem->HostName();
137 TString TFTPPath = TString(
"root://")+User+TString(
"@localhost:")+ port ;
140 TString Details = TString(
"pt:0 ru:1 us:") + User;
146 printf(
"\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
148 printf(
"+ Basic test parameters: +\n");
150 printf(
"+ Local User is : %s \n",User.Data());
151 printf(
"+ Authentication Details : %s \n",Details.Data());
152 printf(
"+ Current directory is : %s \n",gSystem->WorkingDirectory());
153 printf(
"+ TFTP string : %s \n",TFTPPath.Data());
155 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
158 TAuthenticate::ReadRootAuthrc();
160 TAuthenticate::Show();
165 printf(
"+ Testing UsrPwd ... +\n");
169 THostAuth *hasv1 = 0;
170 THostAuth *ha = TAuthenticate::HasHostAuth(Host.Data(),User.Data());
173 hasv1 =
new THostAuth(*ha);
177 ha->AddMethod(0,Details.Data());
180 ha =
new THostAuth(Host.Data(),User.Data(),0,Details.Data());
183 TAuthenticate::GetAuthInfo()->Add(ha);
192 t1 =
new TFTP(TFTPPath.Data(),2);
196 printf(
" >>>>>>>>>>>>>>>> Test of UsrPwd authentication failed \n");
200 if (TestMeth[0] == 1) {
201 TIter next(ha->Established());
203 while ((ai = (TSecContext *) next())) {
204 if (ai->GetMethod() == 0) {
205 Int_t OffSet = ai->GetOffSet();
219 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
223 TAuthenticate::Show();
230 TAuthenticate::GetAuthInfo()->Remove(ha);
236 TAuthenticate::GetAuthInfo()->Remove(hak);
240 printf(
"\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
242 printf(
"+ Result of the tests: +\n");
244 char status[4][20] = {
"failed!",
"successful!",
"not testable",
"not tested"};
246 for( i=0; i<6; i++ ) {
247 if (HaveMeth[i] && TestMeth[i] < 2) {
249 printf(
"+ Method: %d %8s: %11s (reuse: %11s) +\n",i,
250 Form(
"(%s)",TAuthenticate::GetAuthMethod(i)),
251 status[TestMeth[i]],status[TestReUse[i]]);
253 printf(
"+ Method: %d %8s: %11s +\n",i,
254 Form(
"(%s)",TAuthenticate::GetAuthMethod(i)),
255 status[TestMeth[i]]);
258 Bool_t NotPrinted = kTRUE;
259 for( i=0; i<6; i++ ) {
260 if (HaveMeth[i] && TestMeth[i] > 1) {
263 printf(
"+ Could not be tested: +\n");
267 printf(
"+ Method: %d %8s: %11s +\n",i,
268 Form(
"(%s)",TAuthenticate::GetAuthMethod(i)),
269 status[TestMeth[i]]);
273 printf(
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");