24#if ROOTXRDVERS < ROOT_OldXrdOuc
25# define XPD_LOG_01 OUC_LOG_01
27# define XPD_LOG_01 SYS_LOG_01
32#include "Xrd/XrdBuffer.hh"
34#include "XrdNet/XrdNetAddrInfo.hh"
36#include "XrdOuc/XrdOucErrInfo.hh"
37#include "XrdOuc/XrdOucStream.hh"
38#include "XrdSec/XrdSecInterface.hh"
39#include "XrdSys/XrdSysPlugin.hh"
75 TRACE(
REQ,
"undefined client manager: cannot start");
80 TRACE(
REQ,
"undefined session manager: cannot start");
96 if ((
rc =
mgr->Pipe()->Recv(
msg)) != 0) {
97 XPDERR(
"problems receiving message; errno: "<<-
rc);
104 TRACE(
XERR,
"obsolete type: XrdProofdClientMgr::kClientDisconnect");
141 TRACE(
XERR,
"unable to generate the pipe");
173 if (
d->fName ==
"clientmgr") {
186 XPDLOC(
SMGR,
"ClientMgr::DoDirectiveClientMgr")
196 XrdOucString
tok(val);
197 if (
tok.beginswith(
"checkfq:")) {
198 tok.replace(
"checkfq:",
"");
200 }
else if (
tok.beginswith(
"activityto:")) {
201 tok.replace(
"activityto:",
"");
205 val = cfg->GetWord();
234 XPDERR(
"problems parsing file ");
239 msg = (
rcf) ?
"re-configuring" :
"configuring";
258 XPDERR(
"problems parsing previous active clients: "<<
msg);
264 TRACE(
ALL,
"XRD seclib not specified; strong authentication disabled");
267 XPDERR(
"unable to load security system.");
270 TRACE(
ALL,
"security library loaded");
277 std::list<XrdProofdClient *>::iterator
pci;
290 (
void *)&
fManagerCron, 0,
"ClientMgr cron thread") != 0) {
291 XPDERR(
"could not start cron thread");
315 if (
p->Request()->login.role[0] !=
'i' &&
319 "ignoring request ("<<
p->Link()->Host()<<
")");
321 "master not allowed to connect - request ignored");
360 TRACE(
ALL,
" hostname: '"<<
p->Link()->Host()<<
"'");
364 !
strcmp(
p->Link()->Host(),
"localhost") ||
365 !
strcmp(
p->Link()->Host(),
"127.0.0.0")) ? 1 : 0;
370 switch (
p->Request()->login.role[0]) {
373 response->SetTag(
"adm");
377 response->SetTag(
"int");
383 response->SetTag(
"m2c");
385 TRACEP(
p,
XERR,
"top master mode not allowed - ignoring request");
387 "Server not allowed to be top master - ignoring request");
395 response->SetTag(
"m2m");
397 TRACEP(
p,
XERR,
"submaster mode not allowed - ignoring request");
399 "Server not allowed to be submaster - ignoring request");
407 response->SetTag(
"m2l");
408 p->Request()->login.role[0] =
'm';
410 TRACEP(
p,
XERR,
"PLite submaster mode not allowed - ignoring request");
412 "Server not allowed to be PLite submaster - ignoring request");
420 response->SetTag(
"w2m");
422 TRACEP(
p,
XERR,
"worker mode not allowed - ignoring request");
424 "Server not allowed to be worker - ignoring request");
429 TRACEP(
p,
XERR,
"unknown mode: '" <<
p->Request()->login.role[0] <<
"'");
433 response->SetTraceID();
436 pid = (
int)
ntohl(
p->Request()->login.pid);
441 for (i = 0; i < (
int)
sizeof(
un)-1; i++) {
442 if (
p->Request()->login.username[i] ==
'\0' ||
p->Request()->login.username[i] ==
' ')
444 un[i] =
p->Request()->login.username[i];
450 if (
uname ==
"?>buf") {
452 char *buf =
p->Argp()->buff;
453 int len =
p->Request()->login.dlen;
473 p->SetGroupIn(
gname.c_str());
477 p->SetUserIn(
uname.c_str());
480 p->Link()->setID(
uname.c_str(), pid);
482 response->SetTraceID();
483 p->SetClntCapVer(
p->Request()->login.capver[0]);
492 const char *pp =
fCIA->getParms(i,
p->Link()->Name());
525 const char *user, XrdOucString &
emsg)
530 emsg =
"protocol object undefined!";
536 if (
p &&
p->AuthProt() &&
strlen(
p->AuthProt()->Entity.name) > 0) {
537 uname =
p->AuthProt()->Entity.name;
539 emsg =
"username not passed and not available in the protocol security entity - failing";
547 if (
gname.length() > 0) {
552 }
else if (
strncmp(
g->Name(),
"default",7) &&
553 !
g->HasMember(
uname.c_str())) {
564 gname =
g ?
g->Name() :
"default";
573 if (
emsg.length() <= 0)
574 XPDFORM(
emsg,
"Controlled access: user '%s', group '%s' not allowed to connect",
594 c->SetGroup(
gname.c_str());
597 emsg =
"unable to instantiate object for client ";
635 TRACEP(
p,
DBG,
"cannot find valid instance of XrdProofdClient");
637 "MapClient: cannot find valid instance of XrdProofdClient");
649 memcpy(&
psid, (
const void *)&(
p->Request()->login.reserved[0]), 2);
651 TRACEP(
p,
XERR,
"proofsrv callback: sent invalid session id");
653 "MapClient: proofsrv callback: sent invalid session id");
656 protver =
p->Request()->login.capver[0];
668 TRACEP(
p,
XERR,
"proofsrv callback: wrong target session: "<<
psid<<
" : protocol error");
669 response->Send(
kXP_nosession,
"MapClient: proofsrv callback:"
670 " wrong target session: protocol error");
678 TRACEP(
p,
XERR,
"proofsrv callback: could not get XrdProofdResponse object");
679 response->Send(
kXP_nosession,
"MapClient: proofsrv callback: memory issue?");
689 TRACEI(
resp->TraceID(),
DBG,
"proofsrv callback: link assigned to target session "<<
psid);
731 p->SetAdminPath(
cpath.c_str());
740 const char *
srvtype[6] = {
"ANY",
"MasterWorker",
"MasterMaster",
741 "ClientMaster",
"Internal",
"Admin"};
743 p->SuperUser() ?
" (privileged)" :
"",
srvtype[
p->ConnType()+1]);
757 if (!
p || !
p->Link()) {
797 XPDFORM(
emsg,
"CheckAdminPath: invalid inputs (p: %p)",
p);
822 XPDFORM(
emsg,
"CheckAdminPath: reconnection timeout expired: remove %s ",
825 XPDFORM(
emsg,
"CheckAdminPath: problems stat'ing %s (errno: %d): remove ",
828 emsg +=
": failure!";
844 XPDLOC(
CMGR,
"ClientMgr::ParsePreviousClients")
854 TRACE(
DBG,
"creating holders for active clients ...");
861 if (!
strcmp(ent->d_name,
".") || !
strcmp(ent->d_name,
".."))
continue;
869 grp.erase(0,
grp.find(
'.')+1);
874 XPDFORM(
emsg,
"ParsePreviousClients: could not get client instance"
875 " for {%s, %s}",
usr.c_str(),
grp.c_str());
890 if (!
strcmp(
sent->d_name,
"xpdsock"))
continue;
902 if (!
xrm &&
c->ReserveClientID(cid) != 0)
923 emsg +=
": failure!";
937 emsg +=
": failure!";
963 TRACE(
REQ,
"checking active clients ...");
971 if (!
strcmp(ent->d_name,
".") || !
strcmp(ent->d_name,
".."))
continue;
981 TRACE(
XERR,
"instance for client "<<ent->d_name<<
" not found!");
996 if (!
strcmp(
sent->d_name,
"xpdsock"))
continue;
1013 if (
c->Touch() == 1) {
1033 if (
p &&
p->Link()) {
1036 c->SkipSessionsCheck(0,
emsg);
1040 TRACE(
XERR,
"protocol or link associated with ID "<<cid<<
" are invalid");
1050 discpath.replace(
"/disconnected",
"");
1096 return response->Send();
1097 cred.size =
p->Request()->header.dlen;
1098 cred.buffer =
p->Argp()->buff;
1101 if (!
p->AuthProt()) {
1116 p->AuthProt()->Entity.tident =
p->Link()->ID;
1120 char *
u =
new char[
len];
1129 if (
p->AuthProt()->Entity.name &&
strlen(
p->AuthProt()->Entity.name) > 0) {
1130 if (
p->UserIn() &&
strlen(
p->UserIn()) > 0) {
1131 XrdOucString
usrs(
p->AuthProt()->Entity.name);
1137 if (!(
p->AuthProt()->Entity.name))
1138 p->AuthProt()->Entity.name =
strdup(
usr.c_str());
1139 if ((
usr ==
p->UserIn())) {
1140 free(
p->AuthProt()->Entity.name);
1141 p->AuthProt()->Entity.name =
strdup(
usr.c_str());
1147 namsg =
"logging as '";
1148 namsg +=
p->AuthProt()->Entity.name;
1149 namsg +=
"' instead of '";
1151 namsg +=
"' following admin settings";
1153 namsg.insert(
"Warning: ", 0);
1157 TRACEP(
p,
XERR,
"user name is empty: protocol error?");
1160 TRACEP(
p,
XERR,
"name of the authenticated entity is empty: protocol error?");
1165 const char *
msg = (
p->Status() &
XPD_ADMINUSER) ?
" admin login as " :
" login as ";
1166 rc = response->Send();
1167 char status =
p->Status();
1169 p->SetStatus(status);
1170 p->SetAuthEntity(&(
p->AuthProt()->Entity));
1171 if (
p->AuthProt()->Entity.name) {
1188 if (
p->AuthProt()) {
1189 p->AuthProt()->Delete();
1192 TRACEP(
p,
XERR,
"security requested additional auth w/o parms!");
1198 if (
p->AuthProt()) {
1199 p->AuthProt()->Delete();
1222 TRACE(
XERR,
"config file not specified");
1247 TRACE(
XERR,
"no security directives: strong authentication disabled");
1251 TRACE(
XERR,
"creating temporary config file");
1258 TRACE(
XERR,
"Unable to create security service object via " <<
seclib);
1265 TRACE(
ALL,
"strong authentication enabled");
1289 static const char *
pfx[] = {
"xpd.sec.",
"sec.protparm",
"sec.protocol",
"set" };
1333 if (
slin.beginswith(
"xpd."))
slin.replace(
"xpd.",
"");
1343 if (fd >= 0) close(fd);
1363 std::list<XrdProofdClient *>::iterator i;
1367 if ((
c = *i) &&
c->Match(
usr,
grp))
break;
1385 if (
c &&
c->IsValid()) {
1390 c->SetGroup(
g->Name());
1411 XPDFORM(
dmsg,
"instance for {client, group} = {%s, %s} created"
1412 " and added to the list (%p)",
usr,
grp,
c);
1429 if (
c->TrimSessionDirs() != 0) {
1436 if (
dmsg.length() > 0) {
1456 std::list<XrdProofdClient *> *
clnts;
1461 clnts =
new std::list<XrdProofdClient *>;
1467 std::list<XrdProofdClient *>::iterator i;
1489 std::list<XrdProofdClient *> *
clnts;
1495 clnts =
new std::list<XrdProofdClient *>;
1502 std::list<XrdProofdClient *>::iterator i;
1519 buf.c_str())) != 0) {
1520 TRACE(
XERR,
"problem posting the pipe; errno: "<<-
rc);
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
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 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
#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.
XrdSecService *(* XrdSecServLoader_t)(XrdSysLogger *, const char *cfn)
void * XrdProofdClientCron(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 TRACEI(id, act, x)
#define TRACEP(p, act, x)
#define XrdSysMutexHelper
const_iterator begin() const
const_iterator end() const
XrdProofGroup * GetGroup(const char *grp)
Returns the instance of for group 'grp.
XrdProofGroup * GetUserGroup(const char *usr, const char *grp=0)
Returns the instance of the first group to which this user belongs; if grp != 0, return the instance ...
const char * Name() const
static int GetUserInfo(const char *usr, XrdProofUI &ui)
Get information about user 'usr' in a thread safe way.
static int ParseUsrGrp(const char *path, XrdOucString &usr, XrdOucString &grp)
Parse a path in the form of "<usr>[.<grp>][.<pid>]", filling 'usr' and 'grp'.
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 GetIDFromPath(const char *path, XrdOucString &emsg)
Extract an integer from a file.
static int Write(int fd, const void *buf, size_t nb)
Write nb bytes at buf to descriptor 'fd' ignoring interrupts Return the number of bytes written or -1...
static int RmDir(const char *path)
Remove directory at path and its content.
static int CheckIf(XrdOucStream *s, const char *h)
Check existence and match condition of an 'if' directive If none (valid) is found,...
int Auth(XrdProofdProtocol *xp)
Analyse client authentication info.
XrdOucString fClntAdminPath
int CreateAdminPath(XrdProofdProtocol *p, XrdOucString &path, XrdOucString &e)
Create the client directory in the admin path.
int CheckAdminPath(XrdProofdProtocol *p, XrdOucString &cidpath, XrdOucString &emsg)
Check the old-clients admin for an existing entry for this client and read the client ID;.
int CheckClients()
Regular checks of the client admin path; run by the cron job.
char * FilterSecConfig(int &nd)
Grep directives of the form "xpd.sec...", "sec.protparm" and "sec.protocol" from file 'cfn' and save ...
int CheckClient(XrdProofdProtocol *p, const char *user, XrdOucString &emsg)
Perform checks on the client username.
XrdProofdClientMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
std::list< XrdProofdClient * > fProofdClients
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.
XrdSysPlugin * fSecPlugin
void Broadcast(XrdProofdClient *c, const char *msg)
Broadcast message 'msg' to the connected instances of client 'clnt' or to all connected instances if ...
void TerminateSessions(XrdProofdClient *c, const char *msg, int srvtype)
Terminate sessions of client 'clnt' or to of all clients if clnt == 0.
int ParsePreviousClients(XrdOucString &emsg)
Client entries for the clients still connected when the daemon terminated.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int MapClient(XrdProofdProtocol *xp, bool all=1)
Process a login request.
int DoDirectiveClientMgr(char *, XrdOucStream *, bool)
Process 'clientmgr' directive eg: xpd.clientmgr checkfq:120 activityto:600.
void RegisterDirectives()
Register directives for configuration.
int Login(XrdProofdProtocol *xp)
Process a login request.
XrdSecService * LoadSecurity()
Load security framework and plugins, if not already done.
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
XrdSysRecMutex * Mutex() const
int GetClientID(XrdProofdProtocol *p)
Get next free client ID.
const char * User() const
XrdProofdProofServ * GetServer(int psid)
Get from the vector server instance with ID psid.
int SetClientID(int cid, XrdProofdProtocol *p)
Set slot cid to instance 'p'.
bool Match(const char *usr, const char *grp=0)
return TRUE if this instance matches 'id' (and 'grp', if defined)
virtual int Config(bool rcf=0)
void Register(const char *dname, XrdProofdDirective *d)
const char * CfgFile() const
XrdROOTMgr * ROOTMgr() const
XrdProofGroupMgr * GroupsMgr() const
const char * Host() const
bool CheckMaster(const char *m)
Check if master 'm' is allowed to connect to this host.
const char * TMPdir() const
const char * EffectiveUser() 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.
XrdProofdProofServMgr * SessionMgr() const
const char * AdminPath() const
int ResolveKeywords(XrdOucString &s, XrdProofdClient *pcl)
Resolve special keywords in 's' for client 'pcl'.
int Post(int type, const char *msg)
Post message on the pipe.
XrdROOT * DefaultVersion() const