47#define kMAXPATHLEN 4096
57 const std::string &
creds,
const std::string &
dsrcs,
58 const std::string &
ddir,
const std::string &
ddiro,
59 const std::string &
ord,
const std::string &
stag);
61 const std::string &logfile,
const std::string &
rcfile);
94 Info(
"argc=%d: at least 2 additional argument (the process type and debug level) are required - exit",
99 Info(
"ERROR: invalid process type %d (must be > 0) - exit",
gType);
108 }
else if (
gType == 20) {
110 Info(
"ERROR: 'rootd' has been removed from ROOT");
113 Info(
"ERROR: process type %d not yet implemented",
gType);
127 Info(
"argc=%d: at least 5 additional arguments required - exit",
argc);
147 Info(
"FATAL: could not open '%s' for error logging - errno: %d",
157 std::string user =
argv[3];
160 Info(
"ERROR: could noy get identity info for '%s' - errno: %d", user.c_str(), (
int)
errno);
166 std::string::size_type
loc = 0;
188 Info(
"ERROR: could not assert dir '%s'",
sessdir.c_str());
194 while ((
loc = logfile.find(
"<pid>")) != std::string::npos) { logfile.replace(
loc, 5,
spid); }
202 Info(
"ERROR: could not assert dir '%s'",
userdir.c_str());
207 if ((
loc =
stag.rfind(
'/')) != std::string::npos)
stag.erase(0,
loc);
209 if (
loc != std::string::npos)
stag.erase(0,
loc+1);
210 Info(
"session tag: %s",
stag.c_str());
216 Info(
"ERROR: failure calling back parent on '%s'",
sockpath.c_str());
224 Info(
"ERROR: failure sending pid to parent (errno: %d)", -
rcc);
232 Info(
"ERROR: failure receiving admin path and executable from parent (errno: %d)", -
rcc);
247 Info(
"ERROR: failure receiving information about dataset and data dir(s) from parent (errno: %d)", -
rcc);
262 Info(
"ERROR: problems setting relevant user ownerships");
269 Info(
"ERROR: problems renaming '%s' to '%s' (errno: %d)",
276 Info(
"ERROR: problems renaming '%s' to '%s' (errno: %d)",
284 Info(
"ERROR: problems completing '%s'",
rcfile.c_str());
290 Info(
"ERROR: problems setting environment from '%s'",
envfile.c_str());
297 Info(
"ERROR: problems exporting file descriptor");
305 Info(
"ERROR: problems login user '%s' in", user.c_str());
312 Info(
"ERROR: problems redirecting logs to '%s'", logfile.c_str());
318 char *
argvv[6] = {0};
338 argvv[1] = (
char *)((
gType == 0) ?
"proofslave" :
"proofserv");
339 argvv[2] = (
char *)
"xpd";
358 Info(
"ERROR: returned from execv: bad, bad sign !!!");
368 Info(
"loginuser: ERROR: can't change directory to %s, euid: %d, uid: %d; errno: %d",
374 size_t len =
home.length() + 8;
375 char *
h =
new char[
len];
381 char *
u =
new char[
len];
391 Info(
"loginuser: ERROR: could not get required privileges");
399 Info(
"loginuser: acquiring target user identity (%d,%d)", uid, gid);
400 if (rpdpriv::changeperm(uid, gid) != 0) {
401 Info(
"loginuser: ERROR: can't acquire '%s' identity", user.c_str());
416 if (path.length() <= 0)
return -1;
420 Info(
"assertdir: ERROR: could not get privileges (errno: %d)",
errno);
426 Info(
"assertdir: ERROR: unable to create path: %s (errno: %d)", path.c_str(),
errno);
430 if (
chown(path.c_str(),
u,
g) == -1) {
431 Info(
"assertdir: ERROR: unable to set ownership on path: %s (errno: %d)", path.c_str(),
errno);
446 if (
from.length() <= 0 ||
to.length() <= 0)
return -1;
450 Info(
"mvfile: ERROR: could not get privileges (errno: %d)",
errno);
456 Info(
"mvfile: ERROR: unable to rename '%s' to '%s' (errno: %d)",
from.c_str(),
to.c_str(),
errno);
461 if (chmod(
to.c_str(),
mode) == -1) {
462 Info(
"mvfile: ERROR: unable to set mode %o on path: %s (errno: %d)",
mode,
to.c_str(),
errno);
468 Info(
"mvfile: ERROR: unable to set ownership on path: %s (errno: %d)",
to.c_str(),
errno);
484 Info(
"completercfile: ERROR: unable to open rc file: '%s' (errno: %d)",
rcfile.c_str(),
errno);
507 const std::string &logfile,
const std::string &
rcfile)
509 if (
envfile.length() <= 0)
return -1;
514 len = logfile.length() +
strlen(
"ROOTPROOFLOGFILE") + 4;
515 h =
new char[
len + 1];
516 snprintf(
h,
len + 1,
"ROOTPROOFLOGFILE=%s", logfile.c_str());
519 Info(
"setproofservenv: set '%s'",
h);
522 h =
new char[
len + 1];
526 Info(
"setproofservenv: set '%s'",
h);
528 std::fstream
fin(
envfile.c_str(), std::ios::in);
530 Info(
"setproofservenv: ERROR: unable to open env file: %s (errno: %d)",
envfile.c_str(),
errno);
538 if (
line.length() > 0) {
539 h =
new char[
line.length() + 1];
543 Info(
"setproofservenv: set '%s'",
h);
560 if (!conn || (conn && !conn->isvalid(0))) {
561 Info(
"exportsock: ERROR: connection is %s", (conn ?
"invalid" :
"undefined"));
566 int d = conn->exportfd();
569 if (
d == 0 ||
d == 1 ||
d == 2) {
572 while (
natt > 0 && (fd =
dup(
d)) <= 2) {
573 if (fd >= 0 && fd !=
d) close(fd);
577 if (
natt <= 0 && fd <= 2) {
578 Info(
"exportsock: ERROR: no free filedescriptor!");
605 Info(
"redirectoutput: enter: %s", logfile.c_str());
607 if (logfile.length() <= 0) {
608 Info(
"redirectoutput: ERROR: logfile path undefined");
613 Info(
"redirectoutput: reopen %s", logfile.c_str());
616 Info(
"redirectoutput: ERROR: could not freopen stdout (errno: %d)",
errno);
621 Info(
"redirectoutput: dup2 ...");
623 Info(
"redirectoutput: ERROR: could not redirect stderr (errno: %d)",
errno);
632 int len =
strlen(
"ROOTPROOFDONOTREDIR=2");
638 Info(
"redirectoutput: done!");
648 const std::string &
creds,
const std::string &
dsrcs,
649 const std::string &
ddir,
const std::string &
ddiro,
650 const std::string &
ord,
const std::string &
stag)
655 Info(
"setownerships: ERROR: problems getting 'struct passwd' for"
656 " uid: %d (errno: %d)",
euid, (
int)
errno);
660 Info(
"setownerships: ERROR: problems getting 'struct passwd' for"
661 " user: '%s' (errno: %d)", us.c_str(), (
int)
errno);
667 if (
dsrcs.length() > 0) {
669 std::string::size_type
loc =
dsrcs.find(
',', 0);
671 if (
loc != std::string::npos)
dsrc.erase(
loc, std::string::npos);
672 if (
dsrc.length() > 0) {
679 Info(
"setownerships: ERROR: problems asserting '%s' in mode 0755"
680 " (errno: %d)",
d.c_str(), (
int)
errno);
683 Info(
"setownerships: ERROR: problems asserting '%s' in mode 0777"
684 " (errno: %d)",
d.c_str(), (
int)
errno);
689 }
while ((
loc =
dsrcs.find(
',',
loc)) != std::string::npos);
694 if (
ddir.length() > 0 &&
ord.length() > 0 &&
stag.length() > 0) {
699 unsigned int mode = 0755;
700 if (
ddiro.find(
'g') != std::string::npos)
mode = 0775;
701 if (
ddiro.find(
'a') != std::string::npos ||
702 ddiro.find(
'o') != std::string::npos)
mode = 0777;
713 Info(
"setownerships: ERROR: problems asserting '%s' in mode %o"
716 Info(
"setownerships: ERROR: problems asserting '%s' in mode 0777"
717 " (errno: %d)",
dgr.c_str(), (
int)
errno);
722 if (
creds.length() > 0) {
724 Info(
"setownerships: ERROR: problems changing owenership of '%s'",
creds.c_str());
740 if (path.length() <= 0)
return -1;
746 std::string
proot(path);
751 if (ent->d_name[0] ==
'.' || !
strcmp(ent->d_name,
".."))
continue;
757 Info(
"changeown: ERROR: problems changing recursively ownership of '%s'",
769 Info(
"changeown: ERROR: problems opening '%s' (errno: %d)",
770 path.c_str(), (
int)
errno);
776 Info(
"changeown: ERROR: could not get privileges (errno: %d)",
errno);
780 if (
chown(path.c_str(),
u,
g) == -1) {
781 Info(
"changeown: ERROR: cannot set user ownership on path '%s' (errno: %d)",
782 path.c_str(),
errno);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
int exportsock(rpdunix *conn)
Export the descriptor of 'conn' so that it can used in the execv application.
int setownerships(int euid, const std::string &us, const std::string &gr, const std::string &creds, const std::string &dsrcs, const std::string &ddir, const std::string &ddiro, const std::string &ord, const std::string &stag)
Set user ownerships on some critical files or directories.
int completercfile(const std::string &rcfile, const std::string &sessdir, const std::string &stag, const std::string &adminpath)
Finalize the rc file with the missing pieces.
int setproofservenv(const std::string &envfile, const std::string &logfile, const std::string &rcfile)
Initialize the environment following the content of 'envfile'.
int redirectoutput(const std::string &logfile)
Redirect stdout to 'logfile' On success return 0.
void Info(const char *fmt,...)
Write info message to syslog.
int assertdir(const std::string &path, uid_t u, gid_t g, unsigned int mode)
Make sure that 'path' exists, it is owned by the entity described by {u,g} and its mode is 'mode'.
int mvfile(const std::string &from, const std::string &to, uid_t u, gid_t g, unsigned int mode)
Move file form 'from' to 'to', making sure that it is owned by the entity described by {u,...
int loginuser(const std::string &home, const std::string &user, uid_t u, gid_t g)
Login the user in its space.
void start_ps(int argc, char **argv)
Process a request to start a proofserv process.
int changeown(const std::string &path, uid_t u, gid_t g)
Change the ownership of 'path' to the entity described by {u,g}.