18 bool TPCHandler::Configure(
const char *configfn,
XrdOucEnv *myEnv)
26 usingEC = getenv(
"XRDCL_EC")? true :
false;
29 std::string authLibParms;
30 int cfgFD =
open(configfn, O_RDONLY, 0);
32 m_log.
Emsg(
"Config", errno,
"open config file", configfn);
36 static const char *cvec[] = {
"*** http tpc plugin config:", 0 };
39 while ((val =
Config.GetMyFirstWord())) {
40 if (!strcmp(
"http.desthttps", val)) {
41 if (!(val =
Config.GetWord())) {
43 m_log.
Emsg(
"Config",
"http.desthttps value not specified");
46 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
48 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
52 m_log.
Emsg(
"Config",
"https.desthttps value is invalid", val);
55 }
else if (!strcmp(
"tpc.allow", val)) {
56 if (!(val =
Config.GetWord())) {
58 m_log.
Emsg(
"Config",
"tpc.allow value not specified");
61 if (strcmp(val,
"local") == 0) {
63 }
else if (strcmp(val,
"private") == 0) {
64 m_allow_private =
true;
67 m_log.
Emsg(
"Config",
"tpc.allow value is invalid", val);
70 }
else if (!strcmp(
"tpc.deny", val)) {
71 if (!(val =
Config.GetWord())) {
73 m_log.
Emsg(
"Config",
"tpc.deny value not specified");
76 if (strcmp(val,
"local") == 0) {
77 m_allow_local =
false;
78 }
else if (strcmp(val,
"private") == 0) {
79 m_allow_private =
false;
82 m_log.
Emsg(
"Config",
"tpc.deny value is invalid", val);
85 }
else if (!strcmp(
"tpc.trace", val)) {
86 if (!ConfigureLogger(
Config)) {
90 }
else if (!strcmp(
"tpc.fixed_route", val)) {
91 if (!(val =
Config.GetWord())) {
93 m_log.
Emsg(
"Config",
"tpc.fixed_route value not specified");
96 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
98 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
102 m_log.
Emsg(
"Config",
"tpc.fixed_route value is invalid", val);
105 }
else if (!strcmp(
"tpc.header2cgi",val)) {
114 if(authHdr != hdr2cgimap.end()) {
115 hdr2cgimap.erase(authHdr);
117 }
else if (!strcmp(
"tpc.timeout", val)) {
118 if (!(val =
Config.GetWord())) {
120 m_log.
Emsg(
"Config",
"tpc.timeout value not specified.");
return false;
122 if (
XrdOuca2x::a2tm(m_log,
"timeout value", val, &m_timeout, 0))
return false;
124 if ((val =
Config.GetWord())) {
125 if (
XrdOuca2x::a2tm(m_log,
"first byte timeout value", val, &m_first_timeout, 0))
return false;
127 m_first_timeout = 2*m_timeout;
137 auto env_cadir = getenv(
"XRDTPC_CADIR");
138 if (env_cadir) m_cadir = env_cadir;
140 const char *cadir =
nullptr, *cafile =
nullptr;
141 if ((cadir = env_cadir ? env_cadir : myEnv->
Get(
"http.cadir"))) {
145 if (!m_ca_file->IsValid()) {
146 m_log.
Emsg(
"Config",
"CAs / CRL generation for libcurl failed.");
151 if ((cafile = myEnv->
Get(
"http.cafile"))) {
155 if (!cadir && !cafile) {
157 m_log.
Emsg(
"Config",
"neither xrd.tls cadir nor certfile value specified; is TLS enabled?");
161 if ((sfs_raw_ptr = myEnv->
GetPtr(
"XrdSfsFileSystem*"))) {
163 m_log.
Emsg(
"Config",
"Using filesystem object from the framework.");
166 m_log.
Emsg(
"Config",
"No filesystem object available to HTTP-TPC subsystem. Internal error.");
172 bool TPCHandler::ConfigureLogger(
XrdOucStream &config_obj)
174 char *val = config_obj.
GetWord();
177 m_log.
Emsg(
"Config",
"tpc.trace requires at least one directive [all | error | warning | info | debug | none]");
184 if (!strcasecmp(val,
"all"))
188 else if (!strcasecmp(val,
"error"))
192 else if (!strcasecmp(val,
"warning"))
196 else if (!strcasecmp(val,
"info"))
200 else if (!strcasecmp(val,
"debug"))
204 else if (!strcasecmp(val,
"none"))
210 m_log.
Emsg(
"Config",
"tpc.trace encountered an unknown directive (valid values: [all | error | warning | info | debug | none]):", val);
A pragmatic implementation of the HTTP/DAV protocol for the Xrd framework.
static int parseHeader2CGI(XrdOucStream &Config, XrdSysError &err, std::map< std::string, std::string > &header2cgi)
Use this function to parse header2cgi configurations.
void * GetPtr(const char *varname)
char * Get(const char *varname)
char * GetWord(int lowcase=0)
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void setMsgMask(int mask)