From b4dcaaaa62b228febb0af4d25bf1c73e8c30aa08 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 14 Jan 2023 03:44:24 +0000 Subject: [PATCH] Allow setting to "system" to use the system database. --- docs/conf/modules.conf.example | 5 +++-- src/modules/m_cloak_sha256.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 8805ab8d5..8fa43eed9 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -595,7 +595,8 @@ # # # psl - If non-empty then the path to a Mozilla Public Suffix # # List database to use for finding the visible part of a # -# hostname. This overrides the hostparts (above) field. # +# hostname or "system" to use the system database if one # +# exists. This overrides the hostparts (above) field. # # Only available if libpsl was installed at build time. # # # # IMPORTANT: Changing these details will break all of your existing # @@ -610,7 +611,7 @@ # suffix="ip" # case="lower" # hostparts="3" -# psl="/usr/share/publicsuffix/public_suffix_list.dafsa"> +# psl="system"> #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Codepage module: Allows using a custom 8-bit codepage for nicknames diff --git a/src/modules/m_cloak_sha256.cpp b/src/modules/m_cloak_sha256.cpp index 71051e208..096ffec24 100644 --- a/src/modules/m_cloak_sha256.cpp +++ b/src/modules/m_cloak_sha256.cpp @@ -271,10 +271,17 @@ public: throw ModuleException(creator, "Your cloak key should be at least " + ConvToStr(minkeylen) + " characters long, at " + tag->source.str()); psl_ctx_t* psl = nullptr; - const std::string psldb = tag->getString("psl"); + std::string psldb = tag->getString("psl"); if (!psldb.empty()) { #ifdef HAS_LIBPSL + if (stdalgo::string::equalsci(psldb, "system")) + { + psldb = psl_dist_filename(); + if (psldb.empty()) + throw ModuleException(creator, "You specified \"system\" in but libpsl was built without a system copy, at " + tag->source.str()); + } + psl = psl_load_file(psldb.c_str()); if (!psl) throw ModuleException(creator, "The database specified in (" + psldb + ") does not exist, at " + tag->source.str());