xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx |   44 +++++++++--------
 1 file changed, 25 insertions(+), 19 deletions(-)

New commits:
commit a0471ec6e9a000a4985af2ad2967498c71004085
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Jul 12 14:34:43 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jul 12 15:41:26 2023 +0200

    xmlsecurity: fix deadlock on preloading libsdlo.so
    
    The trouble is that calling into the configmgr would require recursive
    access to the service manager, but that's protected by a non-recursive
    mutex.
    
    See
    
<https://gerrit.libreoffice.org/c/core/+/153798/24#message-b04c747da2cb73230d88ec65cc8207ac8b124dda>
    for details.
    
    Change-Id: If75779a995c2ad8855073bd6538832a18953d4cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154356
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx 
b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 7ce82fd9f943..9a6222c59e1e 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -118,23 +118,29 @@ namespace
 
         m_nODF = nTmp;
     }
+
+    std::vector<std::u16string_view>& GetGUIServers()
+    {
+
 #ifdef _WIN32
-std::vector<std::u16string_view> aGUIServers
-    = { u"Gpg4win\\kleopatra.exe",
-        u"Gpg4win\\bin\\kleopatra.exe",
-        u"GNU\\GnuPG\\kleopatra.exe",
-        u"GNU\\GnuPG\\launch-gpa.exe",
-        u"GNU\\GnuPG\\gpa.exe",
-        u"GnuPG\\bin\\gpa.exe",
-        u"GNU\\GnuPG\\bin\\kleopatra.exe",
-        u"GNU\\GnuPG\\bin\\launch-gpa.exe",
-        u"GNU\\GnuPG\\bin\\gpa.exe",
-        officecfg::Office::Common::Security::Scripting::CertMgrPath::get() };
+        static std::vector<std::u16string_view> aGUIServers
+            = { u"Gpg4win\\kleopatra.exe",
+                u"Gpg4win\\bin\\kleopatra.exe",
+                u"GNU\\GnuPG\\kleopatra.exe",
+                u"GNU\\GnuPG\\launch-gpa.exe",
+                u"GNU\\GnuPG\\gpa.exe",
+                u"GnuPG\\bin\\gpa.exe",
+                u"GNU\\GnuPG\\bin\\kleopatra.exe",
+                u"GNU\\GnuPG\\bin\\launch-gpa.exe",
+                u"GNU\\GnuPG\\bin\\gpa.exe",
+                
officecfg::Office::Common::Security::Scripting::CertMgrPath::get() };
 #else
-std::vector<std::u16string_view> aGUIServers
-    = { u"kleopatra", u"seahorse", u"gpa", u"kgpg",
-        officecfg::Office::Common::Security::Scripting::CertMgrPath::get() };
+        static std::vector<std::u16string_view> aGUIServers
+            = { u"kleopatra", u"seahorse", u"gpa", u"kgpg",
+                
officecfg::Office::Common::Security::Scripting::CertMgrPath::get() };
 #endif
+        return aGUIServers;
+    }
 
 }
 
@@ -521,17 +527,17 @@ bool DigitalSignaturesDialog::GetPathAllOS(OUString& 
aPath)
 void DigitalSignaturesDialog::GetCertificateManager(OUString& aPath, OUString& 
sExecutable,
                                             OUString& sFoundGUIServer)
 {
-    aGUIServers.pop_back();
-    
aGUIServers.push_back(officecfg::Office::Common::Security::Scripting::CertMgrPath::get());
+    GetGUIServers().pop_back();
+    
GetGUIServers().push_back(officecfg::Office::Common::Security::Scripting::CertMgrPath::get());
 
-    for (auto it = aGUIServers.rbegin(); it != aGUIServers.rend(); ++it)
+    for (auto it = GetGUIServers().rbegin(); it != GetGUIServers().rend(); 
++it)
     {
         const auto& rServer = *it;
 
         if (rServer.empty())
             continue;
 
-        bool bValidSetMgr = (it == aGUIServers.rbegin() && rServer.size() > 0);
+        bool bValidSetMgr = (it == GetGUIServers().rbegin() && rServer.size() 
> 0);
         sal_Int32 nLastBackslashIndex = -1;
 
         if (bValidSetMgr)
@@ -549,7 +555,7 @@ void 
DigitalSignaturesDialog::GetCertificateManager(OUString& aPath, OUString& s
         if (searchError == osl::FileBase::E_None)
         {
             osl::File::getSystemPathFromFileURL(sFoundGUIServer, sExecutable);
-            if (it != aGUIServers.rbegin())
+            if (it != GetGUIServers().rbegin())
             {
                 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
                     comphelper::ConfigurationChanges::create());

Reply via email to