Reading and writing ROOT files over the net can be done by creating a TNetFile object instead of a TFile object. Since the TNetFile class inherits from the TFile class it has exactly the same interface and behaviour. The only difference is that it reads and writes via a remote rootd daemon.
roots://hpsalo/files/aap.root
root://hpbrun.cern.ch/root/hsimple.root
root://pcna49a:5151/~na49/data/run821.root
root://pcna49d.cern.ch:5050//v1/data/run810.root
The only difference with the well known httpd URL's is that the root of the remote file tree is the remote user's home directory. Therefore an absolute pathname requires a // after the host or port specifier (as shown in the last example above). Further the expansion of the standard shell characters, like ~, $,.., etc. is handled as expected. The default port on which the remote rootd listens is 1094 and this default port is assumed by TNetFile (actually by TUrl which is used by TNetFile). Port number 1094 has officially been assigned by IANA for rootd.
hpsalo [12] telnet
fsgi02.fnal.gov
login: minuser
Password:
<fsgi02> rootd
-p 5151
<fsgi02> exit
hpsalo [13] root
root [0] TFile
*f = TFile::Open("root://fsgi02.fnal.gov:5151/file.root","new")
Name (fsgi02.fnal.gov:rdm): minuser
Password:
root [1] f.ls()
In the above example rootd runs on the remote node under user id minuser and listens to port 5151. When creating a TNetFile object you have to specify this same port number 5151 and use minuser (and corresponding password) as login id. When rootd is started in this way you can only login with the user id under which rootd was started on the remote machine. However, you can make many connections since the original rootd will fork (spawn) a new rootd that will service the requests from the TNetFile. The original rootd keeps listening on the specified port for other connections. Each time a TNetFile makes a connection it gets a new private rootd that will handle its requests. At the end of a root session when all TNetFiles are closed only the original rootd will stay alive ready to service future TNetFiles. fgfgf
#! /usr/bin/perland store the output in $HOME/.rootdpass.
srand(time());
my $randletter = "(int (rand(26)) + (int (rand(1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift;
my $crypttext = crypt($plaintext, $salt);
print "${crypttext}\n";
TFile
*TFile::Open(const Text_t *name, Option_t *option="",
const Text_t *title="",
Depending on the name argument the function returns either a TFile, a TNetFile or a TWebFile object. In case a TNetFile URL specifies a local file a TFile object will be returned (and of course no login information is needed). The arguments of the Open() function are the same as the ones for the TFile constructor.
rootd 1094/tcp
and to /etc/inetd.conf the line:
rootd stream tcp nowait root /usr/local/root/bin/rootd rootd -i
After these changes force inetd to reread its config file with "kill -HUP <pid inetd>".
Setup in this way it is not necessary to specify a port number in the URL given to TNetFile. TNetFile assumes the default port to be 1094 as specified above in the /etc/services file.
Systems using the new xinetd super daemon, like RedHat 7.0, should create a file /etc/xinetd.d/rootd with the following contents:
# default: on
# description: The rootd daemon allows remote access to ROOT files.
service rootd
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/local/root/bin/rootd
server_args = -i /usr/local/root
log_on_success += DURATION USERID
log_on_failure += USERID
}
| -i |
says we are started by (x)inetd |
| -p port# | specifies a different port to listen on. Use
port1-port2 to find first available port in range. Use 0-N for range
relative to service port. |
| -b tcpwindowsize |
specifies the tcp window size in bytes (e.g. see
http://www.psc.edu/networking/perf_tune.html). Default is 65535, only
change default for pipes with a high bandwidth*delay product. |
| -d level |
level of debug info written to syslog 0 = no debug (default) 1 = minimum 2 = medium 3 = maximum |
| -r |
files can only be opened in read-only mode |
| -f |
do not run as daemon, run in foreground |
| -P file |
use this password file instead of
$HOME/.srootdpass SRP password file |
| -R bitmask |
bit mask specifies which methods will allow
authentication to be re-used |
| -S keytabfile |
use this keytab file, instead of the default (option only supported when compiled with Kerberos5 support) |
| -T tmpdir | specifies the directory path to be used to place temporary files, default is /usr/tmp. Useful if not running as root. |
| -G gridmapfile |
defines the gridmap file to be used for globus
authentication if different from globus default
(/etc/grid-security/gridmap); (re)defines the GRIDMAP environment
variable. |
| -C hostcertfile |
defines a file where to find information for the
local host Globus information (see GLOBUS.README for details) |
| -s <sshd_port> |
specifies the port number for the sshd daemon
(default is 22) |
| rootsys_dir |
directory containing the ROOT etc and bin
directories. Superseeds ROOTSYS or built-in (as specified to
./configure). |
Similar command line arguments are accepted by
proofd.
rootd:*:71:72:Anonymous rootd:/var/spool/rootd:/bin/falsewhere you may modify the uid, gid (71, 72) and the home directory to suite your system.
rootd:*:72:rootdwhere the gid must match the gid in /etc/passwd.
mkdir /var/spool/rootdWhere /var/spool/rootd must match the rootd home directory as specified in the rootd /etc/passwd entry.
mkdir /var/spool/rootd/tmp
chmod 777 /var/spool/rootd/tmp
mkdir /var/spool/rootd/pubThat's all.
chown rootd:rootd /var/spool/rootd/pub
Several remarks: