Properly notify gpgme about spawn executable location on Windows

classic Classic list List threaded Threaded
5 messages Options
Kaganski Mike Kaganski Mike
Reply | Threaded
Open this post in threaded view
|

Properly notify gpgme about spawn executable location on Windows

Hi Thorsten, *,

When working on a 6-0-based branch on Windows, in make check, two python
tests emit modal error dialogs about missing gpgme-w32spawn.exe:

> ---------------------------
> GpgME not installed correctly
> ---------------------------
> gpgme-w32spawn.exe was not found in the detected installation directory
> of GpgME
> "C:\lo\src\core\instdir\program\python-core-3.5.5\bin"
>
> Crypto operations will not work.
>
> If you see this it indicates a problem with your installation.
> Please report the problem to your distributor of GpgME.
>
> Developer's Note: The install dir can be manually set with:
> gpgme_set_global_flag
> ---------------------------
> ОК
> ---------------------------

For completeness, the tests are sw_python and
pyuno_pytests_insertremovecells, but this is not really important;
obviously, the tests themselves don't need the initialization of
security context, and the unneeded initialization was fixed somewhere
down the road, and later versions don't block on the tests.

However, I suppose that it's possible in theory that some user python
script could ultimately need initializing gpgme. In that case, the
problem would hit the user. Having a modal dialog waiting on a possibly
headless server is not a correct behavior :-)

The cause here is that by default, gpgme only expects to find the spawn
process in the same location as the current executable (see
_gpgme_get_w32spawn_path and _gpgme_get_inst_dir in
gpgmepp/src/w32-util.c). It works when the executable is soffice.bin;
but for python, which is located in a subdirectory of instdir/program,
this is not true (see error message above). It needs to be told
explicitly where to look for the executable; and it's only possible
using gpgme_set_global_flag call.

So I went ahead and prepared a patch for this:
https://gerrit.libreoffice.org/71014, which adds a check if the spawn
executable is in the same directory as current process executable, and
if not, queries UNO_PATH environment variable to check if it contains
the executable, to notify gpgme about the path.

My questions are:

1. First of all - do I understand it correctly that the problem is real
- so there are possible scenarios involving e.g. python (or another
process which executable is not in LO's instdir/program), that might
need gpgme? I'm not familiar with our scripting framework, so I might
actually invent a non-existing problem after all. I see that problem
happening only with those tests, and I don't know if the later fix has
completely ruled away the possibility to run that code from python, or
just made that called only when really needed (which implies that it
will happen eventually).

2. To find the executable, I use UNO_PATH envvar. As far as I can tell,
even directly running soffice.bin without having UNO_PATH set in
environment, sets the variable correctly, so this works as expected. But
is there a better way?

3. The patch needs to add a gpgmepp wrapper for gpgme_set_global_flag
function, because the function itself is not accessible from the place:
if I simply used it, linking it fails:

> [LNK] Library/xsec_xmlsec.dll
>    Creating library C:/lo/src/core/workdir/LinkTarget/Library/ixsec_xmlsec.lib and object C:/lo/src/core/workdir/LinkTarget/Library/ixsec_xmlsec.exp
> SecurityEnvironment.o : error LNK2019: unresolved external symbol gpgme_set_global_flag referenced in function "public: __cdecl SecurityEnvironmentGpg::SecurityEnvironmentGpg(void)" (??0SecurityEnvironmentGpg@@QEAA@XZ)
> C:/lo/src/core/instdir/program/xsec_xmlsec.dll : fatal error LNK1120: 1 unresolved externals

I could overlook how to use the function without the need of the wrapper
- if so, please give me a hint how to do that properly. If there's no
way to do that, then I'll create a pr to https://github.com/KDE/gpgmepp.

Thanks.

--
Best regards,
Mike Kaganski
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Thorsten Behrens-6 Thorsten Behrens-6
Reply | Threaded
Open this post in threaded view
|

Re: Properly notify gpgme about spawn executable location on Windows

Hi Mike,

Kaganski Mike wrote:
> However, I suppose that it's possible in theory that some user python
> script could ultimately need initializing gpgme. In that case, the
> problem would hit the user. Having a modal dialog waiting on a possibly
> headless server is not a correct behavior :-)
>
Hmm - so the uitests are rigging the office in a very specific way,
using subprocess.Popen to spawn a child soffice process from python
(which calls CreateProcess on Windows). Code for that is in
uitest/libreoffice/connection.py, Python3 help blurb is

 https://docs.python.org/3/library/subprocess.html#subprocess.Popen

It is a tad surprising that this would somehow 'think' it is still the
main python executable on Windows, perhaps there's a way to
parameterize the Popen call differently to rectify that?

> My questions are:
>
> 1. First of all - do I understand it correctly that the problem is real
> - so there are possible scenarios involving e.g. python (or another
> process which executable is not in LO's instdir/program), that might
> need gpgme?
>
See above - but even for uitests, the issue might become relevant, so
I see at least no harm in keeping that fix (unless Popen can be fixed
to not have Windows inherit too much parent process attributes).

> 2. To find the executable, I use UNO_PATH envvar. As far as I can tell,
> even directly running soffice.bin without having UNO_PATH set in
> environment, sets the variable correctly, so this works as expected. But
> is there a better way?
>
The canonical way seems to be something like:

    OUString aProgramURL("$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/<executable>");
    rtl::Bootstrap::expandMacros(aProgramURL);

> 3. The patch needs to add a gpgmepp wrapper for gpgme_set_global_flag
> function,
> [snip]
> If there's no way to do that, then I'll create a pr to
> https://github.com/KDE/gpgmepp.
>
Yes please, that's how we did that in the past, too.

Thanks a lot for chasing this,

-- Thorsten
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (1K) Download Attachment
Kaganski Mike Kaganski Mike
Reply | Threaded
Open this post in threaded view
|

Re: Properly notify gpgme about spawn executable location on Windows

Hi Thorsten,

Thanks for your analysis!

On 21.04.2019 0:22, Thorsten Behrens wrote:

> Kaganski Mike wrote:
>> However, I suppose that it's possible in theory that some user python
>> script could ultimately need initializing gpgme. In that case, the
>> problem would hit the user. Having a modal dialog waiting on a possibly
>> headless server is not a correct behavior :-)
>>
> Hmm - so the uitests are rigging the office in a very specific way,
> using subprocess.Popen to spawn a child soffice process from python
> (which calls CreateProcess on Windows). Code for that is in
> uitest/libreoffice/connection.py, Python3 help blurb is
>
>   https://docs.python.org/3/library/subprocess.html#subprocess.Popen
>
> It is a tad surprising that this would somehow 'think' it is still the
> main python executable on Windows, perhaps there's a way to
> parameterize the Popen call differently to rectify that?

I am quite sure that's python.exe process that I debug in VS here (path:
C:\lo\src\core\instdir\program\python-core-3.5.5\bin\python.exe,
launched by python.exe in C:\lo\src\core\instdir\program); with a
command line like this:

> "C:\lo\src\core\instdir\program\\python-core-3.5.5" "-m" "unittest" "insertremovecells"

... and a call stack like this:

> xsec_xmlsec.dll!SecurityEnvironmentGpg::{ctor}::__l2::<lambda>() Line 49
> at c:\lo\src\core\xmlsecurity\source\gpg\securityenvironment.cxx(49)
> xsec_xmlsec.dll!SecurityEnvironmentGpg::SecurityEnvironmentGpg() Line 66
> at c:\lo\src\core\xmlsecurity\source\gpg\securityenvironment.cxx(66)
> xsec_xmlsec.dll!SEInitializerGpg::createSecurityContext(const rtl::OUString & __formal) Line 45
> at c:\lo\src\core\xmlsecurity\source\gpg\seinitializer.cxx(45)
> xmlsecurity.dll!DocumentSignatureManager::init() Line 80
> at c:\lo\src\core\xmlsecurity\source\helper\documentsignaturemanager.cxx(80)
> xmlsecurity.dll!DocumentDigitalSignatures::ImplVerifySignatures(const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & rxStorage, const com::sun::star::uno::Reference<com::sun::star::io::XInputStream> & xSignStream, DocumentSignatureMode eMode) Line 313
> at c:\lo\src\core\xmlsecurity\source\component\documentdigitalsignatures.cxx(313)
> xmlsecurity.dll!DocumentDigitalSignatures::verifyDocumentContentSignatures(const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & rxStorage, const com::sun::star::uno::Reference<com::sun::star::io::XInputStream> & xSignInStream) Line 176
> at c:\lo\src\core\xmlsecurity\source\component\documentdigitalsignatures.cxx(176)
> sfxlo.dll!SfxObjectShell::ImplAnalyzeSignature(bool bScriptingContent, const com::sun::star::uno::Reference<com::sun::star::security::XDocumentDigitalSignatures> & xSigner) Line 1538
> at c:\lo\src\core\sfx2\source\doc\objserv.cxx(1538)
> sfxlo.dll!SfxObjectShell::ImplGetSignatureState(bool bScriptingContent) Line 1567
> at c:\lo\src\core\sfx2\source\doc\objserv.cxx(1567)
> sfxlo.dll!SfxObjectShell::GetDocumentSignatureState() Line 1718
> at c:\lo\src\core\sfx2\source\doc\objserv.cxx(1718)
> sfxlo.dll!SfxObjectShell::CheckForBrokenDocSignatures_Impl() Line 981
> at c:\lo\src\core\sfx2\source\doc\objmisc.cxx(981)
> sfxlo.dll!SfxObjectShell::CheckSecurityOnLoading_Impl() Line 933
> at c:\lo\src\core\sfx2\source\doc\objmisc.cxx(933)
> sfxlo.dll!SfxObjectShell::FinishedLoading(SfxLoadedFlags nFlags) Line 1081
> at c:\lo\src\core\sfx2\source\doc\objmisc.cxx(1081)
> sclo.dll!ScDocShell::Load(SfxMedium & rMedium) Line 658
> at c:\lo\src\core\sc\source\ui\docshell\docsh.cxx(658)
> sfxlo.dll!SfxObjectShell::LoadOwnFormat(SfxMedium & rMedium) Line 3041
> at c:\lo\src\core\sfx2\source\doc\objstor.cxx(3041)
> sfxlo.dll!SfxObjectShell::DoLoad(SfxMedium * pMed) Line 723
> at c:\lo\src\core\sfx2\source\doc\objstor.cxx(723)
> sfxlo.dll!SfxBaseModel::load(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & seqArguments) Line 1795
> at c:\lo\src\core\sfx2\source\doc\sfxbasemodel.cxx(1795)
> sfxlo.dll!`anonymous namespace'::SfxFrameLoader_Impl::load(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & rArgs, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & _rTargetFrame) Line 693
> at c:\lo\src\core\sfx2\source\view\frmload.cxx(693)
> fwklo.dll!framework::LoadEnv::impl_loadContent() Line 1141
> at c:\lo\src\core\framework\source\loadenv\loadenv.cxx(1141)
> fwklo.dll!framework::LoadEnv::startLoading() Line 375
> at c:\lo\src\core\framework\source\loadenv\loadenv.cxx(375)
> fwklo.dll!framework::LoadEnv::loadComponentFromURL(const com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> & xLoader, const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> & xContext, const rtl::OUString & sURL, const rtl::OUString & sTarget, long nFlags, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArgs) Line 162
> at c:\lo\src\core\framework\source\loadenv\loadenv.cxx(162)
> fwklo.dll!framework::Desktop::loadComponentFromURL(const rtl::OUString & sURL, const rtl::OUString & sTargetFrameName, long nSearchFlags, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments) Line 618
> at c:\lo\src\core\framework\source\services\desktop.cxx(618)
> mscx_uno.dll!`anonymous namespace'::cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, _typelib_TypeDescriptionReference * pReturnTypeRef, long nParams, _typelib_MethodParameter * pParams, void * pUnoReturn, void * * pUnoArgs, _uno_Any * * ppUnoExc) Line 214
> at c:\lo\src\core\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx(214)
> mscx_uno.dll!bridges::cpp_uno::shared::unoInterfaceProxyDispatch(_uno_Interface * pUnoI, const _typelib_TypeDescription * pMemberTD, void * pReturn, void * * pArgs, _uno_Any * * ppException) Line 429
> at c:\lo\src\core\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx(429)
> reflectionlo.dll!stoc_corefl::IdlInterfaceMethodImpl::invoke(const com::sun::star::uno::Any & rObj, com::sun::star::uno::Sequence<com::sun::star::uno::Any> & rArgs) Line 699
> at c:\lo\src\core\stoc\source\corereflection\criface.cxx(699)
> invocationlo.dll!stoc_inv::Invocation_Impl::invoke(const rtl::OUString & FunctionName, const com::sun::star::uno::Sequence<com::sun::star::uno::Any> & InParams, com::sun::star::uno::Sequence<short> & OutIndices, com::sun::star::uno::Sequence<com::sun::star::uno::Any> & OutParams) Line 681
> at c:\lo\src\core\stoc\source\invocation\invocation.cxx(681)
> pyuno_d.pyd!pyuno::PyUNO_callable_call(_object * self, _object * args, _object * __formal) Line 96
> at c:\lo\src\core\pyuno\source\module\pyuno_callable.cxx(96)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4991
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4991)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4787
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4787)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4857
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4857)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4783
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4783)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!ext_do_call(_object * func, _object * * * pp_stack, int flags, int na, int nk) Line 5089
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(5089)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3331
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3331)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!method_call(_object * func, _object * arg, _object * kw) Line 330
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\classobject.c(330)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!slot_tp_call(_object * self, _object * args, _object * kwds) Line 6099
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\typeobject.c(6099)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4991
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4991)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4787
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4787)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!ext_do_call(_object * func, _object * * * pp_stack, int flags, int na, int nk) Line 5089
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(5089)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3331
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3331)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!method_call(_object * func, _object * arg, _object * kw) Line 330
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\classobject.c(330)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!slot_tp_call(_object * self, _object * args, _object * kwds) Line 6099
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\typeobject.c(6099)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4991
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4991)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4787
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4787)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!ext_do_call(_object * func, _object * * * pp_stack, int flags, int na, int nk) Line 5089
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(5089)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3331
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3331)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!method_call(_object * func, _object * arg, _object * kw) Line 330
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\classobject.c(330)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!slot_tp_call(_object * self, _object * args, _object * kwds) Line 6099
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\typeobject.c(6099)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4991
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4991)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4787
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4787)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!ext_do_call(_object * func, _object * * * pp_stack, int flags, int na, int nk) Line 5089
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(5089)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3331
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3331)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!method_call(_object * func, _object * arg, _object * kw) Line 330
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\classobject.c(330)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!slot_tp_call(_object * self, _object * args, _object * kwds) Line 6099
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\typeobject.c(6099)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4991
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4991)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4787
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4787)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4857
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4857)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4783
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4783)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4857
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4857)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4783
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4783)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!method_call(_object * func, _object * arg, _object * kw) Line 330
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\classobject.c(330)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!slot_tp_init(_object * self, _object * args, _object * kwds) Line 6314
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\typeobject.c(6314)
> python35_d.dll!type_call(_typeobject * type, _object * args, _object * kwds) Line 905
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\typeobject.c(905)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4991
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4991)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4787
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4787)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!PyEval_EvalCode(_object * co, _object * globals, _object * locals) Line 783
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(783)
> python35_d.dll!builtin_exec_impl(_object * module, _object * source, _object * globals, _object * locals) Line 956
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\bltinmodule.c(956)
> python35_d.dll!builtin_exec(_object * module, _object * args) Line 274
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\clinic\bltinmodule.c.h(274)
> python35_d.dll!PyCFunction_Call(_object * func, _object * args, _object * kwds) Line 109
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\methodobject.c(109)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4758
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4758)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4871
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4871)
> python35_d.dll!call_function(_object * * * pp_stack, int oparg) Line 4783
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4783)
> python35_d.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3291
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(3291)
> python35_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4071
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4071)
> python35_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure) Line 4096
> at c:\lo\src\core\workdir\unpackedtarball\python3\python\ceval.c(4096)
> python35_d.dll!function_call(_object * func, _object * arg, _object * kw) Line 627
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\funcobject.c(627)
> python35_d.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2166
> at c:\lo\src\core\workdir\unpackedtarball\python3\objects\abstract.c(2166)
> python35_d.dll!RunModule(wchar_t * modname, int set_argv0) Line 208
> at c:\lo\src\core\workdir\unpackedtarball\python3\modules\main.c(208)
> python35_d.dll!Py_Main(int argc, wchar_t * * argv) Line 735
> at c:\lo\src\core\workdir\unpackedtarball\python3\modules\main.c(735)
> python.exe!wmain(int argc, wchar_t * * argv) Line 15
> at c:\lo\src\core\workdir\unpackedtarball\python3\programs\python.c(15)
> python.exe!invoke_main() Line 91
> at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(91)
> python.exe!__scrt_common_main_seh() Line 288
> at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
> python.exe!__scrt_common_main() Line 331
> at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331)
> python.exe!wmainCRTStartup() Line 17
> at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_wmain.cpp(17)
> kernel32.dll!BaseThreadInitThunk()
> ntdll.dll!RtlUserThreadStart()

- so I don't think that it's soffice.bin somehow "thinking" it's python.

>> 1. First of all - do I understand it correctly that the problem is real
>> - so there are possible scenarios involving e.g. python (or another
>> process which executable is not in LO's instdir/program), that might
>> need gpgme?
>>
> See above - but even for uitests, the issue might become relevant, so
> I see at least no harm in keeping that fix (unless Popen can be fixed
> to not have Windows inherit too much parent process attributes).

Ok - so then I'll merge it.

>> 2. To find the executable, I use UNO_PATH envvar. As far as I can tell,
>> even directly running soffice.bin without having UNO_PATH set in
>> environment, sets the variable correctly, so this works as expected. But
>> is there a better way?
>>
> The canonical way seems to be something like:
>
>      OUString aProgramURL("$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/<executable>");
>      rtl::Bootstrap::expandMacros(aProgramURL);

Thanks! Done.

>> 3. The patch needs to add a gpgmepp wrapper for gpgme_set_global_flag
>> function,
>> [snip]
>> If there's no way to do that, then I'll create a pr to
>> https://github.com/KDE/gpgmepp.
>>
> Yes please, that's how we did that in the past, too.

Will do - waiting for account confirmation.

--
Best regards,
Mike Kaganski
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Kaganski Mike Kaganski Mike
Reply | Threaded
Open this post in threaded view
|

Re: Properly notify gpgme about spawn executable location on Windows

In reply to this post by Thorsten Behrens-6
On 21.04.2019 0:22, Thorsten Behrens wrote:
>> 1. First of all - do I understand it correctly that the problem is real
>> - so there are possible scenarios involving e.g. python (or another
>> process which executable is not in LO's instdir/program), that might
>> need gpgme?
>>
> See above - but even for uitests, the issue might become relevant, so
> I see at least no harm in keeping that fix (unless Popen can be fixed
> to not have Windows inherit too much parent process attributes).
>

Just checked with master, that the call to gpgme is avoided now due to
commit 7ac4e48687d7679927f5659e941024445946ffa7 "tdf#118593 sfx2: no
need to call into xmlsecurity without signature streams", which added a
check to SfxObjectShell::GetDocumentSignatureInformation. And thus - I
believe that the patch is indeed useful for the cases where the
signature streams would be present.

It's a pity that buildbots don't run those tests on Windows hosts. And I
suppose that we should introduce such a python test with a document with
signature stream, to properly test this on platforms with substantially
different implementations. (Not volunteering to the task, though,
because of lack of required skills.)

--
Best regards,
Mike Kaganski
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Thorsten Behrens-6 Thorsten Behrens-6
Reply | Threaded
Open this post in threaded view
|

Re: Properly notify gpgme about spawn executable location on Windows

In reply to this post by Kaganski Mike
Hi Mike,

Kaganski Mike wrote:

> On 21.04.2019 0:22, Thorsten Behrens wrote:
> > Hmm - so the uitests are rigging the office in a very specific way,
> > using subprocess.Popen to spawn a child soffice process from python
> > (which calls CreateProcess on Windows). Code for that is in
> > uitest/libreoffice/connection.py, Python3 help blurb is
> >
> >   https://docs.python.org/3/library/subprocess.html#subprocess.Popen
> >
> > It is a tad surprising that this would somehow 'think' it is still the
> > main python executable on Windows, perhaps there's a way to
> > parameterize the Popen call differently to rectify that?
>
> I am quite sure that's python.exe process that I debug in VS here (path:
> C:\lo\src\core\instdir\program\python-core-3.5.5\bin\python.exe,
> launched by python.exe in C:\lo\src\core\instdir\program); with a
> command line like this:
>
No idea where I got the impression you were talking about uitests -
you didn't mention it anywhere. :/

Anyway, what I say above is a nonsense, as you're referencing pyuno's
own unittests here, which are even more special (and exhibit the
behaviour you describe). ;)

That stuff pulls in test module's libtest (via dlopen from
initTestEnvironment (in pyuno_module.cxx)), which in turn rigs up a
very minimal office suitable for unit tests (see test/Library_test.mk
for what's linked into that).

So this is an artificial environment, that -- except for python-based
unit tests -- is not going to happen in the wild. With that, your
change is only strictly needed if there would be python tests
exercising xmlsecurity functionality.

Cheers,

-- Thorsten
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (1K) Download Attachment