28#include "XrdVersion.hh"
29#include "Xrd/XrdProtocol.hh"
30#include "XrdOuc/XrdOucEnv.hh"
31#include "XrdOuc/XrdOucStream.hh"
104#if defined(LIBC_SCCS) && !defined(lint)
105static char sccsid[] =
"@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94";
107#include <sys/cdefs.h>
108__FBSDID(
"$FreeBSD: src/lib/libc/gen/getgrouplist.c,v 1.14 2005/05/03 16:20:03 delphij Exp $");
114#include <sys/types.h>
141 for (i = 0; i <
ngroups; i++) {
146 for (i = 0;
grp->gr_mem[i]; i++) {
180 TRACE(
REQ,
"undefined manager: cannot start");
184 TRACE(
REQ,
"started with frequency " <<
mgr->CronFrequency() <<
" sec");
188 int mid = XrdSysTimer::Midnight(
now);
196 TRACE(
REQ,
"running periodical checks");
198 mgr->CheckLogFileOwnership();
200 int tw =
mgr->CronFrequency();
209 if (
mgr->SessionMgr())
mgr->SessionMgr()->Config(1);
210 if (
mgr->GroupsMgr())
mgr->GroupsMgr()->Config(
mgr->GroupsMgr()->GetCfgFile());
212 XrdSysTimer::Wait(
tw * 1000);
343 TRACE(
ALL,
"xrootd protocol service created");
354 XPDLOC(
ALL,
"Manager::CheckLogFileOwnership")
372 TRACE(
XERR,
"could not get effective user identity; errno: " <<
errno);
377 if (
st.st_uid !=
epwd->pw_uid ||
st.st_gid !=
epwd->pw_gid) {
395 std::list<XrdOucString *>::iterator i;
397 if (
wm.matches((*i)->c_str())) {
418 e =
"CheckUser: 'usr' string is undefined ";
424 e =
"CheckUser: 'root' logins not accepted ";
430 e =
"CheckUser: 'grp' string is undefined ";
441 e =
"CheckUser: unknown ClientID: ";
448 e =
"CheckUser: problems getting user info for id: ";
507#if defined(__APPLE__)
522 e =
"Controlled access (UNIX group): user '";
524 e =
"', UNIX group '";
526 e +=
"' denied to connect";
540 e =
"Controlled access";
541 e +=
" (PROOF group): user '";
543 e +=
"', PROOF group '";
545 e +=
"' denied to connect";
563 e =
"Controlled access: user '";
565 e +=
"', PROOF group '";
567 e +=
"' not allowed to connect";
594 XrdOucString
name, lib,
m;
607 char *val = 0, *var = 0;
608 while ((var = cfg.GetMyFirstWord())) {
609 if (!(
strcmp(
"xpd.sched", var))) {
631 if (
name ==
"default" || !(
name.length() > 0 && lib.length() > 0)) {
632 if ((
name.length() <= 0 && lib.length() > 0) ||
633 (
name.length() > 0 && lib.length() <= 0)) {
634 XPDFORM(
m,
"missing or incomplete info (name: %s, lib: %s)",
name.c_str(), lib.c_str());
637 TRACE(
DBG,
"instantiating default scheduler");
641 if (lib.beginswith(
"~") || lib.beginswith(
"$"))
654 TRACE(
XERR,
"unable to create scheduler object from " << lib);
661 if (!(
sched->IsValid())) {
662 TRACE(
XERR,
" unable to instantiate the " <<
sched->Name() <<
" scheduler using " << (
cfn ?
cfn :
"<nul>"));
693 TRACE(
XERR,
"error getting list of workers from the scheduler");
696 std::list<XrdProofWorker *>::iterator
iw,
iaw;
713 if (
w->fHost ==
uw->fHost &&
w->fPort ==
uw->fPort) {
732 xps->AddWorker(
ord.c_str(),
w);
733 w->AddProofServ(
xps);
739 if (
w->fType ==
'M') {
740 if (
lw.length() > 0)
lw.insert(
'&',0);
741 lw.insert(
w->Export(), 0);
744 if (
lw.length() > 0)
lw +=
'&';
761 xps->AddWorker(
ord.c_str(),
w);
763 w->AddProofServ(
xps);
768 int proto = (
xps->ROOT()) ?
xps->ROOT()->SrvProtVers() : -1;
769 if (
rc != 2 || (
proto < 21 &&
rc == 0)) {
771 if (
lw.length() <= 0)
xps->ExportWorkers(
lw);
773 }
else if (
proto >= 21) {
781 if (!
uwrks.empty()) {
808 if (
ss.length() > 0)
ss +=
",";
826 XrdOucString *ls = (XrdOucString *)s;
833 if (ls->length() > 0) *ls +=
",";
857 XPDERR(
"problems parsing file ");
862 msg = (
rcf) ?
"re-configuring" :
"configuring";
885 char *host = XrdSysDNS::getHostName();
886 fHost = host ? host :
"";
893 const char *
roles[] = {
"any",
"worker",
"submaster",
"master" };
951 XPDERR(
"unable to assert working dir: " <<
wdir);
959 if (
wdir.length() > 0) {
980 if (chmod(
fDataDir.c_str(), 0777) != 0) {
981 XPDERR(
"problems setting permissions 0777 data dir: " <<
fDataDir);
991 std::list<XrdOucString *>::iterator i;
993 TRACE(
ALL,
"masters allowed to connect: " << (*i)->c_str());
995 TRACE(
ALL,
"masters allowed to connect: any");
1013 XPDERR(
"scheduler initialization failed");
1016 const char *
st[] = {
"disabled",
"enabled" };
1022 TRACE(
ALL,
"multi-process on nodes handled with proof-lite");
1028 std::list<XrdProofdDSInfo *>::iterator
ii =
fDataSetSrcs.begin();
1031 TRACE(
ALL,
">> Defined dataset: " << (*ii)->ToString());
1032 if ((*ii)->fType ==
"file") {
1034 XPDERR(
"source " << (*ii)->fUrl <<
" could not be validated");
1042 TRACE(
ALL,
"Skipping validation (no \"file\" type dataset source)");
1049 TRACE(
ALL,
">> Valid dataset: " << (*ii)->ToString());
1050 if ((*ii)->fLocal && (*ii)->fRW) {
1056 TRACE(
ALL,
"no dataset sources defined");
1059 TRACE(
ALL,
"no dataset sources defined");
1070 XPDFORM(
msg,
"could not resolve effective uid %d (errno: %d)",
1091 XPDFORM(
msg,
"running in controlled access mode: users removed because"
1092 " unknown to the system: %s",
ius.c_str());
1099 if (
uls.allowed.length()) {
1100 XPDFORM(
msg,
"running in controlled access mode: users allowed: %s",
uls.allowed.c_str());
1103 if (
uls.denied.length()) {
1104 XPDFORM(
msg,
"running in controlled access mode: users denied: %s",
uls.denied.c_str());
1110 if (
gls.allowed.length()) {
1111 XPDFORM(
msg,
"running in controlled access mode: UNIX groups allowed: %s",
gls.allowed.c_str());
1114 if (
gls.denied.length()) {
1115 XPDFORM(
msg,
"running in controlled access mode: UNIX groups denied: %s",
gls.denied.c_str());
1130 if (
ldir.length() > 0) {
1140 if (!
strncmp(ent->d_name,
"libCore", 7)) {
1156 ctrim =
" (lib paths filter applied)";
1177 XPDERR(
"problems configuring the admin handler");
1183 XPDERR(
"problems configuring the network manager");
1189 XPDERR(
"problems configuring the priority manager");
1197 XPDERR(
"problems configuring the ROOT versions manager");
1204 XPDERR(
"problems configuring the client manager");
1210 XPDERR(
"problems configuring the session manager");
1216 XPDERR(
"problems configuring the scheduler");
1222 TRACE(
ALL,
"file serving (protocol: 'root://') not available");
1229 (
void *)
this, 0,
"ProofdManager cron thread") != 0) {
1230 XPDERR(
"could not start cron thread");
1233 TRACE(
ALL,
"manager cron thread started");
1247 XPDLOC(
ALL,
"Manager::ValidateLocalDataSetSrc")
1252 if (
url.length() > 0) {
1254 if (
url.beginswith(
"file:"))
url.replace(
"file:",
"");
1255 if (
url.beginswith(
"/")) {
1264 TRACE(
XERR,
"Problems setting permissions 0777 on path '" <<
url <<
"'");
1267 TRACE(
XERR,
"Cannot assert path '" <<
url <<
"' - ignoring");
1272 fnpath +=
"/dataset.list";
1288 TRACE(
XERR,
"Problems setting permissions to 0666 on file '" <<
fnpath <<
"'; errno: " <<
errno);
1293 fnpath.replace(
"/dataset.list",
"/lock.location");
1303 fnlock.replace(
"/",
"%");
1304 fnlock.replace(
":",
"%");
1305 fnlock.insert(
"/tmp/", 0);
1313 }
else if (ofs == (
off_t)(-1)) {
1322 TRACE(
XERR,
"Problems setting permissions to 0644 on file '" <<
fnpath <<
"'; errno: " <<
errno);
1328 TRACE(
ALL,
"New dataset with no URL!");
1389 if (s.replace(
"<workdir>",
WorkDir()))
1395 if (s.replace(
"<host>",
Host()))
1401 if (s.find(
"<port>") !=
STR_NPOS) {
1404 if (s.replace(
"<port>",
sport.c_str()))
1409 if (s.find(
"<effuser>") !=
STR_NPOS) {
1412 if (s.replace(
"<effuser>",
eui.fUser.c_str()))
1419 if (s.replace(
"<user>",
pcl->User()))
1424 if (s.replace(
"<group>",
pcl->Group()))
1429 if (s.replace(
"<homedir>",
pcl->UI().fHomeDir.c_str()))
1436 if (s.replace(
"<uid>",
suid.c_str()))
1444 if (s.replace(
"<gid>",
sgid.c_str()))
1469 if (
d->fName ==
"trace") {
1471 }
else if (
d->fName ==
"groupfile") {
1473 }
else if (
d->fName ==
"maxoldlogs") {
1475 }
else if (
d->fName ==
"allow") {
1477 }
else if (
d->fName ==
"allowedgroups") {
1479 }
else if (
d->fName ==
"allowedusers") {
1481 }
else if (
d->fName ==
"role") {
1483 }
else if (
d->fName ==
"multiuser") {
1485 }
else if (
d->fName ==
"port") {
1487 }
else if (
d->fName ==
"datadir") {
1489 }
else if (
d->fName ==
"datasetsrc") {
1491 }
else if (
d->fName ==
"rootd") {
1493 }
else if (
d->fName ==
"rootdallow") {
1495 }
else if (
d->fName ==
"xrd.protocol") {
1497 }
else if (
d->fName ==
"filterlibpaths") {
1499 }
else if (
d->fName ==
"xrootd") {
1502 TRACE(
XERR,
"unknown directive: " <<
d->fName);
1511 XPDLOC(
ALL,
"Manager::DoDirectiveTrace")
1548 while (val && val[0]) {
1550 if (val[0] ==
'-') {
1554 if (!
strcmp(val,
"err")) {
1556 }
else if (!
strcmp(val,
"req")) {
1558 }
else if (!
strcmp(val,
"dbg")) {
1563 }
else if (!
strcmp(val,
"login")) {
1565 }
else if (!
strcmp(val,
"fork")) {
1567 }
else if (!
strcmp(val,
"mem")) {
1569 }
else if (!
strcmp(val,
"hdbg")) {
1575 }
else if (!
strcmp(val,
"rsp")) {
1577 }
else if (!
strcmp(val,
"aux")) {
1579 }
else if (!
strcmp(val,
"cmgr")) {
1581 }
else if (!
strcmp(val,
"smgr")) {
1583 }
else if (!
strcmp(val,
"nmgr")) {
1585 }
else if (!
strcmp(val,
"pmgr")) {
1587 }
else if (!
strcmp(val,
"gmgr")) {
1589 }
else if (!
strcmp(val,
"sched")) {
1591 }
else if (!
strcmp(val,
"all") || !
strcmp(val,
"dump")) {
1598 val = cfg->GetWord();
1609 XPDLOC(
ALL,
"Manager::DoDirectiveGroupfile")
1624 TRACE(
XERR,
"groups manager already initialized: ignoring ");
1689 XrdOucString s = val;
1691 XrdOucString
grp, gid;
1695 if (
grp.beginswith(
'-')) {
1697 grp.erasefromstart(1);
1702 gid.form(
"%d", (
int)
gi.fGid);
1731 XrdOucString s = val;
1737 if (
usr.beginswith(
'-')) {
1739 usr.erasefromstart(1);
1765 XrdOucString
tval(val);
1766 if (
tval ==
"supermaster") {
1769 }
else if (
tval ==
"master") {
1771 }
else if (
tval ==
"submaster") {
1773 }
else if (
tval ==
"worker") {
1775 }
else if (
tval ==
"any") {
1791 XrdOucString port(val);
1792 if (port.beginswith(
"xproofd:")) {
1793 port.replace(
"xproofd:",
"");
1795 if (port.length() > 0 && port.isdigit()) {
1808 XPDLOC(
ALL,
"Manager::DoDirectiveMultiUser")
1815 int mu =
strtol(val, 0, 10);
1819 val = cfg->GetWord();
1840 while ((
nxt = cfg->GetWord())) {
1846 if (
u.Proto ==
"" &&
u.HostWPort ==
"")
local = 1;
1858 std::list<XrdProofdDSInfo *>::iterator
ii =
fDataSetSrcs.begin();
1861 if ((*ii)->fLocal) {
1867 if (
opts.length() <= 0) {
1868 opts =
rw ?
"Ar:Av:" :
"-Ar:-Av:";
1896 while ((
nxt = cfg->GetWord()) && (
opts.length() == 0)) {
1917 XPDLOC(
ALL,
"Manager::DoDirectiveXrootd")
1925 TRACE(
ALL,
"WARNING: built against an XRootD version without libXrdXrootd.so :");
1926 TRACE(
ALL,
"WARNING: loading external " << val <<
" may lead to incompatibilities");
1942 XPDLOC(
ALL,
"Manager::DoDirectiveRootd")
1957 XPDLOC(
ALL,
"Manager::DoDirectiveRootdAllow")
1971 XPDLOC(
ALL,
"Manager::DoDirectiveRemoveLibPaths")
1989 while ((
nxt = cfg->GetWord())) {
1993 if (
p.length() > 0) {
2014 TRACEP(
p,
REQ,
"req id: " <<
p->Request()->header.requestid <<
" (" <<
2019 switch (
p->Request()->header.requestid) {
2025 TRACEP(
p,
XERR,
"invalid request: " <<
p->Request()->header.requestid);
2027 return p->Link()->setEtext(
"protocol sequence error 1");
2033 switch (
p->Request()->header.requestid) {
2046 emsg +=
"Invalid request: ";
2047 emsg +=
p->Request()->header.requestid;
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 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 type
#define kXPD_OpModeControlled
const char *const XPD_GW_QueryEnqueued
XrdProofSched *(* XrdProofSchedLoader_t)(const char *, XrdProofdManager *, XrdProofGroupMgr *, const char *, XrdOucError *)
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 int RemoveInvalidUsers(const char *k, int *, void *s)
Add the key value in the string passed via the void argument.
void * XrdProofdManagerCron(void *p)
This is an endless loop to periodically check the system.
static int FillKeyValues(const char *k, int *d, void *s)
Add the key value in the string passed via the void argument.
XrdProtocol *(* XrdProtocolLoader_t)(const char *, char *, XrdProtocol_Config *)
#define XPD_SETRESP(p, x)
#define TRACEP(p, act, x)
#define TRACESET(act, on)
R__EXTERN XrdOucTrace * XrdProofdTrace
#define XrdSysMutexHelper
const_iterator begin() const
const_iterator end() const
void Print(const char *grp)
Return a string describing the group.
int Config(const char *fn)
(Re-)configure the group info using the file 'fn'.
virtual int GetWorkers(XrdProofdProofServ *xps, std::list< XrdProofWorker * > *, const char *)
Get a list of workers that can be used by session 'xps'.
virtual int Config(bool rcf=0)
Configure this instance using the content of file 'cfn'.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int Process(XrdProofdProtocol *p, int type)
Process admin request.
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 const char * ProofRequestTypes(int type)
Translates the proof request type in a human readable string.
static int GetGroupInfo(const char *grp, XrdProofGI &gi)
Get information about group with 'gid' in a thread safe way.
static int ChangeMod(const char *path, unsigned int mode)
Change the permission mode of 'path' to 'mode'.
static int CheckIf(XrdOucStream *s, const char *h)
Check existence and match condition of an 'if' directive If none (valid) is found,...
static char * Expand(char *p)
Expand path 'p' relative to: $HOME if begins with ~/ <user>'s $HOME if begins with ~<user>/ $PWD if d...
int Auth(XrdProofdProtocol *xp)
Analyse client authentication info.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int Login(XrdProofdProtocol *xp)
Process a login request.
virtual int Config(bool rcf=0)
void Register(const char *dname, XrdProofdDirective *d)
const char * CfgFile() const
int DoDirectiveRootd(char *, XrdOucStream *, bool)
Process 'rootd' directive xpd.rootd deny|allow [rootsys:<tag>] [path:abs-path/] [mode:ro|rw] [auth:no...
int GetWorkers(XrdOucString &workers, XrdProofdProofServ *, const char *)
Get a list of workers from the available resource broker.
XrdProofdPriorityMgr * fPriorityMgr
int DoDirectiveRole(char *, XrdOucStream *, bool)
Process 'role' directive.
int DoDirectiveDataSetSrc(char *, XrdOucStream *, bool)
Process 'datasetsrc' directive.
XrdProofdProofServMgr * fSessionMgr
XrdOucString fStageReqRepo
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
XrdOucString fSockPathDir
int Process(XrdProofdProtocol *p)
Process manager request.
XrdProofSched * LoadScheduler()
Load PROOF scheduler.
virtual ~XrdProofdManager()
Destructor.
XrdOucString fDataDirUrlOpts
int DoDirectiveMaxOldLogs(char *, XrdOucStream *, bool)
Process 'maxoldlogs' directive.
int DoDirectiveAllowedGroups(char *, XrdOucStream *, bool)
Process 'allowedgroups' directive.
int DoDirectiveMultiUser(char *, XrdOucStream *, bool)
Process 'multiuser' directive.
XrdProofGroupMgr * fGroupsMgr
XrdOucString fEffectiveUser
const char * Host() const
int DoDirectiveFilterLibPaths(char *, XrdOucStream *, bool)
Process 'filterlibpaths' directive xpd.filterlibpaths 1|0 [path1,path2 path3 path4 ....
int DoDirectivePort(char *, XrdOucStream *, bool)
Process 'xrd.protocol' directive to find the port.
XrdOucHash< int > fAllowedGroups
XrdProofdNetMgr * fNetMgr
int DoDirectiveDataDir(char *, XrdOucStream *, bool)
Process 'datadir' directive.
void CheckLogFileOwnership()
Make sure that the log file belongs to the original effective user.
XrdSysPlugin * fXrootdPlugin
int DoDirectiveRootdAllow(char *, XrdOucStream *, bool)
Process 'rootdallow' directive xpd.rootdallow host1,host2 host3 Host names may contain the wild card ...
XrdOucHash< int > fAllowedUsers
bool CheckMaster(const char *m)
Check if master 'm' is allowed to connect to this host.
void RegisterDirectives()
Register directives for configuration.
XrdOucHash< XrdOucString > fLibPathsToRemove
XrdProtocol * LoadXrootd(char *parms, XrdProtocol_Config *pi, XrdSysError *edest)
Load the Xrootd protocol, if required.
XrdProofdManager(char *parms, XrdProtocol_Config *pi, XrdSysError *edest)
Constructor.
XrdOucString fBareLibPath
int DoDirectiveGroupfile(char *, XrdOucStream *, bool)
Process 'groupfile' directive.
int DoDirectiveTrace(char *, XrdOucStream *, bool)
Scan the config file for tracing settings.
std::list< XrdProofdDSInfo * > fDataSetSrcs
int DoDirectiveAllowedUsers(char *, XrdOucStream *, bool)
Process 'allowedusers' directive.
std::list< XrdOucString * > fMastersAllowed
const char * WorkDir() const
int CheckUser(const char *usr, const char *grp, XrdProofUI &ui, XrdOucString &e, bool &su)
Check if the user is allowed to use the system Return 0 if OK, -1 if not.
XrdOucString fDataDirOpts
bool ValidateLocalDataSetSrc(XrdOucString &url, bool &local)
Validate local dataset src at URL (check the URL and make the relevant directories).
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
XrdProofSched * fProofSched
XrdOucString fXrootdLibPath
int DoDirectiveXrootd(char *, XrdOucStream *, bool)
Process 'xrootd' directive xpd.xrootd [path/]libXrdXrootd.so.
XrdProofdClientMgr * fClientMgr
int DoDirectiveAllow(char *, XrdOucStream *, bool)
Process 'allow' directive.
int ResolveKeywords(XrdOucString &s, XrdProofdClient *pcl)
Resolve special keywords in 's' for client 'pcl'.
bool WorkerUsrCfg() const
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int ReadBuffer(XrdProofdProtocol *p)
Process a readbuf request.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int Process(XrdProofdProtocol *p)
Process manager request.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
static int EUidAtStartup()
static void SetWorkdir(const char *wdir)
static void SetMaxOldSessions(int mxses)
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
void SetLogDir(const char *d)
Set the log dir.