#include "RConfigure.h"
#include "RConfig.h"
#include <ctype.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <errno.h>
#include <netdb.h>
#include "snprintf.h"
#include <sys/types.h>
#include <dirent.h>
#include <sys/statfs.h>
#include "rootdp.h"
#include "rsadef.h"
#include "rsalib.h"
Go to the source code of this file.
Enumerations | |
enum | EFileMode |
Functions | |
void | Err (int level, const char *msg, int size) |
void | ErrFatal (int level, const char *msg, int size) |
void | ErrSys (int level, const char *msg, int size) |
static int | EscChar (const char *src, char *dst, int dstlen, const char *specchars, char escchar) |
void | SigPipe (int) |
static const char * | HomeDirectory (const char *name) |
char * | RootdExpandPathName (const char *name) |
int | RootdCheckTab (int mode) |
void | RootdCloseTab (int force=0) |
int | RootdIsOpen () |
void | RootdCloseFtp () |
void | RootdClose () |
void | RootdFlush () |
void | RootdStat () |
void | RootdFstat (const char *buf) |
void | RootdParallel () |
static int | SysOpen (const char *pathname, int flags, unsigned int mode) |
void | RootdOpen (const char *msg) |
void | RootdPut (const char *msg) |
void | RootdGet (const char *msg) |
void | RootdGets (const char *msg) |
void | RootdPutFile (const char *msg) |
void | RootdGetFile (const char *msg) |
void | RootdChdir (const char *dir) |
void | RootdAccess (const char *buf) |
void | RootdFreeDir () |
void | RootdGetDirEntry () |
void | RootdOpenDir (const char *dir) |
void | RootdMkdir (const char *fdir) |
void | RootdRmdir (const char *fdir) |
void | RootdLsdir (const char *cmd) |
void | RootdPwd () |
void | RootdMv (const char *msg) |
void | RootdRm (const char *file) |
void | RootdChmod (const char *msg) |
static void | RootdTerm (int) |
void | RootdLoop () |
void | Usage (const char *name, int rc) |
int | main (int argc, char **argv) |
Variables | |
int | gDebug = 0 |
static std::string | gRootdTab |
static std::string | gRpdAuthTab |
static EService | gService = kROOTD |
static int | gProtocol = 18 |
static int | gClientProtocol = -1 |
static int | gAnon = 0 |
static double | gBytesRead = 0 |
static double | gBytesWritten = 0 |
static DIR * | gRDDirectory = 0 |
static int | gDownloaded = 0 |
static int | gFd = -1 |
static int | gFtp = 0 |
static int | gInetdFlag = 0 |
static char | gOption [32] = { 0 } |
static char | gFile [kMAXPATHLEN] = { 0 } |
static int | gUploaded = 0 |
static int | gWritable = 0 |
static int | gReadOnly = 0 |
static std::string | gUser |
static std::string | gPasswd |
static int | gCastorFlag = 0 |
static std::string | gCastorFile |
static std::string | gCastorReqId |
const char * | shellMeta = "~*[]{}?$" |
const char * | shellStuff = "(){}<>\"'" |
const char | shellEscape = '\\' |
void Err | ( | int | level, | |
const char * | msg, | |||
int | size | |||
) |
void ErrFatal | ( | int | level, | |
const char * | msg, | |||
int | size | |||
) |
Definition at line 381 of file rootd.cxx.
References ROOT::NetSendError(), ROOT::Perror(), and RootdClose().
void ErrSys | ( | int | level, | |
const char * | msg, | |||
int | size | |||
) |
static int EscChar | ( | const char * | src, | |
char * | dst, | |||
int | dstlen, | |||
const char * | specchars, | |||
char | escchar | |||
) | [static] |
static const char* HomeDirectory | ( | const char * | name | ) | [static] |
Definition at line 438 of file rootd.cxx.
References kMAXPATHLEN, and passwd::pw_dir.
Referenced by G__G__Base2_242_0_68(), and RootdExpandPathName().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 2270 of file rootd.cxx.
References access, ROOT::DaemonStart(), Err, ErrFatal(), Error, ROOT::ErrorInfo(), ROOT::ErrorInit(), ErrSys(), fprintf(), free(), gAnon, gCastorFile, gCastorFlag, gCastorReqId, gClientProtocol, gDebug, getenv(), gInetdFlag, gPasswd, gProtocol, gReadOnly, gRootdTab, gService, gUser, i, kDMN_HOSTEQ, kDMN_RQAUTH, kDMN_SYSLOG, kErrFatal, ROOT::NetClose(), ROOT::NetInit(), ROOT::NetOpen(), ROOT::NetSetSigPipeHook(), p, putenv, RootdExpandPathName(), RootdLoop(), RootdTerm(), ROOT::RpdGenRSAKeys(), ROOT::RpdInit(), ROOT::RpdInitSession(), ROOT::RpdSetErrorHandler(), ROOT::RpdSetSysLogFlag(), s, SigPipe(), sprintf(), strtol(), Usage(), and W_OK.
void RootdAccess | ( | const char * | buf | ) |
Definition at line 1830 of file rootd.cxx.
References access, buffer, ROOT::ErrorInfo(), kMAXPATHLEN, kROOTD_ACCESS, ROOT::NetSend(), ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdChdir | ( | const char * | dir | ) |
Definition at line 1780 of file rootd.cxx.
References buffer, chdir, fclose(), fopen, fread, gUser, i, kMAXBUFLEN, kMAXPATHLEN, kMESS_STRING, kROOTD_CHDIR, len, ROOT::NetSend(), p, ROOT::Perror(), passwd::pw_dir, and ROOT::SPrintf().
Referenced by RootdLoop().
int RootdCheckTab | ( | int | mode | ) |
Definition at line 559 of file rootd.cxx.
References access, close, Error, ROOT::ErrorInfo(), ErrSys(), fchmod(), fstat, ftruncate, gDebug, GetErrno(), gFile, gRootdTab, gUser, int, kErrFatal, kMAXPATHLEN, l, lseek, memmove, n, open, read, ResetErrno(), result(), s, SEEK_SET, size_t, sprintf(), stat, and write.
Referenced by RootdGetFile(), RootdOpen(), and RootdPutFile().
void RootdChmod | ( | const char * | msg | ) |
Definition at line 2090 of file rootd.cxx.
References buffer, ROOT::ErrorInfo(), gAnon, kMAXPATHLEN, kROOTD_CHMOD, ROOT::NetSend(), ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdClose | ( | ) |
Definition at line 846 of file rootd.cxx.
References close, ROOT::ErrorInfo(), gBytesRead, gBytesWritten, gDebug, gFd, gFile, gFtp, ROOT::NetGetBytesRecv(), ROOT::NetGetBytesSent(), RootdCloseFtp(), RootdCloseTab(), and RootdIsOpen().
void RootdCloseFtp | ( | ) |
Definition at line 831 of file rootd.cxx.
References ROOT::ErrorInfo(), gBytesRead, gBytesWritten, gDebug, gDownloaded, gUploaded, ROOT::NetGetBytesRecv(), and ROOT::NetGetBytesSent().
Referenced by RootdClose().
void RootdCloseTab | ( | int | force = 0 |
) |
Definition at line 715 of file rootd.cxx.
References access, close, ROOT::ErrorInfo(), fstat, ftruncate, gDebug, GetErrno(), gFile, gRootdTab, gUser, int, kMAXPATHLEN, l, lseek, memmove, n, open, read, ResetErrno(), s, SEEK_SET, size_t, stat, and write.
Referenced by RootdClose(), RootdGetFile(), RootdOpen(), and RootdPutFile().
char* RootdExpandPathName | ( | const char * | name | ) |
Definition at line 466 of file rootd.cxx.
References xmlio::cnt, EOF, ErrFatal(), Error, ErrSys(), EscChar(), HomeDirectory(), i, kErrFatal, kMAXPATHLEN, p, shellEscape, shellMeta, shellStuff, strcat(), and strlcpy().
Referenced by main(), and RootdOpen().
void RootdFlush | ( | ) |
Definition at line 871 of file rootd.cxx.
References Error, ROOT::ErrorInfo(), ErrSys(), fsync, gDebug, gFd, gFile, gWritable, kErrFatal, and RootdIsOpen().
Referenced by RootdLoop().
void RootdFreeDir | ( | ) |
Definition at line 1865 of file rootd.cxx.
References buffer, closedir, ROOT::ErrorInfo(), gRDDirectory, kMAXPATHLEN, kROOTD_FREEDIR, ROOT::NetSend(), ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdFstat | ( | const char * | buf | ) |
Definition at line 891 of file rootd.cxx.
References flags, fstat, fstat64(), gClientProtocol, gFd, if(), kROOTD_FSTAT, Long64_t, lstat, lstat64(), ROOT::NetSend(), RootdIsOpen(), size, sprintf(), stat, and stat64().
Referenced by RootdLoop().
void RootdGet | ( | const char * | msg | ) |
Definition at line 1249 of file rootd.cxx.
References buf, ErrFatal(), Error, ROOT::ErrorInfo(), ErrSys(), gBytesRead, gDebug, GetErrno(), gFd, gFile, kErrFileGet, kErrNoAccess, kROOTD_GET, len, Long64_t, lseek, lseek64(), ROOT::NetSend(), ROOT::NetSendRaw(), read, ResetErrno(), RootdIsOpen(), SEEK_SET, and ssize_t.
Referenced by RootdLoop().
void RootdGetDirEntry | ( | ) |
Definition at line 1885 of file rootd.cxx.
References buffer, ROOT::ErrorInfo(), GetErrno(), gRDDirectory, kMAXPATHLEN, kROOTD_DIRENTRY, ROOT::NetSend(), ROOT::Perror(), readdir, and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdGetFile | ( | const char * | msg | ) |
Definition at line 1626 of file rootd.cxx.
References buf, close, double, Err, ErrFatal(), Error, ROOT::ErrorInfo(), fstat, fstat64(), gBytesRead, gDownloaded, GetErrno(), gettimeofday(), gFtp, int, kErrBadFile, kErrFatal, kErrFileGet, kErrFileOpen, kMAXPATHLEN, kROOTD_GETFILE, Long64_t, lseek, lseek64(), MAP_FILE, ROOT::NetSend(), ROOT::NetSendRaw(), O_BINARY, read, ResetErrno(), RootdCheckTab(), RootdCloseTab(), S_ISREG, SEEK_SET, ROOT::SPrintf(), stat, stat64(), strlcpy(), SysOpen(), and t.
Referenced by RootdLoop().
void RootdGets | ( | const char * | msg | ) |
Definition at line 1299 of file rootd.cxx.
References ErrFatal(), Error, ROOT::ErrorInfo(), ErrSys(), gBytesRead, gDebug, GetErrno(), gFd, gFile, i, kErrFileGet, kErrNoAccess, kROOTD_GETS, len, Long64_t, lseek, lseek64(), ROOT::NetRecvRaw(), ROOT::NetSend(), ROOT::NetSendRaw(), ptr, read, ResetErrno(), RootdIsOpen(), SEEK_SET, size, and ssize_t.
Referenced by RootdLoop().
void RootdLoop | ( | ) |
Definition at line 2129 of file rootd.cxx.
References debug, ErrFatal(), Error, ROOT::ErrorInfo(), gClientProtocol, gDebug, kErrBadOp, kErrFatal, kMAXRECVBUF, kROOTD_ACCESS, kROOTD_BYE, kROOTD_CHDIR, kROOTD_CHMOD, kROOTD_CLOSE, kROOTD_DIRENTRY, kROOTD_FLUSH, kROOTD_FREEDIR, kROOTD_FSTAT, kROOTD_GET, kROOTD_GETFILE, kROOTD_GETS, kROOTD_LSDIR, kROOTD_MKDIR, kROOTD_MV, kROOTD_OPEN, kROOTD_OPENDIR, kROOTD_PASS, kROOTD_PUT, kROOTD_PUTFILE, kROOTD_PWD, kROOTD_RM, kROOTD_RMDIR, kROOTD_STAT, ROOT::NetRecv(), RootdAccess(), RootdChdir(), RootdChmod(), RootdClose(), RootdFlush(), RootdFreeDir(), RootdFstat(), RootdGet(), RootdGetDirEntry(), RootdGetFile(), RootdGets(), RootdLsdir(), RootdMkdir(), RootdMv(), RootdOpen(), RootdOpenDir(), RootdParallel(), RootdPut(), RootdPutFile(), RootdPwd(), RootdRm(), RootdRmdir(), and RootdStat().
Referenced by main().
void RootdLsdir | ( | const char * | cmd | ) |
Definition at line 1981 of file rootd.cxx.
References buffer, xmlio::cnt, EOF, ROOT::ErrorInfo(), gAnon, i, kMAXPATHLEN, kMESS_STRING, kROOTD_LSDIR, ROOT::NetSend(), ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdMkdir | ( | const char * | fdir | ) |
Definition at line 1931 of file rootd.cxx.
References buffer, dir(), ROOT::ErrorInfo(), gAnon, kMAXPATHLEN, kROOTD_MKDIR, mkdir, ROOT::NetSend(), ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdMv | ( | const char * | msg | ) |
Definition at line 2047 of file rootd.cxx.
References buffer, ROOT::ErrorInfo(), gAnon, kMAXPATHLEN, kROOTD_MV, ROOT::NetSend(), ROOT::Perror(), rename, and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdOpen | ( | const char * | msg | ) |
Definition at line 1012 of file rootd.cxx.
References access, close, ErrFatal(), Error, ROOT::ErrorInfo(), ErrSys(), free(), fstat, gAnon, gBytesRead, gBytesWritten, gCastorFile, gCastorFlag, gCastorReqId, gClientProtocol, gDebug, gFd, gFile, gOption, gPasswd, gReadOnly, gUser, gWritable, kErrBadFile, kErrFileExists, kErrFileOpen, kErrFileReadOpen, kErrFileWriteOpen, kErrNoAccess, kErrNoFile, kMAXPATHLEN, kROOTD_OPEN, ROOT::NetResetByteCount(), ROOT::NetSend(), O_BINARY, option, R_OK, read, RootdCheckTab(), RootdCloseTab(), RootdExpandPathName(), stat, strlcpy(), SysOpen(), update(), and W_OK.
Referenced by RootdLoop().
void RootdOpenDir | ( | const char * | dir | ) |
Definition at line 1910 of file rootd.cxx.
References buffer, ROOT::ErrorInfo(), gRDDirectory, kMAXPATHLEN, kROOTD_OPENDIR, ROOT::NetSend(), opendir, ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdParallel | ( | ) |
Definition at line 976 of file rootd.cxx.
References buf, ErrFatal(), Error, ROOT::ErrorInfo(), gDebug, kErrFatal, ROOT::NetParOpen(), ROOT::NetRecvRaw(), XrdMonCtrCollector::port, and size.
Referenced by RootdLoop().
void RootdPut | ( | const char * | msg | ) |
Definition at line 1201 of file rootd.cxx.
References buf, ErrFatal(), Error, ROOT::ErrorInfo(), ErrSys(), gBytesWritten, gDebug, GetErrno(), gFd, gFile, gWritable, kErrFilePut, kErrNoAccess, kROOTD_PUT, len, Long64_t, lseek, lseek64(), ROOT::NetRecvRaw(), ROOT::NetSend(), ResetErrno(), RootdIsOpen(), SEEK_SET, ssize_t, and write.
Referenced by RootdLoop().
void RootdPutFile | ( | const char * | msg | ) |
Definition at line 1416 of file rootd.cxx.
References buf, close, double, Err, ErrFatal(), Error, ROOT::ErrorInfo(), ErrSys(), fchmod(), gAnon, gBytesWritten, GetErrno(), gettimeofday(), gFile, gFtp, gUploaded, i, int, j, kAscii, kBinary, kErrFatal, kErrFileExists, kErrFileOpen, kErrFilePut, kErrFileWriteOpen, kErrNoSpace, kErrRestartSeek, kMAXPATHLEN, kROOTD_PUTFILE, Long64_t, lseek, lseek64(), n, ROOT::NetRecvRaw(), ROOT::NetSend(), O_BINARY, ResetErrno(), RootdCheckTab(), RootdCloseTab(), SEEK_SET, size, ssize_t, stat, statfs, strlcpy(), SysOpen(), t, and write.
Referenced by RootdLoop().
void RootdPwd | ( | ) |
Definition at line 2031 of file rootd.cxx.
References buffer, ROOT::ErrorInfo(), kMAXPATHLEN, kROOTD_PWD, ROOT::NetSend(), ROOT::Perror(), and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdRm | ( | const char * | file | ) |
Definition at line 2070 of file rootd.cxx.
References buffer, ROOT::ErrorInfo(), gAnon, kMAXPATHLEN, kROOTD_RM, ROOT::NetSend(), ROOT::Perror(), ROOT::SPrintf(), and unlink.
Referenced by RootdLoop().
void RootdRmdir | ( | const char * | fdir | ) |
Definition at line 1956 of file rootd.cxx.
References buffer, dir(), ROOT::ErrorInfo(), gAnon, kMAXPATHLEN, kROOTD_RMDIR, ROOT::NetSend(), ROOT::Perror(), rmdir, and ROOT::SPrintf().
Referenced by RootdLoop().
void RootdStat | ( | ) |
static void RootdTerm | ( | int | ) | [static] |
Definition at line 2115 of file rootd.cxx.
References ROOT::ErrorInfo(), ROOT::NetClose(), and ROOT::RpdAuthCleanup().
Referenced by main().
void SigPipe | ( | int | ) |
Definition at line 425 of file rootd.cxx.
References ROOT::ErrorInfo(), RootdClose(), and ROOT::RpdAuthCleanup().
Referenced by main().
static int SysOpen | ( | const char * | pathname, | |
int | flags, | |||
unsigned int | mode | |||
) | [static] |
Definition at line 996 of file rootd.cxx.
References O_BINARY, open, and open64().
Referenced by ClassImp(), RootdGetFile(), RootdOpen(), and RootdPutFile().
void Usage | ( | const char * | name, | |
int | rc | |||
) |
int gAnon = 0 [static] |
Definition at line 349 of file rootd.cxx.
Referenced by main(), RootdChmod(), RootdLsdir(), RootdMkdir(), RootdMv(), RootdOpen(), RootdPutFile(), RootdRm(), and RootdRmdir().
double gBytesRead = 0 [static] |
Definition at line 350 of file rootd.cxx.
Referenced by RootdClose(), RootdCloseFtp(), RootdGet(), RootdGetFile(), RootdGets(), and RootdOpen().
double gBytesWritten = 0 [static] |
Definition at line 351 of file rootd.cxx.
Referenced by RootdClose(), RootdCloseFtp(), RootdOpen(), RootdPut(), and RootdPutFile().
std::string gCastorFile [static] |
int gCastorFlag = 0 [static] |
std::string gCastorReqId [static] |
int gClientProtocol = -1 [static] |
Definition at line 348 of file rootd.cxx.
Referenced by main(), RootdFstat(), RootdLoop(), and RootdOpen().
int gDownloaded = 0 [static] |
int gFd = -1 [static] |
Definition at line 354 of file rootd.cxx.
Referenced by RootdClose(), RootdFlush(), RootdFstat(), RootdGet(), RootdGets(), RootdIsOpen(), RootdOpen(), and RootdPut().
char gFile[kMAXPATHLEN] = { 0 } [static] |
int gFtp = 0 [static] |
Definition at line 355 of file rootd.cxx.
Referenced by RootdClose(), RootdGetFile(), and RootdPutFile().
int gInetdFlag = 0 [static] |
char gOption[32] = { 0 } [static] |
std::string gPasswd [static] |
DIR* gRDDirectory = 0 [static] |
Definition at line 352 of file rootd.cxx.
Referenced by RootdFreeDir(), RootdGetDirEntry(), and RootdOpenDir().
int gReadOnly = 0 [static] |
std::string gRootdTab [static] |
Definition at line 344 of file rootd.cxx.
Referenced by main(), RootdCheckTab(), and RootdCloseTab().
std::string gRpdAuthTab [static] |
int gUploaded = 0 [static] |
std::string gUser [static] |
Definition at line 362 of file rootd.cxx.
Referenced by main(), ProofdExec(), RerouteUser(), RootdChdir(), RootdCheckTab(), RootdCloseTab(), and RootdOpen().
int gWritable = 0 [static] |
const char shellEscape = '\\' |
const char* shellStuff = "(){}<>\"'" |