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"
63#define PutEnv(x,e) { if (e) { putenv(x); } else { delete[] x; } }
90 TRACE(
XERR,
"undefined session manager: cannot start");
119 if ((
rc =
mgr->Pipe()->Recv(
msg)) != 0) {
120 TRACE(
XERR,
"problems receiving message; errno: "<<-
rc);
128 TRACE(
XERR,
"kSessionRemoval: problems receiving process ID (buf: '"<<
129 msg.Buf()<<
"'); errno: "<<-
rc);
134 mgr->DeleteFromSessions(
fpid.c_str());
140 TRACE(
XERR,
"kSessionRemoval: problem posting the scheduler pipe");
145 " has been removed from the active list");
148 TRACE(
XERR,
"obsolete type: XrdProofdProofServMgr::kClientDisconnect");
157 TRACE(
XERR,
"kCleanSessions: problems parsing message (buf: '"<<
158 msg.Buf()<<
"'); errno: "<<-
rc);
166 mgr->CleanupLostProofServ();
169 mgr->ProcessSem()->Post();
172 mgr->BroadcastClusterInfo();
188 mgr->SetNextSessionsCheck(
now + 5);
190 TRACE(
ALL,
"postponing sessions check (will retry in 5 secs)");
194 TRACE(
ALL,
"Max time without checks reached ("<<
maxdelay<<
"): force a session check");
200 bool full = (
now >
mgr->NextSessionsCheck() -
deltat) ? 1 : 0;
203 mgr->CheckActiveSessions();
204 mgr->CheckTerminatedSessions();
206 mgr->CleanupLostProofServ();
219 TRACE(
ALL,
"next sessions check in "<<
mgr->CheckFrequency()<<
" secs");
221 TRACE(
HDBG,
"nothing to do; "<<
mgr->NextSessionsCheck()-
now<<
" secs to full check");
247 TRACE(
XERR,
"undefined session manager: cannot start");
252 int rc =
mgr->RecoverActiveSessions();
256 TRACE(
ALL,
"timeout recovering sessions: "<<
rc<<
" sessions not recovered");
258 TRACE(
XERR,
"some problem occured while recovering sessions");
260 TRACE(
ALL,
"recovering successfully terminated");
310 TRACE(
XERR,
"unable to generate pipe for the session poller");
344 msg = (
rcf) ?
"re-configuring" :
"configuring";
352 msg =
"client sessions shutdown after disconnection";
354 XPDFORM(
msg,
"client sessions kept %sfor %d secs after disconnection",
398 XPDFORM(
msg,
"using %s to start proofserv sessions",
fUseFork ?
"fork()" :
"system()");
405 TRACE(
XERR,
"problems trying to recover active sessions");
407 XPDFORM(
msg,
"%d active sessions have been recovered",
nr);
417 (
void *)&
fManagerCron, 0,
"ProofServMgr cron thread") != 0) {
418 TRACE(
XERR,
"could not start cron thread");
421 XPDPRT(
"cron thread started");
435 TRACE(
REQ,
"adding new active session ...");
438 if (!s || !
p->Client()) {
439 TRACE(
XERR,
"invalid inputs: "<<(s ?
"" :
"s, ") <<
", "<< (
p->Client() ?
"" :
"p->Client()"));
450 int rc =
info.SaveToFile(path.c_str());
473 if (!
spath.endswith(
".sock"))
return 0;
479 apath.replace(
".sock",
"");
515 opath.replace(
".status",
"");
518 opath.replace(
".status",
"");
529 spath.replace(
".sock",
".status");
544 "; target file: "<<
npath<<
"; errno: "<<
errno);
568 if (
unlink(path.c_str()) == 0)
571 TRACE(
XERR,
"session pid file cannot be unlinked: "<<
572 path<<
"; error: "<<
errno);
592 XrdOucString path(
fpath);
597 if (
utime(path.c_str(), 0) == 0)
600 TRACE(
XERR,
"time stamps for session pid file cannot be updated: "<<
601 path<<
"; error: "<<
errno);
635 if (stat(path.c_str(), &
st)) {
636 TRACE(
XERR,
"session status file cannot be stat'ed: "<<
637 path<<
"; error: "<<
errno);
644 if (path.endswith(
".status")) {
646 path.erase(path.rfind(
".status"));
649 TRACE(
DBG,
"admin path for session "<<
fpid<<
" hase not been touched"
650 " since at least "<<
xto <<
" secs");
660 TRACE(
DBG,
"admin path for session "<<
fpid<<
" was touched " <<
671 XPDLOC(
SMGR,
"ProofServMgr::DeleteFromSessions")
681 XrdOucString key =
fpid;
682 key.replace(
".status",
"");
683 key.erase(0, key.rfind(
'.') + 1);
711 XPDLOC(
SMGR,
"ProofServMgr::PrepareSessionRecovering")
719 TRACE(
REQ,
"preparing recovering of active sessions ...");
725 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
727 XrdOucString rest,
a;
730 if (
a.length() > 0)
continue;
735 TRACE(
DBG,
"found active session: "<<pid);
757 0,
"ProofServMgr session recover thread") != 0) {
758 TRACE(
XERR,
"could not start session recover thread");
761 XPDPRT(
"session recover thread started");
782 XPDLOC(
SMGR,
"ProofServMgr::RecoverActiveSessions")
788 TRACE(
XERR,
"recovering clients list undefined");
794 TRACE(
REQ,
"start recovering of "<<
nrc<<
" clients");
814 if (
cls->fProofServs.size() <= 0) {
838 rc += (*ii)->fProofServs.size();
863 XPDLOC(
SMGR,
"ProofServMgr::IsClientRecovering")
876 if ((*ii)->fClient && (*ii)->fClient->Match(
usr,
grp)) {
884 TRACE(
DBG,
"checking usr: "<<
usr<<
", grp:"<<
grp<<
" ... recovering? "<<
899 XPDLOC(
SMGR,
"ProofServMgr::CheckActiveSessions")
901 TRACE(
REQ,
"checking active sessions ...");
913 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
918 XrdOucString rest, key,
after;
921 if (
after !=
"status")
continue;
943 bool oldvers = (
xps &&
xps->ROOT() &&
xps->ROOT()->SrvProtVers() >= 18) ? 0 : 1;
957 if (
xps->VerifyProofServ(0) != 0) {
981 XPDLOC(
SMGR,
"ProofServMgr::CheckTerminatedSessions")
983 TRACE(
REQ,
"checking terminated sessions ...");
996 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
998 XrdOucString rest,
a;
1011 int rcst = stat(path.c_str(), &
st);
1012 TRACE(
DBG, pid<<
": rcst: "<<
rcst<<
", now - mtime: "<<
now -
st.st_mtime<<
" secs")
1040 XPDLOC(
SMGR,
"ProofServMgr::CleanClientSessions")
1051 XrdOucString path, rest, key,
a;
1054 XrdSysRecMutex *
mtx = 0;
1061 if (
c)
mtx =
c->Mutex();
1076 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
1114 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
1117 if (
a ==
"status")
continue;
1157 if (!active)
fSessions.Del(key.c_str());
1199 if (
d->fName ==
"proofservmgr") {
1201 }
else if (
d->fName ==
"putenv") {
1203 }
else if (
d->fName ==
"putrc") {
1205 }
else if (
d->fName ==
"shutdown") {
1218 XPDLOC(
SMGR,
"ProofServMgr::DoDirectiveProofServMgr")
1236 XrdOucString
tok(val);
1237 if (
tok.beginswith(
"checkfq:")) {
1238 tok.replace(
"checkfq:",
"");
1240 }
else if (
tok.beginswith(
"termto:")) {
1241 tok.replace(
"termto:",
"");
1243 }
else if (
tok.beginswith(
"verifyto:")) {
1244 tok.replace(
"verifyto:",
"");
1246 }
else if (
tok.beginswith(
"recoverto:")) {
1247 tok.replace(
"recoverto:",
"");
1249 }
else if (
tok.beginswith(
"checklost:")) {
1250 tok.replace(
"checklost:",
"");
1252 }
else if (
tok.beginswith(
"usefork:")) {
1253 tok.replace(
"usefork:",
"");
1257 val = cfg->GetWord();
1275 XPDFORM(
msg,
"checkfq: %d s, termto: %d s, verifyto: %d s, recoverto: %d s, checklost: %d, usefork: %d",
1295 ExtractEnv(val, cfg,
users,
groups,
rcval,
rcnam,
smi,
smx,
vmi,
vmx, hex);
1326 ExtractEnv(val, cfg,
users,
groups,
rcval,
rcnam,
smi,
smx,
vmi,
vmx, hex);
1345 while (val && val[0]) {
1349 }
else if (!
strncmp(val,
"g:", 2)) {
1352 }
else if (!
strncmp(val,
"s:", 2)) {
1362 }
else if (!
strncmp(val,
"v:", 2)) {
1366 if (
sver.beginswith(
'x')) {
1378 if (
rcval.length() > 0) {
1385 val = cfg->GetWord();
1395 const char *
usrs,
const char *
grps,
1411 if (
users.length() > 0) {
1415 if (
usr.length() > 0) {
1416 if (
groups.length() > 0) {
1420 if (
grp.length() > 0) {
1432 if (
groups.length() > 0) {
1436 if (
grp.length() > 0) {
1463 if (
dp >= 0 &&
dp <= 2)
1466 if ((val = cfg->GetWord())) {
1469 XrdOucString
tval = val;
1471 if (val[
l-1] ==
's') {
1473 }
else if (val[
l-1] ==
'm') {
1476 }
else if (val[
l-1] ==
'h') {
1479 }
else if (val[
l-1] < 48 || val[
l-1] > 57) {
1511 TRACEP(
p,
REQ,
"enter: req id: " <<
p->Request()->header.requestid <<
" (" <<
1517 XrdOucString
emsg(
"Invalid request code: ");
1523 "ProofServMgr::Process: error posting internal pipe for authorization to proceed");
1528 "ProofServMgr::Process: timed-out waiting for authorization to proceed - retry later");
1535 switch(
p->Request()->header.requestid) {
1545 emsg +=
p->Request()->header.requestid;
1582 if (!(
xps =
c->GetServer(
psid)) || !
xps->IsValid()) {
1602 if (!
xps || !
xps->IsValid()) {
1611 memcpy((
void *)&sid, (
const void *)&(
p->Request()->header.streamid[0]), 2);
1620 if (!(
xps->Parent()))
1628 if (!
dpu.endswith(
'/'))
1632 (
void *)
dpu.c_str(),
dpu.length());
1638 TRACEP(
p,
XERR,
"sending start process message ("<<
xps->StartMsg()->fSize<<
" bytes)");
1640 xps->StartMsg()->fBuff,
xps->StartMsg()->fSize);
1652 unsigned short &sid)
1654 XPDLOC(
SMGR,
"ProofServMgr::PrepareProofServ")
1658 xps->SetClient(
p->Client()->User());
1659 xps->SetSrvType(
p->ConnType());
1662 memcpy((
void *)&sid, (
const void *)&(
p->Request()->header.streamid[0]), 2);
1672 xps->SetROOT(
p->Client()->ROOT());
1674 XPDFORM(
msg,
"using ROOT version: %s",
xps->ROOT()->Export());
1679 XPDFORM(
msg,
"++++ Using NON-default ROOT version: %s ++++\n",
xps->ROOT()->Export());
1693 XrdOucString &tag, XrdOucString &
ord,
1697 XPDLOC(
SMGR,
"ProofServMgr::ParseCreateBuffer")
1700 char *buf =
p->Argp()->buff;
1701 int len =
p->Request()->proof.dlen;
1704 tag.assign(buf,0,
len-1);
1708 tag.erase(tag.find(
'|'));
1709 xps->SetTag(tag.c_str());
1719 ord.erase(
ord.find(
"|"));
1723 xps->SetOrdinal(
ord.c_str());
1744 TRACEP(
p,
DBG,
"P-Lite master with "<<
nwk<<
" workers (0 means # or cores)");
1760 if (
uenvs.length() > 0) {
1765 s.erase(s.find(
','));
1796 XPDFORM(
msg,
" ++++ Max number of sessions reached (%d) - please retry later ++++ \n",
cursess);
1809 TRACEP(
p,
DBG, nc <<
" threads are creating a new session");
1835 response->Send(
kXP_ServerError,
"timed-out acquiring fork semaphore");
1841 if (!(
fpc.IsValid()) || !(
fcp.IsValid())) {
1845 "unable to create pipes for communication during setup");
1856 if (!(pid =
fMgr->
Sched()->Fork(
"proofsrv"))) {
1869 XrdOucString
pmsg =
"*** spawned child process ";
1875 if (
chown(in.
fLogFile.c_str(),
p->Client()->UI().fUid,
p->Client()->UI().fGid) != 0)
1882 if (
fpc.Poll() < 0) {
1883 TRACE(
XERR,
"error while polling to receive the admin path from parent - EXIT" );
1887 TRACE(
XERR,
"error reading message while waiting for the admin path from parent - EXIT" );
1890 if (
xmsg.Type() < 0) {
1891 TRACE(
XERR,
"the parent failed to setup the admin path - EXIT" );
1901 if (
fpc.Poll() < 0) {
1902 TRACE(
XERR,
"error while polling to receive the sock path from parent - EXIT" );
1906 TRACE(
XERR,
"error reading message while waiting for the sock path from parent - EXIT" );
1909 if (
xmsg.Type() < 0) {
1910 TRACE(
XERR,
"the parent failed to setup the sock path - EXIT" );
1930 emsg =
"SetUserOwnerships did not return OK - EXIT";
1932 if (
fcp.Post(0,
emsg.c_str()) != 0)
1939 emsg =
"SetUserEnvironment did not return OK - EXIT";
1941 if (
fcp.Post(0,
emsg.c_str()) != 0)
1946 char *
argvv[7] = {0};
1950 emsg =
"XrdProofdManager instance undefined!";
1952 if (
fcp.Post(0,
emsg.c_str()) != 0)
1964 sxpd =
new char[10];
1969 char slog[10] = {0};
1973 char ssrv[10] = {0};
1977 argvv[0] = (
char *)
xps->ROOT()->PrgmSrv();
1980 argvv[2] = (
char *)
"xpd";
1988 emsg =
"SetProofServEnv did not return OK - EXIT";
1990 if (
fcp.Post(0,
emsg.c_str()) != 0)
1998 if (
fcp.Post(1,
xps->Fileout()) != 0) {
1999 TRACE(
XERR,
"cannot write log file path to internal pipe; errno: "<<
errno);
2017 ", psrv: "<<
xps->ROOT()->PrgmSrv()<<
", argvv[1]: "<<
argvv[1]);
2022 TRACE(
XERR,
"returned from execv: bad, bad sign !!! errno:" << (
int)
errno);
2053 if (
xps->UNIXSock()) {
2054 TRACEP(
p,
FORK,
"current UNIX sock: "<<
xps->UNIXSock() <<
", path: "<<
xps->UNIXSockPath());
2055 xps->DeleteUNIXSock();
2062 p->Client()->User(),
p->Client()->Group(), pid);
2067 emsg =
"socket path very long (";
2069 emsg +=
"): this may lead to stack corruption!";
2070 emsg +=
" Use xpd.sockpathdir to change it";
2076 if ((
pathrc =
fpc.Post(0, path.c_str())) != 0) {
2077 emsg =
"failed to communicating path to child";
2082 emsg =
"failed to setup child admin path";
2084 if ((
pathrc =
fpc.Post(-1, path.c_str())) != 0) {
2085 emsg +=
": failed communicating failure to child";
2095 emsg =
"failure creating UNIX socket on " ;
2104 emsg =
"failure changing ownership of the UNIX socket on " ;
2106 emsg +=
"; errno: " ;
2116 emsg =
"failed to communicating path to child";
2121 emsg =
"failed to setup child admin path";
2124 emsg +=
": failed communicating failure to child";
2142 TRACEP(
p,
FORK,
"waiting for client setup status ...");
2144 emsg =
"proofserv setup";
2151 if ((
prc =
fcp.Poll(2)) > 0) {
2155 emsg =
"error receiving message from pipe";
2165 if (
xbuf.length() <= 0) {
2166 emsg =
"error reading buffer {logfile, error message} from message received on the pipe";
2174 xps->SetFileout(
xbuf.c_str());
2191 }
else if (
prc < 0) {
2192 emsg =
"error receive status-of-setup from pipe";
2197 TRACEP(
p,
FORK,
"receiving status-of-setup from pipe: waiting 2 s ..."<<pid);
2210 emsg =
"failure setting up proofserv" ;
2211 if (
prc == 0)
emsg +=
": timed-out receiving status-of-setup from pipe";
2233 (
void *)
info.c_str(),
info.length());
2237 TRACEP(
p,
FORK,
"server launched: wait for callback ");
2240 xps->SetSrvPID(pid);
2244 emsg =
"problems accepting callback: ";
2247 emsg +=
"process could not be killed - pid: ";
2249 emsg +=
"process killed - pid: ";
2262 xps->SetGroup(
p->Client()->Group());
2267 p->Client()->User(),
dp) != 0) {
2268 TRACEP(
p,
XERR,
"problems changing child process priority");
2269 }
else if (
dp > 0) {
2270 TRACEP(
p,
DBG,
"priority of the child process changed by " <<
dp <<
" units");
2274 TRACEP(
p,
FORK,
"xps: "<<
xps<<
", ClientID: "<<(
int *)cid<<
" (sid: "<<sid<<
")"<<
" NClients: "<<
xps->GetNClients(1));
2277 if (
p->Client()->Sandbox()->AddSession(
xps->Tag()) == -1)
2278 TRACEP(
p,
REQ,
"problems recording session in sandbox");
2284 XrdOucString key; key += pid;
2292 if (!
xps->IsValid()) {
2309 bool assert = (pid > 0) ? 1 : 0;
2311 p->Client()->User(),
p->Client()->Group());
2312 if (pid > 0) path += pid;
2314 XPDFORM(
emsg,
"failure setting admin path '%s'", path.c_str());
2327 unsigned int seq, XrdOucString &
emsg)
2337 XPDFORM(
emsg,
"socket path very long (%d): this may lead to stack corruption! ",
sockpath.length());
2347 if (chmod(
sockpath.c_str(), 0755) != 0) {
2348 XPDFORM(
emsg,
"failure changing permissions of the UNIX socket on '%s'; errno: %d",
2364 XrdOucString
emsg(
"An error occured: the content of errlog follows:");
2366 emsg =
"------------------------------------------------\n";
2389 if ((
nr = read(
ierr, buf,
nb)) < 0) {
2400 emsg =
"------------------------------------------------";
2431 if (
si.fSrvProtVers < 18) {
2432 TRACE(
DBG,
"session does not support recovering: protocol "
2433 <<
si.fSrvProtVers<<
" < 18");
2439 si.fUnixPath.c_str());
2441 TRACE(
DBG,
"client instance not initialized");
2449 TRACE(
DBG,
"server object not initialized");
2457 TRACE(
XERR,
"failure creating UNIX socket on " <<
xps->UNIXSockPath());
2469 if ((*ii)->fClient ==
c)
2474 (*ii)->fProofServs.push_back(
xps);
2511 if (
emsg ==
"timeout") {
2512 TRACE(
DBG,
"timeout while accepting callback");
2518 XrdOucString key; key +=
xps->SrvPID();
2521 xps->Protocol()->SetAdminPath(
xps->AdminPath());
2528 int pid =
xps->SrvPID();
2532 " successfully recovered ("<<left<<
" left); pid: "<<pid);
2548 int to, XrdOucString &
msg)
2556 if (!
xps || !
xps->UNIXSock()) {
2557 XPDFORM(
msg,
"session pointer undefined or socket invalid: %p",
xps);
2560 TRACE(
REQ,
"waiting for server callback for "<<
to<<
" secs ... on "<<
xps->UNIXSockPath());
2570 msg =
"could not assert connected peer: ";
2594 peerpsrv.InetName = XrdSysDNS::getHostName(
"localhost");
2598 msg =
"could not allocate network object: ";
2605 TRACE(
DBG,
"connection accepted: matching protocol ... ");
2609 msg =
"match failed: protocol error: ";
2617 XrdOucString
apath(
xps->AdminPath());
2622 msg =
"handshake with internal link failed: ";
2629 msg =
"could not attach new internal link to poller: ";
2663 int to, XrdOucString &
msg)
2672 XPDFORM(
msg,
"session pointer undefined or socket invalid: %p",
xps);
2675 TRACE(
REQ,
"waiting for server callback for "<<
to<<
" secs ... on "<<
xps->UNIXSockPath());
2685 msg =
"could not assert connected peer: ";
2709 msg =
"could not allocate network object: ";
2714 TRACE(
DBG,
"connection accepted: matching protocol ... ");
2718 msg =
"match failed: protocol error: ";
2726 XrdOucString
apath(
xps->AdminPath());
2731 msg =
"handshake with internal link failed: ";
2738 msg =
"could not attach new internal link to poller: ";
2782 if (!
p->Client() || !(
xps =
p->Client()->GetServer(
psid))) {
2787 xps->FreeClientID(
p->Pid());
2815 if (!
p->Client() || !(
xpsref =
p->Client()->GetServer(
psid))) {
2816 TRACEP(
p,
XERR,
"reference session ID not found");
2822 XPDFORM(
msg,
"all sessions destroyed by %s",
p->Link()->ID);
2850 if (env &&
xwe &&
xwe->fMgr &&
xwe->fClient &&
xwe->fEnv) {
2851 if (env->
fEnv.length() > 0) {
2853 xwe->fMgr->ResolveKeywords(env->
fEnv,
xwe->fClient);
2855 char *
ev =
new char[env->
fEnv.length()+1];
2857 ev[env->
fEnv.length()] = 0;
2865 emsg =
"some input undefined";
2879 XPDLOC(
SMGR,
"ProofServMgr::SetProofServEnvOld")
2884 if (!
p || !
p->Client() || !
input) {
2885 TRACE(
XERR,
"at leat one input is invalid - cannot continue");
2891 TRACE(
XERR,
"problems setting basic environment - exit");
2900 TRACE(
XERR,
"unable to get instance of proofserv proxy");
2907 XrdOucString
udir =
p->Client()->Sandbox()->Dir();
2908 TRACE(
DBG,
"working dir for "<<
p->Client()->User()<<
" is: "<<
udir);
2933 snprintf(
ev,
len,
"ROOTVERSIONTAG=%s",
p->Client()->ROOT()->Tag());
2944 "unable to open env file: "<<
envfile);
2950 if (
p->AuthProt()) {
2959 if (env.length() > 0) {
2961 ev =
new char[env.length()+1];
2963 ev[env.length()] = 0;
2975 ev =
new char[
len + 1];
3024 fprintf(
fenv,
"ROOTENTITY=%s@%s\n",
p->Client()->User(),
p->Link()->Host());
3033 fprintf(
fenv,
"ROOTPROOFCLNTVERS=%d\n",
p->ProofProtocol());
3039 if (
getenv(
"ROOTVERSIONTAG"))
3043 if (in->
fCfg.length() > 0)
3057 int envmatch = (*ienvs).Matches(
p->Client()->User(),
p->Client()->Group(),
3058 p->Client()->ROOT()->VersionCode());
3063 p->Client()->ROOT()->VersionCode());
3083 if (
xps->UserEnvs() &&
3086 XrdOucString
ue =
xps->UserEnvs();
3089 while ((
from =
ue.tokenize(env,
from,
',')) != -1) {
3090 if (env.length() > 0 && (
ieq = env.find(
'=')) != -1) {
3093 ev =
new char[env.length()+1];
3095 ev[env.length()] = 0;
3121 syml +=
"/last-worker-session";
3123 syml +=
"/last-master-session";
3125 TRACE(
XERR,
"problems creating symlink to last session (errno: "<<
errno<<
")");
3138 XPDLOC(
SMGR,
"ProofServMgr::SetProofServEnv")
3143 TRACE(
REQ,
"ROOT dir: "<< (
r ?
r->Dir() :
"*** undef ***"));
3146 char *
libdir = (
char *)
r->LibDir();
3148 if (
mgr->BareLibPath() &&
strlen(
mgr->BareLibPath()) > 0) {
3166 char *
bindir = (
char *)
r->BinDir();
3173 char *
confdir = (
char *)
r->DataDir();
3190 TRACE(
XERR,
"XrdROOT instance undefined!");
3200 XrdOucString &
outfn)
3203 XrdOucString
ord =
xps->Ordinal();
3208 host.erase(host.find(
"."));
3211 else role =
"master";
3236 XrdOucString
udir =
p->Client()->Sandbox()->Dir();
3243 host.erase(host.find(
"."));
3265 }
else if (pid > 0) {
3278 if (pid == (
int)
getpid()) {
3293 TRACE(
XERR,
"negative pid ("<<pid<<
"): should not have got here!");
3310 XrdOucString
rc =
erc->fEnv;
3311 if (
rc.length() > 0) {
3312 if (
rc.find(
"Proof.DataSetManager") !=
STR_NPOS) {
3313 TRACE(
ALL,
"Proof.DataSetManager ignored: use xpd.datasetsrc to define dataset managers");
3321 emsg =
"file or input entry undefined";
3334 XPDLOC(
SMGR,
"ProofServMgr::SetProofServEnv")
3337 if (!
p || !
p->Client() || !
input) {
3338 TRACE(
XERR,
"at leat one input is invalid - cannot continue");
3343 int rootvers =
p->Client()->ROOT() ?
p->Client()->ROOT()->SrvProtVers() : -1;
3353 TRACE(
XERR,
"unable to get instance of proofserv proxy");
3360 XrdOucString
udir =
p->Client()->Sandbox()->Dir();
3361 TRACE(
DBG,
"sandbox for "<<
p->Client()->User()<<
" is: "<<
udir);
3375 TRACE(
XERR,
"problems setting basic environment - exit");
3380 TRACE(
DBG,
"creating rc and env files");
3399 syml +=
"/last-worker-session";
3401 syml +=
"/last-master-session";
3403 TRACE(
XERR,
"problems creating symlink to "
3404 " last session (errno: "<<
errno<<
")");
3420 XPDLOC(
SMGR,
"ProofServMgr::CreateProofServEnvFile")
3435 TRACE(
XERR,
"unable to get instance of proofserv proxy");
3449 if (
p->AuthProt()) {
3458 if (env.length() > 0) {
3460 ev =
new char[env.length()+1];
3462 ev[env.length()] = 0;
3474 ev =
new char[
lev+1];
3482 XrdOucString
credsdir =
p->Client()->Sandbox()->Dir();
3523 snprintf(
ev,
len,
"ROOTVERSIONTAG=%s",
p->Client()->ROOT()->Tag());
3544 TRACE(
HDBG,
nrk <<
" placeholders resolved for LOCALDATASERVER");
3569 int envmatch = (*ienvs).Matches(
p->Client()->User(),
p->Client()->Group(),
3570 p->Client()->ROOT()->VersionCode());
3575 p->Client()->ROOT()->VersionCode());
3594 if (
xps->UserEnvs() &&
3597 XrdOucString
ue =
xps->UserEnvs();
3600 while ((
from =
ue.tokenize(env,
from,
',')) != -1) {
3601 if (env.length() > 0 && (
ieq = env.find(
'=')) != -1) {
3604 ev =
new char[env.length()+1];
3606 ev[env.length()] = 0;
3607 if (env.find(
"WRAPPERCMD") ==
STR_NPOS || !
xps->IsPLite())
3611 if (env.find(
"WRAPPERCMD") ==
STR_NPOS || !
xps->IsPLite()) {
3642 XPDLOC(
SMGR,
"ProofServMgr::CreateProofServRootRc")
3656 TRACE(
XERR,
"unable to get instance of proofserv proxy");
3669 TRACE(
XERR,
"problems creating symlink to 'session.rootrc' (errno: "<<
errno<<
")");
3675 fprintf(
frc,
"# XrdProofdProtocol listening port\n");
3680 fprintf(
frc,
"# Prefix to be prepended to local paths\n");
3687 if (!
purl.endswith(
"/"))
3689 fprintf(
frc,
"# URL for the data pool entry-point\n");
3708 if (
p->Client()->ROOT()) {
3710 fprintf(
frc,
"ProofServ.RootVersionTag: %s\n",
p->Client()->ROOT()->Tag());
3713 if (
p->Client()->Group()) {
3715 fprintf(
frc,
"ProofServ.ProofGroup: %s\n",
p->Client()->Group());
3720 fprintf(
frc,
"# File with group information\n");
3725 XrdOucString
udir =
p->Client()->Sandbox()->Dir();
3745 int proofvrs = (
p->Client()->ROOT()) ?
p->Client()->ROOT()->SrvProtVers() : -1;
3748 fprintf(
frc,
"ProofServ.AdminPath: %s\n",
xps->AdminPath());
3752 fprintf(
frc,
"ProofServ.AdminPath: %s.status\n",
xps->AdminPath());
3758 fprintf(
frc,
"# Whether user specific config files are enabled\n");
3763 fprintf(
frc,
"ProofServ.OpenSock: %s\n",
xps->UNIXSockPath());
3766 if (
p->Client()->UI().fGroup.length() > 0)
3768 p->Client()->User(),
p->Client()->UI().fGroup.c_str(),
p->Link()->Host());
3770 fprintf(
frc,
"ProofServ.Entity: %s@%s\n",
p->Client()->User(),
p->Link()->Host());
3779 fprintf(
frc,
"ProofServ.ClientID: %d\n",
p->CID());
3783 fprintf(
frc,
"ProofServ.ClientVersion: %d\n",
p->ProofProtocol());
3786 if (in->
fCfg.length() > 0) {
3787 if (in->
fCfg ==
"masteronly") {
3799 fprintf(
frc,
"ProofServ.ProofConfFile: sm:\n");
3800 }
else if (
xps->IsPLite()) {
3801 fprintf(
frc,
"ProofServ.ProofConfFile: lite:\n");
3802 fprintf(
frc,
"# Number of ProofLite workers\n");
3815 fprintf(
frc,
"# Default settings for XrdClient\n");
3820 int vrscode = (
p->Client()->ROOT()) ?
p->Client()->ROOT()->VersionCode() : -1;
3822 fprintf(
frc,
"# Force remote reading also for local files to avoid a wrong TTreeCache initialization\n");
3829 fprintf(
frc,
"# Additional rootrcs (xpd.putrc directives)\n");
3834 int rcmatch = (*ircs).Matches(
p->Client()->User(),
p->Client()->Group(),
3835 p->Client()->ROOT()->VersionCode());
3839 int rcmtcex =
rcenv->Matches(
p->Client()->User(),
p->Client()->Group(),
3840 p->Client()->ROOT()->VersionCode());
3860 XrdOucString
rc(
"Proof.DataSetManager: ");
3861 std::list<XrdProofdDSInfo *>::iterator
ii;
3870 rc += (*ii)->fObscure;
3877 fprintf(
frc,
"# Dataset staging requests repository\n");
3886 p->Client()->Group(),
p->Client()->User(),
xps->Ordinal(),
3911 XPDLOC(
SMGR,
"ProofServMgr::CleanupLostProofServ")
3918 TRACE(
REQ,
"checking for orphalin proofserv processes ...");
3922 std::map<int,XrdOucString>
procs;
3924 TRACE(
DBG,
" no proofservs around: nothing to do");
3943 std::map<int,XrdOucString>::iterator
ip;
3947 if ((
ia = cmd.find(
"xpdpath:")) !=
STR_NPOS) {
3949 apath.replace(
"xpdpath:",
"");
3950 if (
apath.length() <= 0) {
3951 TRACE(
ALL,
"admin path not found; initial cmd line: "<<cmd);
3969 const char *
subdir[2] = {
"activesessions",
"terminatedsessions"};
3970 for (
int i = 0; i < 2; i++) {
3998 TRACE(
ALL,
"process: "<<pid<<
" lost its controller: killing");
4021 XPDLOC(
SMGR,
"ProofServMgr::CleanupProofServ")
4027 const char *
pn =
"proofserv";
4034 TRACE(
DBG,
"usr must be defined for all = FALSE");
4038 TRACE(
DBG,
"problems getting info for user " <<
usr);
4048 XrdOucString
emsg(
"cannot open /proc - errno: ");
4056 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
4057 if (
DIGIT(ent->d_name[0])) {
4058 XrdOucString
fn(
"/proc/", 256);
4064 XrdOucString
emsg(
"cannot open file ");
4074 char line[2048] = { 0 };
4129 XrdOucString
emsg(
"cannot open /proc - errno: ");
4137 if (!
strncmp(ent->d_name,
".", 1) || !
strncmp(ent->d_name,
"..", 2))
continue;
4138 if (
DIGIT(ent->d_name[0])) {
4139 XrdOucString
fn(
"/proc/", 256);
4145 XrdOucString
emsg(
"cannot open file ");
4157 XrdOucString
emsg(
"cannot read ");
4205#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
4211 if ((
ern = XrdProofdAux::GetMacProcList(&
pl,
np)) != 0) {
4212 XrdOucString
emsg(
"cannot get the process list: errno: ");
4260 XrdOucString cmd =
"ps ";
4280 cmd +=
" | grep proofserv 2>/dev/null";
4287 XrdOucString
pids =
":";
4290 char line[2048] = { 0 };
4342 const char *
ord,
const char *
stag)
4344 XPDLOC(
SMGR,
"ProofServMgr::SetUserOwnerships")
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) {
4359 XPDFORM(
d,
"%s/%s", ((*ii)->fUrl).c_str(),
p->Client()->UI().fGroup.c_str());
4362 XPDFORM(
d,
"%s/%s/%s", ((*ii)->fUrl).c_str(),
p->Client()->UI().fGroup.c_str(),
4363 p->Client()->UI().fUser.c_str());
4366 TRACE(
XERR,
"problems setting permissions 0755 on: "<<
d);
4372 TRACE(
XERR,
"problems setting permissions 0777 on: "<<
d);
4387 XrdOucString
dgr,
dus[3];
4391 unsigned int mode = 0755;
4394 XPDFORM(
dus[0],
"%s/%s",
dgr.c_str(),
p->Client()->UI().fUser.c_str());
4397 for (
int i = 0; i < 3; i++) {
4400 std::ios_base::fmtflags oflags = std::cerr.flags();
4402 std::cerr.flags(oflags);
4410 TRACE(
XERR,
"problems setting permissions 0777 on: "<<
dgr);
4419 XrdOucString
creds(
p->Client()->Sandbox()->Dir());
4440 XPDLOC(
SMGR,
"ProofServMgr::SetUserEnvironment")
4446 TRACE(
XERR,
"couldn't change directory to "<<
p->Client()->Sandbox()->Dir());
4452 len = 8 +
strlen(
p->Client()->Sandbox()->Dir());
4453 char *
h =
new char[
len];
4460 char *
u =
new char[
len];
4472 TRACE(
XERR,
"could not get privileges");
4476 initgroups(
p->Client()->UI().fUser.c_str(),
p->Client()->UI().fGid);
4481 TRACE(
DBG,
"acquiring target user identity: "<<(
uid_t)
p->Client()->UI().fUid<<
4482 ", "<<(
gid_t)
p->Client()->UI().fGid);
4484 (
gid_t)
p->Client()->UI().fGid) != 0) {
4485 TRACE(
XERR,
"can't acquire "<<
p->Client()->UI().fUser <<
" identity");
4500 XrdOucString key; key += pid;
4513 int nb = *(
bp->fNBroadcast);
4520 ?
bp->fGroupMgr->GetGroup(ps->
Group()) : 0;
4522 if (
g &&
g->Active() > 0) {
4523 TRACE(
DBG,
"priority: "<<
g->Priority()<<
" active: "<<
g->Active());
4524 int prio = (
int) (
g->Priority() * 100);
4532 emsg =
"input entry undefined";
4545 XPDLOC(
SMGR,
"ProofServMgr::BroadcastClusterInfo")
4568 TRACE(
DBG,
"No master or submaster controlled by this manager");
4578 XPDLOC(
SMGR,
"ProofServMgr::BroadcastPriorities")
4631 std::map<XrdProofdProtocol*,int>::iterator iter =
fDestroyTimes.begin();
4633 int rect =
now - iter->second;
4635 if (
p == iter->first)
alive =
false;
4652 int pid = *((
int *)s);
4661 TRACE(
XERR,
"protocol error: undefined session!");
4683 int *
ntm = (
int *)s;
4691 emsg =
"input entry undefined";
4704 XPDLOC(
SMGR,
"ProofServMgr::CurrentSessions")
4732 if (
lfr.endswith(
".log"))
lfr.erase(
lfr.rfind(
".log"));
4733 s.replace(
"<logfilemst>",
lfr);
4736 if (
lfr.endswith(
".log"))
lfr.erase(
lfr.rfind(
".log"));
4737 s.replace(
"<logfilewrk>",
lfr);
4743 s.replace(
"<user>",
usr);
4749 s.replace(
"<rootsys>",
rootsys);
4770 fID = s ? s->
ID() : -1;
4810 "' not availabe anymore: setting the default");
4827 if (!file ||
strlen(file) <= 0) {
4828 TRACE(
XERR,
"invalid input: "<< (file ? file :
"<nul>"));
4831 TRACE(
HDBG,
"session saved to file: "<<file);
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);
4895 if (!file ||
strlen(file) <= 0) {
4896 TRACE(
XERR,
"invalid input: "<<(file ? file :
"<nul>"));
4904 XrdOucString
sline, t;
4910 TRACE(
XERR,
"warning: fUser: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4912 TRACE(
XERR,
"warning: fGroup: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4923 TRACE(
XERR,
"warning: fPid: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4926 TRACE(
XERR,
"warning: fID: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4929 TRACE(
XERR,
"warning: fSrvType: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4937 TRACE(
XERR,
"warning: fOrdinal: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4939 TRACE(
XERR,
"warning: fTag: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4952 TRACE(
XERR,
"warning: fSrvProtVers: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4955 TRACE(
XERR,
"warning: fROOTTag: corrupted line? "<<
line<<
" (file: "<<file<<
")");
4964 int wanted = (left > 4095) ? 4095 : left;
4976 }
while (
len > 0 && left > 0);
4983 if (!stat(file, &
st))
4986 TRACE(
XERR,
"session file cannot be open: "<< file<<
"; error: "<<
errno);
4991 XrdOucString
fs(file);
5003 TRACE(
DBG,
"no session status file for: "<<
fs<<
"; session was probably terminated");
5022 if (
fUsers.length() > 0) {
5023 XrdOucString
u(
usr);
5024 if ((
nmtc =
u.matches(
fUsers.c_str())) == 0)
return -1;
5032 XrdOucString
g(
grp);
5061 ptc =
xv - min * 256;
5066 ptc =
xv - min * 100;
5069 int vc = (
maj << 16) + (min << 8) +
ptc;
5080 XrdOucString
vmi(
"-1"),
vmx(
"-1");
5093 XrdOucString
u(
"allusers"),
g(
"allgroups");
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define TRACE(Flag, Args)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
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 np
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 void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
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
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
R__EXTERN C unsigned int sleep(unsigned int seconds)
#define kXPD_ClientMaster
#define kXPD_MasterMaster
#define kXPD_MasterWorker
int DoDirectiveString(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Process directive for a string.
int DoDirectiveClass(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Generic class directive processor.
int DoDirectiveInt(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Process directive for an integer.
#define XpdBadPGuard(g, u)
static XpdManagerCron_t fManagerCron
static int WriteSessRCs(const char *, XpdEnv *erc, void *f)
Run thorugh entries to broadcast the relevant priority.
static int FreeClientID(const char *, XrdProofdProofServ *ps, void *s)
Run through entries to reset the disconnecting client slots.
static int WriteSessEnvs(const char *, XpdEnv *env, void *s)
Run thorugh entries to broadcast the relevant priority.
static int CountTopMasters(const char *, XrdProofdProofServ *ps, void *s)
Run thorugh entries to count top-masters.
static int BroadcastPriority(const char *, XrdProofdProofServ *ps, void *s)
Run thorugh entries to broadcast the relevant priority.
void * XrdProofdProofServRecover(void *p)
Waiting for session to recover after an abrupt shutdown.
void * XrdProofdProofServCron(void *p)
This is an endless loop to check the system periodically or when triggered via a message in a dedicat...
static XpdManagerCron_t fManagerCron
#define XPD_SETRESP(p, x)
#define TRACEP(p, act, x)
#define XrdSysMutexHelper
const_iterator begin() const
const_iterator end() const
XrdProofdClient * fClient
std::list< XrdProofdProofServ * > fProofServs
int Matches(const char *usr, const char *grp, int ver=-1)
Check if this env applies to 'usr', 'grp, 'ver'.
void Print(const char *what)
Print the content of this env.
static int ToVersCode(int ver, bool hex=0)
Transform version number ver (format patch + 100*minor + 10000*maj, e.g.
static int Attach(XrdLink *lp)
const char * GetCfgFile() const
virtual int MaxSessions() const
void FillProofServ(XrdProofdProofServ &s, XrdROOTMgr *rmgr)
Fill 's' fields using the stored info.
int SaveToFile(const char *file)
Save content to 'file'.
void Reset()
Reset the content.
XrdProofSessionInfo(XrdProofdClient *c, XrdProofdProofServ *s)
Construct from 'c' and 's'.
int ReadFromFile(const char *file)
Read content from 'file'.
static int ChangeOwn(const char *path, XrdProofUI ui)
Change the ownership of 'path' to the entity described by 'ui'.
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 VerifyProcessByID(int pid, const char *pname="proofserv")
Check if a process named 'pname' and process 'pid' is still in the process table.
static long int GetLong(char *str)
Extract first integer from string at 'str', if any.
static const char * ProofRequestTypes(int type)
Translates the proof request type in a human readable string.
static int KillProcess(int pid, bool forcekill, XrdProofUI ui, bool changeown)
Kill the process 'pid'.
static int ChangeToDir(const char *dir, XrdProofUI ui, bool changeown)
Change current directory to 'dir'.
static int ChangeMod(const char *path, unsigned int mode)
Change the permission mode of 'path' to 'mode'.
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,...
static int GetIDFromPath(const char *path, XrdOucString &emsg)
Extract an integer from a file.
static void LogEmsgToFile(const char *flog, const char *emsg, const char *pfx=0)
Logs error message 'emsg' to file 'flog' using standard technology.
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.
static int CheckIf(XrdOucStream *s, const char *h)
Check existence and match condition of an 'if' directive If none (valid) is found,...
static int ParsePidPath(const char *path, XrdOucString &before, XrdOucString &after)
Parse a path in the form of "<before>[.<pid>][.<after>]", filling 'rest' and returning 'pid'.
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.
const char * Group() const
const char * User() const
bool ReadFile(bool update=true)
Return true if the file has never been read or did change since last reading, false otherwise.
virtual int Config(bool rcf=0)
void Register(const char *dname, XrdProofdDirective *d)
const char * CfgFile() const
XrdProofdPriorityMgr * PriorityMgr() const
const char * PoolURL() const
XrdProofSched * ProofSched() const
const char * SockPathDir() const
const char * DataDirUrlOpts() const
XrdROOTMgr * ROOTMgr() const
std::list< XrdProofdDSInfo * > * DataSetSrcs()
const char * DataDirOpts() const
XrdProofdNetMgr * NetMgr() const
XrdProofGroupMgr * GroupsMgr() const
XrdScheduler * Sched() const
XrdProofdClientMgr * ClientMgr() const
const char * LocalROOT() const
const char * Host() const
const char * StageReqRepo() const
const char * Image() const
const char * DataDir() const
const char * NameSpace() const
const char * TMPdir() const
const char * EffectiveUser() const
const char * AdminPath() const
int ResolveKeywords(XrdOucString &s, XrdProofdClient *pcl)
Resolve special keywords in 's' for client 'pcl'.
bool WorkerUsrCfg() const
int SetProcessPriority(int pid, const char *usr, int &dp)
Change priority of process pid belonging to user, if needed.
XrdProofdProofServ * GetActiveSession(int pid)
Return active session with process ID pid, if any.
int Attach(XrdProofdProtocol *p)
Handle a request to attach to an existing session.
int Create(XrdProofdProtocol *p)
Handle a request to create a new session.
void BroadcastClusterInfo()
Broadcast cluster info to the active sessions.
XrdProofdProofServ * PrepareProofServ(XrdProofdProtocol *p, XrdProofdResponse *r, unsigned short &sid)
Allocate and prepare the XrdProofdProofServ object describing this session.
int SetUserEnvironment(XrdProofdProtocol *p)
Set user environment: set effective user and group ID of the process to the ones of the owner of this...
XrdOucString fParentExecs
int Destroy(XrdProofdProtocol *p)
Handle a request to shutdown an existing session.
int CurrentSessions(bool recalculate=0)
Return the number of current sessions (top masters)
int DoDirectiveProofServMgr(char *, XrdOucStream *, bool)
Process 'proofswrvmgr' directive eg: xpd.proofswrvmgr checkfq:120 termto:100 verifyto:5 recoverto:20.
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'.
int CheckTerminatedSessions()
Go through the terminated sessions admin path and make sure sessions they are gone.
int Detach(XrdProofdProtocol *p)
Handle a request to detach from an existing session.
int PrepareSessionRecovering()
Go through the active sessions admin path and prepare reconnection of those still alive.
int CleanupLostProofServ()
Cleanup (kill) all 'proofserv' processes which lost control from their creator or controller daemon.
int BroadcastPriorities()
Broadcast priorities to the active sessions.
XrdProofdProofServMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
int DoDirectivePutRc(char *, XrdOucStream *, bool)
Process 'putrc' directives.
int CleanupProofServ(bool all=0, const char *usr=0)
Cleanup (kill) all 'proofserv' processes from the process table.
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.
int AcceptPeer(XrdProofdProofServ *xps, int to, XrdOucString &e)
Accept a callback from a starting-up server and setup the related protocol object.
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.
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...
int MvSession(const char *fpid)
Move session file from the active to the terminated areas.
void FormFileNameInSessionDir(XrdProofdProtocol *p, XrdProofdProofServ *xps, const char *sessiondir, const char *extension, XrdOucString &outfn)
void DisconnectFromProofServ(int pid)
Change reconnecting status.
XrdOucHash< XrdProofdProofServ > fSessions
int SetProofServEnv(XrdProofdProtocol *p, void *in)
Set environment for proofserv.
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...
bool IsReconnecting()
Return true if in reconnection state, i.e.
XrdOucString fTermAdminPath
int DoDirectiveShutdown(char *, XrdOucStream *, bool)
Process 'shutdown' directive.
XrdSecCredsSaver_t fCredsSaver
int RmSession(const char *fpid)
Remove session file from the terminated sessions area.
int SetProofServEnvOld(XrdProofdProtocol *p, void *in)
Set environment for proofserv; old version preparing the environment for proofserv protocol version <...
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...
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
XrdOucSemWait fProcessSem
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,...
std::list< XrdProofdProofServ * > fActiveSessions
XrdSysRecMutex fRecoverMutex
int DoDirectivePutEnv(char *, XrdOucStream *, bool)
Process 'putenv' directives.
int RecoverActiveSessions()
Accept connections from sessions still alive.
int AddSession(XrdProofdProtocol *p, XrdProofdProofServ *s)
Add new active session.
std::map< XrdProofdProtocol *, int > fDestroyTimes
int CheckActiveSessions(bool verify=1)
Go through the active sessions admin path and make sure sessions are alive.
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 SetupProtocol(XrdNetPeer &peerpsrv, XrdProofdProofServ *xps, XrdOucString &e)
Setup the protocol object serving the peer described by 'peerpsrv'.
XrdOucString fActiAdminPath
int SetUserOwnerships(XrdProofdProtocol *p, const char *ord, const char *stag)
Set user ownerships on some critical files or directories.
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.
std::list< XpdClientSessions * > * fRecoverClients
void RegisterDirectives()
Register directives for configuration.
bool Alive(XrdProofdProtocol *p)
Check destroyed status.
unsigned int fSeqSessionN
int DeleteFromSessions(const char *pid)
Delete from the hash list the session with ID pid.
int Recover(XpdClientSessions *cl)
Handle a request to recover a session after stop&restart for a specific client.
std::list< XpdEnv > fProofServRCs
int TouchSession(const char *fpid, const char *path=0)
Update the access time for the session pid file to the current time.
void SendErrLog(const char *errlog, XrdProofdResponse *r)
Send content of errlog upstream asynchronously.
XrdOucString fProofPlugin
int Process(XrdProofdProtocol *p)
Process manager request.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
void SetReconnectTime(bool on=1)
Change reconnecting status.
int CreateProofServRootRc(XrdProofdProtocol *p, void *input, const char *rcfn)
Create in 'rcfn' the rootrc file for the proofserv being created return 0 on success,...
void ResolveKeywords(XrdOucString &s, ProofServEnv_t *in)
Resolve some keywords in 's' <logfileroot>, <user>, <rootsys>
XrdSysRecMutex fEnvsMutex
int VerifySession(const char *fpid, int to=-1, const char *path=0)
Check if the session is alive, i.e.
int ResolveSession(const char *fpid)
Handle a request to recover a session after stop&restart.
std::list< XpdEnv > fProofServEnvs
int CleanClientSessions(const char *usr, int srvtype)
Go through the sessions admin path and clean all sessions belonging to 'usr'.
int BroadcastPriority(int priority)
Broadcast a new group priority value to the worker servers.
const char * Client() const
void SetPLiteNWrks(int n)
void SetOrdinal(const char *o)
void SetGroup(const char *g)
void SetClient(const char *c)
void SetTag(const char *t)
const char * AdminPath() const
const char * Ordinal() const
const char * UserEnvs() const
const char * Alias() const
const char * UNIXSockPath() const
int FreeClientID(int pid)
Free instance corresponding to protocol connecting process 'pid'.
int SetAdminPath(const char *a, bool assert, bool setown)
Set the admin path and make sure the file exists.
void SetFileout(const char *f)
void SetUserEnvs(const char *t)
const char * Group() const
void SetAlias(const char *a)
void SetUNIXSockPath(const char *s)
const char * Fileout() const
static int EUidAtStartup()
XrdROOT * DefaultVersion() const
static int GetVersionCode(const char *release)
Translate 'release' into a version code integer following the rules in $ROOTSYS/include/RVersion....
kXR_int16 SrvProtVers() const
static int ChangePerm(uid_t uid, gid_t gid)
XrdOucString fTopSessionTag
XrdProofGroupMgr * fGroupMgr
XrdProofdClient * fClient