27 #include "Xrd/XrdBuffer.hh"
29 #include "Xrd/XrdScheduler.hh"
30 #include "XrdNet/XrdNet.hh"
31 #include "XrdOuc/XrdOucRash.hh"
32 #include "XrdOuc/XrdOucStream.hh"
34 #include "XrdSys/XrdSysPlugin.hh"
52 } XpdBroadcastPriority_t;
61 #define PutEnv(x,e) { if (e) { putenv(x); } else { delete[] x; } }
82 XPDLOC(SMGR,
"ProofServCron")
88 TRACE(XERR,
"undefined session manager: cannot start");
94 int quickcheckfreq = 5;
98 int lastrun = time(0);
99 int lastcheck = lastrun, ckfreq = mgr->
CheckFrequency(), waitt = 0;
100 int deltat = ((int)(0.1*ckfreq) >= 1) ? (
int)(0.1*ckfreq) : 1;
101 int maxdelay = 5*ckfreq;
103 TRACE(ALL,
"next full sessions check in "<<ckfreq<<
" secs");
108 waitt = ckfreq - (time(0) - lastcheck);
109 if (waitt > quickcheckfreq || waitt <= 0)
110 waitt = quickcheckfreq;
111 int pollRet = mgr->
Pipe()->
Poll(waitt);
117 if ((rc = mgr->
Pipe()->
Recv(msg)) != 0) {
118 TRACE(XERR,
"problems receiving message; errno: "<<-rc);
125 if ((rc = msg.
Get(fpid)) != 0) {
126 TRACE(XERR,
"kSessionRemoval: problems receiving process ID (buf: '"<<
127 msg.
Buf()<<
"'); errno: "<<-rc);
138 TRACE(XERR,
"kSessionRemoval: problem posting the scheduler pipe");
142 TRACE(REQ,
"kSessionRemoval: session: "<<fpid<<
143 " has been removed from the active list");
146 TRACE(XERR,
"obsolete type: XrdProofdProofServMgr::kClientDisconnect");
153 rc = (rc == 0) ? msg.
Get(svrtype) : rc;
155 TRACE(XERR,
"kCleanSessions: problems parsing message (buf: '"<<
156 msg.
Buf()<<
"'); errno: "<<-rc);
160 TRACE(REQ,
"kCleanSessions: request for user: '"<<usr<<
"', server type: "<<svrtype);
172 TRACE(XERR,
"unknown type: "<<msg.
Type());
183 if ((now - lastrun) < maxdelay) {
185 lastcheck = now + 5 - ckfreq;
188 TRACE(ALL,
"postponing sessions check (will retry in 5 secs)");
192 TRACE(ALL,
"Max time without checks reached ("<<maxdelay<<
"): force a session check");
203 if (clnlostscale <= 0) {
211 TRACE(ALL, cursess <<
" sessions are currently active");
240 XPDLOC(SMGR,
"ProofServRecover")
245 TRACE(XERR,
"undefined session manager: cannot start");
254 TRACE(ALL,
"timeout recovering sessions: "<<rc<<
" sessions not recovered");
256 TRACE(XERR,
"some problem occured while recovering sessions");
258 TRACE(ALL,
"recovering successfully terminated");
272 XPDLOC(SMGR,
"XrdProofdProofServMgr")
308 TRACE(XERR,
"unable to generate pipe for the session poller");
322 XPDLOC(SMGR,
"ProofServMgr::Config")
326 bool notify = (rcf) ? 0 : 1;
337 TRACE(XERR,
"problems parsing file ");
342 msg = (rcf) ?
"re-configuring" :
"configuring";
350 msg =
"client sessions shutdown after disconnection";
352 XPDFORM(msg,
"client sessions kept %sfor %d secs after disconnection",
386 for ( ; ircs !=
fProofServRCs.end(); ircs++) { (*ircs).Print(
"rc"); }
391 for ( ; ienvs !=
fProofServEnvs.end(); ienvs++) { (*ienvs).Print(
"env"); }
396 XPDFORM(msg,
"using %s to start proofserv sessions",
fUseFork ?
"fork()" :
"system()");
403 TRACE(XERR,
"problems trying to recover active sessions");
405 XPDFORM(msg,
"%d active sessions have been recovered", nr);
415 (
void *)&fManagerCron, 0,
"ProofServMgr cron thread") != 0) {
416 TRACE(XERR,
"could not start cron thread");
419 XPDPRT(
"cron thread started");
431 XPDLOC(SMGR,
"ProofServMgr::AddSession")
433 TRACE(REQ,
"adding new active session ...");
437 TRACE(XERR,
"invalid inputs: "<<(s ?
"" :
"s, ") <<
", "<< (p->
Client() ?
"" :
"p->Client()"));
448 int rc = info.SaveToFile(path.c_str());
459 XPDLOC(SMGR,
"ProofServMgr::IsSessionSocket")
461 TRACE(REQ,
"checking "<<fpid<<
" ...");
464 if (!fpid || strlen(fpid) <= 0) {
465 TRACE(XERR,
"invalid input: "<<(fpid ? fpid :
"<nul>"));
470 XrdOucString spath(fpid);
471 if (!spath.endswith(
".sock"))
return 0;
476 XrdOucString apath = spath;
477 apath.replace(
".sock",
"");
481 if (stat(apath.c_str(), &st) != 0 && (errno == ENOENT)) {
484 unlink(spath.c_str());
485 TRACE(REQ,
"missing admin path: removing "<<spath<<
" ...");
498 XPDLOC(SMGR,
"ProofServMgr::MvSession")
500 TRACE(REQ,
"moving "<<fpid<<
" ...");
503 if (!fpid || strlen(fpid) <= 0) {
504 TRACE(XERR,
"invalid input: "<<(fpid ? fpid :
"<nul>"));
509 XrdOucString opath(fpid), npath;
513 opath.replace(
".status",
"");
516 opath.replace(
".status",
"");
523 XrdOucString spath = opath;
525 if (unlink(spath.c_str()) != 0 && errno != ENOENT)
526 TRACE(XERR,
"problems removing the UNIX socket path: "<<spath<<
"; errno: "<<errno);
527 spath.replace(
".sock",
".status");
528 if (unlink(spath.c_str()) != 0 && errno != ENOENT)
529 TRACE(XERR,
"problems removing the status file: "<<spath<<
"; errno: "<<errno);
534 if ((rc = rename(opath.c_str(), npath.c_str())) == 0 || (errno == ENOENT)) {
541 TRACE(XERR,
"session pid file cannot be moved: "<<opath<<
542 "; target file: "<<npath<<
"; errno: "<<errno);
551 XPDLOC(SMGR,
"ProofServMgr::RmSession")
553 TRACE(REQ,
"removing "<<fpid<<
" ...");
556 if (!fpid || strlen(fpid) <= 0) {
557 TRACE(XERR,
"invalid input: "<< (fpid ? fpid :
"<nul>"));
566 if (unlink(path.c_str()) == 0)
569 TRACE(XERR,
"session pid file cannot be unlinked: "<<
570 path<<
"; error: "<<errno);
579 XPDLOC(SMGR,
"ProofServMgr::TouchSession")
581 TRACE(REQ,
"touching "<<(fpid ? fpid :
"<nul>")<<
", "<<(fpath ? fpath :
"<nul>")<<
" ...");
584 if (!fpid || strlen(fpid) <= 0) {
585 TRACE(XERR,
"invalid input: "<<(fpid ? fpid :
"<nul>"));
590 XrdOucString path(fpath);
591 if (!fpath || !fpath[0])
595 if (utime(path.c_str(), 0) == 0)
598 TRACE(XERR,
"time stamps for session pid file cannot be updated: "<<
599 path<<
"; error: "<<errno);
610 int to,
const char *fpath)
612 XPDLOC(SMGR,
"ProofServMgr::VerifySession")
615 if (!fpid || strlen(fpid) <= 0) {
616 TRACE(XERR,
"invalid input: "<<(fpid ? fpid :
"<nul>"));
622 if (fpath && strlen(fpath) > 0)
623 XPDFORM(path,
"%s/%s", fpath, fpid);
633 if (stat(path.c_str(), &st)) {
634 TRACE(XERR,
"session status file cannot be stat'ed: "<<
635 path<<
"; error: "<<errno);
640 deltat = time(0) - st.st_mtime;
642 if (path.endswith(
".status")) {
644 path.erase(path.rfind(
".status"));
647 TRACE(DBG,
"admin path for session "<<fpid<<
" hase not been touched"
648 " since at least "<< xto <<
" secs");
658 TRACE(DBG,
"admin path for session "<<fpid<<
" was touched " <<
659 deltat <<
" secs ago");
669 XPDLOC(SMGR,
"ProofServMgr::DeleteFromSessions")
671 TRACE(REQ,
"session: "<<fpid);
674 if (!fpid || strlen(fpid) <= 0) {
675 TRACE(XERR,
"invalid input: "<<(fpid ? fpid :
"<nul>"));
679 XrdOucString key = fpid;
680 key.replace(
".status",
"");
681 key.erase(0, key.rfind(
'.') + 1);
687 XPDFORM(msg,
"session: %s terminated by peer", fpid);
709 XPDLOC(SMGR,
"ProofServMgr::PrepareSessionRecovering")
717 TRACE(REQ,
"preparing recovering of active sessions ...");
721 struct dirent *ent = 0;
722 while ((ent = (
struct dirent *)readdir(dir))) {
723 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
725 XrdOucString rest,
a;
728 if (a.length() > 0)
continue;
733 TRACE(DBG,
"found active session: "<<pid);
755 0,
"ProofServMgr session recover thread") != 0) {
756 TRACE(XERR,
"could not start session recover thread");
759 XPDPRT(
"session recover thread started");
780 XPDLOC(SMGR,
"ProofServMgr::RecoverActiveSessions")
786 TRACE(XERR,
"recovering clients list undefined");
792 TRACE(REQ,
"start recovering of "<<nrc<<
" clients");
821 TRACE(REQ, nrc<<
" clients still to recover");
834 std::list<XpdClientSessions* >::iterator ii =
fRecoverClients->begin();
836 rc += (*ii)->fProofServs.size();
861 XPDLOC(SMGR,
"ProofServMgr::IsClientRecovering")
864 TRACE(XERR,
"invalid inputs: usr: "<<(usr ? usr :
"")<<
", grp:"<<(grp ? grp :
"")<<
" ...");
872 std::list<XpdClientSessions *>::iterator ii =
fRecoverClients->begin();
874 if ((*ii)->fClient && (*ii)->fClient->Match(usr, grp)) {
882 TRACE(DBG,
"checking usr: "<<usr<<
", grp:"<<grp<<
" ... recovering? "<<
883 rc<<
", until: "<<deadline);
897 XPDLOC(SMGR,
"ProofServMgr::CheckActiveSessions")
899 TRACE(REQ,
"checking active sessions ...");
909 struct dirent *ent = 0;
910 while ((ent = (
struct dirent *)readdir(dir))) {
911 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
914 if (strstr(ent->d_name,
".sock") &&
IsSessionSocket(ent->d_name))
continue;
916 XrdOucString rest, key, after;
919 if (after !=
"status")
continue;
929 bool sessionalive = (
VerifySession(ent->d_name) == 0) ? 1 : 0;
932 if (!xps->
IsValid() || !sessionalive) rmsession = 1;
936 if (sessionalive)
continue;
954 if (!rmsession && verify && !oldvers) {
960 TRACE(REQ,
"session: "<<ent->d_name<<
"; nc: "<<nc<<
"; rm: "<<rmsession);
979 XPDLOC(SMGR,
"ProofServMgr::CheckTerminatedSessions")
981 TRACE(REQ,
"checking terminated sessions ...");
992 struct dirent *ent = 0;
993 while ((ent = (
struct dirent *)readdir(dir))) {
994 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
996 XrdOucString rest,
a;
1001 now = (now > 0) ? now : time(0);
1009 int rcst = stat(path.c_str(), &st);
1010 TRACE(DBG, pid<<
": rcst: "<<rcst<<
", now - mtime: "<<now - st.st_mtime<<
" secs")
1038 XPDLOC(SMGR,
"ProofServMgr::CleanClientSessions")
1040 TRACE(REQ,
"cleaning "<<usr<<
" ...");
1043 bool all = (!usr || strlen(usr) <= 0 || !strcmp(usr,
"all")) ? 1 : 0;
1049 XrdOucString path, rest, key,
a;
1059 if (c) mtx = c->
Mutex();
1062 std::list<int> tobedel;
1071 struct dirent *ent = 0;
1072 while ((ent = (
struct dirent *)readdir(dir))) {
1074 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
1082 if (!all && info.fUser != usr)
continue;
1084 if (srvtype !=
kXPD_AnyServer && info.fSrvType != srvtype)
continue;
1109 struct dirent *ent = 0;
1110 while ((ent = (
struct dirent *)readdir(dir))) {
1112 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
1115 if (a ==
"status")
continue;
1120 if (!all && info.fUser != usr)
continue;
1122 if (srvtype !=
kXPD_AnyServer && info.fSrvType != srvtype)
continue;
1129 tobedel.push_back(pid);
1141 std::list<int>::iterator ii = tobedel.begin();
1142 while (ii != tobedel.end()) {
1147 std::list<XrdProofdProofServ *>::iterator ixps =
fActiveSessions.begin();
1155 if (!active)
fSessions.Del(key.c_str());
1189 char *val, XrdOucStream *cfg,
bool rcf)
1191 XPDLOC(SMGR,
"ProofServMgr::DoDirective")
1197 if (d->
fName ==
"proofservmgr") {
1199 }
else if (d->
fName ==
"putenv") {
1201 }
else if (d->
fName ==
"putrc") {
1203 }
else if (d->
fName ==
"shutdown") {
1216 XPDLOC(SMGR,
"ProofServMgr::DoDirectiveProofServMgr")
1234 XrdOucString tok(val);
1235 if (tok.beginswith(
"checkfq:")) {
1236 tok.replace(
"checkfq:",
"");
1237 checkfq = strtol(tok.c_str(), 0, 10);
1238 }
else if (tok.beginswith(
"termto:")) {
1239 tok.replace(
"termto:",
"");
1240 termto = strtol(tok.c_str(), 0, 10);
1241 }
else if (tok.beginswith(
"verifyto:")) {
1242 tok.replace(
"verifyto:",
"");
1243 verifyto = strtol(tok.c_str(), 0, 10);
1244 }
else if (tok.beginswith(
"recoverto:")) {
1245 tok.replace(
"recoverto:",
"");
1246 recoverto = strtol(tok.c_str(), 0, 10);
1247 }
else if (tok.beginswith(
"checklost:")) {
1248 tok.replace(
"checklost:",
"");
1249 checklost = strtol(tok.c_str(), 0, 10);
1250 }
else if (tok.beginswith(
"usefork:")) {
1251 tok.replace(
"usefork:",
"");
1252 usefork = strtol(tok.c_str(), 0, 10);
1255 val = cfg->GetWord();
1273 XPDFORM(msg,
"checkfq: %d s, termto: %d s, verifyto: %d s, recoverto: %d s, checklost: %d, usefork: %d",
1290 XrdOucString users, groups, rcval, rcnam;
1291 int smi = -1, smx = -1, vmi = -1, vmx = -1;
1293 ExtractEnv(val, cfg, users, groups, rcval, rcnam, smi, smx, vmi, vmx, hex);
1296 int iequ = rcnam.find(
'=');
1297 if (iequ == STR_NPOS)
return -1;
1302 users.c_str(), groups.c_str(), smi, smx, vmi, vmx,
hex);
1321 XrdOucString users, groups, rcval, rcnam;
1322 int smi = -1, smx = -1, vmi = -1, vmx = -1;
1324 ExtractEnv(val, cfg, users, groups, rcval, rcnam, smi, smx, vmi, vmx, hex);
1328 users.c_str(), groups.c_str(), smi, smx, vmi, vmx,
hex);
1337 XrdOucString &users, XrdOucString &groups,
1338 XrdOucString &rcval, XrdOucString &rcnam,
1339 int &smi,
int &smx,
int &vmi,
int &vmx,
bool &
hex)
1341 XrdOucString ssvn, sver;
1343 while (val && val[0]) {
1344 if (!strncmp(val,
"u:", 2)) {
1347 }
else if (!strncmp(val,
"g:", 2)) {
1350 }
else if (!strncmp(val,
"s:", 2)) {
1353 idash = ssvn.find(
'-');
1354 if (idash != STR_NPOS) {
1355 if (ssvn.isdigit(0, idash-1)) smi = ssvn.atoi(0, idash-1);
1356 if (ssvn.isdigit(idash+1)) smx = ssvn.atoi(idash+1);
1358 if (ssvn.isdigit()) smi = ssvn.atoi();
1360 }
else if (!strncmp(val,
"v:", 2)) {
1364 if (sver.beginswith(
'x')) {
1368 idash = sver.find(
'-');
1369 if (idash != STR_NPOS) {
1370 if (sver.isdigit(0, idash-1)) vmi = sver.atoi(0, idash-1);
1371 if (sver.isdigit(idash+1)) vmx = sver.atoi(idash+1);
1373 if (sver.isdigit()) vmi = sver.atoi();
1376 if (rcval.length() > 0) {
1383 val = cfg->GetWord();
1393 const char *usrs,
const char *grps,
1394 int smi,
int smx,
int vmi,
int vmx,
bool hex)
1396 XPDLOC(SMGR,
"ProofServMgr::FillEnvList")
1399 TRACE(ALL,
"env list undefined!");
1403 XrdOucString users(usrs), groups(grps);
1408 XpdEnv xpe(nam, val, users.c_str(), groups.c_str(), smi, smx, vmi, vmx);
1409 if (users.length() > 0) {
1412 while ((from = users.tokenize(usr, from,
',')) != -1) {
1413 if (usr.length() > 0) {
1414 if (groups.length() > 0) {
1417 while ((fromg = groups.tokenize(grp, from,
',')) != -1) {
1418 if (grp.length() > 0) {
1419 xpe.
Reset(nam, val, usr.c_str(), grp.c_str(), smi, smx, vmi, vmx);
1424 xpe.Reset(nam, val, usr.c_str(), 0, smi, smx, vmi, vmx);
1430 if (groups.length() > 0) {
1433 while ((fromg = groups.tokenize(grp, fromg,
',')) != -1) {
1434 if (grp.length() > 0) {
1435 xpe.Reset(nam, val, 0, grp.c_str(), smi, smx, vmi, vmx);
1460 int dp = strtol(val,0,10);
1461 if (dp >= 0 && dp <= 2)
1464 if ((val = cfg->GetWord())) {
1465 int l = strlen(val);
1467 XrdOucString tval = val;
1469 if (val[l-1] ==
's') {
1471 }
else if (val[l-1] ==
'm') {
1474 }
else if (val[l-1] ==
'h') {
1477 }
else if (val[l-1] < 48 || val[l-1] > 57) {
1481 int de = strtol(val,0,10);
1504 XPDLOC(SMGR,
"ProofServMgr::Process")
1515 XrdOucString emsg(
"Invalid request code: ");
1520 response->Send(kXR_ServerError,
1521 "ProofServMgr::Process: error posting internal pipe for authorization to proceed");
1525 response->Send(kXR_ServerError,
1526 "ProofServMgr::Process: timed-out waiting for authorization to proceed - retry later");
1548 response->Send(kXR_InvalidRequest, emsg.c_str());
1557 XPDLOC(SMGR,
"ProofServMgr::Attach")
1559 int psid = -1, rc = 0;
1564 TRACEP(p, REQ,
"psid: "<<psid<<
", CID = "<<p->
CID());
1569 TRACEP(p, XERR,
"client instance undefined");
1570 response->Send(kXR_ServerError,
"client instance undefined");
1579 while ((deadline < 0) || (now < deadline)) {
1580 if (!(xps = c->GetServer(psid)) || !xps->
IsValid()) {
1584 TRACEP(p, XERR,
"session ID not found: "<<psid);
1585 response->Send(kXR_InvalidRequest,
"session ID not found");
1589 deadline = (deadline > 0) ? deadline : defdeadline;
1600 if (!xps || !xps->
IsValid()) {
1601 TRACEP(p, XERR,
"session ID not found: "<<psid);
1602 response->Send(kXR_InvalidRequest,
"session ID not found");
1605 TRACEP(p, DBG,
"xps: "<<xps<<
", status: "<< xps->
Status());
1609 memcpy((
void *)&sid, (
const void *)&(p->
Request()->
header.streamid[0]), 2);
1626 if (!dpu.endswith(
'/'))
1630 (
void *) dpu.c_str(), dpu.length());
1650 unsigned short &sid)
1652 XPDLOC(SMGR,
"ProofServMgr::PrepareProofServ")
1660 memcpy((
void *)&sid, (
const void *)&(p->
Request()->
header.streamid[0]), 2);
1677 XPDFORM(msg,
"++++ Using NON-default ROOT version: %s ++++\n", xps->
ROOT()->
Export());
1691 XrdOucString &tag, XrdOucString &
ord,
1692 XrdOucString &cffile,
1693 XrdOucString &uenvs,
int &intwait)
1695 XPDLOC(SMGR,
"ProofServMgr::ParseCreateBuffer")
1698 char *buf = p->
Argp()->buff;
1702 tag.assign(buf,0,len-1);
1704 TRACEP(p, DBG,
"received buf: "<<tag);
1706 tag.erase(tag.find(
'|'));
1707 xps->
SetTag(tag.c_str());
1708 TRACEP(p, DBG,
"tag: "<<tag);
1713 ord.assign(buf,0,len-1);
1714 int iord = ord.find(
"|ord:");
1715 if (iord != STR_NPOS) {
1716 ord.erase(0,iord+5);
1717 ord.erase(ord.find(
"|"));
1724 cffile.assign(buf,0,len-1);
1725 int icf = cffile.find(
"|cf:");
1726 if (icf != STR_NPOS) {
1727 cffile.erase(0,icf+4);
1728 cffile.erase(cffile.find(
"|"));
1733 XrdOucString plitenwk;
1734 plitenwk.assign(buf,0,len-1);
1735 int inwk = plitenwk.find(
"|plite:");
1736 if (inwk != STR_NPOS) {
1737 plitenwk.erase(0,inwk+7);
1738 plitenwk.erase(plitenwk.find(
"|"));
1739 int nwk = plitenwk.atoi();
1742 TRACEP(p, DBG,
"P-Lite master with "<<nwk<<
" workers (0 means # or cores)");
1747 uenvs.assign(buf,0,len-1);
1748 int ienv = uenvs.find(
"|envs:");
1749 if (ienv != STR_NPOS) {
1750 uenvs.erase(0,ienv+6);
1751 uenvs.erase(uenvs.find(
"|"));
1758 if (uenvs.length() > 0) {
1759 TRACEP(p, DBG,
"user envs: "<<uenvs);
1761 if ((iiw = uenvs.find(
"PROOF_INTWAIT=")) != STR_NPOS) {
1762 XrdOucString s(uenvs, iiw + strlen(
"PROOF_INTWAIT="));
1763 s.erase(s.find(
','));
1766 TRACEP(p, ALL,
"startup internal wait set by user to "<<intwait);
1777 XPDLOC(SMGR,
"ProofServMgr::Create")
1779 int psid = -1, rc = 0;
1792 TRACEP(p,ALL,
" cursess: "<<cursess);
1793 if (mxsess <= cursess) {
1794 XPDFORM(msg,
" ++++ Max number of sessions reached (%d) - please retry later ++++ \n", cursess);
1795 response->Send(kXR_attn,
kXPD_srvmsg, (
char *) msg.c_str(), msg.length());
1807 TRACEP(p, DBG, nc <<
" threads are creating a new session");
1820 XrdOucString tag,
ord, cffile, uenvs;
1824 TRACEP(p, DBG,
"{ord,cfg,psid,cid,log}: {"<<ord<<
","<<cffile<<
","<<psid
1825 <<
","<<p->
CID()<<
","<<loglevel<<
"}");
1833 response->Send(
kXP_ServerError,
"timed-out acquiring fork semaphore");
1843 "unable to create pipes for communication during setup");
1848 ProofServEnv_t in = {xps, loglevel, cffile.c_str(),
"",
"", tag.c_str(),
"",
"", 1};
1853 TRACEP(p, FORK,
"Forking external proofsrv");
1854 if (!(pid =
fMgr->
Sched()->Fork(
"proofsrv"))) {
1867 XrdOucString pmsg =
"*** spawned child process ";
1868 pmsg += (int) getpid();
1874 TRACE(XERR,
"chown on '"<<in.
fLogFile.c_str()<<
"'; errno: "<<errno);
1877 XrdOucString path, sockpath, emsg;
1880 if (fpc.
Poll() < 0) {
1881 TRACE(XERR,
"error while polling to receive the admin path from parent - EXIT" );
1884 if (fpc.
Recv(xmsg) != 0) {
1885 TRACE(XERR,
"error reading message while waiting for the admin path from parent - EXIT" );
1888 if (xmsg.Type() < 0) {
1889 TRACE(XERR,
"the parent failed to setup the admin path - EXIT" );
1895 TRACE(FORK,
"admin path: "<<path);
1899 if (fpc.
Poll() < 0) {
1900 TRACE(XERR,
"error while polling to receive the sock path from parent - EXIT" );
1903 if (fpc.
Recv(xmsg) != 0) {
1904 TRACE(XERR,
"error reading message while waiting for the sock path from parent - EXIT" );
1907 if (xmsg.Type() < 0) {
1908 TRACE(XERR,
"the parent failed to setup the sock path - EXIT" );
1912 sockpath = xmsg.Buf();
1914 TRACE(FORK,
"UNIX sock path: "<<sockpath);
1917 bool asserdatadir = 1;
1919 TRACE(ALL,
"srvtype = "<< srvtype);
1925 const char *pord = asserdatadir ? ord.c_str() : 0;
1926 const char *ptag = asserdatadir ? in.
fSessionTag.c_str() : 0;
1928 emsg =
"SetUserOwnerships did not return OK - EXIT";
1930 if (fcp.
Post(0, emsg.c_str()) != 0)
1931 TRACE(XERR,
"cannot write to internal pipe; errno: "<<errno);
1937 emsg =
"SetUserEnvironment did not return OK - EXIT";
1939 if (fcp.
Post(0, emsg.c_str()) != 0)
1940 TRACE(XERR,
"cannot write to internal pipe; errno: "<<errno);
1944 char *argvv[7] = {0};
1948 emsg =
"XrdProofdManager instance undefined!";
1950 if (fcp.
Post(0, emsg.c_str()) != 0)
1951 TRACE(XERR,
"cannot write to internal pipe; errno: "<<errno);
1957 size_t len = strlen(
fMgr->
AdminPath()) + strlen(
"xpdpath:") + 1;
1958 sxpd =
new char[len];
1962 sxpd =
new char[10];
1963 snprintf(sxpd, 10,
"%d", getppid());
1967 char slog[10] = {0};
1968 snprintf(slog, 10,
"%d", loglevel);
1971 char ssrv[10] = {0};
1972 snprintf(ssrv, 10,
"%d", xps->
SrvType());
1978 argvv[2] = (
char *)
"xpd";
1979 argvv[3] = (
char *)sxpd;
1980 argvv[4] = (
char *)slog;
1981 argvv[5] = (
char *)ssrv;
1986 emsg =
"SetProofServEnv did not return OK - EXIT";
1988 if (fcp.
Post(0, emsg.c_str()) != 0)
1989 TRACE(XERR,
"cannot write to internal pipe; errno: "<<errno);
1992 TRACE(FORK, (
int)getpid() <<
": proofserv env set up");
1997 TRACE(XERR,
"cannot write log file path to internal pipe; errno: "<<errno);
2000 TRACE(FORK, (
int)getpid()<<
": log file path communicated");
2004 sigemptyset(&myset);
2005 sigaddset(&myset, SIGUSR1);
2006 sigaddset(&myset, SIGUSR2);
2007 pthread_sigmask(SIG_UNBLOCK, &myset, 0);
2014 ", uid: "<<getuid()<<
", euid:"<<geteuid()<<
2015 ", psrv: "<<xps->
ROOT()->
PrgmSrv()<<
", argvv[1]: "<<argvv[1]);
2020 TRACE(XERR,
"returned from execv: bad, bad sign !!! errno:" << (
int)errno);
2035 TRACEP(p, FORK,
"Parent process: child is "<<pid);
2058 XrdOucString path, sockpath;
2063 struct sockaddr_un unserver;
2064 if (sockpath.length() > (int)(
sizeof(unserver.sun_path) - 1)) {
2065 emsg =
"socket path very long (";
2066 emsg += sockpath.length();
2067 emsg +=
"): this may lead to stack corruption!";
2068 emsg +=
" Use xpd.sockpathdir to change it";
2069 TRACEP(p, XERR, emsg.c_str());
2074 if ((pathrc = fpc.
Post(0, path.c_str())) != 0) {
2075 emsg =
"failed to communicating path to child";
2077 TRACEP(p, XERR, emsg.c_str());
2080 emsg =
"failed to setup child admin path";
2082 if ((pathrc = fpc.
Post(-1, path.c_str())) != 0) {
2083 emsg +=
": failed communicating failure to child";
2085 TRACEP(p, XERR, emsg.c_str());
2093 emsg =
"failure creating UNIX socket on " ;
2096 TRACEP(p, XERR, emsg.c_str());
2102 emsg =
"failure changing ownership of the UNIX socket on " ;
2104 emsg +=
"; errno: " ;
2107 TRACEP(p, XERR, emsg.c_str());
2113 if ((pathrc = fpc.
Post(0, sockpath.c_str())) != 0) {
2114 emsg =
"failed to communicating path to child";
2116 TRACEP(p, XERR, emsg.c_str());
2119 emsg =
"failed to setup child admin path";
2121 if ((pathrc = fpc.
Post(-1, sockpath.c_str())) != 0) {
2122 emsg +=
": failed communicating failure to child";
2124 TRACEP(p, XERR, emsg.c_str());
2135 emsg.insert(npfx, 0);
2140 TRACEP(p, FORK,
"waiting for client setup status ...");
2142 emsg =
"proofserv setup";
2146 int ntry = 10, prc = 0, rst = -1;
2147 while (prc == 0 && ntry--) {
2149 if ((prc = fcp.
Poll(2)) > 0) {
2152 if (fcp.
Recv(xmsg) != 0) {
2153 emsg =
"error receiving message from pipe";
2155 TRACEP(p, XERR, emsg.c_str());
2162 XrdOucString xbuf = xmsg.
Buf();
2163 if (xbuf.length() <= 0) {
2164 emsg =
"error reading buffer {logfile, error message} from message received on the pipe";
2166 TRACEP(p, XERR, emsg.c_str());
2174 XrdOucString stag(xbuf);
2175 stag.erase(stag.rfind(
'/'));
2176 stag.erase(0, stag.find(
"session-") + strlen(
"session-"));
2177 xps->
SetTag(stag.c_str());
2185 TRACEP(p, XERR, emsg.c_str());
2189 }
else if (prc < 0) {
2190 emsg =
"error receive status-of-setup from pipe";
2192 TRACEP(p, XERR, emsg.c_str());
2195 TRACEP(p, FORK,
"receiving status-of-setup from pipe: waiting 2 s ..."<<pid);
2208 emsg =
"failure setting up proofserv" ;
2209 if (prc == 0) emsg +=
": timed-out receiving status-of-setup from pipe";
2218 TRACEP(p, XERR, emsg.c_str());
2219 emsg.insert(npfx, 0);
2231 (
void *) info.c_str(), info.length());
2235 TRACEP(p, FORK,
"server launched: wait for callback ");
2242 emsg =
"problems accepting callback: ";
2245 emsg +=
"process could not be killed - pid: ";
2247 emsg +=
"process killed - pid: ";
2254 TRACEP(p, XERR, emsg.c_str());
2255 emsg.insert(npfx, 0);
2256 response->Send(kXR_attn,
kXPD_errmsg, (
char *) emsg.c_str(), emsg.length());
2266 TRACEP(p, XERR,
"problems changing child process priority");
2267 }
else if (dp > 0) {
2268 TRACEP(p, DBG,
"priority of the child process changed by " << dp <<
" units");
2272 TRACEP(p, FORK,
"xps: "<<xps<<
", ClientID: "<<(
int *)cid<<
" (sid: "<<sid<<
")"<<
" NClients: "<<xps->
GetNClients(1));
2276 TRACEP(p, REQ,
"problems recording session in sandbox");
2282 XrdOucString key; key += pid;
2284 fSessions.Add(key.c_str(), xps, 0, Hash_keepdata);
2292 TRACEP(p, XERR,
"PROOF session is invalid: protocol error? " <<emsg);
2307 bool assert = (pid > 0) ? 1 : 0;
2310 if (pid > 0) path += pid;
2312 XPDFORM(emsg,
"failure setting admin path '%s'", path.c_str());
2325 unsigned int seq, XrdOucString &emsg)
2327 XPDLOC(SMGR,
"ProofServMgr::CreateSockPath")
2329 XrdOucString sockpath;
2332 TRACEP(p, ALL,
"socket path: " << sockpath);
2333 struct sockaddr_un unserver;
2334 if (sockpath.length() > (int)(
sizeof(unserver.sun_path) - 1)) {
2335 XPDFORM(emsg,
"socket path very long (%d): this may lead to stack corruption! ", sockpath.length());
2342 XPDFORM(emsg,
"failure creating UNIX socket on '%s'", sockpath.c_str());
2345 if (chmod(sockpath.c_str(), 0755) != 0) {
2346 XPDFORM(emsg,
"failure changing permissions of the UNIX socket on '%s'; errno: %d",
2347 sockpath.c_str(), (int)errno);
2360 XPDLOC(SMGR,
"ProofServMgr::SendErrLog")
2362 XrdOucString emsg(
"An error occured: the content of errlog follows:");
2364 emsg =
"------------------------------------------------\n";
2365 r->
Send(kXR_attn,
kXPD_srvmsg, 2, (
char *) emsg.c_str(), emsg.length());
2367 int ierr =
open(errlog, O_RDONLY);
2369 XPDFORM(emsg,
"cannot open '%s' (errno: %d)", errlog, errno);
2370 r->
Send(kXR_attn,
kXPD_srvmsg, 2, (
char *) emsg.c_str(), emsg.length());
2374 if (fstat(ierr, &st) != 0) {
2375 XPDFORM(emsg,
"cannot stat '%s' (errno: %d)", errlog, errno);
2376 r->
Send(kXR_attn,
kXPD_srvmsg, 2, (
char *) emsg.c_str(), emsg.length());
2380 off_t len = st.st_size;
2381 TRACE(ALL,
" reading "<<len<<
" bytes from "<<errlog);
2382 ssize_t chunk = 2048, nb, nr;
2386 nb = (left > chunk) ? chunk : left;
2387 if ((nr =
read(ierr, buf, nb)) < 0) {
2388 XPDFORM(emsg,
"problems reading from '%s' (errno: %d)", errlog, errno);
2389 r->
Send(kXR_attn,
kXPD_srvmsg, 2, (
char *) emsg.c_str(), emsg.length());
2398 emsg =
"------------------------------------------------";
2399 r->
Send(kXR_attn,
kXPD_srvmsg, 2, (
char *) emsg.c_str(), emsg.length());
2410 XPDLOC(SMGR,
"ProofServMgr::ResolveSession")
2412 TRACE(REQ,
"resolving "<< (fpid ? fpid :
"<nul>")<<
" ...");
2429 if (
si.fSrvProtVers < 18) {
2430 TRACE(DBG,
"session does not support recovering: protocol "
2431 <<
si.fSrvProtVers<<
" < 18");
2437 si.fUnixPath.c_str());
2439 TRACE(DBG,
"client instance not initialized");
2447 TRACE(DBG,
"server object not initialized");
2465 std::list<XpdClientSessions *>::iterator ii =
fRecoverClients->begin();
2467 if ((*ii)->fClient == c)
2472 (*ii)->fProofServs.push_back(xps);
2488 XPDLOC(SMGR,
"ProofServMgr::Recover")
2491 TRACE(XERR,
"invalid input!");
2509 if (emsg ==
"timeout") {
2510 TRACE(DBG,
"timeout while accepting callback");
2512 TRACE(XERR,
"problems accepting callback: "<<emsg);
2516 XrdOucString key; key += xps->
SrvPID();
2517 fSessions.Add(key.c_str(), xps, 0, Hash_keepdata);
2530 " successfully recovered ("<<left<<
" left); pid: "<<pid);
2539 #ifndef ROOT_XrdFour
2546 int to, XrdOucString &msg)
2548 XPDLOC(SMGR,
"ProofServMgr::AcceptPeer")
2551 XrdNetPeer peerpsrv;
2555 XPDFORM(msg,
"session pointer undefined or socket invalid: %p", xps);
2558 TRACE(REQ,
"waiting for server callback for "<<to<<
" secs ... on "<<xps->
UNIXSockPath());
2561 if (!(xps->
UNIXSock()->Accept(peerpsrv, XRDNET_NODNTRIM, to))) {
2568 msg =
"could not assert connected peer: ";
2582 XPDLOC(SMGR,
"ProofServMgr::SetupProtocol")
2585 XrdLink *linkpsrv = 0;
2586 XrdProtocol *xp = 0;
2591 if (peerpsrv.InetName)
free(peerpsrv.InetName);
2592 peerpsrv.InetName = XrdSysDNS::getHostName(
"localhost");
2595 if (!(linkpsrv = XrdLink::Alloc(peerpsrv, lnkopts))) {
2596 msg =
"could not allocate network object: ";
2602 peerpsrv.InetBuff = 0;
2603 TRACE(DBG,
"connection accepted: matching protocol ... ");
2606 if (!(xp = p->
Match(linkpsrv))) {
2607 msg =
"match failed: protocol error: ";
2619 if (xp->Process(linkpsrv) != 0) {
2620 msg =
"handshake with internal link failed: ";
2627 msg =
"could not attach new internal link to poller: ";
2639 linkpsrv->setProtocol(xp);
2641 TRACE(REQ,
"Protocol "<<xp<<
" attached to link "<<linkpsrv<<
" ("<< peerpsrv.InetName <<
")");
2644 fMgr->
Sched()->Schedule((XrdJob *)linkpsrv);
2661 int to, XrdOucString &msg)
2663 XPDLOC(SMGR,
"ProofServMgr::AcceptPeer")
2669 if (!xps || !xps->UNIXSock()) {
2670 XPDFORM(msg,
"session pointer undefined or socket invalid: %p", xps);
2673 TRACE(REQ,
"waiting for server callback for "<<to<<
" secs ... on "<<xps->
UNIXSockPath());
2676 if (!(xps->
UNIXSock()->Accept(netaddr, 0, to))) {
2683 msg =
"could not assert connected peer: ";
2697 XPDLOC(SMGR,
"ProofServMgr::SetupProtocol")
2700 XrdLink *linkpsrv = 0;
2701 XrdProtocol *xp = 0;
2706 if (!(linkpsrv = XrdLink::Alloc(netaddr, lnkopts))) {
2707 msg =
"could not allocate network object: ";
2712 TRACE(DBG,
"connection accepted: matching protocol ... ");
2715 if (!(xp = p->
Match(linkpsrv))) {
2716 msg =
"match failed: protocol error: ";
2728 if (xp->Process(linkpsrv) != 0) {
2729 msg =
"handshake with internal link failed: ";
2736 msg =
"could not attach new internal link to poller: ";
2748 linkpsrv->setProtocol(xp);
2750 TRACE(REQ,
"Protocol "<<xp<<
" attached to link "<<linkpsrv<<
" ("<< netaddr.Name() <<
")");
2753 fMgr->
Sched()->Schedule((XrdJob *)linkpsrv);
2769 XPDLOC(SMGR,
"ProofServMgr::Detach")
2771 int psid = -1, rc = 0;
2776 TRACEP(p, REQ,
"psid: "<<psid);
2781 TRACEP(p, XERR,
"session ID not found: "<<psid);
2782 response->Send(kXR_InvalidRequest,
"session ID not found");
2798 XPDLOC(SMGR,
"ProofServMgr::Destroy")
2800 int psid = -1, rc = 0;
2805 TRACEP(p, REQ,
"psid: "<<psid);
2814 TRACEP(p, XERR,
"reference session ID not found");
2815 response->Send(kXR_InvalidRequest,
"reference session ID not found");
2820 XPDFORM(msg,
"all sessions destroyed by %s", p->
Link()->ID);
2842 XPDLOC(SMGR,
"WriteSessEnvs")
2846 XpdWriteEnv_t *xwe = (XpdWriteEnv_t *)s;
2848 if (env && xwe && xwe->fMgr && xwe->fClient && xwe->
fEnv) {
2849 if (env->
fEnv.length() > 0) {
2851 xwe->fMgr->ResolveKeywords(env->
fEnv, xwe->fClient);
2853 char *ev =
new char[env->
fEnv.length()+1];
2854 strncpy(ev, env->
fEnv.c_str(), env->
fEnv.length());
2855 ev[env->
fEnv.length()] = 0;
2856 fprintf(xwe->fEnv,
"%s\n", ev);
2858 PutEnv(ev, xwe->fExport);
2863 emsg =
"some input undefined";
2867 TRACE(XERR,
"protocol error: "<<emsg);
2877 XPDLOC(SMGR,
"ProofServMgr::SetProofServEnvOld")
2882 if (!p || !p->
Client() || !input) {
2883 TRACE(XERR,
"at leat one input is invalid - cannot continue");
2889 TRACE(XERR,
"problems setting basic environment - exit");
2898 TRACE(XERR,
"unable to get instance of proofserv proxy");
2901 int psid = xps->
ID();
2908 size_t len = strlen(
"ROOTPROOFSESSDIR=") + in->
fWrkDir.length() + 2;
2910 snprintf(ev, len,
"ROOTPROOFSESSDIR=%s", in->
fWrkDir.c_str());
2915 len = strlen(
"ROOTPROOFLOGLEVEL=") + 5;
2917 snprintf(ev, len,
"ROOTPROOFLOGLEVEL=%d", in->
fLogLevel);
2922 len = strlen(
"ROOTPROOFORDINAL=")+strlen(xps->
Ordinal()) + 2;
2924 snprintf(ev, len,
"ROOTPROOFORDINAL=%s", xps->
Ordinal());
2929 len = strlen(
"ROOTVERSIONTAG=")+strlen(p->
Client()->
ROOT()->
Tag())+2;
2931 snprintf(ev, len,
"ROOTVERSIONTAG=%s", p->
Client()->
ROOT()->
Tag());
2936 TRACE(DBG,
"creating env file");
2937 XrdOucString envfile = in->
fWrkDir;
2939 FILE *fenv = fopen(envfile.c_str(),
"w");
2942 "unable to open env file: "<<envfile);
2945 TRACE(DBG,
"environment file: "<< envfile);
2951 XrdOucString secenvs(getenv(
"XrdSecENVS"));
2952 if (secenvs.length() > 0) {
2956 while ((from = secenvs.tokenize(env, from,
',')) != -1) {
2957 if (env.length() > 0) {
2959 ev =
new char[env.length()+1];
2960 strncpy(ev, env.c_str(), env.length());
2961 ev[env.length()] = 0;
2963 fprintf(fenv,
"%s\n", ev);
2970 XrdSecCredentials *creds = p->
AuthProt()->getCredentials();
2972 len = strlen(
"XrdSecCREDS=")+creds->size;
2973 ev =
new char[len + 1];
2974 strcpy(ev,
"XrdSecCREDS=");
2975 memcpy(ev + strlen(
"XrdSecCREDS="), creds->buffer, creds->size);
2978 TRACE(DBG,
"XrdSecCREDS set");
2980 XrdOucString credsdir = udir;
2981 credsdir +=
"/.creds";
2985 TRACE(DBG,
"problems in saving authentication creds under "<<credsdir);
2988 TRACE(XERR,
"unable to create creds dir: "<<credsdir);
2997 fprintf(fenv,
"ROOTSYS=%s\n", xps->
ROOT()->
Dir());
3000 fprintf(fenv,
"ROOTCONFDIR=%s\n", xps->
ROOT()->
Dir());
3003 fprintf(fenv,
"ROOTTMPDIR=%s\n",
fMgr->
TMPdir());
3006 fprintf(fenv,
"ROOTXPDPORT=%d\n",
fMgr->
Port());
3009 fprintf(fenv,
"ROOTPROOFWORKDIR=%s\n", udir.c_str());
3012 fprintf(fenv,
"ROOTPROOFSESSIONTAG=%s\n", in->
fSessionTag.c_str());
3016 fprintf(fenv,
"ROOTUSEUSERCFG=1\n");
3019 fprintf(fenv,
"ROOTOPENSOCK=%s\n", xps->
UNIXSockPath());
3022 fprintf(fenv,
"ROOTENTITY=%s@%s\n", p->
Client()->
User(), p->
Link()->Host());
3025 fprintf(fenv,
"ROOTSESSIONID=%d\n", psid);
3028 fprintf(fenv,
"ROOTCLIENTID=%d\n", p->
CID());
3031 fprintf(fenv,
"ROOTPROOFCLNTVERS=%d\n", p->
ProofProtocol());
3034 fprintf(fenv,
"ROOTPROOFORDINAL=%s\n", xps->
Ordinal());
3037 if (getenv(
"ROOTVERSIONTAG"))
3038 fprintf(fenv,
"ROOTVERSIONTAG=%s\n", getenv(
"ROOTVERSIONTAG"));
3041 if (in->
fCfg.length() > 0)
3042 fprintf(fenv,
"ROOTPROOFCFGFILE=%s\n", in->
fCfg.c_str());
3045 fprintf(fenv,
"ROOTPROOFLOGFILE=%s\n", in->
fLogFile.c_str());
3052 XrdOucHash<XpdEnv> sessenvs;
3057 if (envmatch >= 0) {
3058 XpdEnv *env = sessenvs.Find((*ienvs).fName.c_str());
3062 if (envmatch > envmtcex) {
3065 sessenvs.Rep(env->
fName.c_str(), env, 0, Hash_keepdata);
3070 sessenvs.Add(env->
fName.c_str(), env, 0, Hash_keepdata);
3072 TRACE(HDBG,
"Adding: "<<(*ienvs).fEnv);
3085 XrdOucString env, namelist;
3086 int from = 0, ieq = -1;
3087 while ((from = ue.tokenize(env, from,
',')) != -1) {
3088 if (env.length() > 0 && (ieq = env.find(
'=')) != -1) {
3091 ev =
new char[env.length()+1];
3092 strncpy(ev, env.c_str(), env.length());
3093 ev[env.length()] = 0;
3095 fprintf(fenv,
"%s\n", ev);
3098 if (namelist.length() > 0)
3104 len = strlen(
"PROOF_ALLVARS=") + namelist.length() + 2;
3106 snprintf(ev, len,
"PROOF_ALLVARS=%s", namelist.c_str());
3108 fprintf(fenv,
"%s\n", ev);
3116 TRACE(DBG,
"creating symlink");
3117 XrdOucString syml = udir;
3119 syml +=
"/last-worker-session";
3121 syml +=
"/last-master-session";
3123 TRACE(XERR,
"problems creating symlink to last session (errno: "<<errno<<
")");
3136 XPDLOC(SMGR,
"ProofServMgr::SetProofServEnv")
3141 TRACE(REQ,
"ROOT dir: "<< (r ? r->
Dir() :
"*** undef ***"));
3144 char *libdir = (
char *) r->
LibDir();
3147 len = 32 + strlen(libdir) + strlen(mgr->
BareLibPath());
3148 ldpath =
new char[len];
3151 len = 32 + strlen(libdir);
3152 ldpath =
new char[len];
3153 snprintf(ldpath, len,
"%s=%s",
XPD_LIBPATH, libdir);
3157 char *rootsys = (
char *) r->
Dir();
3158 len = 15 + strlen(rootsys);
3160 snprintf(ev, len,
"ROOTSYS=%s", rootsys);
3164 char *bindir = (
char *) r->
BinDir();
3165 len = 15 + strlen(bindir);
3167 snprintf(ev, len,
"ROOTBINDIR=%s", bindir);
3171 char *confdir = (
char *) r->
DataDir();
3172 len = 20 + strlen(confdir);
3174 snprintf(ev, len,
"ROOTCONFDIR=%s", confdir);
3178 len = 20 + strlen(mgr->
TMPdir());
3180 snprintf(ev, len,
"TMPDIR=%s", mgr->
TMPdir());
3188 TRACE(XERR,
"XrdROOT instance undefined!");
3196 const char *sessiondir,
3198 XrdOucString &outfn)
3205 if (host.find(
".") != STR_NPOS)
3206 host.erase(host.find(
"."));
3209 else role =
"master";
3214 XPDFORM(outfn,
"%s/%s-%s-%s.%s",
3228 XrdOucString &sesstag, XrdOucString &topsesstag,
3229 XrdOucString &sessiondir, XrdOucString &sesswrkdir)
3231 XPDLOC(SMGR,
"GetTagDirs")
3240 if (host.find(
".") != STR_NPOS)
3241 host.erase(host.find(
"."));
3242 XPDFORM(sesstag,
"%s-%d-", host.c_str(), (int)time(0));
3247 sessiondir +=
"/session-";
3248 sessiondir += sesstag;
3249 topsesstag = sesstag;
3252 sessiondir += xps->
Tag();
3253 topsesstag = xps->
Tag();
3254 topsesstag.replace(
"session-",
"");
3258 TRACE(XERR,
"problems asserting dir '"<<sessiondir<<
"' - errno: "<<errno);
3263 }
else if (pid > 0) {
3270 topsesstag = sesstag;
3272 xps->
SetTag(sesstag.c_str());
3276 if (pid == (
int) getpid()) {
3284 sesswrkdir = sessiondir;
3286 XPDFORM(sesswrkdir,
"%s/worker-%s-%s", sessiondir.c_str(), xps->
Ordinal(), sesstag.c_str());
3288 XPDFORM(sesswrkdir,
"%s/master-%s-%s", sessiondir.c_str(), xps->
Ordinal(), sesstag.c_str());
3291 TRACE(XERR,
"negative pid ("<<pid<<
"): should not have got here!");
3303 XPDLOC(SMGR,
"WriteSessRCs")
3306 FILE *frc = (FILE *)f;
3308 XrdOucString rc = erc->
fEnv;
3309 if (rc.length() > 0) {
3310 if (rc.find(
"Proof.DataSetManager") != STR_NPOS) {
3311 TRACE(ALL,
"Proof.DataSetManager ignored: use xpd.datasetsrc to define dataset managers");
3313 fprintf(frc,
"%s\n", rc.c_str());
3319 emsg =
"file or input entry undefined";
3323 TRACE(XERR,
"protocol error: "<<emsg);
3332 XPDLOC(SMGR,
"ProofServMgr::SetProofServEnv")
3335 if (!p || !p->
Client() || !input) {
3336 TRACE(XERR,
"at leat one input is invalid - cannot continue");
3342 TRACE(DBG,
"rootvers: "<< rootvers);
3343 if (rootvers < 14 && rootvers > -1)
3351 TRACE(XERR,
"unable to get instance of proofserv proxy");
3354 int psid = xps->
ID();
3373 TRACE(XERR,
"problems setting basic environment - exit");
3378 TRACE(DBG,
"creating rc and env files");
3379 XrdOucString rcfile, envfile;
3382 TRACE(XERR,
"problems creating RC file "<<rcfile.c_str());
3388 TRACE(XERR,
"problems creating environment file "<<envfile.c_str());
3394 TRACE(REQ,
"creating symlink");
3395 XrdOucString syml = udir;
3397 syml +=
"/last-worker-session";
3399 syml +=
"/last-master-session";
3401 TRACE(XERR,
"problems creating symlink to "
3402 " last session (errno: "<<errno<<
")");
3416 const char *envfn,
const char *rcfn)
3418 XPDLOC(SMGR,
"ProofServMgr::CreateProofServEnvFile")
3421 if (!p || !input || (!envfn ||
3422 (envfn && strlen(envfn) <= 0)) || (!rcfn || (rcfn && strlen(rcfn) <= 0))) {
3423 TRACE(XERR,
"invalid inputs!");
3433 TRACE(XERR,
"unable to get instance of proofserv proxy");
3437 FILE *fenv = fopen(envfn,
"w");
3439 TRACE(XERR,
"unable to open env file: "<<envfn);
3442 TRACE(REQ,
"environment file: "<< envfn);
3450 XrdOucString secenvs(getenv(
"XrdSecENVS"));
3451 if (secenvs.length() > 0) {
3455 while ((from = secenvs.tokenize(env, from,
',')) != -1) {
3456 if (env.length() > 0) {
3458 ev =
new char[env.length()+1];
3459 strncpy(ev, env.c_str(), env.length());
3460 ev[env.length()] = 0;
3461 fprintf(fenv,
"%s\n", ev);
3469 XrdSecCredentials *creds = p->
AuthProt()->getCredentials();
3471 int lev = strlen(
"XrdSecCREDS=") + creds->size;
3472 ev =
new char[lev+1];
3473 strncpy(ev,
"XrdSecCREDS=", lev);
3474 memcpy(ev+strlen(
"XrdSecCREDS="), creds->buffer, creds->size);
3477 TRACE(DBG,
"XrdSecCREDS set");
3481 credsdir +=
"/.creds";
3485 TRACE(DBG,
"problems in saving authentication creds under "<<credsdir);
3488 TRACE(XERR,
"unable to create creds dir: "<<credsdir);
3500 fprintf(fenv,
"ROOTSYS=%s\n", xps->
ROOT()->
Dir());
3503 fprintf(fenv,
"ROOTCONFDIR=%s\n", xps->
ROOT()->
Dir());
3506 fprintf(fenv,
"TMPDIR=%s\n",
fMgr->
TMPdir());
3510 len = strlen(
"ROOTRCFILE=") + strlen(rcfn) + 2;
3512 snprintf(ev, len,
"ROOTRCFILE=%s", rcfn);
3513 fprintf(fenv,
"%s\n", ev);
3519 len = strlen(
"ROOTVERSIONTAG=") + strlen(p->
Client()->
ROOT()->
Tag()) + 2;
3521 snprintf(ev, len,
"ROOTVERSIONTAG=%s", p->
Client()->
ROOT()->
Tag());
3522 fprintf(fenv,
"%s\n", ev);
3528 len = strlen(
"ROOTPROOFLOGFILE=") + in->
fLogFile.length() + 2;
3530 snprintf(ev, len,
"ROOTPROOFLOGFILE=%s", in->
fLogFile.c_str());
3531 fprintf(fenv,
"%s\n", ev);
3538 XrdOucString locdatasrv;
3551 TRACE(HDBG, nrk <<
" placeholders resolved for LOCALDATASERVER");
3552 len = strlen(
"LOCALDATASERVER=") + locdatasrv.length() + 2;
3554 snprintf(ev, len,
"LOCALDATASERVER=%s", locdatasrv.c_str());
3555 fprintf(fenv,
"%s\n", ev);
3561 len = strlen(
"XRDCF=") + strlen(
CfgFile()) + 2;
3563 snprintf(ev, len,
"XRDCF=%s",
CfgFile());
3564 fprintf(fenv,
"%s\n", ev);
3573 XrdOucHash<XpdEnv> sessenvs;
3578 if (envmatch >= 0) {
3579 XpdEnv *env = sessenvs.Find((*ienvs).fName.c_str());
3583 if (envmatch > envmtcex) {
3586 sessenvs.Rep(env->
fName.c_str(), env, 0, Hash_keepdata);
3591 sessenvs.Add(env->
fName.c_str(), env, 0, Hash_keepdata);
3593 TRACE(HDBG,
"Adding: "<<(*ienvs).fEnv);
3605 XrdOucString env, namelist;
3606 int from = 0, ieq = -1;
3607 while ((from = ue.tokenize(env, from,
',')) != -1) {
3608 if (env.length() > 0 && (ieq = env.find(
'=')) != -1) {
3611 ev =
new char[env.length()+1];
3612 strncpy(ev, env.c_str(), env.length());
3613 ev[env.length()] = 0;
3614 if (env.find(
"WRAPPERCMD") == STR_NPOS || !xps->
IsPLite())
3615 fprintf(fenv,
"%s\n", ev);
3618 if (env.find(
"WRAPPERCMD") == STR_NPOS || !xps->
IsPLite()) {
3620 if (namelist.length() > 0)
3627 len = strlen(
"PROOF_ALLVARS=") + namelist.length() + 2;
3629 snprintf(ev, len,
"PROOF_ALLVARS=%s", namelist.c_str());
3630 fprintf(fenv,
"%s\n", ev);
3647 void *input,
const char *rcfn)
3649 XPDLOC(SMGR,
"ProofServMgr::CreateProofServRootRc")
3652 if (!p || !input || (!rcfn || (rcfn && strlen(rcfn) <= 0))) {
3653 TRACE(XERR,
"invalid inputs!");
3663 TRACE(XERR,
"unable to get instance of proofserv proxy");
3666 int psid = xps->
ID();
3668 FILE *frc = fopen(rcfn,
"w");
3670 TRACE(XERR,
"unable to open rootrc file: "<<rcfn);
3676 TRACE(XERR,
"problems creating symlink to 'session.rootrc' (errno: "<<errno<<
")");
3679 TRACE(REQ,
"session rootrc file: "<< rcfn);
3682 fprintf(frc,
"# XrdProofdProtocol listening port\n");
3683 fprintf(frc,
"ProofServ.XpdPort: %d\n",
fMgr->
Port());
3687 fprintf(frc,
"# Prefix to be prepended to local paths\n");
3694 if (!purl.endswith(
"/"))
3696 fprintf(frc,
"# URL for the data pool entry-point\n");
3697 fprintf(frc,
"ProofServ.PoolUrl: %s\n", purl.c_str());
3702 fprintf(frc,
"# The session working dir\n");
3703 fprintf(frc,
"ProofServ.SessionDir: %s\n", in->
fWrkDir.c_str());
3707 fprintf(frc,
"# Proof Log/Debug level\n");
3708 fprintf(frc,
"Proof.DebugLevel: %d\n", in->
fLogLevel);
3711 fprintf(frc,
"# Ordinal number\n");
3712 fprintf(frc,
"ProofServ.Ordinal: %s\n", xps->
Ordinal());
3716 fprintf(frc,
"# ROOT Version tag\n");
3717 fprintf(frc,
"ProofServ.RootVersionTag: %s\n", p->
Client()->
ROOT()->
Tag());
3721 fprintf(frc,
"# Proof group\n");
3722 fprintf(frc,
"ProofServ.ProofGroup: %s\n", p->
Client()->
Group());
3727 fprintf(frc,
"# File with group information\n");
3733 fprintf(frc,
"# Users sandbox\n");
3734 fprintf(frc,
"ProofServ.Sandbox: %s\n", udir.c_str());
3738 fprintf(frc,
"# Server image\n");
3739 fprintf(frc,
"ProofServ.Image: %s\n",
fMgr->
Image());
3744 fprintf(frc,
"# Session tag\n");
3745 fprintf(frc,
"ProofServ.SessionTag: %s\n", in->
fSessionTag.c_str());
3746 fprintf(frc,
"# Top Session tag\n");
3747 fprintf(frc,
"ProofServ.TopSessionTag: %s\n", in->
fTopSessionTag.c_str());
3751 fprintf(frc,
"# Session admin path\n");
3753 if (proofvrs < 0 || proofvrs < 27) {
3755 fprintf(frc,
"ProofServ.AdminPath: %s\n", xps->
AdminPath());
3759 fprintf(frc,
"ProofServ.AdminPath: %s.status\n", xps->
AdminPath());
3765 fprintf(frc,
"# Whether user specific config files are enabled\n");
3766 fprintf(frc,
"ProofServ.UseUserCfg: 1\n");
3769 fprintf(frc,
"# Open socket\n");
3770 fprintf(frc,
"ProofServ.OpenSock: %s\n", xps->
UNIXSockPath());
3772 fprintf(frc,
"# Entity\n");
3774 fprintf(frc,
"ProofServ.Entity: %s:%s@%s\n",
3777 fprintf(frc,
"ProofServ.Entity: %s@%s\n", p->
Client()->
User(), p->
Link()->Host());
3781 fprintf(frc,
"# Session ID\n");
3782 fprintf(frc,
"ProofServ.SessionID: %d\n", psid);
3785 fprintf(frc,
"# Client ID\n");
3786 fprintf(frc,
"ProofServ.ClientID: %d\n", p->
CID());
3789 fprintf(frc,
"# Client Protocol\n");
3790 fprintf(frc,
"ProofServ.ClientVersion: %d\n", p->
ProofProtocol());
3793 if (in->
fCfg.length() > 0) {
3794 if (in->
fCfg ==
"masteronly") {
3795 fprintf(frc,
"# MasterOnly option\n");
3797 fprintf(frc,
"Proof.MasterOnly: 1\n");
3799 fprintf(frc,
"# Config file\n");
3801 fprintf(frc,
"ProofServ.ProofConfFile: %s\n", in->
fCfg.c_str());
3804 fprintf(frc,
"# Config file\n");
3806 fprintf(frc,
"ProofServ.ProofConfFile: sm:\n");
3808 fprintf(frc,
"ProofServ.ProofConfFile: lite:\n");
3809 fprintf(frc,
"# Number of ProofLite workers\n");
3810 fprintf(frc,
"ProofLite.Workers: %d\n", xps->
PLiteNWrks());
3811 fprintf(frc,
"# Users sandbox\n");
3812 fprintf(frc,
"ProofLite.Sandbox: %s\n", udir.c_str());
3813 fprintf(frc,
"# No subpaths\n");
3814 fprintf(frc,
"ProofLite.SubPath: 0\n");
3816 fprintf(frc,
"ProofServ.ProofConfFile: %s\n",
fProofPlugin.c_str());
3822 fprintf(frc,
"# Default settings for XrdClient\n");
3823 fprintf(frc,
"XNet.FirstConnectMaxCnt 3\n");
3824 fprintf(frc,
"XNet.ConnectTimeout 5\n");
3829 fprintf(frc,
"# Force remote reading also for local files to avoid a wrong TTreeCache initialization\n");
3830 fprintf(frc,
"Path.ForceRemote 1\n");
3836 fprintf(frc,
"# Additional rootrcs (xpd.putrc directives)\n");
3838 XrdOucHash<XpdEnv> sessrcs;
3844 XpdEnv *rcenv = sessrcs.Find((*ircs).fName.c_str());
3848 if (rcmatch > rcmtcex) {
3851 sessrcs.Rep(rcenv->
fName.c_str(), rcenv, 0, Hash_keepdata);
3856 sessrcs.Add(rcenv->
fName.c_str(), rcenv, 0, Hash_keepdata);
3858 TRACE(HDBG,
"Adding: "<<(*ircs).fEnv);
3866 fprintf(frc,
"# Dataset sources\n");
3867 XrdOucString rc(
"Proof.DataSetManager: ");
3868 std::list<XrdProofdDSInfo *>::iterator ii;
3877 rc += (*ii)->fObscure;
3879 fprintf(frc,
"%s\n", rc.c_str());
3884 fprintf(frc,
"# Dataset staging requests repository\n");
3890 fprintf(frc,
"# Data directory\n");
3898 fprintf(frc,
"%s\n", rc.c_str());
3918 XPDLOC(SMGR,
"ProofServMgr::CleanupLostProofServ")
3921 TRACE(REQ,
"disabled ...");
3925 TRACE(REQ,
"checking for orphalin proofserv processes ...");
3929 std::map<int,XrdOucString> procs;
3931 TRACE(DBG,
" no proofservs around: nothing to do");
3942 XrdOucRash<int, int> controlled, xrdproc;
3945 XrdOucHash<XrdOucString> sessionspaths;
3949 XrdOucString cmd, apath, pidpath, sessiondir, emsg, rest, after;
3950 std::map<int,XrdOucString>::iterator ip;
3951 for (ip = procs.begin(); ip != procs.end(); ip++) {
3954 if ((ia = cmd.find(
"xpdpath:")) != STR_NPOS) {
3955 cmd.tokenize(apath, ia,
' ');
3956 apath.replace(
"xpdpath:",
"");
3957 if (apath.length() <= 0) {
3958 TRACE(ALL,
"admin path not found; initial cmd line: "<<cmd);
3962 XPDFORM(pidpath,
"%s/xrootd.pid", apath.c_str());
3963 TRACE(ALL,
"pidpath: "<<pidpath);
3965 int *alive = xrdproc.Find(xpid);
3968 xrdproc.Add(xpid, a);
3976 const char *subdir[2] = {
"activesessions",
"terminatedsessions"};
3977 for (
int i = 0; i < 2; i++) {
3978 XPDFORM(sessiondir,
"%s/%s", apath.c_str(), subdir[i]);
3979 if (!sessionspaths.Find(sessiondir.c_str())) {
3980 DIR *sdir = opendir(sessiondir.c_str());
3982 XPDFORM(emsg,
"cannot open '%s' - errno: %d", apath.c_str(), errno);
3983 TRACE(XERR, emsg.c_str());
3986 struct dirent *sent = 0;
3987 while ((sent = readdir(sdir))) {
3988 if (!strncmp(sent->d_name,
".", 1) || !strncmp(sent->d_name,
"..", 2))
3993 controlled.Add(ppid, ppid);
3996 sessionspaths.Add(sessiondir.c_str(), 0, 0, Hash_data_is_key);
3998 ok = (controlled.Find(pid)) ? 1 : ok;
4005 TRACE(ALL,
"process: "<<pid<<
" lost its controller: killing");
4028 XPDLOC(SMGR,
"ProofServMgr::CleanupProofServ")
4030 TRACE(REQ,
"all: "<<all<<
", usr: " << (usr ? usr :
"undef"));
4034 const char *pn =
"proofserv";
4041 TRACE(DBG,
"usr must be defined for all = FALSE");
4045 TRACE(DBG,
"problems getting info for user " << usr);
4053 DIR *dir = opendir(
"/proc");
4055 XrdOucString emsg(
"cannot open /proc - errno: ");
4057 TRACE(DBG, emsg.c_str());
4061 struct dirent *ent = 0;
4062 while ((ent = readdir(dir))) {
4063 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
4064 if (
DIGIT(ent->d_name[0])) {
4065 XrdOucString fn(
"/proc/", 256);
4069 FILE *ffn = fopen(fn.c_str(),
"r");
4071 XrdOucString emsg(
"cannot open file ");
4072 emsg += fn; emsg +=
" - errno: "; emsg += errno;
4077 bool xname = 1, xpid = 1, xppid = 1;
4078 bool xuid = (all) ? 0 : 1;
4081 char line[2048] = { 0 };
4082 while (fgets(line,
sizeof(line), ffn) &&
4083 (xname || xpid || xppid || xuid)) {
4085 if (xname && strstr(line,
"Name:")) {
4086 if (!strstr(line, pn))
4090 if (xpid && strstr(line,
"Pid:")) {
4094 if (xppid && strstr(line,
"PPid:")) {
4102 if (xuid && strstr(line,
"Uid:")) {
4111 if (!xname && !xpid && !xppid && !xuid) {
4119 if (!srv || (srv && !strcmp(usr, srv->
Client())))
4131 #elif defined(__sun)
4134 DIR *dir = opendir(
"/proc");
4136 XrdOucString emsg(
"cannot open /proc - errno: ");
4142 struct dirent *ent = 0;
4143 while ((ent = readdir(dir))) {
4144 if (!strncmp(ent->d_name,
".", 1) || !strncmp(ent->d_name,
"..", 2))
continue;
4145 if (
DIGIT(ent->d_name[0])) {
4146 XrdOucString fn(
"/proc/", 256);
4150 int ffd =
open(fn.c_str(), O_RDONLY);
4152 XrdOucString emsg(
"cannot open file ");
4153 emsg += fn; emsg +=
" - errno: "; emsg += errno;
4159 bool xuid = (all) ? 0 : 1;
4163 if (
read(ffd, &psi,
sizeof(psinfo_t)) !=
sizeof(psinfo_t)) {
4164 XrdOucString emsg(
"cannot read ");
4165 emsg += fn; emsg +=
": errno: "; emsg += errno;
4175 if (!strstr(psi.pr_fname, pn))
4181 if (refuid == psi.pr_uid)
4185 int ppid = psi.pr_ppid;
4193 if (!xname && !xppid && !xuid) {
4200 if (!srv || (srv && !strcmp(usr, srv->
Client())))
4212 #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
4218 if ((ern = XrdProofdAux::GetMacProcList(&pl, np)) != 0) {
4219 XrdOucString emsg(
"cannot get the process list: errno: ");
4228 if (strstr(pl[ii].kp_proc.p_comm, pn)) {
4229 if (all || (
int)(pl[ii].kp_eproc.e_ucred.cr_uid) == refuid) {
4231 int ppid = pl[ii].kp_eproc.e_ppid;
4233 if (ppid != getpid()) {
4236 if (strstr(pl[jj].kp_proc.p_comm,
"xrootd") &&
4237 pl[jj].kp_proc.p_pid == ppid) {
4250 if (!srv || (srv && !strcmp(usr, srv->
Client())))
4267 XrdOucString cmd =
"ps ";
4269 const char *cusr = (usr && strlen(usr) && fSuperUser) ? usr : fPClient->ID();
4280 cmd +=
" | grep proofserv 2>/dev/null";
4284 snprintf(cpid, 10,
"%d", getpid());
4287 XrdOucString pids =
":";
4288 FILE *fp = popen(cmd.c_str(),
"r");
4290 char line[2048] = { 0 };
4291 while (fgets(line,
sizeof(line), fp)) {
4293 char *px = strstr(line,
"xpd");
4297 char *
pi = strstr(px+3, cpid);
4302 TRACE(HDBG,
"found alternative parent ID: "<< ppid);
4310 from += strlen(cusr);
4318 if (!srv || (srv && !strcmp(usr, srv->
Client())))
4342 const char *
ord,
const char *stag)
4344 XPDLOC(SMGR,
"ProofServMgr::SetUserOwnerships")
4346 TRACE(REQ,
"enter");
4353 std::list<XrdProofdDSInfo *>::iterator ii;
4355 TRACE(ALL,
"Checking dataset source: url:"<<(*ii)->fUrl<<
", local:"
4356 <<(*ii)->fLocal<<
", rw:"<<(*ii)->fRW);
4357 if ((*ii)->fLocal && (*ii)->fRW) {
4366 TRACE(XERR,
"problems setting permissions 0755 on: "<<d);
4369 TRACE(XERR,
"problems asserting: "<<d);
4372 TRACE(XERR,
"problems setting permissions 0777 on: "<<d);
4375 TRACE(XERR,
"problems asserting: "<<d);
4387 XrdOucString dgr, dus[3];
4391 unsigned int mode = 0755;
4395 XPDFORM(dus[1],
"%s/%s", dus[0].c_str(), ord);
4396 XPDFORM(dus[2],
"%s/%s", dus[1].c_str(), stag);
4397 for (
int i = 0; i < 3; i++) {
4400 std::ios_base::fmtflags oflags = std::cerr.flags();
4401 TRACE(XERR,
"problems setting permissions "<< oct << mode<<
" on: "<<dus[i]);
4402 std::cerr.flags(oflags);
4405 TRACE(XERR,
"problems asserting: "<<dus[i]);
4410 TRACE(XERR,
"problems setting permissions 0777 on: "<<dgr);
4413 TRACE(XERR,
"problems asserting: "<<dgr);
4422 TRACE(XERR,
"can't change ownership of "<<creds);
4440 XPDLOC(SMGR,
"ProofServMgr::SetUserEnvironment")
4442 TRACE(REQ,
"enter");
4453 char *
h =
new char[len];
4456 TRACE(DBG,
"set "<<h);
4460 char *u =
new char[len];
4461 snprintf(u, len,
"USER=%s", p->
Client()->
User());
4463 TRACE(DBG,
"set "<<u);
4467 TRACE(DBG,
"setting ACLs");
4472 TRACE(XERR,
"could not get privileges");
4500 XrdOucString key; key += pid;
4509 XPDLOC(SMGR,
"BroadcastPriority")
4511 XpdBroadcastPriority_t *bp = (XpdBroadcastPriority_t *)s;
4513 int nb = *(bp->fNBroadcast);
4520 ? bp->fGroupMgr->GetGroup(ps->
Group()) : 0;
4521 TRACE(DBG,
"group: "<< g<<
", client: "<<ps->
Client());
4522 if (g && g->
Active() > 0) {
4524 int prio = (int) (g->
Priority() * 100);
4532 emsg =
"input entry undefined";
4536 TRACE(XERR,
"protocol error: "<<emsg);
4545 XPDLOC(SMGR,
"ProofServMgr::BroadcastClusterInfo")
4547 TRACE(REQ,
"enter");
4549 int tot = 0, act = 0;
4559 XPDPRT(
"tot: "<<tot<<
", act: "<<act);
4564 (*si)->SrvType() !=
kXPD_Worker) (*si)->SendClusterInfo(tot, act);
4568 TRACE(DBG,
"No master or submaster controlled by this manager");
4578 XPDLOC(SMGR,
"ProofServMgr::BroadcastPriorities")
4580 TRACE(REQ,
"enter");
4633 int rect = now - iter->second;
4635 if (p == iter->first) alive =
false;
4650 XPDLOC(SMGR,
"FreeClientID")
4652 int pid = *((
int *)s);
4661 TRACE(XERR,
"protocol error: undefined session!");
4681 XPDLOC(SMGR,
"CountTopMasters")
4683 int *ntm = (
int *)s;
4691 emsg =
"input entry undefined";
4695 TRACE(XERR,
"protocol error: "<<emsg);
4704 XPDLOC(SMGR,
"ProofServMgr::CurrentSessions")
4706 TRACE(REQ,
"enter");
4730 if (!isWorker && s.find(
"<logfilemst>") != STR_NPOS) {
4732 if (lfr.endswith(
".log")) lfr.erase(lfr.rfind(
".log"));
4733 s.replace(
"<logfilemst>", lfr);
4734 }
else if (isWorker && s.find(
"<logfilewrk>") != STR_NPOS) {
4736 if (lfr.endswith(
".log")) lfr.erase(lfr.rfind(
".log"));
4737 s.replace(
"<logfilewrk>", lfr);
4741 if (getenv(
"USER") && s.find(
"<user>") != STR_NPOS) {
4742 XrdOucString usr(getenv(
"USER"));
4743 s.replace(
"<user>", usr);
4747 if (getenv(
"ROOTSYS") && s.find(
"<rootsys>") != STR_NPOS) {
4748 XrdOucString rootsys(getenv(
"ROOTSYS"));
4749 s.replace(
"<rootsys>", rootsys);
4765 fUser = c ? c->
User() :
"";
4766 fGroup = c ? c->
Group() :
"";
4769 fPid = s ? s->
SrvPID() : -1;
4770 fID = s ? s->
ID() : -1;
4771 fSrvType = s ? s->
SrvType() : -1;
4774 fOrdinal = s ? s->
Ordinal() :
"";
4775 fTag = s ? s->
Tag() :
"";
4776 fAlias = s ? s->
Alias() :
"";
4777 fLogFile = s ? s->
Fileout() :
"";
4778 fROOTTag = (s && s->
ROOT())? s->
ROOT()->
Tag() :
"";
4780 fUserEnvs = s ? s->
UserEnvs() :
"";
4790 XPDLOC(SMGR,
"SessionInfo::FillProofServ")
4809 TRACE(ALL,
"ROOT version '"<< fROOTTag <<
4810 "' not availabe anymore: setting the default");
4824 XPDLOC(SMGR,
"SessionInfo::SaveToFile")
4827 if (!file || strlen(file) <= 0) {
4828 TRACE(XERR,
"invalid input: "<< (file ? file :
"<nul>"));
4831 TRACE(HDBG,
"session saved to file: "<<file);
4834 FILE *fpid = fopen(file,
"w");
4836 fprintf(fpid,
"%s %s\n", fUser.c_str(), fGroup.c_str());
4837 fprintf(fpid,
"%s\n", fUnixPath.c_str());
4838 fprintf(fpid,
"%d %d %d %d\n", fPid, fID, fSrvType, fPLiteNWrks);
4839 fprintf(fpid,
"%s %s %s\n", fOrdinal.c_str(), fTag.c_str(), fAlias.c_str());
4840 fprintf(fpid,
"%s\n", fLogFile.c_str());
4841 fprintf(fpid,
"%d %s\n", fSrvProtVers, fROOTTag.c_str());
4842 if (fUserEnvs.length() > 0)
4843 fprintf(fpid,
"\n%s", fUserEnvs.c_str());
4848 if (chmod(file, 0666) != 0) {
4849 TRACE(XERR,
"could not change mode to 0666 on file "<<
4850 file<<
"; error: "<<errno);
4856 TRACE(XERR,
"session pid file cannot be (re-)created: "<<
4857 file<<
"; error: "<<errno);
4890 XPDLOC(SMGR,
"SessionInfo::ReadFromFile")
4895 if (!file || strlen(file) <= 0) {
4896 TRACE(XERR,
"invalid input: "<<(file ? file :
"<nul>"));
4901 FILE *fpid = fopen(file,
"r");
4904 XrdOucString sline, t;
4906 if (fgets(line,
sizeof(line), fpid)) {
4907 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] =
'\0';
4909 if ((from = sline.tokenize(fUser, from,
' ')) == -1)
4910 TRACE(XERR,
"warning: fUser: corrupted line? "<<line<<
" (file: "<<file<<
")");
4911 if ((from = sline.tokenize(fGroup, from,
' ')) == -1)
4912 TRACE(XERR,
"warning: fGroup: corrupted line? "<<line<<
" (file: "<<file<<
")");
4914 if (fgets(line,
sizeof(line), fpid)) {
4915 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] =
'\0';
4918 if (fgets(line,
sizeof(line), fpid)) {
4919 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] =
'\0';
4922 if ((from = sline.tokenize(t, from,
' ')) == -1)
4923 TRACE(XERR,
"warning: fPid: corrupted line? "<<line<<
" (file: "<<file<<
")");
4925 if ((from = sline.tokenize(t, from,
' ')) == -1)
4926 TRACE(XERR,
"warning: fID: corrupted line? "<<line<<
" (file: "<<file<<
")");
4928 if ((from = sline.tokenize(t, from,
' ')) == -1)
4929 TRACE(XERR,
"warning: fSrvType: corrupted line? "<<line<<
" (file: "<<file<<
")");
4930 fSrvType = t.atoi();
4932 if (fgets(line,
sizeof(line), fpid)) {
4933 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] =
'\0';
4936 if ((from = sline.tokenize(fOrdinal, from,
' ')) == -1)
4937 TRACE(XERR,
"warning: fOrdinal: corrupted line? "<<line<<
" (file: "<<file<<
")");
4938 if ((from = sline.tokenize(fTag, from,
' ')) == -1)
4939 TRACE(XERR,
"warning: fTag: corrupted line? "<<line<<
" (file: "<<file<<
")");
4940 if ((from = sline.tokenize(fAlias, from,
' ')) == -1)
4941 TRACE(HDBG,
"fAlias undefined "<<line);
4943 if (fgets(line,
sizeof(line), fpid)) {
4944 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] =
'\0';
4947 if (fgets(line,
sizeof(line), fpid)) {
4948 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] =
'\0';
4951 if ((from = sline.tokenize(t, from,
' ')) == -1)
4952 TRACE(XERR,
"warning: fSrvProtVers: corrupted line? "<<line<<
" (file: "<<file<<
")");
4953 fSrvProtVers = t.atoi();
4954 if ((from = sline.tokenize(fROOTTag, from,
' ')) == -1)
4955 TRACE(XERR,
"warning: fROOTTag: corrupted line? "<<line<<
" (file: "<<file<<
")");
4959 off_t lnow = lseek(fileno(fpid), (off_t) 0, SEEK_CUR);
4960 off_t ltot = lseek(fileno(fpid), (off_t) 0, SEEK_END);
4961 int left = (int)(ltot - lnow);
4964 int wanted = (left > 4095) ? 4095 : left;
4965 while ((len =
read(fileno(fpid), line, wanted)) < 0 &&
4968 if (len < 0 || len < wanted) {
4976 }
while (len > 0 && left > 0);
4983 if (!stat(file, &st))
4984 fLastAccess = st.st_atime;
4986 TRACE(XERR,
"session file cannot be open: "<< file<<
"; error: "<<errno);
4991 XrdOucString fs(file);
4993 fpid = fopen(fs.c_str(),
"r");
4996 if (fgets(line,
sizeof(line), fpid)) {
4997 if (line[strlen(line)-1] ==
'\n') line[strlen(line)-1] = 0;
4998 fStatus = atoi(line);
5003 TRACE(DBG,
"no session status file for: "<< fs<<
"; session was probably terminated");
5018 XPDLOC(SMGR,
"XpdEnv::Matches")
5022 if (fUsers.length() > 0) {
5023 XrdOucString u(usr);
5024 if ((nmtc = u.matches(fUsers.c_str())) == 0)
return -1;
5031 if (fGroups.length() > 0) {
5032 XrdOucString
g(grp);
5033 if ((nmtcg = g.matches(fGroups.c_str())) == 0)
return -1;
5035 nmtcg = strlen(grp);
5039 TRACE(HDBG, fEnv <<
", u:"<<usr<<
", g:"<<grp<<
" --> nmtc: "<<nmtc);
5042 TRACE(HDBG, fEnv <<
", ver:"<<ver);
5043 if (fVerMin > 0 && ver < fVerMin)
return -1;
5044 if (fVerMax > 0 && ver > fVerMax)
return -1;
5056 int maj = -1,
min = -1, ptc = -1, xv = ver;
5061 ptc = xv -
min * 256;
5066 ptc = xv -
min * 100;
5069 int vc = (maj << 16) + (
min << 8) + ptc;
5080 XrdOucString vmi(
"-1"), vmx(
"-1");
5082 int maj = (fVerMin >> 16);
5083 int min = ((fVerMin - maj * 65536) >> 8);
5084 int ptc = fVerMin - maj * 65536 - min * 256;
5085 XPDFORM(vmi,
"%d%d%d", maj, min, ptc);
5088 int maj = (fVerMax >> 16);
5089 int min = ((fVerMax - maj * 65536) >> 8);
5090 int ptc = fVerMax - maj * 65536 - min * 256;
5091 XPDFORM(vmx,
"%d%d%d", maj, min, ptc);
5093 XrdOucString u(
"allusers"),
g(
"allgroups");
5094 if (fUsers.length() > 0) u = fUsers;
5095 if (fGroups.length() > 0) u = fGroups;
5097 TRACE(ALL,
"'"<<fEnv<<
"' {"<<u<<
"|"<<g<<
5098 "} svn:["<<fSvnMin<<
","<<fSvnMax<<
"] vers:["<<vmi<<
","<<vmx<<
"]");
int CreateSockPath(XrdProofdProofServ *xps, XrdProofdProtocol *p, unsigned int seq, XrdOucString &emsg)
Create the socket path for the starting session Return 0 on success, -1 on error (error message in 'e...
int FreeClientID(int pid)
Free instance corresponding to protocol connecting process 'pid'.
double read(const std::string &file_name)
reading
void SetParent(XrdClientID *cid)
int SetupProtocol(XrdNetPeer &peerpsrv, XrdProofdProofServ *xps, XrdOucString &e)
Setup the protocol object serving the peer described by 'peerpsrv'.
static int BroadcastPriority(const char *, XrdProofdProofServ *ps, void *s)
Run thorugh entries to broadcast the relevant priority.
void Reset(const char *n, const char *env, const char *usr=0, const char *grp=0, int smi=-1, int smx=-1, int vmi=-1, int vmx=-1)
int BroadcastPriorities()
Broadcast priorities to the active sessions.
XrdOucHash< XrdProofdProofServ > fSessions
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
void SetReconnectTime(bool on=1)
Change reconnecting status.
XrdProofdClientMgr * ClientMgr() const
int Poll(int to=-1)
Poll over the read pipe for to secs; return whatever poll returns.
int CurrentSessions(bool recalculate=0)
Return the number of current sessions (top masters)
static int ToVersCode(int ver, bool hex=0)
Transform version number ver (format patch + 100*minor + 10000*maj, e.g.
const char * DataDirUrlOpts() const
int Process(XrdProofdProtocol *p)
Process manager request.
const char * PoolURL() const
void Print(const char *what)
Print the content of this env.
static int GetUserInfo(const char *usr, XrdProofUI &ui)
Get information about user 'usr' in a thread safe way.
XrdProtocol * Match(XrdLink *lp)
Check whether the request matches this protocol.
int CleanupProofServ(bool all=0, const char *usr=0)
Cleanup (kill) all 'proofserv' processes from the process table.
bool IsClientRecovering(const char *usr, const char *grp, int &deadline)
Returns true (an the recovering deadline) if the client has sessions in recovering state; returns fal...
void ParseCreateBuffer(XrdProofdProtocol *p, XrdProofdProofServ *xps, XrdOucString &tag, XrdOucString &ord, XrdOucString &cffile, XrdOucString &uenvs, int &intwait)
Extract relevant quantities from the buffer received during a create request.
void SetAlias(const char *a)
int SetUserOwnerships(XrdProofdProtocol *p, const char *ord, const char *stag)
Set user ownerships on some critical files or directories.
int SetProofServEnv(XrdProofdProtocol *p, void *in)
Set environment for proofserv.
std::map< XrdProofdProtocol *, int > fDestroyTimes
int DoDirectiveClass(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Generic class directive processor.
const char * SockPathDir() const
bool IsSessionSocket(const char *fpid)
Checks is fpid is the path of a session UNIX socket Returns TRUE is yes; cleans the socket if the ses...
int CheckSession(bool oldvers, bool isrec, int shutopt, int shutdel, bool changeown, int &nc)
Calculate the effective number of users on this session nodes and communicate it to the master togeth...
int CreateProofServRootRc(XrdProofdProtocol *p, void *input, const char *rcfn)
Create in 'rcfn' the rootrc file for the proofserv being created return 0 on success, -1 on error.
const char * DataDir() const
kXR_int16 SrvProtVers() const
#define TRACE(Flag, Args)
XrdProofGroupMgr * GroupsMgr() const
void UpdateCounter(int t, int n)
void SetSid(unsigned short sid)
int RmSession(const char *fpid)
Remove session file from the terminated sessions area.
XrdProofdProofServ * GetServObj(int id)
Get server at 'id'. If needed, increase the vector size.
int CheckFrequency() const
void SetPLiteNWrks(int n)
int DeleteFromSessions(const char *pid)
Delete from the hash list the session with ID pid.
void Reset()
Reset this instance.
static int FreeClientID(const char *, XrdProofdProofServ *ps, void *s)
Run through entries to reset the disconnecting client slots.
const char * RootdExe() const
int DoDirectiveInt(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Process directive for an integer.
XrdSysSemWait fProcessSem
const char * BareLibPath() const
#define kXPD_MasterMaster
XrdClientID * Parent() const
void ResolveKeywords(XrdOucString &s, ProofServEnv_t *in)
Resolve some keywords in 's' , ,
void SetOrdinal(const char *o)
void SetAdminPath(const char *p)
bool Alive(XrdProofdProtocol *p)
Check destroyed status.
XrdSysRecMutex fRecoverMutex
int AddSession(XrdProofdProtocol *p, XrdProofdProofServ *s)
Add new active session.
#define kXPD_ClientMaster
static int ChangePerm(uid_t uid, gid_t gid)
XrdClientID * GetClientID(int cid)
Get instance corresponding to cid.
XrdOucString fParentExecs
XrdSysRecMutex * Mutex() const
struct ClientRequestHdr header
XrdSysSemWait * ProcessSem()
int CreateUNIXSock(XrdSysError *edest)
Create UNIX socket for internal connections.
int Recv(XpdMsg &msg)
Recv message from the pipe.
const char * UNIXSockPath() const
static int CountTopMasters(const char *, XrdProofdProofServ *ps, void *s)
Run thorugh entries to count top-masters.
XrdROOT * DefaultVersion() const
void * XrdProofdProofServRecover(void *p)
Waiting for session to recover after an abrupt shutdown.
XrdSecCredsSaver_t fCredsSaver
int CreateProofServEnvFile(XrdProofdProtocol *p, void *input, const char *envfn, const char *rcfn)
Create in 'rcfn' the rootrc file for the proofserv being created return 0 on success, -1 on error.
static int GetVersionCode(const char *release)
Translate 'release' into a version code integer following the rules in $ROOTSYS/include/RVersion.h.
const char * BinDir() const
void ExtractEnv(char *, XrdOucStream *, XrdOucString &users, XrdOucString &groups, XrdOucString &rcval, XrdOucString &rcnam, int &smi, int &smx, int &vmi, int &vmx, bool &hex)
Extract env information from the stream 'cfg'.
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
static int ParsePidPath(const char *path, XrdOucString &before, XrdOucString &after)
Parse a path in the form of "
[.][.]", filling 'rest' and returning 'pid'...
int Destroy(XrdProofdProtocol *p)
Handle a request to shutdown an existing session.
static int SymLink(const char *path, const char *link)
Create a symlink 'link' to 'path' Return 0 in case of success, -1 in case of error.
void SetProtocol(XrdProofdProtocol *p)
void FormFileNameInSessionDir(XrdProofdProtocol *p, XrdProofdProofServ *xps, const char *sessiondir, const char *extension, XrdOucString &outfn)
short int ProofProtocol() const
int CreateAdminPath(XrdProofdProofServ *xps, XrdProofdProtocol *p, int pid, XrdOucString &emsg)
Create the admin path for the starting session Return 0 on success, -1 on error (error message in 'em...
XrdProofSessionInfo(XrdProofdClient *c, XrdProofdProofServ *s)
Construct from 'c' and 's'.
int SetProcessPriority(int pid, const char *usr, int &dp)
Change priority of process pid belonging to user, if needed.
std::map< std::string, std::string >::const_iterator iter
std::list< XpdEnv > fProofServEnvs
bool IsReconnecting()
Return true if in reconnection state, i.e.
if(pyself &&pyself!=Py_None)
const char * DataDir() const
XrdOucString fTermAdminPath
const char * Client() const
XrdSysRecMutex fEnvsMutex
void Close()
If open, close and invalidated the pipe descriptors.
void DeleteUNIXSock()
Delete the current UNIX socket.
XrdProofdClientMgr * fClientMgr
int CheckActiveSessions(bool verify=1)
Go through the active sessions admin path and make sure sessions are alive.
static int Attach(XrdLink *lp)
void SetUNIXSockPath(const char *s)
int TouchSession(const char *fpid, const char *path=0)
Update the access time for the session pid file to the current time.
std::list< XrdProofdProofServ * > fActiveSessions
static int EUidAtStartup()
void DisconnectFromProofServ(int pid)
Change reconnecting status.
void SetGroup(const char *g)
int Matches(const char *usr, const char *grp, int ver=-1)
Check if this env applies to 'usr', 'grp, 'ver'.
XrdProofdProtocol * Protocol() const
XrdProofSched * ProofSched() const
std::list< XpdClientSessions * > * fRecoverClients
void FillProofServ(XrdProofdProofServ &s, XrdROOTMgr *rmgr)
Fill 's' fields using the stored info.
void RegisterDirectives()
Register directives for configuration.
XrdProofSched * fProofSched
std::list< XrdProofdProofServ * > fProofServs
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
const char * NameSpace() const
void SetFileout(const char *f)
XrdSrvBuffer * StartMsg() const
int Attach(XrdProofdProtocol *p)
Handle a request to attach to an existing session.
const char * Ordinal() const
XPClientRequest * Request() const
int GetNClients(bool check)
Get the number of connected clients.
std::list< XpdEnv > fProofServRCs
#define kXPD_MasterWorker
static XpdManagerCron_t fManagerCron
static const char * ProofRequestTypes(int type)
Translates the proof request type in a human readable string.
static int GetIDFromPath(const char *path, XrdOucString &emsg)
Extract an integer from a file.
const char * Image() const
int ResolveSession(const char *fpid)
Handle a request to recover a session after stop&restart.
void SetP(XrdProofdProtocol *p)
XrdROOT * GetVersion(const char *tag)
Return pointer to the ROOT version corresponding to 'tag' or 0 if not found.
#define XrdSysMutexHelper
static int WriteSessEnvs(const char *, XpdEnv *env, void *s)
Run thorugh entries to broadcast the relevant priority.
struct XPClientProofRequest proof
XrdScheduler * Sched() const
virtual int MaxSessions() const
void Reset()
Reset the content.
int Recover(XpdClientSessions *cl)
Handle a request to recover a session after stop&restart for a specific client.
const char * AdminPath() const
#define TRACEP(p, act, x)
int CleanClientSessions(const char *usr, int srvtype)
Go through the sessions admin path and clean all sessions belonging to 'usr'.
int MvSession(const char *fpid)
Move session file from the active to the terminated areas.
#define XpdBadPGuard(g, u)
XrdSecProtocol * AuthProt() const
int PrepareSessionRecovering()
Go through the active sessions admin path and prepare reconnection of those still alive...
int VerifySession(const char *fpid, int to=-1, const char *path=0)
Check if the session is alive, i.e.
XrdProofdNetMgr * NetMgr() const
std::list< XrdProofdDSInfo * > * DataSetSrcs()
void Reset(Detail::TBranchProxy *x)
int Active(const char *usr=0)
Return the number of active groups (usr = 0) or the number of active sessions for user 'usr'...
int Detach(XrdProofdProtocol *p)
Handle a request to detach from an existing session.
const char * StageReqRepo() const
static long int GetLong(char *str)
Extract first integer from string at 'str', if any.
const char * AdminPath() const
void GetTagDirs(int opt, XrdProofdProtocol *p, XrdProofdProofServ *xps, XrdOucString &sesstag, XrdOucString &topsesstag, XrdOucString &sessiondir, XrdOucString &sesswrkdir)
Determine the unique tag and relevant dirs for this session.
void SetTag(const char *t)
int AddSession(const char *tag)
Record entry for new proofserv session tagged 'tag' in the active sessions file (/.sessions).
XrdOucString fProofPlugin
int BroadcastPriority(int priority)
Broadcast a new group priority value to the worker servers.
const char * UserEnvs() const
const char * GetCfgFile() const
int SetAdminPath(const char *a, bool assert, bool setown)
Set the admin path and make sure the file exists.
static int AssertDir(const char *path, XrdProofUI ui, bool changeown)
Make sure that 'path' exists and is owned by the entity described by 'ui'.
XrdProofdSandbox * Sandbox() const
XrdNet * UNIXSock() const
void TerminateSessions(int srvtype, XrdProofdProofServ *ref, const char *msg, XrdProofdPipe *pipe, bool changeown)
Terminate client sessions; IDs of signalled processes are added to sigpid.
XrdProofdProofServMgr * fSessionMgr
static int CheckIf(XrdOucStream *s, const char *h)
Check existence and match condition of an 'if' directive If none (valid) is found, return -1.
int CheckTerminatedSessions()
Go through the terminated sessions admin path and make sure sessions they are gone.
int ResolveKeywords(XrdOucString &s, XrdProofdClient *pcl)
Resolve special keywords in 's' for client 'pcl'.
int DoDirectiveString(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Process directive for a string.
void SendErrLog(const char *errlog, XrdProofdResponse *r)
Send content of errlog upstream asynchronously.
int CleanupLostProofServ()
Cleanup (kill) all 'proofserv' processes which lost control from their creator or controller daemon...
int SetProofServEnvOld(XrdProofdProtocol *p, void *in)
Set environment for proofserv; old version preparing the environment for proofserv protocol version <...
const char * Alias() const
const char * Host() const
void SetValid(bool valid=1)
void SetUserEnvs(const char *t)
XrdProofdProofServ * PrepareProofServ(XrdProofdProtocol *p, XrdProofdResponse *r, unsigned short &sid)
Allocate and prepare the XrdProofdProofServ object describing this session.
static int ChangeMod(const char *path, unsigned int mode)
Change the permission mode of 'path' to 'mode'.
const char * Group() const
int DoDirectiveShutdown(char *, XrdOucStream *, bool)
Process 'shutdown' directive.
#define XPD_SETRESP(p, x)
const char * LocalROOT() const
R__EXTERN C unsigned int sleep(unsigned int seconds)
static int WriteSessRCs(const char *, XpdEnv *erc, void *f)
Run thorugh entries to broadcast the relevant priority.
unsigned int fSeqSessionN
bool WorkerUsrCfg() const
void FillEnvList(std::list< XpdEnv > *el, const char *nam, const char *val, const char *usrs=0, const char *grps=0, int smi=-1, int smx=-1, int vmi=-1, int vmx=-1, bool hex=0)
Fill env entry(ies) in the relevant list.
XrdProofdPriorityMgr * PriorityMgr() const
void SetNextSessionsCheck(int t)
const char * Fileout() const
int Get(int &i)
Get next token and interpret it as an int.
const char * Export() const
XrdProofdProofServMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
int Create(XrdProofdProtocol *p)
Handle a request to create a new session.
const char * EffectiveUser() const
const char * User() const
const char * PrgmSrv() const
static int ChangeToDir(const char *dir, XrdProofUI ui, bool changeown)
Change current directory to 'dir'.
XrdROOTMgr * ROOTMgr() const
void * XrdProofdProofServCron(void *p)
This is an endless loop to check the system periodically or when triggered via a message in a dedicat...
const char * DataDirOpts() const
XrdOucString fTopSessionTag
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
int DoDirectivePutRc(char *, XrdOucStream *, bool)
Process 'putrc' directives.
ClassImp(TSlaveInfo) Int_t TSlaveInfo const TSlaveInfo * si
Used to sort slaveinfos by ordinal.
XrdProofdProofServ * GetActiveSession(int pid)
Return active session with process ID pid, if any.
int ReadFromFile(const char *file)
Read content from 'file'.
XrdProofdClient * GetClient(const char *usr, const char *grp=0, bool create=1)
Handle request for localizing a client instance for {usr, grp} from the list.
static int ChangeOwn(const char *path, XrdProofUI ui)
Change the ownership of 'path' to the entity described by 'ui'.
int Post(int type, const char *msg)
Post message on the pipe.
static int VerifyProcessByID(int pid, const char *pname="proofserv")
Check if a process named 'pname' and process 'pid' is still in the process table. ...
int AcceptPeer(XrdProofdProofServ *xps, int to, XrdOucString &e)
Accept a callback from a starting-up server and setup the related protocol object.
int RecoverActiveSessions()
Accept connections from sessions still alive.
int DoDirectivePutEnv(char *, XrdOucStream *, bool)
Process 'putenv' directives.
const char * CfgFile() const
XrdProofdProofServ * GetServer(int psid)
Get from the vector server instance with ID psid.
static int GetProcesses(const char *pn, std::map< int, XrdOucString > *plist)
Get from the process table list of PIDs for processes named "proofserv' For {linux, sun, macosx} it uses the system info; for other systems it invokes the command shell 'ps ax' via popen.
static void LogEmsgToFile(const char *flog, const char *emsg, const char *pfx=0)
Logs error message 'emsg' to file 'flog' using standard technology.
XrdOucString fActiAdminPath
int fCounters[PSMMAXCNTS]
int VerifyProofServ(bool fw)
Check if the associated proofserv process is alive.
XrdProofdProofServ * GetFreeServObj()
Get next free server ID.
virtual int Config(bool rcf=0)
bool ReadFile(bool update=true)
Return true if the file has never been read or did change since last reading, false otherwise...
int Send(void)
Auxilliary Send method.
XrdProofdClient * fClient
void SetClient(const char *c)
const char * TMPdir() const
static int KillProcess(int pid, bool forcekill, XrdProofUI ui, bool changeown)
Kill the process 'pid'.
void Register(const char *dname, XrdProofdDirective *d)
XrdProofdClient * Client() const
int SaveToFile(const char *file)
Save content to 'file'.
const char * LibDir() const
int DoDirectiveProofServMgr(char *, XrdOucStream *, bool)
Process 'proofswrvmgr' directive eg: xpd.proofswrvmgr checkfq:120 termto:100 verifyto:5 recoverto:20...
void BroadcastClusterInfo()
Broadcast cluster info to the active sessions.
int SetUserEnvironment(XrdProofdProtocol *p)
Set user environment: set effective user and group ID of the process to the ones of the owner of this...
const char * Group() const