summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-04-09 15:18:04 +0100
committerSadie Powell <sadie@witchery.services>2020-04-09 15:18:04 +0100
commitbb39d78be61e45555cdd87985e26ea07b725fabf (patch)
tree157dc8144dca9d65eec162773fe3f845e6a5582f /src/modules/extra
parent52a433cfccad8559ff7d12f7ea308d8f4570444f (diff)
Set the minimum length to 1 for most config items with a default.
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_geo_maxmind.cpp2
-rw-r--r--src/modules/extra/m_regex_stdlib.cpp2
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp8
-rw-r--r--src/modules/extra/m_ssl_mbedtls.cpp8
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp18
5 files changed, 19 insertions, 19 deletions
diff --git a/src/modules/extra/m_geo_maxmind.cpp b/src/modules/extra/m_geo_maxmind.cpp
index 0cf082775..984a2c6cb 100644
--- a/src/modules/extra/m_geo_maxmind.cpp
+++ b/src/modules/extra/m_geo_maxmind.cpp
@@ -160,7 +160,7 @@ class ModuleGeoMaxMind : public Module
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("maxmind");
- const std::string file = ServerInstance->Config->Paths.PrependConfig(tag->getString("file", "GeoLite2-Country.mmdb"));
+ const std::string file = ServerInstance->Config->Paths.PrependConfig(tag->getString("file", "GeoLite2-Country.mmdb", 1));
// Try to read the new database.
MMDB_s mmdb;
diff --git a/src/modules/extra/m_regex_stdlib.cpp b/src/modules/extra/m_regex_stdlib.cpp
index 418237dd1..80cf299f1 100644
--- a/src/modules/extra/m_regex_stdlib.cpp
+++ b/src/modules/extra/m_regex_stdlib.cpp
@@ -75,8 +75,8 @@ public:
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* Conf = ServerInstance->Config->ConfValue("stdregex");
- std::string regextype = Conf->getString("type", "ecmascript");
+ const std::string regextype = Conf->getString("type", "ecmascript", 1);
if (stdalgo::string::equalsci(regextype, "bre"))
ref.regextype = std::regex::basic;
else if (stdalgo::string::equalsci(regextype, "ere"))
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index bc8b0b472..1953851e3 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -664,12 +664,12 @@ namespace GnuTLS
Config(const std::string& profilename, ConfigTag* tag)
: name(profilename)
- , certstr(ReadFile(tag->getString("certfile", "cert.pem")))
- , keystr(ReadFile(tag->getString("keyfile", "key.pem")))
- , dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem"))))
+ , certstr(ReadFile(tag->getString("certfile", "cert.pem", 1)))
+ , keystr(ReadFile(tag->getString("keyfile", "key.pem", 1)))
+ , dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem", 1))))
, priostr(GetPrioStr(profilename, tag))
, mindh(tag->getUInt("mindhbits", 1024))
- , hashstr(tag->getString("hash", "md5"))
+ , hashstr(tag->getString("hash", "md5", 1))
, requestclientcert(tag->getBool("requestclientcert", true))
{
// Load trusted CA and revocation list, if set
diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp
index a1e0c9f28..d330afe51 100644
--- a/src/modules/extra/m_ssl_mbedtls.cpp
+++ b/src/modules/extra/m_ssl_mbedtls.cpp
@@ -419,13 +419,13 @@ namespace mbedTLS
Config(const std::string& profilename, ConfigTag* tag, CTRDRBG& ctr_drbg)
: name(profilename)
, ctrdrbg(ctr_drbg)
- , certstr(ReadFile(tag->getString("certfile", "cert.pem")))
- , keystr(ReadFile(tag->getString("keyfile", "key.pem")))
- , dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem")))
+ , certstr(ReadFile(tag->getString("certfile", "cert.pem", 1)))
+ , keystr(ReadFile(tag->getString("keyfile", "key.pem", 1)))
+ , dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem", 1)))
, ciphersuitestr(tag->getString("ciphersuites"))
, curvestr(tag->getString("curves"))
, mindh(tag->getUInt("mindhbits", 2048))
- , hashstr(tag->getString("hash", "sha256"))
+ , hashstr(tag->getString("hash", "sha256", 1))
, castr(tag->getString("cafile"))
, minver(tag->getUInt("minver", 0))
, maxver(tag->getUInt("maxver", 0))
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index c27626639..9a5fa98af 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -386,7 +386,7 @@ namespace OpenSSL
public:
Profile(const std::string& profilename, ConfigTag* tag)
: name(profilename)
- , dh(ServerInstance->Config->Paths.PrependConfig(tag->getString("dhfile", "dhparams.pem")))
+ , dh(ServerInstance->Config->Paths.PrependConfig(tag->getString("dhfile", "dhparams.pem", 1)))
, ctx(SSL_CTX_new(SSLv23_server_method()))
, clictx(SSL_CTX_new(SSLv23_client_method()))
, allowrenego(tag->getBool("renegotiation")) // Disallow by default
@@ -395,7 +395,7 @@ namespace OpenSSL
if ((!ctx.SetDH(dh)) || (!clictx.SetDH(dh)))
throw Exception("Couldn't set DH parameters");
- std::string hash = tag->getString("hash", "md5");
+ const std::string hash = tag->getString("hash", "md5", 1);
digest = EVP_get_digestbyname(hash.c_str());
if (digest == NULL)
throw Exception("Unknown hash type " + hash);
@@ -411,7 +411,7 @@ namespace OpenSSL
}
#ifndef OPENSSL_NO_ECDH
- std::string curvename = tag->getString("ecdhcurve", "prime256v1");
+ const std::string curvename = tag->getString("ecdhcurve", "prime256v1", 1);
if (!curvename.empty())
ctx.SetECDH(curvename);
#endif
@@ -422,14 +422,14 @@ namespace OpenSSL
/* Load our keys and certificates
* NOTE: OpenSSL's error logging API sucks, don't blame us for this clusterfuck.
*/
- std::string filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("certfile", "cert.pem"));
+ std::string filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("certfile", "cert.pem", 1));
if ((!ctx.SetCerts(filename)) || (!clictx.SetCerts(filename)))
{
ERR_print_errors_cb(error_callback, this);
throw Exception("Can't read certificate file: " + lasterr);
}
- filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("keyfile", "key.pem"));
+ filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("keyfile", "key.pem", 1));
if ((!ctx.SetPrivateKey(filename)) || (!clictx.SetPrivateKey(filename)))
{
ERR_print_errors_cb(error_callback, this);
@@ -437,7 +437,7 @@ namespace OpenSSL
}
// Load the CAs we trust
- filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("cafile", "ca.pem"));
+ filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("cafile", "ca.pem", 1));
if ((!ctx.SetCA(filename)) || (!clictx.SetCA(filename)))
{
ERR_print_errors_cb(error_callback, this);
@@ -445,9 +445,9 @@ namespace OpenSSL
}
// Load the CRLs.
- std::string crlfile = tag->getString("crlfile");
- std::string crlpath = tag->getString("crlpath");
- std::string crlmode = tag->getString("crlmode", "chain");
+ const std::string crlfile = tag->getString("crlfile");
+ const std::string crlpath = tag->getString("crlpath");
+ const std::string crlmode = tag->getString("crlmode", "chain", 1);
ctx.SetCRL(crlfile, crlpath, crlmode);
clictx.SetVerifyCert();