[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - net/Socket.cpp

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 12 11:24:45 UTC 2020


 net/Socket.cpp |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit ceae8f59ab3f13ca3e33c9a5e822b16295207bec
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Jun 12 12:19:50 2020 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Jun 12 13:24:27 2020 +0200

    Snap needs a specific unix socket name.
    
    Change-Id: I7fd816eb6d23df0f27e40f345181833dbe85e022
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96181
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/net/Socket.cpp b/net/Socket.cpp
index ee76a5a1a..0d0b3ed0b 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -755,15 +755,22 @@ std::string LocalServerSocket::bind()
 {
     int rc;
     struct sockaddr_un addrunix;
+
+    // snap needs a specific socket name
+    std::string socketAbstractUnixName(SOCKET_ABSTRACT_UNIX_NAME);
+    const char* snapInstanceName = std::getenv("SNAP_INSTANCE_NAME");
+    if (snapInstanceName && snapInstanceName[0])
+        socketAbstractUnixName = std::string("0snap.") + snapInstanceName + ".loolwsd-";
+
     do
     {
         std::memset(&addrunix, 0, sizeof(addrunix));
         addrunix.sun_family = AF_UNIX;
-        std::memcpy(addrunix.sun_path, SOCKET_ABSTRACT_UNIX_NAME, sizeof(SOCKET_ABSTRACT_UNIX_NAME));
+        std::memcpy(addrunix.sun_path, socketAbstractUnixName.c_str(), socketAbstractUnixName.length());
         addrunix.sun_path[0] = '\0'; // abstract name
 
         std::string rand = Util::rng::getFilename(8);
-        memcpy(addrunix.sun_path + sizeof(SOCKET_ABSTRACT_UNIX_NAME) - 1, rand.c_str(), 8);
+        memcpy(addrunix.sun_path + socketAbstractUnixName.length(), rand.c_str(), 8);
 
         rc = ::bind(getFD(), (const sockaddr *)&addrunix, sizeof(struct sockaddr_un));
         LOG_TRC("Bind to location " << std::string(&addrunix.sun_path[1]) <<


More information about the Libreoffice-commits mailing list