Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
5.3.1
-
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())
tempPath = tempDir->path();
tempPath += QLatin1Char('/') + requestedServerName;
}
this constructs a wrong name if requestedServerName is passed as a absolute path and a socketOption is set.