]> jfr.im git - irc/znc/coverity.git/commitdiff
Don't load modperl as a python module
authorAlexey Sokolov <redacted>
Thu, 17 Sep 2020 22:02:22 +0000 (23:02 +0100)
committerAlexey Sokolov <redacted>
Thu, 17 Sep 2020 22:08:19 +0000 (23:08 +0100)
Close #1757

modules/modpython/znc.py
test/integration/tests/scripting.cpp

index feb98fda88f1f1f009eea5bc40ac5687f6f9e84e..5f0784f3287785246ce8bd3f50af8db155a5afd9 100644 (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):
index e4dcfc8e797cfa5b82aa7a0ddc0e5bd866fe1f13..d269b1d70969b0a42c08585c3226abf741bad3b2 100644 (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