21#include "RConfigure.h"
23#include "RGitCommit.h"
31#include "Xrd/XrdScheduler.hh"
32#include "XrdOuc/XrdOucStream.hh"
43 const char *incdir,
const char *libdir,
const char *datadir)
57 if (!dir || strlen(dir) <= 0)
59 if (tag && strlen(tag) > 0) {
70 if (!incdir || strlen(incdir) <= 0) {
78 TRACE(XERR,
"unable to extract ROOT version information from path "<<
fIncDir);
87 if (!libdir || strlen(libdir) <= 0) {
95 if (!bindir || strlen(bindir) <= 0) {
103 if (!datadir || strlen(datadir) <= 0) {
129 if (dir && strlen(dir) > 0) {
132 if (stat(dir, &st) == -1) {
133 TRACE(XERR,
"unable to stat path "<<dir);
137 if (!S_ISDIR(st.st_mode)) {
138 TRACE(XERR,
"path "<<dir<<
" is not a directory");
144 TRACE(XERR,
"path is undefined");
158 XrdOucString vs(
" ");
160 fExport.replace(vs,XrdOucString(
""));
175 XPDLOC(SMGR,
"ParseROOTVersionInfo")
179 TRACE(XERR,
"incomplete info found in "<<versfile<<
": version code missing or bad: "<<
fVersionCode);
186 TRACE(XERR,
"incomplete info found in "<<versfile<<
": release tag missing or bad: "<<
fRelease);
212 return ((maj << 16) + (min << 8) + patch);
221 int &maj,
int &min,
int &patch)
223 if (!release || strlen(release) <= 0)
return -1;
225 XrdOucString rel(release, 7), tkn;
227 if ((from = rel.tokenize(tkn, from,
'.')) == -1)
return -1;
228 maj = atoi(tkn.c_str());
229 if ((from = rel.tokenize(tkn, from,
'/')) == -1)
return -1;
230 min = atoi(tkn.c_str());
231 if ((from = rel.tokenize(tkn, from,
' ')) == -1)
return -1;
232 patch = atoi(tkn.c_str());
260 XPDLOC(SMGR,
"ROOTMgr::SetLogDir")
262 if (
fMgr && dir && strlen(dir)) {
268 XPDERR(
"unable to assert the rootsys log validation path: "<<
fLogDir);
282 XPDLOC(SMGR,
"ROOTMgr::Config")
286 TRACE(XERR,
"problems parsing file ");
291 msg = (rcf) ?
"re-configuring" :
"configuring";
297 std::list<XrdROOT *>::iterator tri;
298 if (
fROOT.size() > 0) {
299 for (tri =
fROOT.begin(); tri !=
fROOT.end();) {
300 if ((*tri)->IsParked()) {
302 tri =
fROOT.erase(tri);
310 if (
fROOT.size() <= 0) {
311 XrdOucString dir, bd, ld,
id, dd;
313 if (getenv(
"ROOTIGNOREPREFIX"))
315 dir = getenv(
"ROOTSYS");
326 if (dir.length() > 0) {
328 bd.c_str(),
id.c_str(), ld.c_str(), dd.c_str());
331 fROOT.push_back(rootc);
334 XPDFORM(mnp,
"ROOT version details: git: '%s', code: %d, {mnp} = {%d,%d,%d}",
339 XPDFORM(msg,
"ROOT dist: '%s' could not be validated", rootc->
Export());
343 if (
fROOT.size() <= 0) {
344 TRACE(XERR,
"no ROOT dir defined; ROOTSYS location missing - unloading");
366 char *val, XrdOucStream *cfg,
bool rcf)
368 XPDLOC(SMGR,
"ROOTMgr::DoDirective")
374 if (
d->fName ==
"rootsys") {
377 TRACE(XERR,
"unknown directive: "<<
d->fName);
386 XPDLOC(SMGR,
"ROOTMgr::DoDirectiveRootSys")
393 XrdOucString dir = val;
394 val = cfg->GetWord();
395 XrdOucString tag = val;
407 if (tag.length() > 0) {
408 while ((val = cfg->GetWord())) {
a[i++] = val; }
411 a[1].c_str(),
a[2].c_str(),
a[3].c_str());
413 std::list<XrdROOT *>::iterator ori;
414 for (ori =
fROOT.begin(); ori !=
fROOT.end(); ++ori) {
415 if ((*ori)->Match(rootc->
Dir(), rootc->
Tag())) {
416 if ((*ori)->IsParked()) {
426 TRACE(REQ,
"validation OK for: "<<rootc->
Export());
428 XPDFORM(mnp,
"version details: git: '%s', code: %d, {mnp} = {%d,%d,%d}",
433 fROOT.push_back(rootc);
435 TRACE(XERR,
"could not validate "<<rootc->
Export());
450 XPDLOC(SMGR,
"ROOTMgr::Validate")
452 TRACE(REQ,
"forking test and protocol retrieval");
454 if (
r->IsInvalid()) {
456 TRACE(XERR,
"invalid instance - cannot be validated");
461 if (!
r->PrgmSrv() || strlen(
r->PrgmSrv()) <= 0) {
462 TRACE(XERR,
"path to PROOF server application undefined - exit");
468 TRACE(XERR,
"scheduler undefined - exit");
475 TRACE(XERR,
"PROOT protocol number communication");
484 XrdOucString logfile, rootrc;
486 XrdOucString tag(
r->Tag());
487 tag.replace(
"/",
"-");
490 XPDFORM(rootrc,
"%s/root.%s.rootrc",
fLogDir.c_str(), tag.c_str());
495 TRACE(FORK,
"XrdROOTMgr::Validate: forking external proofsrv");
497 if (!(pid = sched->Fork(
"proofsrv"))) {
499 if (logfile.length() > 0 &&
fLogger) {
501 fLogger->Bind(logfile.c_str());
503 size_t len = strlen(
"ROOTPROOFLOGFILE=") + logfile.length() + 2;
504 char *ev =
new char[
len];
505 snprintf(ev,
len,
"ROOTPROOFLOGFILE=%s", logfile.c_str());
507 if (debug && rootrc.length() > 0) {
509 FILE *frc = fopen(rootrc.c_str(),
"w");
511 fprintf(frc,
"Proof.DebugLevel: 1\n");
515 len = strlen(
"ROOTRCFILE=") + rootrc.length() + 2;
517 snprintf(ev,
len,
"ROOTRCFILE=%s", rootrc.c_str());
522 char *argvv[6] = {0};
525 argvv[0] = (
char *)
r->PrgmSrv();
526 argvv[1] = (
char *)
"proofserv";
527 argvv[2] = (
char *)
"xpd";
528 argvv[3] = (
char *)
"test";
530 argvv[4] = (
char *)
"1";
539 TRACE(XERR,
" SetProofServEnv did not return OK - EXIT");
544 char *ev =
new char[25];
545 snprintf(ev, 25,
"ROOTOPENSOCK=%d", fp[1]);
553 TRACE(XERR,
"could not get info for user-id: "<<geteuid());
559 TRACE(XERR,
"can't acquire "<<ui.
fUser <<
" identity");
566 execv(
r->PrgmSrv(), argvv);
569 TRACE(XERR,
"returned from execv: bad, bad sign !!!");
575 TRACE(XERR,
"forking failed - exit");
582 TRACE(FORK,
"test server launched: wait for protocol ");
588 fds_r.events = POLLIN;
593 while (pollRet == 0 && ntry--) {
594 while ((pollRet = poll(&fds_r, 1, 2000)) < 0 &&
595 (errno == EINTR)) { }
597 TRACE(DBG,
"receiving PROOF server protocol number: waiting 2 s ...");
601 TRACE(XERR,
"problems receiving PROOF server protocol number");
606 TRACE(XERR,
"timed-out receiving PROOF server protocol number");
608 TRACE(XERR,
"failed to receive PROOF server protocol number");
614 r->SetValid((kXR_int16) ntohl(
proto));
617 if (logfile.length() > 0 && !debug) {
618 if (unlink(logfile.c_str()) != 0) {
619 TRACE(XERR,
"problems unlinking "<<logfile<<
"; errno: "<<errno);
622 if (debug && rootrc.length() > 0 && unlink(rootrc.c_str()) != 0) {
623 TRACE(XERR,
"problems unlinking "<<rootrc<<
"; errno: "<<errno);
643 std::list<XrdROOT *>::iterator ip;
644 for (ip =
fROOT.begin(); ip !=
fROOT.end(); ++ip) {
650 out += (*ip)->Export();
666 std::list<XrdROOT *>::iterator ip;
667 for (ip =
fROOT.begin(); ip !=
fROOT.end(); ++ip) {
668 if ((*ip)->MatchTag(tag)) {
#define ROOT_VERSION_PATCH
#define ROOT_VERSION_MAJOR
#define ROOT_VERSION_CODE
#define ROOT_VERSION_MINOR
#define TRACE(Flag, Args)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
int DoDirectiveClass(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Generic class directive processor.
static int GetUserInfo(const char *usr, XrdProofUI &ui)
Get information about user 'usr' in a thread safe way.
static int AssertDir(const char *path, XrdProofUI ui, bool changeown)
Make sure that 'path' exists and is owned by the entity described by 'ui'.
static int CheckIf(XrdOucStream *s, const char *h)
Check existence and match condition of an 'if' directive If none (valid) is found,...
virtual int Config(bool rcf=0)
void Register(const char *dname, XrdProofdDirective *d)
XrdScheduler * Sched() const
const char * Host() const
const char * EffectiveUser() const
int SetProofServEnv(XrdProofdProtocol *p, void *in)
Set environment for proofserv.
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...
XrdROOT * GetVersion(const char *tag)
Return pointer to the ROOT version corresponding to 'tag' or 0 if not found.
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
void RegisterDirectives()
Register directives for configuration.
XrdOucString ExportVersions(XrdROOT *def)
Return a string describing the available versions, with the default version 'def' markde with a '*'.
std::list< XrdROOT * > fROOT
XrdROOTMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
void SetLogDir(const char *d)
Set the log dir.
int DoDirectiveRootSys(char *, XrdOucStream *, bool)
Process 'rootsys' directive.
static int GetVersionCode(const char *release)
Translate 'release' into a version code integer following the rules in $ROOTSYS/include/RVersion....
const char * Export() const
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...
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.
int CheckDir(const char *dir)
Check if 'dir' exists Return 0 on succes, -1 on failure.
int ParseROOTVersionInfo()
Extract ROOT version information associated with 'dir'.
const char * GitCommit() const
void SetValid(kXR_int16 vers=-1)
Set valid, save protocol and finalize the export string.
static int ChangePerm(uid_t uid, gid_t gid)