Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-40826

QLocalServer bug with absoulte pathnames on UNIX

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • 5.3.1
    • Network: Sockets
    • None
    • Fedora 20 64bit

    Description

      If one tries to create a QLocalServer using an absoulte Pathname on UNIX QLocalServer stumbles on building the correct path. For example if you try to use

      QLocalServer server;
      server.setSocketOptions(QLocalServer::WorldAccessOption);
      server.listen("/var/run/application/test.sock")

      it ends up creating some temp Directory /var/run/application/test.sock123456 and then tries to create a socket named /var/run/application/test.sock12345//var/run/application/test.sock which fails. This only happens with a socket option set.

      Not using absolute paths creates a socket as expected in /tmp. Also if you do not specify setSocketOptions the socket gets created as expected.

      However there is a big problem with using /tmp for sockets in newer Linux distributions which use namespaced /tmp directory since processes are only able to see /tmp files of their own user. So you can't use /tmp sockets for IPC between different users (eg. webserver frontend running as 'http' user and backend server running as 'app' user.

      The bug is located in qlocalserver_unix.cpp somewhere in 'bool QLocalServerPrivate::listen(const QString &requestedServerName)' between lines 100 and 108:

      // Check any of the flags
      if (socketOptions & QLocalServer::WorldAccessOption) {
      tempDir.reset(new QTemporaryDir(fullServerName));
      if (!tempDir->isValid())

      { setError(QLatin1String("QLocalServer::listen")); return false; }

      tempPath = tempDir->path();
      tempPath += QLatin1Char('/') + requestedServerName;
      }

      this constructs a wrong name if requestedServerName is passed as a absolute path and a socketOption is set.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peter-har Peter Hartmann
            fen Frank Enderle
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes