diff options
author | Piotr Mikolajczyk <piotr.mikolajczyk@qt.io> | 2021-01-14 11:29:06 +0100 |
---|---|---|
committer | Piotr Mikolajczyk <piotr.mikolajczyk@qt.io> | 2021-04-01 06:57:04 +0100 |
commit | 2e3f48637e2e4fbd99424a98f361a0df277ea351 (patch) | |
tree | 274ad045334d025b87bb8973fb4afb47b6c3f8c9 /src/network/socket/qlocalserver.cpp | |
parent | aa84de1afa78cf4b63239b35a4b65f1c9c4eab6c (diff) |
Linux: Add abstract address support for QLocal{Socket,Server}
Takes advantage of Linux's and Android's support for abstract namespace
when binding sockets, which is independent of the filesystem (see man
entry for unix domain sockets).
To make QLocalServer and QLocalSocket use an abstract socket address,
one needs to set the socket options to QLocalServer::AbstractNamespaceOption.
Fixes: QTBUG-16090
Change-Id: Ia9f9c9cc1ac5c28f9d44b0a48d854a7cfbd39b11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/socket/qlocalserver.cpp')
-rw-r--r-- | src/network/socket/qlocalserver.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index 16dc907149..6517d6dc6a 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -90,6 +90,8 @@ QT_BEGIN_NAMESPACE socket. This changes the access permissions on platforms (Linux, Windows) that support access permissions on the socket. Both GroupAccess and OtherAccess may vary slightly in meanings depending on the platform. + On Linux and Android it is possible to use sockets with abstract addresses; + socket permissions have no meaning for such sockets. \value NoOptions No access restrictions have been set. \value UserAccessOption @@ -102,6 +104,10 @@ QT_BEGIN_NAMESPACE Access is available to everyone on Windows. \value WorldAccessOption No access restrictions. + \value AbstractNamespaceOption + The listening socket will be created in the abstract namespace. This flag is specific to Linux. + In case of other platforms, for the sake of code portability, this flag is equivalent + to WorldAccessOption. \sa socketOptions */ @@ -161,6 +167,11 @@ QLocalServer::~QLocalServer() in the Windows documentation). OtherAccessOption refers to the well known "Everyone" group. + On Linux platforms it is possible to create a socket in the abstract + namespace, which is independent of the filesystem. Using this kind + of socket implies ignoring permission options. On other platforms + AbstractNamespaceOption is equivalent to WorldAccessOption. + By default none of the flags are set, access permissions are the platform default. @@ -365,7 +376,9 @@ bool QLocalServer::listen(const QString &name) serverName(), fullServerName() may return a string with a name if this option is supported by the platform; - otherwise, they return an empty QString. + otherwise, they return an empty QString. In particular, the addresses + of sockets in the abstract namespace supported by Linux will + not yield useful names if they contain unprintable characters. \sa isListening(), close() */ |