officecfg/registry/schema/org/openoffice/Office/Common.xcs | 8 ++++++++ pyuno/Library_pythonloader.mk | 5 +++++ pyuno/source/loader/pyuno_loader.cxx | 5 +++++ 3 files changed, 18 insertions(+)
New commits: commit 5372538648dd865f36f53f2cee4490203385cd50 Author: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de> AuthorDate: Tue Dec 19 10:59:34 2023 +0300 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue Jan 9 00:48:18 2024 +0100 tdf#158375: add expert option DisablePythonRuntime When DisablePythonRuntime is set, anything that utilizes pyuno bindings won't work (e.g. python macros and extensions). Change-Id: Id42d01647eebee42b120b399470a1f944e4ba00f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160968 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 1ea33be5ba77..ecd6a05b927b 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2516,6 +2516,14 @@ </info> <value>false</value> </prop> + <prop oor:name="DisablePythonRuntime" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Specifies whether or not to disable Python Runtime Environment. + Extensions and macros that utilize Python will not function when disabled. + </desc> + </info> + <value>false</value> + </prop> <prop oor:name="CheckDocumentEvents" oor:type="xs:boolean" oor:nillable="false"> <info> <desc>Warn on load when a document binds an event to a macro</desc> diff --git a/pyuno/Library_pythonloader.mk b/pyuno/Library_pythonloader.mk index 4e3776b84897..2f1e69cfaef8 100644 --- a/pyuno/Library_pythonloader.mk +++ b/pyuno/Library_pythonloader.mk @@ -9,6 +9,10 @@ $(eval $(call gb_Library_Library,pythonloader)) +$(eval $(call gb_Library_use_custom_headers,pythonloader,\ + officecfg/registry \ +)) + $(eval $(call gb_Library_set_componentfile,pythonloader,pyuno/source/loader/pythonloader,pyuno)) $(eval $(call gb_Library_set_include,pythonloader,\ @@ -22,6 +26,7 @@ $(eval $(call gb_Library_use_api,pythonloader,\ )) $(eval $(call gb_Library_use_libraries,pythonloader,\ + comphelper \ cppu \ cppuhelper \ pyuno \ diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index 05a03fe72c4d..afdb016aa764 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -36,6 +36,8 @@ #include <com/sun/star/uno/XComponentContext.hpp> +#include <officecfg/Office/Common.hxx> + // apparently PATH_MAX is not standard and not defined by MSVC #ifndef PATH_MAX #ifdef _MAX_PATH @@ -242,6 +244,9 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* pyuno_Loader_get_implementation( css::uno::XComponentContext* ctx , css::uno::Sequence<css::uno::Any> const&) { + if (officecfg::Office::Common::Security::Scripting::DisablePythonRuntime::get()) + return nullptr; + // tdf#114815 init python only once, via single-instace="true" in pythonloader.component pythonInit();