18bool TPCHandler::Configure(
const char *configfn,
XrdOucEnv *myEnv)
21 XrdOucStream
Config(&m_log, getenv(
"XRDINSTANCE"), &cfgEnv,
"=====> ");
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.trace", val)) {
57 if (!ConfigureLogger(Config)) {
61 }
else if (!strcmp(
"tpc.fixed_route", val)) {
62 if (!(val =
Config.GetWord())) {
64 m_log.Emsg(
"Config",
"tpc.fixed_route value not specified");
67 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
69 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
73 m_log.Emsg(
"Config",
"tpc.fixed_route value is invalid", val);
76 }
else if (!strcmp(
"tpc.header2cgi",val)) {
85 if(authHdr != hdr2cgimap.end()) {
86 hdr2cgimap.erase(authHdr);
88 }
else if (!strcmp(
"tpc.timeout", val)) {
89 if (!(val =
Config.GetWord())) {
91 m_log.Emsg(
"Config",
"tpc.timeout value not specified.");
return false;
93 if (
XrdOuca2x::a2tm(m_log,
"timeout value", val, &m_timeout, 0))
return false;
95 if ((val =
Config.GetWord())) {
96 if (
XrdOuca2x::a2tm(m_log,
"first byte timeout value", val, &m_first_timeout, 0))
return false;
98 m_first_timeout = 2*m_timeout;
108 auto env_cadir = getenv(
"XRDTPC_CADIR");
109 if (env_cadir) m_cadir = env_cadir;
111 const char *cadir =
nullptr, *cafile =
nullptr;
112 if ((cadir = env_cadir ? env_cadir : myEnv->
Get(
"http.cadir"))) {
115 m_ca_file.reset(
new XrdTlsTempCA(&m_log, m_cadir));
116 if (!m_ca_file->IsValid()) {
117 m_log.Emsg(
"Config",
"CAs / CRL generation for libcurl failed.");
122 if ((cafile = myEnv->
Get(
"http.cafile"))) {
126 if (!cadir && !cafile) {
128 m_log.Emsg(
"Config",
"neither xrd.tls cadir nor certfile value specified; is TLS enabled?");
132 if ((sfs_raw_ptr = myEnv->
GetPtr(
"XrdSfsFileSystem*"))) {
133 m_sfs =
static_cast<XrdSfsFileSystem*
>(sfs_raw_ptr);
134 m_log.Emsg(
"Config",
"Using filesystem object from the framework.");
137 m_log.Emsg(
"Config",
"No filesystem object available to HTTP-TPC subsystem. Internal error.");
143bool TPCHandler::ConfigureLogger(XrdOucStream &config_obj)
145 char *val = config_obj.
GetWord();
148 m_log.Emsg(
"Config",
"tpc.trace requires at least one directive [all | error | warning | info | debug | none]");
155 if (!strcasecmp(val,
"all"))
159 else if (!strcasecmp(val,
"error"))
163 else if (!strcasecmp(val,
"warning"))
167 else if (!strcasecmp(val,
"info"))
171 else if (!strcasecmp(val,
"debug"))
175 else if (!strcasecmp(val,
"none"))
181 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)
char * Get(const char *varname)
void * GetPtr(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)