ROOT  6.06/09
Reference Guide
XrdROOT.cxx
Go to the documentation of this file.
1 // @(#)root/proofd:$Id$
2 // Author: Gerardo Ganis June 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // XrdROOT //
15 // //
16 // Authors: G. Ganis, CERN, 2007 //
17 // //
18 // Class describing a ROOT version //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 #include "RConfigure.h"
22 
23 #include "XrdProofdPlatform.h"
24 
25 #include "XrdROOT.h"
26 #include "XrdProofdManager.h"
27 #include "XrdProofdProtocol.h"
28 #include "XrdProofdProofServMgr.h"
29 #include "Xrd/XrdScheduler.hh"
30 #include "XrdOuc/XrdOucStream.hh"
31 #include "XrdSys/XrdSysPriv.hh"
32 #include "XpdSysLogger.h"
33 
34 // Tracing
35 #include "XrdProofdTrace.h"
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Constructor: validates 'dir', gets the version and defines the tag.
39 
40 XrdROOT::XrdROOT(const char *dir, const char *tag, const char *bindir,
41  const char *incdir, const char *libdir, const char *datadir)
42 {
43  XPDLOC(SMGR, "XrdROOT")
44 
45  fStatus = -1;
46  fSrvProtVers = -1;
47  fRelease = "";
48  fGitCommit = "";
49  fVersionCode = -1;
50  fVrsMajor = -1;
51  fVrsMinor = -1;
52  fVrsPatch = -1;
53 
54  // 'dir' must make sense
55  if (!dir || strlen(dir) <= 0)
56  return;
57  if (tag && strlen(tag) > 0) {
58  fExport = tag;
59  fExport += " "; fExport += dir;
60  } else
61  fExport += dir;
62  // ... and exist
63  if (CheckDir(dir) != 0) return;
64  fDir = dir;
65 
66  // Include dir
67  fIncDir = incdir;
68  if (!incdir || strlen(incdir) <= 0) {
69  fIncDir = fDir;
70  fIncDir += "/include";
71  }
72  if (CheckDir(fIncDir.c_str()) != 0) return;
73 
74  // Parse version info
75  if (ParseROOTVersionInfo() == -1) {
76  TRACE(XERR, "unable to extract ROOT version information from path "<<fIncDir);
77  return;
78  }
79 
80  // Default tag is the version
81  fTag = (!tag || strlen(tag) <= 0) ? fRelease : tag;
82 
83  // Lib dir
84  fLibDir = libdir;
85  if (!libdir || strlen(libdir) <= 0) {
86  fLibDir = fDir;
87  fLibDir += "/lib";
88  }
89  if (CheckDir(fLibDir.c_str()) != 0) return;
90 
91  // Bin dir
92  fBinDir = bindir;
93  if (!bindir || strlen(bindir) <= 0) {
94  fBinDir = fDir;
95  fBinDir += "/bin";
96  }
97  if (CheckDir(fBinDir.c_str()) != 0) return;
98 
99  // Data dir
100  fDataDir = datadir;
101  if (!datadir || strlen(datadir) <= 0) {
102  fDataDir = fDir;
103  }
104  if (CheckDir(fDataDir.c_str()) != 0) return;
105 
106  // The application to be run
107  fPrgmSrv = fBinDir;
108  fPrgmSrv += "/proofserv";
109 
110  // Export string
111  fExport = fTag;
112  fExport += " "; fExport += fRelease;
113  fExport += " "; fExport += dir;
114 
115  // First step OK
116  fStatus = 0;
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Check if 'dir' exists
121 /// Return 0 on succes, -1 on failure
122 
123 int XrdROOT::CheckDir(const char *dir)
124 {
125  XPDLOC(SMGR, "CheckDir")
126 
127  if (dir && strlen(dir) > 0) {
128  // The path should exist and be statable
129  struct stat st;
130  if (stat(dir, &st) == -1) {
131  TRACE(XERR, "unable to stat path "<<dir);
132  return -1;
133  }
134  // ... and be a directory
135  if (!S_ISDIR(st.st_mode)) {
136  TRACE(XERR, "path "<<dir<<" is not a directory");
137  return -1;
138  }
139  // Ok
140  return 0;
141  }
142  TRACE(XERR, "path is undefined");
143  return -1;
144 }
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 /// Set valid, save protocol and finalize the export string
148 
149 void XrdROOT::SetValid(kXR_int16 vers)
150 {
151  fStatus = 1;
152 
153  if (vers > 0) {
154  // Cleanup export, if needed
155  if (fSrvProtVers > 0) {
156  XrdOucString vs(" ");
157  vs += fSrvProtVers;
158  fExport.replace(vs,XrdOucString(""));
159  }
160  fSrvProtVers = vers;
161 
162  // Finalize export string
163  fExport += " ";
164  fExport += (int)fSrvProtVers;
165  }
166 }
167 
168 ////////////////////////////////////////////////////////////////////////////////
169 /// Extract ROOT version information associated with 'dir'.
170 
172 {
173  XPDLOC(SMGR, "ParseROOTVersionInfo")
174 
175  int rc = -1;
176 
177  XrdOucString versfile = fIncDir;
178  versfile += "/RVersion.h";
179 
180  // Open file
181  FILE *fv = fopen(versfile.c_str(), "r");
182  if (!fv) {
183  TRACE(XERR, "unable to open "<<versfile);
184  return rc;
185  }
186 
187  // Reset the related variables
188  fRelease = "";
189  fGitCommit = "";
190  fVersionCode = -1;
191  fVrsMajor = -1;
192  fVrsMinor = -1;
193  fVrsPatch = -1;
194 
195  // Read the file
196  char *pv = 0;
197  XrdOucString tkn, sline;
198  char line[1024];
199  while (fgets(line, sizeof(line), fv)) {
200  if (fRelease.length() <= 0 && (pv = (char *) strstr(line, "ROOT_RELEASE"))) {
201  if (line[strlen(line)-1] == '\n')
202  line[strlen(line)-1] = 0;
203  pv += strlen("ROOT_RELEASE") + 1;
204  fRelease = pv;
205  fRelease.replace("\"","");
206  } else if (fGitCommit.length() <= 0 && (pv = (char *) strstr(line, "ROOT_GIT_COMMIT"))) {
207  if (line[strlen(line)-1] == '\n')
208  line[strlen(line)-1] = 0;
209  pv += strlen("ROOT_GIT_COMMIT") + 1;
210  fGitCommit = pv;
211  fGitCommit.replace("\"","");
212  } else if ((pv = (char *) strstr(line, "ROOT_VERSION_CODE"))) {
213  if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0;
214  pv += strlen("ROOT_VERSION_CODE");
215  while (pv[0] == ' ') pv++;
216  fVersionCode = atoi(pv);
217  }
218  }
219 
220  // Close the file
221  fclose(fv);
222 
223  // Version code must be there
224  if (fVersionCode < 0) {
225  TRACE(XERR, "incomplete info found in "<<versfile<<": version code missing or bad: "<<fVersionCode);
226  return rc;
227  }
228 
229  // Release tag must be there and in the right format
230  if (fRelease.length() <= 0 ||
232  TRACE(XERR, "incomplete info found in "<<versfile<<": release tag missing or bad: "<<fRelease);
233  return rc;
234  }
235 
236  // Retrieve GIT commit string from dedicated file if the case
237  if (fGitCommit.length() <= 0) {
238 
239  XrdOucString gitcommit = fIncDir;
240  gitcommit += "/RGitCommit.h";
241 
242  // Open file
243  if ((fv = fopen(gitcommit.c_str(), "r"))) {
244 
245  // Read the file
246  pv = 0;
247  while (fgets(line, sizeof(line), fv)) {
248  if (fGitCommit.length() <= 0 && (pv = (char *) strstr(line, "ROOT_GIT_COMMIT"))) {
249  if (line[strlen(line)-1] == '\n')
250  line[strlen(line)-1] = 0;
251  pv += strlen("ROOT_GIT_COMMIT") + 1;
252  fGitCommit = pv;
253  fGitCommit.replace("\"","");
254  if (fGitCommit.length() > 0) break;
255  }
256  }
257 
258  // Close the file
259  fclose(fv);
260 
261  } else {
262  TRACE(REQ, "file "<<gitcommit<<" not found");
263  }
264  }
265 
266  // Done
267  return 0;
268 }
269 
270 ////////////////////////////////////////////////////////////////////////////////
271 /// Translate 'release' into a version code integer following the rules
272 /// in $ROOTSYS/include/RVersion.h.
273 /// 'release' must be in the format 'M.N/PP<something else>', e.g. 5.20/04-cms
274 
275 int XrdROOT::GetVersionCode(const char *release)
276 {
277  int maj, min, patch;
278  if (XrdROOT::ParseReleaseString(release, maj, min, patch) < 0) return -1;
279  return XrdROOT::GetVersionCode(maj, min, patch);
280 }
281 
282 ////////////////////////////////////////////////////////////////////////////////
283 /// Translate 'release' into a version code integer following the rules
284 /// in $ROOTSYS/include/RVersion.h
285 
286 int XrdROOT::GetVersionCode(int maj, int min, int patch)
287 {
288  return ((maj << 16) + (min << 8) + patch);
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Extract from 'release' its major, minor and patch numerical components;
293 /// 'release' must be in the format 'M.N/PP<something else>', e.g. 5.20/04-cms;
294 /// the part <something else> is ignored.
295 
296 int XrdROOT::ParseReleaseString(const char *release,
297  int &maj, int &min, int &patch)
298 {
299  if (!release || strlen(release) <= 0) return -1;
300 
301  XrdOucString rel(release, 7), tkn;
302  int from = 0;
303  if ((from = rel.tokenize(tkn, from, '.')) == -1) return -1;
304  maj = atoi(tkn.c_str());
305  if ((from = rel.tokenize(tkn, from, '/')) == -1) return -1;
306  min = atoi(tkn.c_str());
307  if ((from = rel.tokenize(tkn, from, ' ')) == -1) return -1;
308  patch = atoi(tkn.c_str());
309 
310  return 0;
311 }
312 
313 //
314 // Manager
315 
316 ////////////////////////////////////////////////////////////////////////////////
317 /// Constructor
318 
320  XrdProtocol_Config *pi, XrdSysError *e)
321  : XrdProofdConfig(pi->ConfigFN, e)
322 {
323  fMgr = mgr;
324  fLogger = pi->eDest->logger();
325  fROOT.clear();
326 
327  // Configuration directives
329 }
330 
331 ////////////////////////////////////////////////////////////////////////////////
332 /// Set the log dir
333 
334 void XrdROOTMgr::SetLogDir(const char *dir)
335 {
336  XPDLOC(SMGR, "ROOTMgr::SetLogDir")
337 
338  if (fMgr && dir && strlen(dir)) {
339  // MAke sure that the directory to store logs from validation exists
340  XPDFORM(fLogDir, "%s/rootsysvalidation", dir);
341  XrdProofUI ui;
343  if (XrdProofdAux::AssertDir(fLogDir.c_str(), ui, fMgr->ChangeOwn()) != 0) {
344  XPDERR("unable to assert the rootsys log validation path: "<<fLogDir);
345  fLogDir = "";
346  } else {
347  TRACE(ALL,"rootsys log validation path: "<<fLogDir);
348  }
349  }
350 }
351 
352 ////////////////////////////////////////////////////////////////////////////////
353 /// Run configuration and parse the entered config directives.
354 /// Return 0 on success, -1 on error
355 
356 int XrdROOTMgr::Config(bool rcf)
357 {
358  XPDLOC(SMGR, "ROOTMgr::Config")
359 
360  // Run first the configurator
361  if (XrdProofdConfig::Config(rcf) != 0) {
362  TRACE(XERR, "problems parsing file ");
363  return -1;
364  }
365 
366  XrdOucString msg;
367  msg = (rcf) ? "re-configuring" : "configuring";
368  TRACE(ALL, msg);
369 
370  // ROOT dirs
371  if (rcf) {
372  // Remove parked ROOT sys entries
373  std::list<XrdROOT *>::iterator tri;
374  if (fROOT.size() > 0) {
375  for (tri = fROOT.begin(); tri != fROOT.end();) {
376  if ((*tri)->IsParked()) {
377  delete (*tri);
378  tri = fROOT.erase(tri);
379  } else {
380  tri++;
381  }
382  }
383  }
384  } else {
385  // Check the ROOT dirs
386  if (fROOT.size() <= 0) {
387 #ifdef R__HAVE_CONFIG
388  XrdOucString dir(ROOTPREFIX), bd(ROOTBINDIR), ld(ROOTLIBDIR),
389  id(ROOTINCDIR), dd(ROOTDATADIR);
390 #else
391  XrdOucString dir(getenv("ROOTSYS")), bd, ld, id, dd;
392 #endif
393  // None defined: use ROOTSYS as default, if any; otherwise we fail
394  if (dir.length() > 0) {
395  XrdROOT *rootc = new XrdROOT(dir.c_str(), "",
396  bd.c_str(), id.c_str(), ld.c_str(), dd.c_str());
397  if (Validate(rootc, fMgr->Sched()) == 0) {
398  XPDFORM(msg, "ROOT dist: '%s' validated", rootc->Export());
399  fROOT.push_back(rootc);
400  TRACE(ALL, msg);
401  XrdOucString mnp;
402  XPDFORM(mnp, "ROOT version details: git: '%s', code: %d, {mnp} = {%d,%d,%d}",
403  rootc->GitCommit(), rootc->VersionCode(), rootc->VrsMajor(),
404  rootc->VrsMinor(), rootc->VrsPatch());
405  TRACE(ALL, mnp);
406  } else {
407  XPDFORM(msg, "ROOT dist: '%s' could not be validated", rootc->Export());
408  TRACE(XERR, msg);
409  }
410  }
411  if (fROOT.size() <= 0) {
412  TRACE(XERR, "no ROOT dir defined; ROOTSYS location missing - unloading");
413  return -1;
414  }
415  }
416  }
417 
418  // Done
419  return 0;
420 }
421 
422 ////////////////////////////////////////////////////////////////////////////////
423 /// Register directives for configuration
424 
426 {
427  Register("rootsys", new XrdProofdDirective("rootsys", this, &DoDirectiveClass));
428 }
429 
430 ////////////////////////////////////////////////////////////////////////////////
431 /// Update the priorities of the active sessions.
432 
434  char *val, XrdOucStream *cfg, bool rcf)
435 {
436  XPDLOC(SMGR, "ROOTMgr::DoDirective")
437 
438  if (!d)
439  // undefined inputs
440  return -1;
441 
442  if (d->fName == "rootsys") {
443  return DoDirectiveRootSys(val, cfg, rcf);
444  }
445  TRACE(XERR, "unknown directive: "<<d->fName);
446  return -1;
447 }
448 
449 ////////////////////////////////////////////////////////////////////////////////
450 /// Process 'rootsys' directive
451 
452 int XrdROOTMgr::DoDirectiveRootSys(char *val, XrdOucStream *cfg, bool)
453 {
454  XPDLOC(SMGR, "ROOTMgr::DoDirectiveRootSys")
455 
456  if (!val || !cfg)
457  // undefined inputs
458  return -1;
459 
460  // Two tokens may be meaningful
461  XrdOucString dir = val;
462  val = cfg->GetWord();
463  XrdOucString tag = val;
464  bool ok = 1;
465  if (tag == "if") {
466  tag = "";
467  // Conditional
468  cfg->RetToken();
469  ok = (XrdProofdAux::CheckIf(cfg, fMgr->Host()) > 0) ? 1 : 0;
470  }
471  if (ok) {
472  // Check for additional info in the form: bindir incdir libdir datadir
473  XrdOucString a[4];
474  int i = 0;
475  if (tag.length() > 0) {
476  while ((val = cfg->GetWord())) { a[i++] = val; }
477  }
478  XrdROOT *rootc = new XrdROOT(dir.c_str(), tag.c_str(), a[0].c_str(),
479  a[1].c_str(), a[2].c_str(), a[3].c_str());
480  // Check if already validated
481  std::list<XrdROOT *>::iterator ori;
482  for (ori = fROOT.begin(); ori != fROOT.end(); ori++) {
483  if ((*ori)->Match(rootc->Dir(), rootc->Tag())) {
484  if ((*ori)->IsParked()) {
485  (*ori)->SetValid();
486  SafeDel(rootc);
487  break;
488  }
489  }
490  }
491  // If not, try validation
492  if (rootc) {
493  if (Validate(rootc, fMgr->Sched()) == 0) {
494  TRACE(REQ, "validation OK for: "<<rootc->Export());
495  XrdOucString mnp;
496  XPDFORM(mnp, "version details: git: '%s', code: %d, {mnp} = {%d,%d,%d}",
497  rootc->GitCommit(), rootc->VersionCode(), rootc->VrsMajor(),
498  rootc->VrsMinor(), rootc->VrsPatch());
499  TRACE(REQ, mnp);
500  // Add to the list
501  fROOT.push_back(rootc);
502  } else {
503  TRACE(XERR, "could not validate "<<rootc->Export());
504  SafeDel(rootc);
505  }
506  }
507  }
508  return 0;
509 }
510 
511 ////////////////////////////////////////////////////////////////////////////////
512 /// Start a trial server application to test forking and get the version
513 /// of the protocol run by the PROOF server.
514 /// Return 0 if everything goes well, -1 in case of any error.
515 
516 int XrdROOTMgr::Validate(XrdROOT *r, XrdScheduler *sched)
517 {
518  XPDLOC(SMGR, "ROOTMgr::Validate")
519 
520  TRACE(REQ, "forking test and protocol retrieval");
521 
522  if (r->IsInvalid()) {
523  // Cannot be validated
524  TRACE(XERR, "invalid instance - cannot be validated");
525  return -1;
526  }
527 
528  // Make sure the application path has been defined
529  if (!r->PrgmSrv() || strlen(r->PrgmSrv()) <= 0) {
530  TRACE(XERR, "path to PROOF server application undefined - exit");
531  return -1;
532  }
533 
534  // Make sure the scheduler is defined
535  if (!sched) {
536  TRACE(XERR, "scheduler undefined - exit");
537  return -1;
538  }
539 
540  // Pipe to communicate the protocol number
541  int fp[2];
542  if (pipe(fp) != 0) {
543  TRACE(XERR, "PROOT protocol number communication");
544  return -1;
545  }
546 
547  // Debug flag
548  bool debug = 0;
549  if (TRACING(DBG)) debug = 1;
550 
551  // Log the attemp into this file
552  XrdOucString logfile, rootrc;
553  if (fLogDir.length() > 0) {
554  XrdOucString tag(r->Tag());
555  tag.replace("/","-");
556  XPDFORM(logfile, "%s/root.%s.log", fLogDir.c_str(), tag.c_str());
557  if (debug) {
558  XPDFORM(rootrc, "%s/root.%s.rootrc", fLogDir.c_str(), tag.c_str());
559  }
560  }
561 
562  // Fork a test agent process to handle this session
563  TRACE(FORK,"XrdROOTMgr::Validate: forking external proofsrv");
564  int pid = -1;
565  if (!(pid = sched->Fork("proofsrv"))) {
566 
567  if (logfile.length() > 0 && fLogger) {
568  // Log to the session log file from now on
569  fLogger->Bind(logfile.c_str());
570  // Transfer the info to proofserv
571  size_t len = strlen("ROOTPROOFLOGFILE=") + logfile.length() + 2;
572  char *ev = new char[len];
573  snprintf(ev, len, "ROOTPROOFLOGFILE=%s", logfile.c_str());
574  putenv(ev);
575  if (debug && rootrc.length() > 0) {
576  // Create .rootrc
577  FILE *frc = fopen(rootrc.c_str(),"w");
578  if (frc) {
579  fprintf(frc, "Proof.DebugLevel: 1\n");
580  fclose(frc);
581  }
582  // Transfer the info to proofserv
583  len = strlen("ROOTRCFILE=") + rootrc.length() + 2;
584  ev = new char[len];
585  snprintf(ev, len, "ROOTRCFILE=%s", rootrc.c_str());
586  putenv(ev);
587  }
588  }
589 
590  char *argvv[6] = {0};
591 
592  // start server
593  argvv[0] = (char *)r->PrgmSrv();
594  argvv[1] = (char *)"proofserv";
595  argvv[2] = (char *)"xpd";
596  argvv[3] = (char *)"test";
597  if (debug) {
598  argvv[4] = (char *)"1";
599  argvv[5] = 0;
600  } else {
601  argvv[4] = 0;
602  argvv[5] = 0;
603  }
604 
605  // Set basic environment for proofserv
607  TRACE(XERR, " SetProofServEnv did not return OK - EXIT");
608  exit(1);
609  }
610 
611  // Set Open socket
612  char *ev = new char[25];
613  snprintf(ev, 25, "ROOTOPENSOCK=%d", fp[1]);
614  putenv(ev);
615 
616  // Prepare for execution: we need to acquire the identity of
617  // a normal user
618  if (!getuid()) {
619  XrdProofUI ui;
620  if (XrdProofdAux::GetUserInfo(geteuid(), ui) != 0) {
621  TRACE(XERR, "could not get info for user-id: "<<geteuid());
622  exit(1);
623  }
624 
625  // acquire permanently target user privileges
626  if (XrdSysPriv::ChangePerm((uid_t)ui.fUid, (gid_t)ui.fGid) != 0) {
627  TRACE(XERR, "can't acquire "<<ui.fUser <<" identity");
628  exit(1);
629  }
630 
631  }
632 
633  // Run the program
634  execv(r->PrgmSrv(), argvv);
635 
636  // We should not be here!!!
637  TRACE(XERR, "returned from execv: bad, bad sign !!!");
638  exit(1);
639  }
640 
641  // parent process
642  if (pid < 0) {
643  TRACE(XERR, "forking failed - exit");
644  close(fp[0]);
645  close(fp[1]);
646  return -1;
647  }
648 
649  // now we wait for the callback to be (successfully) established
650  TRACE(FORK, "test server launched: wait for protocol ");
651 
652  // Read protocol
653  int proto = -1;
654  struct pollfd fds_r;
655  fds_r.fd = fp[0];
656  fds_r.events = POLLIN;
657  int pollRet = 0;
658  // We wait for 60 secs max (30 x 2000 millisecs): this is enough to
659  // cover possible delays due to heavy load
660  int ntry = 30;
661  while (pollRet == 0 && ntry--) {
662  while ((pollRet = poll(&fds_r, 1, 2000)) < 0 &&
663  (errno == EINTR)) { }
664  if (pollRet == 0)
665  TRACE(DBG, "receiving PROOF server protocol number: waiting 2 s ...");
666  }
667  if (pollRet > 0) {
668  if (read(fp[0], &proto, sizeof(proto)) != sizeof(proto)) {
669  TRACE(XERR, "problems receiving PROOF server protocol number");
670  return -1;
671  }
672  } else {
673  if (pollRet == 0) {
674  TRACE(XERR, "timed-out receiving PROOF server protocol number");
675  } else {
676  TRACE(XERR, "failed to receive PROOF server protocol number");
677  }
678  return -1;
679  }
680 
681  // Set valid, record protocol and update export string
682  r->SetValid((kXR_int16) ntohl(proto));
683 
684  // Cleanup files
685  if (logfile.length() > 0 && !debug) {
686  if (unlink(logfile.c_str()) != 0) {
687  TRACE(XERR, "problems unlinking "<<logfile<<"; errno: "<<errno);
688  }
689  }
690  if (debug && rootrc.length() > 0 && unlink(rootrc.c_str()) != 0) {
691  TRACE(XERR, "problems unlinking "<<rootrc<<"; errno: "<<errno);
692  }
693 
694  // Cleanup
695  close(fp[0]);
696  close(fp[1]);
697 
698  // We are done
699  return 0;
700 }
701 
702 ////////////////////////////////////////////////////////////////////////////////
703 /// Return a string describing the available versions, with the default
704 /// version 'def' markde with a '*'
705 
707 {
708  XrdOucString out;
709 
710  // Generic info about all known sessions
711  std::list<XrdROOT *>::iterator ip;
712  for (ip = fROOT.begin(); ip != fROOT.end(); ++ip) {
713  // Flag the default one
714  if (def == *ip)
715  out += " * ";
716  else
717  out += " ";
718  out += (*ip)->Export();
719  out += "\n";
720  }
721 
722  // Over
723  return out;
724 }
725 
726 ////////////////////////////////////////////////////////////////////////////////
727 /// Return pointer to the ROOT version corresponding to 'tag'
728 /// or 0 if not found.
729 
731 {
732  XrdROOT *r = 0;
733 
734  std::list<XrdROOT *>::iterator ip;
735  for (ip = fROOT.begin(); ip != fROOT.end(); ++ip) {
736  if ((*ip)->MatchTag(tag)) {
737  r = (*ip);
738  break;
739  }
740  }
741 
742  // Over
743  return r;
744 }
XrdROOT(const char *dir, const char *tag, const char *bindir=0, const char *incdir=0, const char *libdir=0, const char *datadir=0)
Constructor: validates 'dir', gets the version and defines the tag.
Definition: XrdROOT.cxx:40
bool ChangeOwn() const
double read(const std::string &file_name)
reading
#define SafeDel(x)
Definition: XrdProofdAux.h:335
void SetLogDir(const char *d)
Set the log dir.
Definition: XrdROOT.cxx:334
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
XrdOucString fRelease
Definition: XrdROOT.h:49
int VersionCode() const
Definition: XrdROOT.h:84
#define TRACING(x)
TLine * line
const double pi
static int GetUserInfo(const char *usr, XrdProofUI &ui)
Get information about user 'usr' in a thread safe way.
XrdROOTMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
Definition: XrdROOT.cxx:319
XrdOucString fBinDir
Definition: XrdROOT.h:40
int SetProofServEnv(XrdProofdProtocol *p, void *in)
Set environment for proofserv.
int DoDirectiveClass(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Generic class directive processor.
XrdOucString fGitCommit
Definition: XrdROOT.h:50
#define TRACE(Flag, Args)
Definition: TGHtml.h:124
int fVersionCode
Definition: XrdROOT.h:51
const char * Tag() const
Definition: XrdROOT.h:83
TArc * a
Definition: textangle.C:12
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
Definition: XrdROOT.cxx:433
static int ChangePerm(uid_t uid, gid_t gid)
bool IsInvalid() const
Definition: XrdROOT.h:74
const char * GitCommit() const
Definition: XrdROOT.h:71
XrdOucString fDir
Definition: XrdROOT.h:39
static int GetVersionCode(const char *release)
Translate 'release' into a version code integer following the rules in $ROOTSYS/include/RVersion.h.
Definition: XrdROOT.cxx:275
int fVrsMajor
Definition: XrdROOT.h:53
int VrsMinor() const
Definition: XrdROOT.h:86
int Validate(XrdROOT *r, XrdScheduler *sched)
Start a trial server application to test forking and get the version of the protocol run by the PROOF...
Definition: XrdROOT.cxx:516
void SetValid(kXR_int16 vers=-1)
Set valid, save protocol and finalize the export string.
Definition: XrdROOT.cxx:149
int DoDirectiveRootSys(char *, XrdOucStream *, bool)
Process 'rootsys' directive.
Definition: XrdROOT.cxx:452
void RegisterDirectives()
Register directives for configuration.
Definition: XrdROOT.cxx:425
XrdOucString fLogDir
Definition: XrdROOT.h:101
XrdOucString fExport
Definition: XrdROOT.h:45
XFontStruct * id
Definition: TGX11.cxx:108
XrdSysLogger * fLogger
Definition: XrdROOT.h:100
std::list< XrdROOT * > fROOT
Definition: XrdROOT.h:103
XrdOucString fTag
Definition: XrdROOT.h:44
char * out
Definition: TBase64.cxx:29
XrdOucString fUser
Definition: XrdProofdAux.h:40
#define XPDLOC(d, x)
int VrsPatch() const
Definition: XrdROOT.h:87
XrdOucString fDataDir
Definition: XrdROOT.h:41
#define XPDERR(x)
int fVrsMinor
Definition: XrdROOT.h:54
ROOT::R::TRInterface & r
Definition: Object.C:4
XrdROOT * GetVersion(const char *tag)
Return pointer to the ROOT version corresponding to 'tag' or 0 if not found.
Definition: XrdROOT.cxx:730
XrdOucString ExportVersions(XrdROOT *def)
Return a string describing the available versions, with the default version 'def' markde with a '*'...
Definition: XrdROOT.cxx:706
XrdScheduler * Sched() const
#define XrdSysError
Definition: XpdSysError.h:8
const char * Dir() const
Definition: XrdROOT.h:65
XrdOucString fLibDir
Definition: XrdROOT.h:43
int fStatus
Definition: XrdROOT.h:38
static int AssertDir(const char *path, XrdProofUI ui, bool changeown)
Make sure that 'path' exists and is owned by the entity described by 'ui'.
int VrsMajor() const
Definition: XrdROOT.h:85
#define XPDFORM
Definition: XrdProofdAux.h:381
int ParseROOTVersionInfo()
Extract ROOT version information associated with 'dir'.
Definition: XrdROOT.cxx:171
static int CheckIf(XrdOucStream *s, const char *h)
Check existence and match condition of an 'if' directive If none (valid) is found, return -1.
kXR_int16 fSrvProtVers
Definition: XrdROOT.h:47
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
Definition: XrdROOT.cxx:356
const char * Host() const
XrdOucString fPrgmSrv
Definition: XrdROOT.h:46
static int ParseReleaseString(const char *release, int &maj, int &min, int &patch)
Extract from 'release' its major, minor and patch numerical components; 'release' must be in the form...
Definition: XrdROOT.cxx:296
XrdProofdManager * fMgr
Definition: XrdROOT.h:99
int CheckDir(const char *dir)
Check if 'dir' exists Return 0 on succes, -1 on failure.
Definition: XrdROOT.cxx:123
XrdOucString fName
Definition: XrdProofdAux.h:111
const char * Export() const
Definition: XrdROOT.h:70
XrdOucString fIncDir
Definition: XrdROOT.h:42
const char * EffectiveUser() const
const char * PrgmSrv() const
Definition: XrdROOT.h:79
bool debug
int fVrsPatch
Definition: XrdROOT.h:55
virtual int Config(bool rcf=0)
void Register(const char *dname, XrdProofdDirective *d)