18 bool TPCHandler::Configure(
const char *configfn,
XrdOucEnv *myEnv)
26 usingEC = getenv(
"XRDCL_EC")? true :
false;
28 allowMissingCRL = (bool) myEnv->
GetInt(
"http.allowmissingcrl");
30 std::string authLibParms;
31 int cfgFD =
open(configfn, O_RDONLY, 0);
33 m_log.
Emsg(
"Config", errno,
"open config file", configfn);
37 static const char *cvec[] = {
"*** http tpc plugin config:", 0 };
40 while ((val =
Config.GetMyFirstWord())) {
41 if (!strcmp(
"http.desthttps", val)) {
42 if (!(val =
Config.GetWord())) {
44 m_log.
Emsg(
"Config",
"http.desthttps value not specified");
47 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
49 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
53 m_log.
Emsg(
"Config",
"https.desthttps value is invalid", val);
56 }
else if (!strcmp(
"tpc.allow", val)) {
57 if (!(val =
Config.GetWord())) {
59 m_log.
Emsg(
"Config",
"tpc.allow value not specified");
62 if (strcmp(val,
"local") == 0) {
64 }
else if (strcmp(val,
"private") == 0) {
65 m_allow_private =
true;
68 m_log.
Emsg(
"Config",
"tpc.allow value is invalid", val);
71 }
else if (!strcmp(
"tpc.deny", val)) {
72 if (!(val =
Config.GetWord())) {
74 m_log.
Emsg(
"Config",
"tpc.deny value not specified");
77 if (strcmp(val,
"local") == 0) {
78 m_allow_local =
false;
79 }
else if (strcmp(val,
"private") == 0) {
80 m_allow_private =
false;
83 m_log.
Emsg(
"Config",
"tpc.deny value is invalid", val);
86 }
else if (!strcmp(
"tpc.trace", val)) {
87 if (!ConfigureLogger(
Config)) {
91 }
else if (!strcmp(
"tpc.fixed_route", val)) {
92 if (!(val =
Config.GetWord())) {
94 m_log.
Emsg(
"Config",
"tpc.fixed_route value not specified");
97 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
99 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
100 m_fixed_route=
false;
103 m_log.
Emsg(
"Config",
"tpc.fixed_route value is invalid", val);
106 }
else if (!strcmp(
"tpc.header2cgi",val)) {
115 if(authHdr != hdr2cgimap.end()) {
116 hdr2cgimap.erase(authHdr);
118 }
else if (!strcmp(
"tpc.timeout", val)) {
119 if (!(val =
Config.GetWord())) {
121 m_log.
Emsg(
"Config",
"tpc.timeout value not specified.");
return false;
123 if (
XrdOuca2x::a2tm(m_log,
"timeout value", val, &m_timeout, 0))
return false;
125 if ((val =
Config.GetWord())) {
126 if (
XrdOuca2x::a2tm(m_log,
"first byte timeout value", val, &m_first_timeout, 0))
return false;
128 m_first_timeout = 2*m_timeout;
138 auto env_cadir = getenv(
"XRDTPC_CADIR");
139 if (env_cadir) m_cadir = env_cadir;
141 const char *cadir =
nullptr, *cafile =
nullptr;
142 if ((cadir = env_cadir ? env_cadir : myEnv->
Get(
"http.cadir"))) {
146 if (!m_ca_file->IsValid()) {
147 m_log.
Emsg(
"Config",
"CAs / CRL generation for libcurl failed.");
152 if ((cafile = myEnv->
Get(
"http.cafile"))) {
156 if (!cadir && !cafile) {
158 m_log.
Emsg(
"Config",
"neither xrd.tls cadir nor certfile value specified; is TLS enabled?");
162 if ((sfs_raw_ptr = myEnv->
GetPtr(
"XrdSfsFileSystem*"))) {
164 m_log.
Emsg(
"Config",
"Using filesystem object from the framework.");
167 m_log.
Emsg(
"Config",
"No filesystem object available to HTTP-TPC subsystem. Internal error.");
173 bool TPCHandler::ConfigureLogger(
XrdOucStream &config_obj)
175 char *val = config_obj.
GetWord();
178 m_log.
Emsg(
"Config",
"tpc.trace requires at least one directive [all | error | warning | info | debug | none]");
185 if (!strcasecmp(val,
"all"))
189 else if (!strcasecmp(val,
"error"))
193 else if (!strcasecmp(val,
"warning"))
197 else if (!strcasecmp(val,
"info"))
201 else if (!strcasecmp(val,
"debug"))
205 else if (!strcasecmp(val,
"none"))
211 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.
long GetInt(const char *varname)
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)