Don't load modperl as a python module

Close #1757
This commit is contained in:
Alexey Sokolov
2020-09-17 23:02:22 +01:00
parent 65eff7a4f9
commit 47e633b267
2 changed files with 22 additions and 0 deletions

View File

@@ -768,6 +768,11 @@ def find_open(modname):
module = importlib.import_module(fullname)
except ImportError:
return (None, None)
if not isinstance(module.__loader__, ZNCModuleLoader):
# If modname/ is a directory, it was "loaded" using _NamespaceLoader.
# This is the case for e.g. modperl.
# https://github.com/znc/znc/issues/1757
return (None, None)
return (module, os.path.join(module.__loader__._datadir, modname))
def load_module(modname, args, module_type, user, network, retmsg, modpython):

View File

@@ -279,5 +279,22 @@ TEST_F(ZNCTest, ModpythonPackage) {
client.ReadUntil("value = b");
}
TEST_F(ZNCTest, ModpythonModperl) {
if (QProcessEnvironment::systemEnvironment().value(
"DISABLED_ZNC_PERL_PYTHON_TEST") == "1") {
return;
}
auto znc = Run();
znc->CanLeak();
auto ircd = ConnectIRCd();
auto client = LoginClient();
// https://github.com/znc/znc/issues/1757
client.Write("znc loadmod modpython");
client.ReadUntil("Loaded module modpython");
client.Write("znc loadmod modperl");
client.ReadUntil("Loaded module modperl");
}
} // namespace
} // namespace znc_inttest