49 Info(
"Notify",
"Processing interrupt signal ...");
61static const char *
gScriptCmd =
"\\\"%s %d localhost:%d/%s -d=%d\\\"";
63static const char *
gSshCmd =
"ssh %s -f4 %s -R %d:localhost:%d sh -c \
64 \"'(sh=\\`basename \'\\\\\\$SHELL\'\\`; \
65 if test xbash = x\'\\\\\\$sh\' -o xsh = x\'\\\\\\$sh\' -o xzsh = x\'\\\\\\$sh\' -o xdash = x\'\\\\\\$sh\'; then \
66 \'\\\\\\$SHELL\' -l -c %s; \
67 elif test xcsh = x\'\\\\\\$sh\' -o xtcsh = x\'\\\\\\$sh\' -o xksh = x\'\\\\\\$sh\'; then \
68 \'\\\\\\$SHELL\' -c %s; \
70 echo \\\"Unknown shell \'\\\\\\$SHELL\'\\\"; \
73static const char *
gSshCmd =
"ssh %s -f4 %s -R %d:localhost:%d sh -c \
74 \"'(sh=`basename $SHELL`; \
75 if test xbash = x$sh -o xsh = x$sh -o xzsh = x$sh -o xdash = x$sh; then \
77 elif test xcsh = x$sh -o xtcsh = x$sh -o xksh = x$sh; then \
80 echo \"Unknown shell $SHELL\"; \
120 std::default_random_engine randomEngine(now);
124 port = randomPort(randomEngine);
130 Error(
"TApplicationRemote",
"unable to find a free port for connections");
142 if (script && *script) {
144 if (script[1] ==
'<') {
148 Error(
"TApplicationRemote",
"illegal script name <");
156 const char *verb =
"";
169 Info(
"TApplicationRemote",
"executing: %s", cmd.
Data());
171 Info(
"TApplicationRemote",
"an error occured during SSH connection");
185 Error(
"TApplicationRemote",
"failed to open connection");
199 Error(
"TApplicationRemote",
"failed to receive startup message");
208 Error(
"TApplicationRemote",
"failed to receive remote server protocol");
214 Info(
"TApplicationRemote",
"server runs a different protocol version: %d (vs %d)",
220 Error(
"TApplicationRemote",
"failed to receive server info - protocol error");
240 gROOT->GetListOfSockets()->Add(
this);
257 gROOT->GetListOfSockets()->Remove(
this);
270 Error(
"Broadcast",
"could not send message");
312 Error(
"Broadcast",
"could not send raw buffer");
356 Info(
"Collect",
"deactivating %p",
s);
370 if (
s == (
TSocket *)(-1) && nto > 0)
418 Info(
"CollectInput",
"what %d", what);
445 gROOT->RefreshBrowsers();
458 Info(
"CollectInput",
"type %d",
type);
470 "server requested an object that we do not have");
496 Info(
"CollectInput",
"kRTT_LogDone: status %d", st);
504 (*mess) >> msg >> lfeed;
506 fprintf(stderr,
"%s\n", msg.
Data());
508 fprintf(stderr,
"%s\r", msg.
Data());
522 Error(
"CollectInput",
"file %s not found in path(s) %s",
544 Info(
"CollectInput",
"no associated header file"
545 " found: tried: %s %s",
546 h.Data(), headfile.
Data());
554 Info(
"CollectInput",
"problems sending file %s", impfile.
Data());
560 Info(
"CollectInput",
"problems sending file %s", headfile.
Data());
574 Warning(
"CollectInput",
"unknown type received from server: %d",
type);
582 Error(
"CollectInput",
"unknown command received from server: %d", what);
603 const Int_t kMAXBUF = 16384;
607 Int_t fdout = fileno(stdout);
609 Warning(
"RecvLogFile",
"file descriptor for outputs undefined (%d):"
610 " will not log msgs", fdout);
613 lseek(fdout, (off_t) 0, SEEK_END);
618 while (filesize < size) {
619 left =
Int_t(size - filesize);
623 filesize = (rec > 0) ? (filesize + rec) : filesize;
631 w = write(fdout, p,
r);
634 SysError(
"RecvLogFile",
"error writing to unit: %d", fdout);
640 }
else if (rec < 0) {
641 Error(
"RecvLogFile",
"error during receiving log file");
653 if (!
IsValid() || !obj)
return -1;
689 if ((*md5) != fs->
fMD5) {
696 Error(
"CheckFile",
"could not calculate local MD5 check sum - dont send");
710 Error(
"CheckFile",
"could not calculate local MD5 check sum - dont send");
724 (*reply) >>
type >> uptodate;
727 Warning(
"CheckFile",
"received wrong type:"
728 " %d (expected %d): protocol error?",
734 Error(
"CheckFile",
"received wrong message: %d (expected %d)",
738 Error(
"CheckFile",
"received empty message");
779 Error(
"SendFile",
"cannot stat file %s",
file);
784 Error(
"SendFile",
"empty file %s",
file);
793 const Int_t kMAXBUF = 32768;
802 size = sendto ? size : 0;
804 if (
gDebug > 1 && size > 0)
805 Info(
"SendFile",
"sending file %s",
file);
807 snprintf(buf, kMAXBUF,
"%s %d %lld", fnam, bin, size);
816 lseek(fd, 0, SEEK_SET);
824 SysError(
"SendFile",
"error reading from file %s",
file);
831 SysError(
"SendFile",
"error writing to server @ %s:%d (now offline)",
875 ::Info(
"TApplicationRemote::SetPortParam",
"port scan: %d attempts in [%d,%d]",
889 if (!strncasecmp(
line,
".q", 2)) {
895 if (!strncmp(
line,
"?", 1)) {
923 if (opt && opt[0] ==
'F') {
943 Info(
"Interrupt",
"*** Ctrl-C not yet enabled *** (type= %d)",
type);
947 char oobc = (char)
type;
948 const int kBufSize = 1024;
949 char waste[kBufSize];
953 Error(
"Interrupt",
"error sending oobc to server");
959 int n, nch, nbytes = 0, nloop = 0;
980 if (nch > kBufSize) nch = kBufSize;
983 Error(
"Interrupt",
"error receiving waste from server");
987 }
else if (
n == -3) {
993 Error(
"Interrupt",
"server does not respond");
997 Error(
"Interrupt",
"error receiving OOB from server");
1021 if (nch > kBufSize) nch = kBufSize;
1024 Error(
"Interrupt",
"error receiving waste (2) from server");
1030 Info(
"Interrupt",
"server synchronized: %d bytes discarded", nbytes);
1059 gROOT->RefreshBrowsers();
const Int_t kRRemote_Protocol
static const char * gSshCmd
static const char * gScript
static const char * gScriptCmd
R__EXTERN TApplication * gApplication
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
R__EXTERN TSystem * gSystem
TApplicationRemote * fApplicationRemote
Bool_t Notify()
TApplicationRemote interrupt handler.
virtual void Browse(TBrowser *b)
Browse remote application (working directory and ROOT files).
void Print(Option_t *option="") const
Print some info about this instance.
Int_t CollectInput()
Collect and analyze available input from the socket.
TObject * fReceivedObject
virtual ~TApplicationRemote()
Destructor.
Int_t BroadcastRaw(const void *buffer, Int_t length)
Broadcast a raw buffer of specified length to the remote session.
Bool_t CheckFile(const char *file, Long_t modtime)
Check if a file needs to be send to the server.
static void SetPortParam(Int_t lower=-1, Int_t upper=-1, Int_t attempts=-1)
Set port parameters for tunnelling. A value of -1 means unchanged.
TRemoteObject * fWorkingDir
void Terminate(Int_t status=0)
Terminate this session.
void Interrupt(Int_t type=kRRI_Hard)
Send interrupt OOB byte to server.
TApplicationRemote(const char *url, Int_t debug=0, const char *script=0)
Main constructor: start a remote session at 'url' accepting callbacks on local port 'port'; if port i...
void RecvLogFile(Int_t size)
Receive the log file from the server.
TSeqCollection * fRootFiles
Int_t SendFile(const char *file, Int_t opt=kAscii, const char *rfile=0)
Send a file to the server.
Int_t BroadcastObject(const TObject *obj, Int_t kind=kMESS_OBJECT)
Broadcast an object to the remote session.
Long_t ProcessLine(const char *line, Bool_t=kFALSE, Int_t *error=0)
Parse a single command line and forward the request to the remote server where it will be processed.
Int_t SendObject(const TObject *obj)
Send object to server.
Int_t Collect(Long_t timeout=-1)
Collect responses from the remote server.
static Int_t fgPortAttempts
TSignalHandler * fIntHandler
Int_t Broadcast(const TMessage &mess)
Broadcast a message to the remote session.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void Help(const char *line)
The function lists useful commands (".help") or opens the online reference guide, generated with Doxy...
void InitializeGraphics()
Initialize the graphics environment.
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
static void NeedGraphicsLibs()
Static method.
Using a TBrowser one can browse all ROOT objects.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
void WriteString(const char *s) override
Write string to I/O buffer.
char * ReadString(char *s, Int_t max) override
Read string from I/O buffer.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
void SetName(const char *name)
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const
Find object using its name.
virtual void Add(TObject *obj)
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
This code implements the MD5 message-digest algorithm.
static TMD5 * FileChecksum(const char *file)
Returns checksum of specified file.
TClass * GetClass() const
virtual void ActivateAll()
Activate all de-activated sockets.
TSocket * Select()
Return pointer to socket for which an event is waiting.
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Int_t GetActive(Long_t timeout=-1) const
Return number of sockets in the active list.
virtual void DeActivateAll()
De-activate all activated sockets.
virtual void DeActivate(TSocket *sock)
De-activate a socket.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
@ kInvalidObject
if object ctor succeeded but object should not be used
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static const char * GetMacroPath()
Get macro search path. Static utility function.
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
const char * GetClassName() const
virtual void Add(TObject *obj)
virtual TSocket * Accept(UChar_t Opt=0)
Accept a connection on a server socket.
virtual void Add()
Add signal handler to system signal handler list.
virtual void Remove()
Remove signal handler from system signal handler list.
Option_t * GetOption() const
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
virtual Int_t SendObject(const TObject *obj, Int_t kind=kMESS_OBJECT)
Send an object.
virtual Bool_t IsValid() const
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
TString & Insert(Ssiz_t pos, const char *s)
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TString & Remove(Ssiz_t pos)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
static void ResetErrno()
Static function resetting system error number.
static Int_t GetErrno()
Static function returning system error number.
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual Int_t GetEffectiveUid()
Returns the effective user id.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
const char * GetFile() const
const char * GetUser() const
const char * GetHost() const
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
const char * GetOptions() const
void SetHost(const char *host)
static constexpr double s