From 0646547c9eecc464dfc3c6fb0c7dfa9a3298a268 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 28 May 2023 20:40:00 -0400 Subject: config: remove dependency on no-delete-null-pointer-checks --- modules/commands/os_config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index 701cdc1f9..d54730462 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -32,7 +32,7 @@ class CommandOSConfig : public Command return; } - Configuration::Block *block = Config->GetBlock(params[1]); + Configuration::MutableBlock *block = Config->GetMutableBlock(params[1]); if (!block) block = Config->GetModule(params[1]); -- cgit From 66f37139cba97f2bb2a490376ffc33f153900b6c Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 28 May 2023 21:25:02 -0400 Subject: regchannels: remove dependency on no-delete-null-pointer-checks --- modules/commands/ns_recover.cpp | 2 +- modules/commands/os_mode.cpp | 4 ++-- modules/protocol/inspircd12.cpp | 2 +- modules/protocol/inspircd3.cpp | 2 +- modules/protocol/unreal.cpp | 2 +- modules/pseudoclients/chanserv.cpp | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index 20309cf86..67994a983 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -284,7 +284,7 @@ class NSRecover : public Module if (it != ei->end()) { for (size_t i = 0; i < it->second.Modes().length(); ++i) - c->SetMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID()); + c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID()); ei->erase(it); if (ei->empty()) diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 11fd8da03..0710065ea 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -37,7 +37,7 @@ class CommandOSMode : public Command const Channel::ModeList chmodes = c->GetModes(); for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it) - c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false); + c->RemoveMode(c->WhoSends(), it->first, it->second, false); if (!c) { @@ -55,7 +55,7 @@ class CommandOSMode : public Command continue; for (size_t i = uc->status.Modes().length(); i > 0; --i) - c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false); + c->RemoveMode(c->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false); } source.Reply(_("All modes cleared on %s."), c->name.c_str()); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index f4fe73ecc..8b1a18bb2 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -144,7 +144,7 @@ class InspIRCd12Proto : public IRCDProto { if (Servers::Capab.count("SVSTOPIC")) { - UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; + UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; } else { diff --git a/modules/protocol/inspircd3.cpp b/modules/protocol/inspircd3.cpp index 6329d5c8c..c58e55519 100644 --- a/modules/protocol/inspircd3.cpp +++ b/modules/protocol/inspircd3.cpp @@ -179,7 +179,7 @@ class InspIRCd3Proto : public IRCDProto { if (Servers::Capab.count("SVSTOPIC")) { - UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; + UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; } else { diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 4f484c603..ed4b95142 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -362,7 +362,7 @@ class UnrealIRCdProto : public IRCDProto /* Unreal does not support updating a channels TS without actually joining a user, * so we will join and part us now */ - BotInfo *bi = c->ci->WhoSends(); + BotInfo *bi = c->WhoSends(); if (!bi) ; else if (c->FindUser(bi) == NULL) diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 90f63b108..0809a25b3 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -288,7 +288,7 @@ class ChanServCore : public Module, public ChanServService if (c->ci) c->SetMode(c->ci->WhoSends(), "REGISTERED", "", false); else - c->RemoveMode(c->ci->WhoSends(), "REGISTERED", "", false); + c->RemoveMode(c->WhoSends(), "REGISTERED", "", false); const Anope::string &require = Config->GetModule(this)->Get("require"); if (!require.empty()) @@ -296,7 +296,7 @@ class ChanServCore : public Module, public ChanServService if (c->ci) c->SetModes(c->ci->WhoSends(), false, "+%s", require.c_str()); else - c->SetModes(c->ci->WhoSends(), false, "-%s", require.c_str()); + c->SetModes(c->WhoSends(), false, "-%s", require.c_str()); } } -- cgit From 07babdbd77f1978f8386791272b309949e56a09b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 2 Jun 2023 18:20:19 -0400 Subject: use Conan for extra's dependencies on Windows conan install src\win32\conanfile.txt --build=missing cmake -B build . cmake --build build --config Release --target PACKAGE --- modules/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ modules/extra/m_regex_pcre2.cpp | 2 +- modules/extra/m_ssl_openssl.cpp | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 4b0fd6eec..0553cad1c 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -3,6 +3,39 @@ if(WIN32) add_definitions(-DMODULE_COMPILE) endif(WIN32) +# enable extra modules if conan is used +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") + include("${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") + conan_basic_setup() + + function(enable_extra NAME PACKAGE) + if(DEFINED "CONAN_${PACKAGE}_ROOT") + message("Enabling the ${NAME} module") + # copy the modules out of extra so it gets picked up by build_modules + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/extra/${NAME}.cpp" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") + else() + message("Unable to enable the ${NAME} module (missing library)") + endif() + endfunction() + + function(copy_extra NAME) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/extra/${NAME}.cpp" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") + endfunction() + + enable_extra("m_mysql" "LIBMYSQLCLIENT") + enable_extra("m_regex_pcre2" "PCRE2") + enable_extra("m_sqlite" "SQLITE3") + enable_extra("m_ssl_openssl" "OPENSSL") + # these don't actually have extra dependencies, but require a module which does + copy_extra("m_sql_authentication") + copy_extra("m_sql_log") + copy_extra("m_sql_oper") + + # Package extra dlls + file(GLOB EXTRA_DLLS "${Anope_SOURCE_DIR}/extradll/bin/*.dll" "${Anope_SOURCE_DIR}/extradll/lib/*.dll") + install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) +endif() + macro(build_modules SRC) if(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt") add_subdirectory("${SRC}") diff --git a/modules/extra/m_regex_pcre2.cpp b/modules/extra/m_regex_pcre2.cpp index b9db11c2c..5655c3324 100644 --- a/modules/extra/m_regex_pcre2.cpp +++ b/modules/extra/m_regex_pcre2.cpp @@ -7,7 +7,7 @@ */ /* RequiredLibraries: pcre2-8 */ -/* RequiredWindowsLibraries: libpcre2-8 */ +/* RequiredWindowsLibraries: pcre2-8 */ #include "module.h" diff --git a/modules/extra/m_ssl_openssl.cpp b/modules/extra/m_ssl_openssl.cpp index a73f144dd..26b47a330 100644 --- a/modules/extra/m_ssl_openssl.cpp +++ b/modules/extra/m_ssl_openssl.cpp @@ -7,7 +7,7 @@ */ /* RequiredLibraries: ssl,crypto */ -/* RequiredWindowsLibraries: ssleay32,libeay32 */ +/* RequiredWindowsLibraries: libssl,libcrypto */ #include "module.h" #include "modules/ssl.h" -- cgit From ce42810265f5d701954ada807492bdd57c795421 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 2 Jun 2023 21:31:12 -0400 Subject: m_ldap: use Wldap on windows --- modules/CMakeLists.txt | 4 ++ modules/extra/m_ldap.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 90 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 0553cad1c..fd6004914 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -26,10 +26,14 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") enable_extra("m_regex_pcre2" "PCRE2") enable_extra("m_sqlite" "SQLITE3") enable_extra("m_ssl_openssl" "OPENSSL") + # this uses Wldap so should always be available + copy_extra("m_ldap") # these don't actually have extra dependencies, but require a module which does copy_extra("m_sql_authentication") copy_extra("m_sql_log") copy_extra("m_sql_oper") + copy_extra("m_ldap_authentication") + copy_extra("m_ldap_oper") # Package extra dlls file(GLOB EXTRA_DLLS "${Anope_SOURCE_DIR}/extradll/bin/*.dll" "${Anope_SOURCE_DIR}/extradll/lib/*.dll") diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index 464b07cf6..37b3df83d 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -10,11 +10,29 @@ */ /* RequiredLibraries: ldap_r|ldap,lber */ -/* RequiredWindowsLibraries: libldap_r|libldap,liblber */ #include "module.h" #include "modules/ldap.h" -#include + +#ifdef _WIN32 +# include +# include +# include +# define LDAP_OPT_SUCCESS LDAP_SUCCESS +# define LDAP_OPT_NETWORK_TIMEOUT LDAP_OPT_SEND_TIMEOUT +# define LDAP_STR(X) const_cast((X).c_str()) +# define LDAP_SASL_SIMPLE static_cast(0) +# define LDAP_TIME(X) reinterpret_cast(&(X)) +# define ldap_first_message ldap_first_entry +# define ldap_next_message ldap_next_entry +# define ldap_unbind_ext(LDAP, UNUSED1, UNUSED2) ldap_unbind(LDAP) +# pragma comment(lib, "Wldap32.lib") +# pragma comment(lib, "Wininet.lib") +#else +# include +# define LDAP_STR(X) ((X).c_str()) +# define LDAP_TIME(X) (&(X)) +#endif #if defined LDAP_API_FEATURE_X_OPENLDAP_REENTRANT && !LDAP_API_FEATURE_X_OPENLDAP_REENTRANT # error Anope requires OpenLDAP to be built as reentrant. @@ -73,13 +91,13 @@ class LDAPBind : public LDAPRequest int run() anope_override; }; -class LDAPSearch : public LDAPRequest +class LDAPSearchRequest : public LDAPRequest { Anope::string base; Anope::string filter; public: - LDAPSearch(LDAPService *s, LDAPInterface *i, const Anope::string &b, const Anope::string &f) + LDAPSearchRequest(LDAPService *s, LDAPInterface *i, const Anope::string &b, const Anope::string &f) : LDAPRequest(s, i) , base(b) , filter(f) @@ -190,6 +208,63 @@ class LDAPService : public LDAPProvider, public Thread, public Condition } private: +#ifdef _WIN32 + // Windows LDAP does not implement this so we need to do it. + int ldap_initialize(LDAP** ldap, const char* url) + { + URL_COMPONENTS urlComponents; + memset(&urlComponents, 0, sizeof(urlComponents)); + urlComponents.dwStructSize = sizeof(urlComponents); + + urlComponents.lpszScheme = new char[8]; + urlComponents.dwSchemeLength = 8; + + urlComponents.lpszHostName = new char[1024]; + urlComponents.dwHostNameLength = 1024; + + if (!InternetCrackUrlA(url, 0, 0, &urlComponents)) + { + delete[] urlComponents.lpszScheme; + delete[] urlComponents.lpszHostName; + return LDAP_CONNECT_ERROR; // Malformed url. + } + + unsigned long port = 389; // Default plaintext port. + bool secure = false; // LDAP defaults to plaintext. + if (urlComponents.dwSchemeLength > 0) + { + const Anope::string scheme(urlComponents.lpszScheme); + if (scheme.equals_ci("ldaps")) + { + port = 636; // Default encrypted port. + secure = true; + } + else if (!scheme.equals_ci("ldap")) + { + delete[] urlComponents.lpszScheme; + delete[] urlComponents.lpszHostName; + return LDAP_CONNECT_ERROR; // Invalid protocol. + } + } + + if (urlComponents.nPort > 0) + { + port = urlComponents.nPort; + } + + *ldap = ldap_sslinit(urlComponents.lpszHostName, port, secure); + delete[] urlComponents.lpszScheme; + delete[] urlComponents.lpszHostName; + if (!*ldap) + { + return LdapGetLastError(); // Something went wrong, find out what. + } + + // We're connected to the LDAP server! + return LDAP_SUCCESS; + } +#endif + void Connect() { int i = ldap_initialize(&this->con, this->server.c_str()); @@ -291,7 +366,7 @@ class LDAPService : public LDAPProvider, public Thread, public Condition if (i == NULL) throw LDAPException("No interface"); - LDAPSearch *s = new LDAPSearch(this, i, base, filter); + LDAPSearchRequest *s = new LDAPSearchRequest(this, i, base, filter); QueueRequest(s); } @@ -590,35 +665,35 @@ int LDAPBind::run() cred.bv_val = strdup(pass.c_str()); cred.bv_len = pass.length(); - int i = ldap_sasl_bind_s(service->GetConnection(), who.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); + int i = ldap_sasl_bind_s(service->GetConnection(), LDAP_STR(who), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); free(cred.bv_val); return i; } -int LDAPSearch::run() +int LDAPSearchRequest::run() { - return ldap_search_ext_s(service->GetConnection(), base.c_str(), LDAP_SCOPE_SUBTREE, filter.c_str(), NULL, 0, NULL, NULL, &tv, 0, &message); + return ldap_search_ext_s(service->GetConnection(), LDAP_STR(base), LDAP_SCOPE_SUBTREE, LDAP_STR(filter), NULL, 0, NULL, NULL, LDAP_TIME(tv), 0, &message); } int LDAPAdd::run() { LDAPMod **mods = LDAPService::BuildMods(attributes); - int i = ldap_add_ext_s(service->GetConnection(), dn.c_str(), mods, NULL, NULL); + int i = ldap_add_ext_s(service->GetConnection(), LDAP_STR(dn), mods, NULL, NULL); LDAPService::FreeMods(mods); return i; } int LDAPDel::run() { - return ldap_delete_ext_s(service->GetConnection(), dn.c_str(), NULL, NULL); + return ldap_delete_ext_s(service->GetConnection(), LDAP_STR(dn), NULL, NULL); } int LDAPModify::run() { LDAPMod **mods = LDAPService::BuildMods(attributes); - int i = ldap_modify_ext_s(service->GetConnection(), base.c_str(), mods, NULL, NULL); + int i = ldap_modify_ext_s(service->GetConnection(), LDAP_STR(base), mods, NULL, NULL); LDAPService::FreeMods(mods); return i; } -- cgit From fbf3b344740f6bd4f9337e485e35e9e8103428bc Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 2 Jun 2023 23:01:27 -0400 Subject: add gettext to conan deps --- modules/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules') diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index fd6004914..460c7b18a 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -5,9 +5,6 @@ endif(WIN32) # enable extra modules if conan is used if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") - include("${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake") - conan_basic_setup() - function(enable_extra NAME PACKAGE) if(DEFINED "CONAN_${PACKAGE}_ROOT") message("Enabling the ${NAME} module") -- cgit